Issue #1229 Changes for non-blocking QcDialog and removal of RestoreFileSelectDlg.
Change-Id: I6a85b553341ddc121f189714b8c36aa5f66ae93d Former-commit-id: 50514227a648be22e689a539428ffbe044c0bf45
This commit is contained in:
parent
368974d799
commit
17f92f7aa2
3 changed files with 46 additions and 205 deletions
|
@ -48,6 +48,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* 1/17/2011 7782 rferrel Dialog now has open return null or
|
||||
* the desired check list; removed the use
|
||||
* of sites to be like OB9.2.X.
|
||||
* 10/09/2012 1229 rferrel Made dialog non-blocking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -89,7 +90,8 @@ public class QcDialog extends CaveSWTDialog {
|
|||
* - parent composite
|
||||
*/
|
||||
public QcDialog(Shell parent, Map<String, String> items) {
|
||||
super(parent, SWT.DIALOG_TRIM, CAVE.PERSPECTIVE_INDEPENDENT);
|
||||
super(parent, SWT.DIALOG_TRIM, CAVE.PERSPECTIVE_INDEPENDENT
|
||||
| CAVE.DO_NOT_BLOCK);
|
||||
setText("AvnFPS QC");
|
||||
|
||||
this.items = items;
|
||||
|
@ -217,7 +219,7 @@ public class QcDialog extends CaveSWTDialog {
|
|||
qcItems.put("impact", "0");
|
||||
}
|
||||
setReturnValue(qcItems);
|
||||
shell.dispose();
|
||||
close();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -229,7 +231,7 @@ public class QcDialog extends CaveSWTDialog {
|
|||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
setReturnValue(null);
|
||||
shell.dispose();
|
||||
close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,183 +0,0 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.viz.aviation.editor;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Dialog;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.List;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.text.db.StdTextProduct;
|
||||
import com.raytheon.viz.texteditor.TextWorkstationNotStartedException;
|
||||
|
||||
public class RestoreFileSelectDlg extends Dialog {
|
||||
/**
|
||||
* Dialog shell.
|
||||
*/
|
||||
private Shell shell;
|
||||
|
||||
/**
|
||||
* The display control.
|
||||
*/
|
||||
private Display display;
|
||||
|
||||
private Font controlFont;
|
||||
|
||||
private List fileList;
|
||||
|
||||
private java.util.List<Object> list;
|
||||
|
||||
/**
|
||||
* Return object when the shell is disposed.
|
||||
*/
|
||||
private int returnIdx = -1;
|
||||
|
||||
public RestoreFileSelectDlg(Shell parent) {
|
||||
super(parent, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Open method used to display the GHG Color dialog.
|
||||
*
|
||||
* @return True/False.
|
||||
* @throws TextWorkstationNotStartedException
|
||||
*/
|
||||
public int open(java.util.List<Object> list)
|
||||
throws TextWorkstationNotStartedException {
|
||||
Shell parent = getParent();
|
||||
display = parent.getDisplay();
|
||||
shell = new Shell(parent, SWT.TITLE);
|
||||
this.list = list;
|
||||
|
||||
// Create the main layout for the shell.
|
||||
GridLayout mainLayout = new GridLayout(1, false);
|
||||
mainLayout.marginHeight = 2;
|
||||
mainLayout.marginWidth = 2;
|
||||
mainLayout.verticalSpacing = 2;
|
||||
shell.setLayout(mainLayout);
|
||||
|
||||
shell.setText("Restore File");
|
||||
|
||||
// Initialize all of the controls and layouts
|
||||
initializeComponents();
|
||||
|
||||
shell.pack();
|
||||
shell.open();
|
||||
|
||||
while (!shell.isDisposed()) {
|
||||
if (!display.readAndDispatch()) {
|
||||
display.sleep();
|
||||
}
|
||||
}
|
||||
|
||||
controlFont.dispose();
|
||||
|
||||
return returnIdx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the controls on the display.
|
||||
*/
|
||||
private void initializeComponents() {
|
||||
controlFont = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL);
|
||||
|
||||
createListControl();
|
||||
// Create the buttons at the bottom of the display.
|
||||
createBottomButtons();
|
||||
}
|
||||
|
||||
private void createListControl() {
|
||||
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
Composite listComp = new Composite(shell, SWT.NONE);
|
||||
listComp.setLayout(new GridLayout(1, false));
|
||||
listComp.setLayoutData(gd);
|
||||
|
||||
Label listLbl = new Label(listComp, SWT.NONE);
|
||||
listLbl.setText("Available files to restore:");
|
||||
|
||||
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
gd.widthHint = 275;
|
||||
gd.heightHint = 300;
|
||||
gd.horizontalSpan = 2;
|
||||
fileList = new List(listComp, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL
|
||||
| SWT.H_SCROLL);
|
||||
fileList.setLayoutData(gd);
|
||||
fileList.setFont(controlFont);
|
||||
|
||||
for (Object obj : list) {
|
||||
StdTextProduct tmp = ((StdTextProduct) (obj));
|
||||
Calendar createTime = Calendar.getInstance(TimeZone
|
||||
.getTimeZone("GMT"));
|
||||
createTime.setTimeInMillis(tmp.getRefTime());
|
||||
String label = tmp.getCccid() + tmp.getNnnid() + tmp.getXxxid()
|
||||
+ " - " + createTime.getTime().toString();
|
||||
fileList.add(label);
|
||||
}
|
||||
}
|
||||
|
||||
private void createBottomButtons() {
|
||||
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
Composite mainButtonComp = new Composite(shell, SWT.NONE);
|
||||
mainButtonComp.setLayout(new GridLayout(1, false));
|
||||
mainButtonComp.setLayoutData(gd);
|
||||
|
||||
gd = new GridData(SWT.CENTER, SWT.DEFAULT, false, false);
|
||||
Composite buttonComp = new Composite(shell, SWT.NONE);
|
||||
buttonComp.setLayout(new GridLayout(2, false));
|
||||
buttonComp.setLayoutData(gd);
|
||||
|
||||
gd = new GridData(100, SWT.DEFAULT);
|
||||
Button restoreBtn = new Button(buttonComp, SWT.PUSH);
|
||||
restoreBtn.setText("Restore");
|
||||
restoreBtn.setLayoutData(gd);
|
||||
restoreBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
int idx = fileList.getSelectionIndex();
|
||||
returnIdx = idx;
|
||||
shell.dispose();
|
||||
}
|
||||
});
|
||||
|
||||
gd = new GridData(100, SWT.DEFAULT);
|
||||
Button cancelBtn = new Button(buttonComp, SWT.PUSH);
|
||||
cancelBtn.setText("Cancel");
|
||||
cancelBtn.setLayoutData(gd);
|
||||
cancelBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
returnIdx = -1;
|
||||
shell.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -134,6 +134,7 @@ import com.raytheon.viz.avnconfig.TafSiteConfigFactory;
|
|||
import com.raytheon.viz.avnconfig.TafSiteData;
|
||||
import com.raytheon.viz.texteditor.TextDisplayModel;
|
||||
import com.raytheon.viz.texteditor.msgs.IAviationObserver;
|
||||
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||
|
||||
/**
|
||||
* This class displays the TAF Viewer and Editor dialog.
|
||||
|
@ -215,6 +216,7 @@ import com.raytheon.viz.texteditor.msgs.IAviationObserver;
|
|||
* 20JUL2012 14570 gzhang/zhao Highlight correct time groups in TAF Viewer
|
||||
* 08AGU2012 15613 zhao Modified highlightTAF()
|
||||
* 04OCT2012 1229 rferrel Changes for non-blocking LoaderDialog.
|
||||
* 09OCT2012 1229 rferrel Changes for non-blocking QcDialog.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -518,6 +520,8 @@ public class TafViewerEditorDlg extends Dialog implements ITafSettable,
|
|||
|
||||
private LoaderDialog loadDlg;
|
||||
|
||||
private QcDialog qcDlg;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
@ -589,7 +593,7 @@ public class TafViewerEditorDlg extends Dialog implements ITafSettable,
|
|||
// }
|
||||
|
||||
// Block the disposal of this dialog.
|
||||
setVisible(false);
|
||||
hideDialog();
|
||||
event.doit = false;
|
||||
}
|
||||
});
|
||||
|
@ -887,6 +891,11 @@ public class TafViewerEditorDlg extends Dialog implements ITafSettable,
|
|||
setVisible(true);
|
||||
}
|
||||
|
||||
if (qcDlg != null && qcDlg.getShell() != null
|
||||
&& qcDlg.isDisposed() == false) {
|
||||
qcDlg.bringToTop();
|
||||
}
|
||||
|
||||
shell.setActive();
|
||||
}
|
||||
|
||||
|
@ -899,6 +908,9 @@ public class TafViewerEditorDlg extends Dialog implements ITafSettable,
|
|||
if (shell.isVisible() == true) {
|
||||
setVisible(false);
|
||||
}
|
||||
if (qcDlg != null) {
|
||||
qcDlg.hide();
|
||||
}
|
||||
}
|
||||
|
||||
private void setVisible(boolean state) {
|
||||
|
@ -3277,33 +3289,40 @@ public class TafViewerEditorDlg extends Dialog implements ITafSettable,
|
|||
}
|
||||
}
|
||||
|
||||
String tafText = editorTafTabComp.getTextEditorControl().getText();
|
||||
List<String> sitesInTaf = getSitesInTaf(tafText);
|
||||
HashMap<String, HashMap<String, String>> qcMap = null;
|
||||
|
||||
if (doQcDialog) {
|
||||
QcDialog qcDlg = new QcDialog(shell, savedQcItems);
|
||||
Object o = qcDlg.open();
|
||||
if (o == null) {
|
||||
return;
|
||||
}
|
||||
HashMap<String, String> qcItems = (HashMap<String, String>) o;
|
||||
qcMap = new HashMap<String, HashMap<String, String>>();
|
||||
for (String site : sitesInTaf) {
|
||||
qcMap.put(site, qcItems);
|
||||
if (qcDlg == null || qcDlg.getShell() == null || qcDlg.isDisposed()) {
|
||||
qcDlg = new QcDialog(shell, savedQcItems);
|
||||
qcDlg.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
String tafText = editorTafTabComp
|
||||
.getTextEditorControl().getText();
|
||||
List<String> sitesInTaf = getSitesInTaf(tafText);
|
||||
if (returnValue instanceof HashMap<?, ?>) {
|
||||
HashMap<String, String> qcItems = (HashMap<String, String>) returnValue;
|
||||
HashMap<String, HashMap<String, String>> qcMap = new HashMap<String, HashMap<String, String>>();
|
||||
for (String site : sitesInTaf) {
|
||||
qcMap.put(site, qcItems);
|
||||
}
|
||||
qcCheck(qcMap);
|
||||
}
|
||||
}
|
||||
});
|
||||
qcDlg.open();
|
||||
} else {
|
||||
qcDlg.bringToTop();
|
||||
}
|
||||
} else {
|
||||
String tafText = editorTafTabComp.getTextEditorControl().getText();
|
||||
List<String> sitesInTaf = getSitesInTaf(tafText);
|
||||
HashMap<String, HashMap<String, String>> qcMap = null;
|
||||
qcMap = new HashMap<String, HashMap<String, String>>();
|
||||
|
||||
for (String site : sitesInTaf) {
|
||||
qcMap.put(site, null);
|
||||
}
|
||||
}
|
||||
try {
|
||||
setWaitCursor(true);
|
||||
qcCheck(qcMap);
|
||||
} finally {
|
||||
setWaitCursor(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3313,6 +3332,7 @@ public class TafViewerEditorDlg extends Dialog implements ITafSettable,
|
|||
@SuppressWarnings("unchecked")
|
||||
private void qcCheck(HashMap<String, HashMap<String, String>> qcMap) {
|
||||
try {
|
||||
setWaitCursor(true);
|
||||
ITafSiteConfig config = TafSiteConfigFactory.getInstance();
|
||||
ArrayList<Object> tafs = new ArrayList<Object>();
|
||||
HashMap<String, Object> siteInfo = new HashMap<String, Object>();
|
||||
|
@ -3550,6 +3570,8 @@ public class TafViewerEditorDlg extends Dialog implements ITafSettable,
|
|||
setMessageStatusError("An Error occured while performing the QC check.");
|
||||
} catch (IOException e) {
|
||||
setMessageStatusError("An Error occured while performing the QC check.");
|
||||
} finally {
|
||||
setWaitCursor(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue