From af2e69fbc28932d14290fa3dceb514983214e405 Mon Sep 17 00:00:00 2001 From: Roger Ferrel Date: Tue, 9 Oct 2012 11:55:37 -0500 Subject: [PATCH] Issue #1229 Changes for non-blocking /SendDialog. Change-Id: Ic159abe9d8808cea581b86025e93f3b224f1a3c0 Former-commit-id: c860253fd22c4e1ce8ac792a62b55d39c70392ba --- .../aviation/editor/TafViewerEditorDlg.java | 37 ++++++-- .../viz/aviation/observer/SendDialog.java | 85 ++++++++++--------- 2 files changed, 73 insertions(+), 49 deletions(-) diff --git a/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/editor/TafViewerEditorDlg.java b/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/editor/TafViewerEditorDlg.java index 71b7fe5098..1e49850bd2 100644 --- a/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/editor/TafViewerEditorDlg.java +++ b/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/editor/TafViewerEditorDlg.java @@ -217,6 +217,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * 08AGU2012 15613 zhao Modified highlightTAF() * 04OCT2012 1229 rferrel Changes for non-blocking LoaderDialog. * 09OCT2012 1229 rferrel Changes for non-blocking QcDialog. + * 09OCT2012 1229 rferrel Changes for non-blocking SendDialog. * * * @@ -522,6 +523,8 @@ public class TafViewerEditorDlg extends Dialog implements ITafSettable, private QcDialog qcDlg; + private SendDialog sendDlg; + /** * Constructor. * @@ -896,6 +899,10 @@ public class TafViewerEditorDlg extends Dialog implements ITafSettable, qcDlg.bringToTop(); } + if (sendDlg != null && sendDlg.getShell() != null + && sendDlg.isDisposed() == false) { + sendDlg.bringToTop(); + } shell.setActive(); } @@ -911,6 +918,9 @@ public class TafViewerEditorDlg extends Dialog implements ITafSettable, if (qcDlg != null) { qcDlg.hide(); } + if (sendDlg != null) { + sendDlg.hide(); + } } private void setVisible(boolean state) { @@ -1776,14 +1786,27 @@ public class TafViewerEditorDlg extends Dialog implements ITafSettable, printForecast(editorTafTabComp.getTextEditorControl() .getText()); } - SendDialog sendDlg = new SendDialog(shell, - editorTafTabComp, msgStatComp, sendCollectMI - .getSelection()); - sendDlg.open(); - // sendDlg sets the "taf sent" field only - if (editorTafTabComp.isTafSent()) { - editorTafTabComp.updateTafSent(true); + + if (sendDlg == null || sendDlg.getShell() == null + || sendDlg.isDisposed()) { + sendDlg = new SendDialog(shell, editorTafTabComp, + msgStatComp, sendCollectMI.getSelection()); + sendDlg.setCloseCallback(new ICloseCallback() { + + @Override + public void dialogClosed(Object returnValue) { + // sendDlg sets the "taf sent" field only + if (editorTafTabComp.isTafSent()) { + editorTafTabComp.updateTafSent(true); + } + sendDlg = null; + } + }); + sendDlg.open(); + } else { + sendDlg.bringToTop(); } + } else { putMessageToForecaster("Cannot send forecast: Press Syntax before transmission"); } diff --git a/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/observer/SendDialog.java b/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/observer/SendDialog.java index 4866319bec..1345a71b6b 100644 --- a/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/observer/SendDialog.java +++ b/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/observer/SendDialog.java @@ -69,6 +69,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * 4/15/2009 1982 grichard Provide feedback when saving a working TAF. * 12/08/2011 11745 rferrel Updated header time to transmission time. * 08AUG2012 15613 zhao Determine proper BBB for transmission + * 09OCT2012 1229 rferrel Make dialog non-blocking. * * * @@ -146,7 +147,7 @@ public class SendDialog extends CaveSWTDialog { public SendDialog(Shell parent, EditorTafTabComp tabComp, IStatusSettable msgStatComp, boolean sendCollective) { super(parent, SWT.DIALOG_TRIM | SWT.RESIZE, - CAVE.PERSPECTIVE_INDEPENDENT); + CAVE.PERSPECTIVE_INDEPENDENT | CAVE.DO_NOT_BLOCK); setText("AvnFPS Send"); this.tabComp = tabComp; @@ -365,7 +366,7 @@ public class SendDialog extends CaveSWTDialog { String siteWmoId = tabComp.getWmoId(); // WMO Site String siteNode = null; - //java.util.List stationIds = new ArrayList(); + // java.util.List stationIds = new ArrayList(); ArrayList tafs = new ArrayList(); ArrayList updatedTafs = new ArrayList(); @@ -407,11 +408,10 @@ public class SendDialog extends CaveSWTDialog { * If "AAX" or "CCX" or "RRX", determine BBB for transmission */ String xmitBbb = bbb; - if ( bbb.equals("AAX") || bbb.equals("CCX") || bbb.equals("RRX") ) { - String type = bbb.substring(0, 2); - xmitBbb = getXmitBbb( type, siteId); + if (bbb.equals("AAX") || bbb.equals("CCX") || bbb.equals("RRX")) { + String type = bbb.substring(0, 2); + xmitBbb = getXmitBbb(type, siteId); } - // Update Header Time to transmission time. tafText = TIMESTAMP_PATTERN.matcher(tafText).replaceFirst( @@ -467,40 +467,41 @@ public class SendDialog extends CaveSWTDialog { shell.dispose(); } - @SuppressWarnings("unchecked") - private String getXmitBbb(String type, String siteId) { - - try { - TafQueueRequest request = new TafQueueRequest(); - request.setType(Type.GET_LIST); - request.setState(TafQueueRecord.TafQueueState.SENT); - ServerResponse> response = (ServerResponse>) ThriftClient.sendRequest(request); - java.util.List payload = response.getPayload(); - String [] records = (String []) payload.toArray(new String[0]); - int numRecords = records.length; - for ( int i = numRecords-1; i >=0; i-- ) { - if ( records[i].contains(siteId) ) { - String [] texts = records[i].split("-"); - String bbb = texts[texts.length-2]; - if ( bbb.equals(" ") ) { - return type+"A"; - } - if ( bbb.subSequence(0, 2).equals(type) ) { - char[] newX = new char[] { bbb.charAt(2) }; - if ( newX[0] == 'X' ) { - newX[0] = 'A'; - } else { - newX[0]++; - } - return type + new String( newX ); - } - } - } - } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - return type + "A"; - } + @SuppressWarnings("unchecked") + private String getXmitBbb(String type, String siteId) { + + try { + TafQueueRequest request = new TafQueueRequest(); + request.setType(Type.GET_LIST); + request.setState(TafQueueRecord.TafQueueState.SENT); + ServerResponse> response = (ServerResponse>) ThriftClient + .sendRequest(request); + java.util.List payload = response.getPayload(); + String[] records = (String[]) payload.toArray(new String[0]); + int numRecords = records.length; + for (int i = numRecords - 1; i >= 0; i--) { + if (records[i].contains(siteId)) { + String[] texts = records[i].split("-"); + String bbb = texts[texts.length - 2]; + if (bbb.equals(" ")) { + return type + "A"; + } + if (bbb.subSequence(0, 2).equals(type)) { + char[] newX = new char[] { bbb.charAt(2) }; + if (newX[0] == 'X') { + newX[0] = 'A'; + } else { + newX[0]++; + } + return type + new String(newX); + } + } + } + } catch (VizException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return type + "A"; + } }