From f34bb941c0c2ff83d11cfd303201175eb3772c03 Mon Sep 17 00:00:00 2001 From: Roger Ferrel Date: Thu, 20 Sep 2012 08:49:47 -0500 Subject: [PATCH 1/8] Issue #1196 Changes for WmoIdSelectiondialog and modification to CaveJFACEDialog's setBlockOnOpen. Change-Id: I3b9cc2bdc32a8f82a2d9ca6927c7fcda02254e9a Former-commit-id: 6cd9792f4673bb51b7d5fd34db8d7ca64660bc6c [formerly 6cd9792f4673bb51b7d5fd34db8d7ca64660bc6c [formerly 54e670d97751f1f78d472d742c4f362c7deee625]] Former-commit-id: 471bab8172b49a510164502235a2e846ded3854c Former-commit-id: 3bf89d22400d5cdb10db3d09f7abd0f01fa3b13a --- .../dialogs/AWIPSHeaderBlockDlg.java | 97 ++-- .../dialogs/RemoteSiteRequestDlg.java | 492 +++++++++++------- .../dialogs/WmoIdSelectionDialog.java | 14 +- .../viz/ui/dialogs/CaveJFACEDialog.java | 26 +- 4 files changed, 383 insertions(+), 246 deletions(-) diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/AWIPSHeaderBlockDlg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/AWIPSHeaderBlockDlg.java index c577058570..dfdad3b7fd 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/AWIPSHeaderBlockDlg.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/AWIPSHeaderBlockDlg.java @@ -23,6 +23,7 @@ package com.raytheon.viz.texteditor.dialogs; import java.util.ArrayList; import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.events.FocusEvent; @@ -46,7 +47,6 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Layout; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; import com.raytheon.uf.common.dataplugin.text.AfosWmoIdDataContainer; import com.raytheon.uf.common.dataplugin.text.db.AfosToAwips; @@ -64,6 +64,7 @@ import com.raytheon.viz.texteditor.msgs.IAfosIdSelectionCallback; import com.raytheon.viz.texteditor.msgs.IWmoIdSelectionCallback; import com.raytheon.viz.texteditor.util.TextEditorUtil; import com.raytheon.viz.ui.dialogs.CaveSWTDialog; +import com.raytheon.viz.ui.dialogs.ICloseCallback; /** * Dialog that allows the user to edit the AWIPS header block. @@ -72,8 +73,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * * SOFTWARE HISTORY * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- * 9/13/07 368 lvenable Initial creation. * 10/11/2007 482 grichard Reformatted file. * 10/18/2007 482 grichard Implemented build 9 features. @@ -91,7 +92,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * 05/30/2012 15046 D.Friedman Always set addressee field to ALL. * 06/19/2012 14975 D.Friedman Run callback when dialog is dismissed. * 07/26/2012 15171 rferrel Disable editor's send and clear AFOS PIL fields when - * invalid product Id and user want to edit it anyway, + * invalid product Id and user want to edit it anyway. + * 09/20/2012 1196 rferrel Changing dialogs being called to not block. * * * @author lvenable @@ -104,12 +106,12 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements /** * WMO data type and area indicator text field. */ - private Text wmoTtaaiiTF; + private StyledText wmoTtaaiiTF; /** * International location indicator text field. */ - private Text ccccTF; + private StyledText ccccTF; /** * Combo box Type of message/indicator group. @@ -124,23 +126,23 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements /** * AFOS site ID text field. */ - private Text wsfoIdTF; + private StyledText wsfoIdTF; /** * Product category text field. */ - private Text prodCatTF; + private StyledText prodCatTF; /** * Product designator text field. */ - private Text prodDesignatorTF; + private StyledText prodDesignatorTF; /** * Address text field. Defines the site where a text product or message is * sent. */ - private Text addresseeTF; + private StyledText addresseeTF; /** * Zeros button. Puts "000" into the addressee text field. Zeros indicates @@ -247,7 +249,7 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements // Create the WMO ID text field. GridData gd = new GridData(55, SWT.DEFAULT); - wmoTtaaiiTF = new Text(wmoIdComp, SWT.BORDER); + wmoTtaaiiTF = new StyledText(wmoIdComp, SWT.BORDER); wmoTtaaiiTF.setTextLimit(6); wmoTtaaiiTF.setLayoutData(gd); @@ -264,7 +266,7 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements // Create the international location indicator text field. gd = new GridData(45, SWT.DEFAULT); - ccccTF = new Text(wmoIdComp, SWT.BORDER); + ccccTF = new StyledText(wmoIdComp, SWT.BORDER); ccccTF.setTextLimit(4); ccccTF.setLayoutData(gd); if (textProd != null && textProd.getSite() != null) { @@ -377,7 +379,7 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements // Create the WSFO ID text field. GridData gd = new GridData(45, SWT.DEFAULT); - wsfoIdTF = new Text(afosIdComp, SWT.BORDER); + wsfoIdTF = new StyledText(afosIdComp, SWT.BORDER); wsfoIdTF.setTextLimit(3); wsfoIdTF.setLayoutData(gd); @@ -386,7 +388,7 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements // Create the Product category text field. gd = new GridData(45, SWT.DEFAULT); - prodCatTF = new Text(afosIdComp, SWT.BORDER); + prodCatTF = new StyledText(afosIdComp, SWT.BORDER); prodCatTF.setTextLimit(3); prodCatTF.setLayoutData(gd); @@ -395,7 +397,7 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements // Create the product designator text field. gd = new GridData(45, SWT.DEFAULT); - prodDesignatorTF = new Text(afosIdComp, SWT.BORDER); + prodDesignatorTF = new StyledText(afosIdComp, SWT.BORDER); prodDesignatorTF.setTextLimit(3); prodDesignatorTF.setLayoutData(gd); prodDesignatorTF.addFocusListener(new FocusListener() { @@ -409,7 +411,13 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements while (sb.length() < 3) { sb.append(' '); } - prodDesignatorTF.setText(sb.toString()); + + // Only trigger the modification listener when there is a + // real change. + String value = sb.toString(); + if (!value.equals(prodDesignatorTF.getText())) { + prodDesignatorTF.setText(value); + } } } @@ -460,7 +468,7 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements addresseeComp.setLayout(rowLayout); RowData rd = new RowData(45, SWT.DEFAULT); - addresseeTF = new Text(addresseeComp, SWT.BORDER); + addresseeTF = new StyledText(addresseeComp, SWT.BORDER); addresseeTF.setTextLimit(4); addresseeTF.setLayoutData(rd); // Set the "default" addressee to "ALL". @@ -471,8 +479,7 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements // text field. addresseeTF.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent event) { - if (addresseeTF.getCaretPosition() == addresseeTF - .getTextLimit()) { + if (addresseeTF.getCaretOffset() == addresseeTF.getTextLimit()) { wmoTtaaiiTF.setFocus(); } @@ -564,13 +571,17 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements } else { lookupWmoIDs(); - if (prodDesignatorTF.getCaretPosition() == prodDesignatorTF - .getTextLimit()) { - addresseeTF.setFocus(); + if (!isDisposed()) { + if (prodDesignatorTF.getCaretOffset() == prodDesignatorTF + .getTextLimit()) { + addresseeTF.setFocus(); + } } } - checkEnableEnter(); + if (!isDisposed()) { + checkEnableEnter(); + } } }); } @@ -757,6 +768,7 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements shell, this, afosIds); dlg.setBlockOnOpen(true); dlg.open(); + return; } else if (list.size() == 1) { setAfosId(list.get(0).getAfosid()); } else { @@ -820,8 +832,16 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements WmoIdSelectionDialog dlg = new WmoIdSelectionDialog( shell, this, ttaaiiIds, ccccIds); - dlg.setBlockOnOpen(true); + dlg.setBlockOnOpen(false); + dlg.setCloseCallback(new ICloseCallback() { + + @Override + public void dialogClosed(Object returnValue) { + lookupAllowed = true; + } + }); dlg.open(); + return; } else if (list.size() == 1) { AfosToAwips id = list.get(0); setWmoId(id.getWmottaaii(), id.getWmocccc()); @@ -839,7 +859,6 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements statusHandler.handle(Priority.PROBLEM, "Error occurred looking up WMO IDs", e); } - lookupAllowed = true; } } @@ -889,8 +908,8 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements enterBtn.setEnabled(enable); } - private void textFieldKeyListener(final Text tf, final Text previousTF, - final Text nextTF) { + private void textFieldKeyListener(final StyledText tf, + final StyledText previousTF, final StyledText nextTF) { tf.addKeyListener(new KeyAdapter() { @Override @@ -898,7 +917,7 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements char c = e.character; if (Character.isLetterOrDigit(c) || Character.isSpaceChar(c)) { - int pos = tf.getCaretPosition(); + int pos = tf.getCaretOffset(); String text = tf.getText(); if (text.length() > pos) { @@ -909,16 +928,16 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements } } else if (e.keyCode == SWT.ARROW_UP) { previousTF.setFocus(); - previousTF.setSelection(0); + previousTF.selectAll(); } else if (e.keyCode == SWT.ARROW_DOWN) { nextTF.setFocus(); - nextTF.setSelection(0); + nextTF.selectAll(); } } }); } - private void textFieldVerifyListener(final Text tf) { + private void textFieldVerifyListener(final StyledText tf) { tf.addVerifyListener(new VerifyListener() { @Override public void verifyText(VerifyEvent e) { @@ -944,8 +963,8 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements }); } - private void textFieldModifyListener(final Text tf, final Text nextTF, - final boolean callAfosLookup) { + private void textFieldModifyListener(final StyledText tf, + final StyledText nextTF, final boolean callAfosLookup) { tf.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent event) { if (tf.getCharCount() == tf.getTextLimit()) { @@ -956,12 +975,14 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements } } - if (tf.getCaretPosition() == tf.getTextLimit()) { - nextTF.setFocus(); - nextTF.setSelection(0); - } + if (!isDisposed()) { + if (tf.getCaretOffset() == tf.getTextLimit()) { + nextTF.setFocus(); + nextTF.selectAll(); + } - checkEnableEnter(); + checkEnableEnter(); + } } }); } diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/RemoteSiteRequestDlg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/RemoteSiteRequestDlg.java index 369fcb8cfe..0e5f24b74c 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/RemoteSiteRequestDlg.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/RemoteSiteRequestDlg.java @@ -27,12 +27,15 @@ import java.util.List; import java.util.TimeZone; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.FocusAdapter; -import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.events.KeyAdapter; +import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.VerifyEvent; +import org.eclipse.swt.events.VerifyListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -40,7 +43,6 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Layout; import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; import com.raytheon.uf.common.dataplugin.text.AfosWmoIdDataContainer; import com.raytheon.uf.common.dataplugin.text.db.AfosToAwips; @@ -58,6 +60,7 @@ import com.raytheon.viz.texteditor.command.CommandFailedException; import com.raytheon.viz.texteditor.msgs.IWmoIdSelectionCallback; import com.raytheon.viz.texteditor.util.TextEditorUtil; import com.raytheon.viz.ui.dialogs.CaveSWTDialog; +import com.raytheon.viz.ui.dialogs.ICloseCallback; /** * The Remote Site Request dialog. @@ -70,39 +73,50 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * ------------ ---------- ----------- -------------------------- * 9/13/07 368 lvenable Initial creation. * 10/11/2007 482 grichard Reformatted file. + * 09/20/2012 1196 rferrel Changing dialogs being called to not block. * * * * @author lvenable */ -public class RemoteSiteRequestDlg extends CaveSWTDialog { - private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(RemoteSiteRequestDlg.class); +public class RemoteSiteRequestDlg extends CaveSWTDialog implements + IWmoIdSelectionCallback { + private static final transient IUFStatusHandler statusHandler = UFStatus + .getHandler(RemoteSiteRequestDlg.class); + + private StyledText ttaaiiTF; + + private StyledText ccccTF; /** * AFOS site ID text field. */ - private Text wsfoIdTF; + private StyledText wsfoIdTF; /** * Product category text field. */ - private Text productCatTF; + private StyledText productCatTF; /** * Product designator text field. */ - private Text prodDesignatorTF; + private StyledText prodDesignatorTF; /** * Address text field. Defines the site where a text product or message is * sent. */ - private Text addresseeTF; - + private StyledText addresseeTF; + private Button enterBtn; - + private String initialAfosID; + private WmoIdSelectionDialog wmoIdSelectionDialog; + + boolean lookupAllowed = true; + /** * Constructor. * @@ -128,7 +142,7 @@ public class RemoteSiteRequestDlg extends CaveSWTDialog { protected void initializeComponents(Shell shell) { createInputFields(); createBottomButtons(); - validate(); + checkEnableEnter(); } /** @@ -141,137 +155,84 @@ public class RemoteSiteRequestDlg extends CaveSWTDialog { gridLayout.marginTop = 1; gridLayout.horizontalSpacing = 20; topComp.setLayout(gridLayout); + GridData gd = null; + Label sepLbl = null; + + gd = new GridData(70, SWT.DEFAULT); + ttaaiiTF = new StyledText(topComp, SWT.BORDER | SWT.READ_ONLY); + ttaaiiTF.setTextLimit(6); + ttaaiiTF.setLayoutData(gd); + ttaaiiTF.setEnabled(false); + ttaaiiTF.setEditable(false); + ttaaiiTF.setBackground(shell.getBackground()); + + Label ttaaiiLbl = new Label(topComp, SWT.NONE); + ttaaiiLbl.setText("TTAAii"); + + gd = new GridData(45, SWT.DEFAULT); + ccccTF = new StyledText(topComp, SWT.BORDER | SWT.READ_ONLY); + ccccTF.setEnabled(false); + ccccTF.setEditable(false); + ccccTF.setLayoutData(gd); + ccccTF.setBackground(shell.getBackground()); + Label ccccLbl = new Label(topComp, SWT.NONE); + ccccLbl.setText("CCCC"); + + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan = 2; + sepLbl = new Label(topComp, SWT.SEPARATOR | SWT.HORIZONTAL); + sepLbl.setLayoutData(gd); - ModifyListener validator = new ModifyListener() { - @Override - public void modifyText(ModifyEvent e) { - validate(); - } - }; - // Create the WSFO ID text field. - GridData gd = new GridData(45, SWT.DEFAULT); - wsfoIdTF = new Text(topComp, SWT.BORDER); + gd = new GridData(45, SWT.DEFAULT); + wsfoIdTF = new StyledText(topComp, SWT.BORDER); wsfoIdTF.setTextLimit(3); wsfoIdTF.setLayoutData(gd); - wsfoIdTF.addFocusListener(new FocusAdapter() { - public void focusLost(FocusEvent event) { - wsfoIdTF.setText(wsfoIdTF.getText().toUpperCase()); - } - }); - - // When the number of characters enter reaches the max limit and - // the caret position is at the end then switch focus to another - // text field. - wsfoIdTF.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent event) { - if (wsfoIdTF.getCaretPosition() == wsfoIdTF.getTextLimit()) { - productCatTF.setFocus(); - } - } - }); - - wsfoIdTF.addModifyListener(validator); Label wsfoIdLbl = new Label(topComp, SWT.NONE); wsfoIdLbl.setText("WSFO Identification"); // Create the product category text field. gd = new GridData(45, SWT.DEFAULT); - productCatTF = new Text(topComp, SWT.BORDER); + productCatTF = new StyledText(topComp, SWT.BORDER); productCatTF.setTextLimit(3); productCatTF.setLayoutData(gd); - productCatTF.addFocusListener(new FocusAdapter() { - public void focusLost(FocusEvent event) { - productCatTF.setText(productCatTF.getText().toUpperCase()); - } - }); - // When the number of characters enter reaches the max limit and - // the caret position is at the end then switch focus to another - // text field. - productCatTF.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent event) { - if (productCatTF.getCaretPosition() == productCatTF - .getTextLimit()) { - prodDesignatorTF.setFocus(); - } - } - }); - - productCatTF.addModifyListener(validator); - Label productCatLbl = new Label(topComp, SWT.NONE); productCatLbl.setText("Product Category"); // Create the product designator text field. gd = new GridData(45, SWT.DEFAULT); - prodDesignatorTF = new Text(topComp, SWT.BORDER); + prodDesignatorTF = new StyledText(topComp, SWT.BORDER); prodDesignatorTF.setTextLimit(3); prodDesignatorTF.setLayoutData(gd); - prodDesignatorTF.addFocusListener(new FocusAdapter() { - public void focusLost(FocusEvent event) { - prodDesignatorTF.setText(prodDesignatorTF.getText() - .toUpperCase()); - } - }); - - // When the number of characters enter reaches the max limit and - // the caret position is at the end then switch focus to another - // text field. - prodDesignatorTF.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent event) { - if (prodDesignatorTF.getCaretPosition() == prodDesignatorTF - .getTextLimit()) { - addresseeTF.setFocus(); - } - } - }); - - prodDesignatorTF.addModifyListener(validator); Label prodDesignatorLbl = new Label(topComp, SWT.NONE); prodDesignatorLbl.setText("Product Designator"); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; - Label sepLbl = new Label(topComp, SWT.SEPARATOR | SWT.HORIZONTAL); + sepLbl = new Label(topComp, SWT.SEPARATOR | SWT.HORIZONTAL); sepLbl.setLayoutData(gd); // Create the addressee text field. gd = new GridData(45, SWT.DEFAULT); - addresseeTF = new Text(topComp, SWT.BORDER); + addresseeTF = new StyledText(topComp, SWT.BORDER); addresseeTF.setTextLimit(4); addresseeTF.setText("DEF"); addresseeTF.setLayoutData(gd); - addresseeTF.addFocusListener(new FocusAdapter() { - public void focusLost(FocusEvent event) { - addresseeTF.setText(addresseeTF.getText().toUpperCase()); - } - }); - - // When the number of characters enter reaches the max limit and - // the caret position is at the end then switch focus to another - // text field. - addresseeTF.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent event) { - if (addresseeTF.getCaretPosition() == addresseeTF - .getTextLimit()) { - wsfoIdTF.setFocus(); - } - } - }); - - addresseeTF.addModifyListener(validator); Label addresseeLbl = new Label(topComp, SWT.NONE); addresseeLbl.setText("Addressee"); + setupTextFieldListeners(); + gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; sepLbl = new Label(topComp, SWT.SEPARATOR | SWT.HORIZONTAL); sepLbl.setLayoutData(gd); - + + // TODO set fields should be moved to preOpen() String ccc = ""; String nnn = ""; String xxx = ""; @@ -287,6 +248,24 @@ public class RemoteSiteRequestDlg extends CaveSWTDialog { prodDesignatorTF.setText(xxx); } + private void setupTextFieldListeners() { + // forces all fields to uppercase and only allows numbers/digits + textFieldVerifyListener(wsfoIdTF); + textFieldVerifyListener(productCatTF); + textFieldVerifyListener(prodDesignatorTF); + textFieldVerifyListener(addresseeTF); + + // forces overwrite and arrow key traversal + textFieldKeyListener(wsfoIdTF, addresseeTF, productCatTF); + textFieldKeyListener(productCatTF, wsfoIdTF, prodDesignatorTF); + textFieldKeyListener(prodDesignatorTF, productCatTF, addresseeTF); + textFieldKeyListener(addresseeTF, prodDesignatorTF, wsfoIdTF); + + textFieldModifyListener(wsfoIdTF, productCatTF, true); + textFieldModifyListener(productCatTF, prodDesignatorTF, true); + textFieldModifyListener(prodDesignatorTF, addresseeTF, false); + } + /** * Create the bottom Enter and Cancel buttons. */ @@ -323,79 +302,9 @@ public class RemoteSiteRequestDlg extends CaveSWTDialog { } }); } - - private void validate() { - if (enterBtn != null) - enterBtn.setEnabled(createReturnValue(true)); - } - // Copied from AWIPSHeaderBlockDlg.lookupWmoIDs() - private boolean lookupWmoId(final RemoteRetrievalRequest rrRequest) { - GetWmoIdRequest request = new GetWmoIdRequest(); - request.setAfosId(rrRequest.getAfosID()); - - try { - Object response = ThriftClient.sendRequest(request); - if (response != null) { - if (response instanceof AfosWmoIdDataContainer) { - AfosWmoIdDataContainer container = (AfosWmoIdDataContainer) response; - if (container.getErrorMessage() != null) { - statusHandler.handle( - Priority.PROBLEM, - "Error occurred looking up WMO IDs\nMessage from server[" - + container - .getErrorMessage() - + "]"); - } - - List list = container.getIdList(); - - if (list.size() > 1) { - ArrayList ttaaiiIds = new ArrayList( - list.size()); - ArrayList ccccIds = new ArrayList( - list.size()); - for (AfosToAwips id : list) { - ttaaiiIds.add(id.getWmottaaii()); - ccccIds.add(id.getWmocccc()); - } - - - IWmoIdSelectionCallback cb = new IWmoIdSelectionCallback() { - @Override - public void setWmoId(String ttaaii, String cccc) { - rrRequest.setWmoHeader(ttaaii + ' ' + cccc); - } - }; - WmoIdSelectionDialog dlg = new WmoIdSelectionDialog( - shell, cb, ttaaiiIds, ccccIds); - dlg.setBlockOnOpen(true); - dlg.open(); - return rrRequest.getWmoHeader() != null && - rrRequest.getWmoHeader().length() > 0; - } else if (list.size() == 1) { - AfosToAwips id = list.get(0); - rrRequest.setWmoHeader(id.getWmottaaii() + ' ' + id.getWmocccc()); - } else { - rrRequest.setWmoHeader(""); - } - - return true; - } else { - statusHandler.handle(Priority.PROBLEM, - "Received unhandled WMO Id lookup response from server. Received obj of type [" - + response.getClass() + "], contents[" - + response + "]"); - } - } - } catch (VizException e) { - statusHandler.handle(Priority.PROBLEM, - "Error occurred looking up WMO IDs", e); - } - return false; - } - - private Calendar createCalRelativeTo(Calendar relative, WMOHeader wmoHeader, int monthAdjustment) { + private Calendar createCalRelativeTo(Calendar relative, + WMOHeader wmoHeader, int monthAdjustment) { Calendar c = new GregorianCalendar(relative.getTimeZone()); c.setTimeInMillis(relative.getTimeInMillis()); c.add(GregorianCalendar.MONTH, monthAdjustment); @@ -406,11 +315,11 @@ public class RemoteSiteRequestDlg extends CaveSWTDialog { c.set(GregorianCalendar.MILLISECOND, 0); return c; } - - private Calendar getCloserCalendar(Calendar reference, Calendar a, Calendar b) { - return Math.abs(a.getTimeInMillis() - reference.getTimeInMillis()) < - Math.abs(b.getTimeInMillis() - reference.getTimeInMillis()) ? - a : b; + + private Calendar getCloserCalendar(Calendar reference, Calendar a, + Calendar b) { + return Math.abs(a.getTimeInMillis() - reference.getTimeInMillis()) < Math + .abs(b.getTimeInMillis() - reference.getTimeInMillis()) ? a : b; } private boolean createReturnValue(boolean validateOnly) { @@ -418,41 +327,41 @@ public class RemoteSiteRequestDlg extends CaveSWTDialog { String nnn = productCatTF.getText(); String xxx = prodDesignatorTF.getText(); String addr = addresseeTF.getText(); - if (ccc.length() != 3 || nnn.length() != 3 || - xxx.length() < 1 || xxx.length() > 3 || - addr.length() < 1) + if (ccc.length() != 3 || nnn.length() != 3 || xxx.length() < 1 + || xxx.length() > 3 || addr.length() < 1) return false; - + if (validateOnly) return true; - + String afosID = ccc + nnn + xxx; GetWmoIdRequest request = new GetWmoIdRequest(); request.setAfosId(afosID); - + RemoteRetrievalRequest req = new RemoteRetrievalRequest(); // TODO: Translate addr via awipsSites.txt or siteDistLists.txt req.setAddressee(addr); req.setAfosID(afosID); - + List latest = null; try { - latest = CommandFactory.getAfosCommand(req.getAfosID()).executeCommand(TextEditorUtil - .getTextDbsrvTransport()); + latest = CommandFactory.getAfosCommand(req.getAfosID()) + .executeCommand(TextEditorUtil.getTextDbsrvTransport()); } catch (CommandFailedException e) { statusHandler.handle(Priority.PROBLEM, "Error retrieving metatdata", e); // but keep going... } - + if (latest != null && latest.size() > 0) { - Calendar c = new GregorianCalendar(TimeZone - .getTimeZone("GMT")); + Calendar c = new GregorianCalendar(TimeZone.getTimeZone("GMT")); c.setTimeInMillis(latest.get(0).getRefTime()); req.setMostRecentTime(c.getTimeInMillis()); // default try { - WMOHeader wmo = new WMOHeader(latest.get(0).getProduct().getBytes()); - Calendar t = getCloserCalendar(c, createCalRelativeTo(c, wmo, 0), + WMOHeader wmo = new WMOHeader(latest.get(0).getProduct() + .getBytes()); + Calendar t = getCloserCalendar(c, + createCalRelativeTo(c, wmo, 0), createCalRelativeTo(c, wmo, 1)); t = getCloserCalendar(c, t, createCalRelativeTo(c, wmo, -1)); req.setMostRecentTime(t.getTimeInMillis()); @@ -463,18 +372,205 @@ public class RemoteSiteRequestDlg extends CaveSWTDialog { } else req.setMostRecentTime(0); - if (! lookupWmoId(req)) - return false; - - req.setValidTime(System.currentTimeMillis() + 600 * 1000); // Current time plus 10 minutes - + String ttaaii = ttaaiiTF.getText(); + String cccc = ccccTF.getText(); + if (ttaaii.length() > 0 && cccc.length() > 0) { + req.setWmoHeader(ttaaii + " " + cccc); + } else { + req.setWmoHeader(""); + } + + req.setValidTime(System.currentTimeMillis() + 600 * 1000); // Current + // time plus + // 10 minutes + setReturnValue(req); return true; } + private void textFieldKeyListener(final StyledText tf, + final StyledText previousTF, final StyledText nextTF) { + tf.addKeyListener(new KeyAdapter() { + + @Override + public void keyPressed(KeyEvent e) { + char c = e.character; + + if (Character.isLetterOrDigit(c) || Character.isSpaceChar(c)) { + int pos = tf.getCaretOffset(); + String text = tf.getText(); + + if (text.length() > pos) { + StringBuilder b = new StringBuilder(text); + b.deleteCharAt(pos); + tf.setText(b.toString()); + tf.setSelection(pos); + } + } else if (e.keyCode == SWT.ARROW_UP) { + previousTF.setFocus(); + previousTF.selectAll(); + } else if (e.keyCode == SWT.ARROW_DOWN) { + nextTF.setFocus(); + nextTF.selectAll(); + } + } + }); + } + + private void textFieldVerifyListener(final StyledText tf) { + tf.addVerifyListener(new VerifyListener() { + @Override + public void verifyText(VerifyEvent e) { + e.text = e.text.toUpperCase(); + StringBuilder b = null; + int posMod = 0; + char[] chars = e.text.toCharArray(); + for (int i = 0; i < chars.length; i++) { + char c = chars[i]; + if (!Character.isLetterOrDigit(c) + && !Character.isSpaceChar(c)) { + if (b == null) { + b = new StringBuilder(e.text); + } + b.deleteCharAt(i - posMod++); + } + } + + if (b != null) { + e.text = b.toString(); + } + } + }); + } + + private void textFieldModifyListener(final StyledText tf, + final StyledText nextTF, final boolean limitCheck) { + tf.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent event) { + if (!limitCheck || tf.getCharCount() == tf.getTextLimit()) { + if (wmoIdSelectionDialog == null) { + lookupWmoIDs(); + } else { + wmoIdSelectionDialog.close(); + wmoIdSelectionDialog = null; + lookupWmoIDs(); + } + } else { + if (wmoIdSelectionDialog != null) { + wmoIdSelectionDialog.close(); + wmoIdSelectionDialog = null; + } + setWmoId("", ""); + checkEnableEnter(); + } + + if (!isDisposed()) { + if (tf.getCaretOffset() == tf.getTextLimit()) { + nextTF.setFocus(); + nextTF.selectAll(); + } + + checkEnableEnter(); + } + } + }); + } + + private void lookupWmoIDs() { + if (lookupAllowed && wsfoIdTF.getCharCount() == wsfoIdTF.getTextLimit() + && productCatTF.getCharCount() == productCatTF.getTextLimit() + && prodDesignatorTF.getText().length() > 0) { + GetWmoIdRequest request = new GetWmoIdRequest(); + request.setAfosId(wsfoIdTF.getText() + productCatTF.getText() + + prodDesignatorTF.getText()); + lookupAllowed = false; + + try { + Object response = ThriftClient.sendRequest(request); + if (response != null) { + if (response instanceof AfosWmoIdDataContainer) { + AfosWmoIdDataContainer container = (AfosWmoIdDataContainer) response; + if (container.getErrorMessage() != null) { + statusHandler + .handle(Priority.PROBLEM, + "Error occurred looking up WMO IDs\nMessage from server[" + + container + .getErrorMessage() + + "]"); + } + + java.util.List list = container + .getIdList(); + + if (list.size() > 1) { + ArrayList ttaaiiIds = new ArrayList( + list.size()); + ArrayList ccccIds = new ArrayList( + list.size()); + for (AfosToAwips id : list) { + ttaaiiIds.add(id.getWmottaaii()); + ccccIds.add(id.getWmocccc()); + } + + wmoIdSelectionDialog = new WmoIdSelectionDialog( + shell, this, ttaaiiIds, ccccIds); + wmoIdSelectionDialog + .setCloseCallback(new ICloseCallback() { + + @Override + public void dialogClosed( + Object returnValue) { + lookupAllowed = true; + wmoIdSelectionDialog = null; + } + }); + wmoIdSelectionDialog.setBlockOnOpen(false); + wmoIdSelectionDialog.open(); + return; + } else if (list.size() == 1) { + AfosToAwips id = list.get(0); + setWmoId(id.getWmottaaii(), id.getWmocccc()); + } else { + setWmoId("", ""); + } + checkEnableEnter(); + } else { + statusHandler.handle(Priority.PROBLEM, + "Received unhandled WMO Id lookup response from server. Received obj of type [" + + response.getClass() + "], contents[" + + response + "]"); + } + } + } catch (VizException e) { + statusHandler.handle(Priority.PROBLEM, + "Error occurred looking up WMO IDs", e); + } + + lookupAllowed = true; + } + } + public void setRequest(RemoteRetrievalRequest lastRemoteRetrievalRequest) { initialAfosID = null; if (lastRemoteRetrievalRequest != null) initialAfosID = lastRemoteRetrievalRequest.getAfosID(); } + + private void checkEnableEnter() { + boolean enabled = false; + if (enterBtn != null && !isDisposed()) { + if (ttaaiiTF.getCharCount() > 0 && ccccTF.getCharCount() > 0 + && addresseeTF.getCharCount() > 0) { + enabled = true; + } + enterBtn.setEnabled(enabled); + } + } + + @Override + public void setWmoId(String ttaaii, String cccc) { + ttaaiiTF.setText(ttaaii); + ccccTF.setText(cccc); + checkEnableEnter(); + } } diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/WmoIdSelectionDialog.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/WmoIdSelectionDialog.java index 0f53a42f45..c9e05dc28e 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/WmoIdSelectionDialog.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/WmoIdSelectionDialog.java @@ -23,6 +23,7 @@ import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; @@ -43,6 +44,8 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Aug 28, 2009 2924 rjpeter Initial creation. + * Sep 19, 2012 1196 rferrel Scroll bar now displays and limit placed + * on the height of the dialog. * * * @author rjpeter @@ -124,7 +127,7 @@ public class WmoIdSelectionDialog extends CaveJFACEDialog { label.setLayoutData(data); wmoIdList = new List(top, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL); - data = new GridData(SWT.BEGINNING, SWT.DEFAULT, true, false); + data = new GridData(SWT.CENTER, SWT.FILL, false, true); wmoIdList.setLayoutData(data); for (int i = 0; i < ttaaiiIds.size(); i++) { @@ -160,4 +163,13 @@ public class WmoIdSelectionDialog extends CaveJFACEDialog { top.layout(); return top; } + + @Override + protected Point getInitialSize() { + Point point = super.getInitialSize(); + if (point.y > 500) { + point.y = 500; + } + return point; + } } diff --git a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/dialogs/CaveJFACEDialog.java b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/dialogs/CaveJFACEDialog.java index 594cfb53f9..24ce2b3d00 100644 --- a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/dialogs/CaveJFACEDialog.java +++ b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/dialogs/CaveJFACEDialog.java @@ -51,6 +51,7 @@ import com.raytheon.viz.ui.perspectives.VizPerspectiveListener; * 04/22/08 1088 chammack Added dialog event propagation fix * 09/13/12 1165 lvenable Update for the initial process * of removing the dialog blocking capability. + * 09/20/12 1196 rferrel Changes to setBlockOnOpen. * * * @@ -93,6 +94,9 @@ public class CaveJFACEDialog extends Dialog implements mgr.addPerspectiveDialog(this); } } + // Eventually this will be the default but for now do not know what this + // will break. + // setBlockOnOpen(false); } /* @@ -234,17 +238,21 @@ public class CaveJFACEDialog extends Dialog implements * @param blockOnOpen * Flag indicating if the dialog should block when opened. */ + @Override public void setBlockOnOpen(boolean blockOnOpen) { - /* - * If the dialog is already opened then just return because setting the - * block won't work. In JFACE the setBlockOnOpen needs to be set before - * the open() call, otherwise it is ignored. - */ - if (isOpen()) { - return; - } + // TODO investigate eventually should never allow blocking? + // /* + // * If the dialog is already opened then just return because setting + // the + // * block won't work. In JFACE the setBlockOnOpen needs to be set + // before + // * the open() call, otherwise it is ignored. + // */ + // if (isOpen()) { + // return; + // } super.setBlockOnOpen(blockOnOpen); - blockedOnOpen = blockOnOpen; + // blockedOnOpen = blockOnOpen; } } From 1bce82f55187bab2c8e44732897e432e266d56bb Mon Sep 17 00:00:00 2001 From: Roger Ferrel Date: Thu, 20 Sep 2012 12:34:47 -0500 Subject: [PATCH 2/8] Issue #1196 Changes for AfosIdSelectionDialog. Change-Id: Ic25b78840899ec5bb0f00272004c683535afc992 Former-commit-id: a1e7271a6351acae2c6eb821cdbaf7e3363a13e4 [formerly a1e7271a6351acae2c6eb821cdbaf7e3363a13e4 [formerly 5e2aa722f39f38bf70331ad161d8740e84bb4af2]] Former-commit-id: 5687572616ddc6fb55dd0763fae69b013bb28352 Former-commit-id: aa0a8ce32c76746738df8d6e0931f13f6de2b50a --- .../texteditor/dialogs/AWIPSHeaderBlockDlg.java | 9 ++++++++- .../texteditor/dialogs/AfosIdSelectionDialog.java | 14 +++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/AWIPSHeaderBlockDlg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/AWIPSHeaderBlockDlg.java index dfdad3b7fd..b93ccbcb25 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/AWIPSHeaderBlockDlg.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/AWIPSHeaderBlockDlg.java @@ -766,7 +766,14 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements AfosIdSelectionDialog dlg = new AfosIdSelectionDialog( shell, this, afosIds); - dlg.setBlockOnOpen(true); + dlg.setCloseCallback(new ICloseCallback() { + + @Override + public void dialogClosed(Object returnValue) { + lookupAllowed = true; + } + }); + dlg.setBlockOnOpen(false); dlg.open(); return; } else if (list.size() == 1) { diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/AfosIdSelectionDialog.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/AfosIdSelectionDialog.java index eb492cb1db..af87c1563b 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/AfosIdSelectionDialog.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/AfosIdSelectionDialog.java @@ -23,6 +23,7 @@ import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; @@ -43,6 +44,8 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Aug 28, 2009 2924 rjpeter Initial creation. + * Sep 20, 1010 1196 rferrel Scroll bar now displays and limit placed + * on the height of the dialog. * * * @author rjpeter @@ -120,7 +123,7 @@ public class AfosIdSelectionDialog extends CaveJFACEDialog { label.setLayoutData(data); afosIdList = new List(top, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL); - data = new GridData(SWT.BEGINNING, SWT.DEFAULT, true, false); + data = new GridData(SWT.CENTER, SWT.FILL, false, true); afosIdList.setLayoutData(data); for (String id : afosIds) { @@ -158,4 +161,13 @@ public class AfosIdSelectionDialog extends CaveJFACEDialog { top.layout(); return top; } + + @Override + protected Point getInitialSize() { + Point point = super.getInitialSize(); + if (point.y > 500) { + point.y = 500; + } + return point; + } } From 4d0ef5a4378479f79c9aca470fed60e00fa049c9 Mon Sep 17 00:00:00 2001 From: Roger Ferrel Date: Thu, 20 Sep 2012 14:45:10 -0500 Subject: [PATCH 3/8] Issue #1196 Changes for RemoteSiteRequestDlg. Change-Id: I1ba3b9b4239c8d2a4e44912628013cba48471f40 Former-commit-id: 8f892d7f80cfa84e85a74d0d1496f388d80bb50d [formerly 8f892d7f80cfa84e85a74d0d1496f388d80bb50d [formerly d05224479c8ca8ea9730253785eafb99e64d52da]] Former-commit-id: 4f0ab091a480be72954465dde6993288e9ef6bb1 Former-commit-id: 5fe74144a9d7fc36b4d324e3c2a437e93f794ed1 --- .../dialogs/RemoteSiteRequestDlg.java | 3 +- .../texteditor/dialogs/TextEditorDialog.java | 42 +++++++++++-------- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/RemoteSiteRequestDlg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/RemoteSiteRequestDlg.java index 0e5f24b74c..3200c03e78 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/RemoteSiteRequestDlg.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/RemoteSiteRequestDlg.java @@ -124,7 +124,8 @@ public class RemoteSiteRequestDlg extends CaveSWTDialog implements * Parent shell. */ public RemoteSiteRequestDlg(Shell parent) { - super(parent, SWT.DIALOG_TRIM, CAVE.PERSPECTIVE_INDEPENDENT); + super(parent, SWT.DIALOG_TRIM, CAVE.PERSPECTIVE_INDEPENDENT + | CAVE.DO_NOT_BLOCK); setText("Send Request"); } diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java index b8e843f94a..e7c7366f79 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java @@ -180,6 +180,7 @@ import com.raytheon.viz.texteditor.util.TextEditorUtil; import com.raytheon.viz.texteditor.util.VtecObject; import com.raytheon.viz.texteditor.util.VtecUtil; import com.raytheon.viz.ui.dialogs.CaveSWTDialog; +import com.raytheon.viz.ui.dialogs.ICloseCallback; import com.raytheon.viz.ui.dialogs.SWTMessageBox; /** @@ -288,6 +289,7 @@ import com.raytheon.viz.ui.dialogs.SWTMessageBox; * 10Sep2012 15103 M.Gamazaychikov DR15103 -do not clear AFOS command from the text box * when obs are updated and refactored executeCommand * 10SEP2012 15401 D.Friedman Fix QC problem caused by DR 15340. + * 20SEP2012 1196 rferrel Refactor dialogs to prevent blocking. * * * @author lvenable @@ -1447,14 +1449,21 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, public void widgetSelected(SelectionEvent event) { RemoteSiteRequestDlg requestDlg = new RemoteSiteRequestDlg( shell); - if (lastRemoteRetrievalRequest != null) + if (lastRemoteRetrievalRequest != null) { requestDlg.setRequest(lastRemoteRetrievalRequest); - RemoteRetrievalRequest req = (RemoteRetrievalRequest) requestDlg - .open(); - if (req != null) { - lastRemoteRetrievalRequest = req; - sendRemoteRetrievalRequest(req); } + requestDlg.setCloseCallback(new ICloseCallback() { + + @Override + public void dialogClosed(Object returnValue) { + RemoteRetrievalRequest req = (RemoteRetrievalRequest) returnValue; + if (req != null) { + lastRemoteRetrievalRequest = req; + sendRemoteRetrievalRequest(req); + } + } + }); + requestDlg.open(); } }); @@ -5245,9 +5254,9 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, public String getAddressee() { return addressee; } - + public void executeCommand(ICommand command) { - executeCommand(command, false); + executeCommand(command, false); } public void executeCommand(ICommand command, boolean isObsUpdated) { @@ -5355,11 +5364,11 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, w, siteNode); } /* - * DR15103 - do not clear AFOS command from the text box - * when obs are updated + * DR15103 - do not clear AFOS command from the text box when + * obs are updated */ - if ( !isObsUpdated ) { - clearAfosCmdTF(); + if (!isObsUpdated) { + clearAfosCmdTF(); } clearWmoTF(); clearAwipsIdTF(); @@ -6469,11 +6478,10 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, @Override public void run() { - /* - * DR15103 - set the flag to 'true' before executing - * AFOS command so the AFOS command box is not cleared - * when obs are updated - */ + /* + * DR15103 - set the flag to 'true' before executing AFOS command so + * the AFOS command box is not cleared when obs are updated + */ executeCommand(command, true); } From 9440bbced2903d4a024cacc815f7494e4fdb30e7 Mon Sep 17 00:00:00 2001 From: Roger Ferrel Date: Thu, 20 Sep 2012 15:17:27 -0500 Subject: [PATCH 4/8] Issue #1196 Changes for AlarmAlertSaveLoadDlg. Change-Id: I9baab44a7c5c97af86ea7446e265a873444fc47e Former-commit-id: fd248ac7445495db25d6b14b117a47f398cf464d [formerly fd248ac7445495db25d6b14b117a47f398cf464d [formerly 80b29e5da16e908ed2855ee5c645b911e054e7f7]] Former-commit-id: 407bd9f25e4e83823b6e92119278c3cc627782d6 Former-commit-id: cdd02b90004e65f1db2b4d744a55c3cff1701c36 --- .../alarmalert/dialogs/AlarmAlertDlg.java | 126 ++++++++++-------- .../dialogs/AlarmAlertSaveLoadDlg.java | 24 ++-- 2 files changed, 81 insertions(+), 69 deletions(-) diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertDlg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertDlg.java index 6cb59dc76c..0504a7b385 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertDlg.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertDlg.java @@ -57,6 +57,7 @@ import com.raytheon.viz.texteditor.alarmalert.util.AAPACombined; import com.raytheon.viz.texteditor.alarmalert.util.AlarmAlertFunctions; import com.raytheon.viz.texteditor.alarmalert.util.AlarmAlertLists; import com.raytheon.viz.ui.dialogs.CaveSWTDialog; +import com.raytheon.viz.ui.dialogs.ICloseCallback; import com.raytheon.viz.ui.dialogs.ModeListener; /** @@ -69,6 +70,7 @@ import com.raytheon.viz.ui.dialogs.ModeListener; * ------------ ---------- ----------- -------------------------- * Sep 9, 2009 mnash Initial creation * Oct 31,2011 8510 rferrel Cleaned up code made more robust + * Sep 20,2011 1196 rferrel Change dialogs so they do not block. * * * @@ -178,8 +180,6 @@ public class AlarmAlertDlg extends CaveSWTDialog { preOpened(); - // shell.open(); - opened(); } @@ -270,29 +270,14 @@ public class AlarmAlertDlg extends CaveSWTDialog { // open dialog AlarmAlertSaveLoadDlg dialog = new AlarmAlertSaveLoadDlg(shell, SaveOrLoad.SAVE); - dialog.open(); - String fname = dialog.getFileName(); - fname = validateFileName(fname); - // AlarmAlertFunctions.validateName(fname); + dialog.setCloseCallback(new ICloseCallback() { - if (fname != null && !fname.isEmpty()) { - setShellText(fname); - setLastFile(fname); - // save alert products - LocalizationFile lFile = AlarmAlertFunctions.getFile( - AlarmAlertFunctions.initUserLocalization(), fname); - if (lFile != null) { - AlarmAlertFunctions.saveAlarms( - aapList.subList(siteAdminNumberAA - 1, - aapList.size()), - papList.subList(siteAdminNumberPA - 1, - papList.size()), lFile); - } else { - statusHandler.handle(Priority.SIGNIFICANT, - "Null localization file", new VizException( - "Null localization file")); + @Override + public void dialogClosed(Object returnValue) { + doSaveAs(returnValue.toString()); } - } + }); + dialog.open(); } }); @@ -303,43 +288,72 @@ public class AlarmAlertDlg extends CaveSWTDialog { // open dialog AlarmAlertSaveLoadDlg dialog = new AlarmAlertSaveLoadDlg(shell, SaveOrLoad.LOAD); - dialog.open(); - // load file - String fname = dialog.getFileName(); - fname = validateFileName(fname); - // AlarmAlertFunctions.validateName(fname); - if (fname != null && !fname.isEmpty()) { + dialog.setCloseCallback(new ICloseCallback() { - // load alert products - LocalizationFile lFile = AlarmAlertFunctions.getFile( - AlarmAlertFunctions.initUserLocalization(), fname); - if (lFile != null) { - File file = lFile.getFile(); - setShellText(fname); - setLastFile(fname); - currentFile = file; - AAPACombined combined = null; - - try { - combined = AlarmAlertFunctions.loadFile(file); - } catch (FileNotFoundException e) { - combined = AlarmAlertFunctions - .createDefaultAAPACombined(); - } - if (combined != null) { - populateLists(combined.getAaList(), - combined.getPaList()); - } - } else { - statusHandler.handle(Priority.SIGNIFICANT, - "Null localization file", new VizException( - "Null localization file")); + @Override + public void dialogClosed(Object returnValue) { + doLoad(returnValue.toString()); } - } + }); + dialog.open(); } }); } + private void doSaveAs(String fname) { + fname = validateFileName(fname); + // AlarmAlertFunctions.validateName(fname); + + if (fname != null && !fname.isEmpty()) { + setShellText(fname); + setLastFile(fname); + // save alert products + LocalizationFile lFile = AlarmAlertFunctions.getFile( + AlarmAlertFunctions.initUserLocalization(), fname); + if (lFile != null) { + AlarmAlertFunctions.saveAlarms( + aapList.subList(siteAdminNumberAA - 1, aapList.size()), + papList.subList(siteAdminNumberPA - 1, papList.size()), + lFile); + } else { + statusHandler.handle(Priority.SIGNIFICANT, + "Null localization file", new VizException( + "Null localization file")); + } + } + } + + private void doLoad(String fname) { + fname = validateFileName(fname); + // AlarmAlertFunctions.validateName(fname); + if (fname != null && !fname.isEmpty()) { + + // load alert products + LocalizationFile lFile = AlarmAlertFunctions.getFile( + AlarmAlertFunctions.initUserLocalization(), fname); + if (lFile != null) { + File file = lFile.getFile(); + setShellText(fname); + setLastFile(fname); + currentFile = file; + AAPACombined combined = null; + + try { + combined = AlarmAlertFunctions.loadFile(file); + } catch (FileNotFoundException e) { + combined = AlarmAlertFunctions.createDefaultAAPACombined(); + } + if (combined != null) { + populateLists(combined.getAaList(), combined.getPaList()); + } + } else { + statusHandler.handle(Priority.SIGNIFICANT, + "Null localization file", new VizException( + "Null localization file")); + } + } + } + /** * Create the buttons right below the menu */ @@ -602,11 +616,11 @@ public class AlarmAlertDlg extends CaveSWTDialog { lists.getFilteredProducts().clear(); lists.getFilteredProducts().addAll(aapList); lists.getFilteredProducts().addAll(papList); - + LocalizationFile lFile = AlarmAlertFunctions.getFile( AlarmAlertFunctions.initUserLocalization(), currentFile.getName()); - + AlarmAlertFunctions.saveAlarms( aapList.subList(siteAdminNumberAA - 1, aapList.size()), papList.subList(siteAdminNumberPA - 1, papList.size()), lFile); diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertSaveLoadDlg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertSaveLoadDlg.java index d36cf44d40..88c84712f2 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertSaveLoadDlg.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertSaveLoadDlg.java @@ -58,6 +58,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * AWIPS2 DR Work * 07/25/2012 953 jkorman Modified file "search" to return LocalizationFile * instead of File so references are deleted in all locations. + * 09/20/2012 1196 rferrel Setup fileName now in return value for + * use with close callback. * * * @@ -74,8 +76,6 @@ public class AlarmAlertSaveLoadDlg extends CaveSWTDialog { private Composite shellComp; - private static AlarmAlertSaveLoadDlg saveLoadDlg = null; - private static String fileName = ""; private SaveOrLoad saveLoad; @@ -91,7 +91,7 @@ public class AlarmAlertSaveLoadDlg extends CaveSWTDialog { */ protected AlarmAlertSaveLoadDlg(Shell parentShell, SaveOrLoad saveLoad) { super(parentShell, SWT.APPLICATION_MODAL | SWT.CLOSE | SWT.TITLE, - CAVE.PERSPECTIVE_INDEPENDENT); + CAVE.PERSPECTIVE_INDEPENDENT | CAVE.DO_NOT_BLOCK); if (saveLoad == SaveOrLoad.SAVE) { setText("Save Lists As..."); } else { @@ -148,7 +148,7 @@ public class AlarmAlertSaveLoadDlg extends CaveSWTDialog { gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); lists.setLayoutData(gd); LocalizationContext lc = AlarmAlertFunctions.initUserLocalization(); - + // Get a list of localization files! LocalizationFile[] fList = PathManagerFactory.getPathManager() .listFiles(lc, "alarms", new String[] { "xml" }, false, true); @@ -191,7 +191,12 @@ public class AlarmAlertSaveLoadDlg extends CaveSWTDialog { loadButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // Set the filename to be returned through getFileName() - fileName = lists.getSelection()[0]; + if (lists.getSelectionCount() > 0) { + fileName = lists.getSelection()[0]; + } else { + fileName = ""; + } + setReturnValue(fileName); shell.close(); } }); @@ -285,6 +290,7 @@ public class AlarmAlertSaveLoadDlg extends CaveSWTDialog { public void widgetSelected(SelectionEvent event) { // Set the filename to be returned through getFileName() fileName = textBox.getText(); + setReturnValue(fileName); shell.close(); } }); @@ -311,12 +317,4 @@ public class AlarmAlertSaveLoadDlg extends CaveSWTDialog { public String getFileName() { return fileName; } - - /** - * @param args - */ - public static void main(String[] args) { - saveLoadDlg = new AlarmAlertSaveLoadDlg(new Shell(), SaveOrLoad.LOAD); - saveLoadDlg.open(); - } } From 162d1272fc367844dbd26457ee7708f492dd5aef Mon Sep 17 00:00:00 2001 From: Roger Ferrel Date: Thu, 20 Sep 2012 16:28:01 -0500 Subject: [PATCH 5/8] Issue #1196 Changes for HelpRequestDlg. Change-Id: I676a49fc36f88426fd5c2b2b42d0551c2d6e4e6d Former-commit-id: 496cb65adfaa93b44b1068535e95d4dc7ecd2797 [formerly 496cb65adfaa93b44b1068535e95d4dc7ecd2797 [formerly 8463663d1c1bb569dc091f2886633832bdf45ffa]] Former-commit-id: c77ed46ddc6cf592550a7e767e2e91f381b2a21a Former-commit-id: 408b7ae03137b7a1f4075857e81d114598908f11 --- .../scripting/dialogs/HelpRequestDlg.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/scripting/dialogs/HelpRequestDlg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/scripting/dialogs/HelpRequestDlg.java index 7136f6e6f6..1d52607a57 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/scripting/dialogs/HelpRequestDlg.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/scripting/dialogs/HelpRequestDlg.java @@ -40,8 +40,6 @@ import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; -import com.raytheon.uf.viz.core.status.StatusConstants; -import com.raytheon.viz.texteditor.Activator; import com.raytheon.viz.ui.dialogs.CaveSWTDialog; /** @@ -53,6 +51,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jun 30, 2009 mfegan Initial creation + * Sep 20, 2012 1196 rferrel Added DO_NOT_BLOCK to constructor * * * @@ -61,7 +60,9 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; */ public class HelpRequestDlg extends CaveSWTDialog implements SelectionListener { - private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(HelpRequestDlg.class); + private static final transient IUFStatusHandler statusHandler = UFStatus + .getHandler(HelpRequestDlg.class); + private static final String DLG_TITLE = "Command Help"; /** the selection list */ @@ -104,7 +105,7 @@ public class HelpRequestDlg extends CaveSWTDialog implements SelectionListener { */ public HelpRequestDlg(Shell parent, EnumHelpTypes type, String token) { super(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.FILL, - CAVE.PERSPECTIVE_INDEPENDENT); + CAVE.PERSPECTIVE_INDEPENDENT | CAVE.DO_NOT_BLOCK); setText(DLG_TITLE); this.type = type; @@ -126,6 +127,7 @@ public class HelpRequestDlg extends CaveSWTDialog implements SelectionListener { shell.setSize(size); createClientArea(); + // TODO Move to preOpened and limit the height of the dialog. loadCommandList(); } @@ -146,8 +148,9 @@ public class HelpRequestDlg extends CaveSWTDialog implements SelectionListener { selections.add(command); } } catch (Exception e) { - statusHandler.handle(Priority.PROBLEM, "Unable to load commands file " - + this.type.getFileName(), e); + statusHandler.handle(Priority.PROBLEM, + "Unable to load commands file " + this.type.getFileName(), + e); } } From 2be355e6720181dbfe926cd0885aa2d60c70be8a Mon Sep 17 00:00:00 2001 From: Roger Ferrel Date: Mon, 24 Sep 2012 08:44:01 -0500 Subject: [PATCH 6/8] Issue #1196 Changes for NewAlarmDlg. Change-Id: I6dd6b3a2984bc0e1590ca199d16adc574c2fbae4 Former-commit-id: d21f3fff14715cabf756d3405823529c1048be5f [formerly d21f3fff14715cabf756d3405823529c1048be5f [formerly 3bb158124bceac8cb10b96bb09423ffee0674ba3]] Former-commit-id: 7efd9fa9fea1302b4536d7b486fcfc71f762d510 Former-commit-id: 98d685f67519a2e1d06a0cd5d409277392cdb45d --- .../alarmalert/dialogs/AlarmAlertDlg.java | 148 +++++++++++------- .../alarmalert/dialogs/NewAlarmDlg.java | 22 +-- 2 files changed, 100 insertions(+), 70 deletions(-) diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertDlg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertDlg.java index 0504a7b385..833a0aa8a2 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertDlg.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertDlg.java @@ -373,21 +373,27 @@ public class AlarmAlertDlg extends CaveSWTDialog { } proximityAlarmDlg = new NewAlarmDlg(shell, "ALARM", new AlarmAlertProduct(isOperationalMode())); - AlarmAlertProduct prod = (AlarmAlertProduct) proximityAlarmDlg - .open(); - if (proximityAlarmDlg.haveOkEvent()) { - aapList.add(prod); - String string = ""; - if (prod.isAlarm()) { - string += " (Alarm)"; + proximityAlarmDlg.setCloseCallback(new ICloseCallback() { + + @Override + public void dialogClosed(Object returnValue) { + AlarmAlertProduct prod = (AlarmAlertProduct) returnValue; + if (proximityAlarmDlg.haveOkEvent()) { + aapList.add(prod); + String string = ""; + if (prod.isAlarm()) { + string += " (Alarm)"; + } + if (!"".equals(prod.getSearchString())) { + string += " containing \"" + + prod.getSearchString() + "\""; + } + aaList.add(prod.getProductId() + string); + changeSaveState(true); + } } - if (!"".equals(prod.getSearchString())) { - string += " containing \"" + prod.getSearchString() - + "\""; - } - aaList.add(prod.getProductId() + string); - changeSaveState(true); - } + }); + proximityAlarmDlg.open(); } }); @@ -403,16 +409,24 @@ public class AlarmAlertDlg extends CaveSWTDialog { proximityAlarmDlg = new NewAlarmDlg(shell, "PROXIMITY", new AlarmAlertProduct(isOperationalMode())); - AlarmAlertProduct prod = (AlarmAlertProduct) proximityAlarmDlg - .open(); - if (proximityAlarmDlg.haveOkEvent()) { - prod.setOperationalMode(isOperationalMode()); - papList.add(prod); - paList.add(prod.getProductId() + " " + prod.getAlarmType() - + " " + prod.getActionCmd() + " " - + AlarmAlertFunctions.buildDistance(prod)); - changeSaveState(true); - } + proximityAlarmDlg.setCloseCallback(new ICloseCallback() { + + @Override + public void dialogClosed(Object returnValue) { + AlarmAlertProduct prod = (AlarmAlertProduct) returnValue; + if (proximityAlarmDlg.haveOkEvent()) { + prod.setOperationalMode(isOperationalMode()); + papList.add(prod); + paList.add(prod.getProductId() + " " + + prod.getAlarmType() + " " + + prod.getActionCmd() + " " + + AlarmAlertFunctions.buildDistance(prod)); + changeSaveState(true); + } + } + }); + + proximityAlarmDlg.open(); } }); @@ -429,48 +443,64 @@ public class AlarmAlertDlg extends CaveSWTDialog { } if (aaList.getSelectionIndex() != -1) { // User might change selection while dialog is displayed. - int index = aaList.getSelectionIndex(); + final int index = aaList.getSelectionIndex(); proximityAlarmDlg = new NewAlarmDlg(shell, "ALARM", aapList .get(index - 1)); - AlarmAlertProduct prod = aapList.set(index - 1, - (AlarmAlertProduct) proximityAlarmDlg.open()); - if (proximityAlarmDlg.haveOkEvent()) { - String string = ""; - if (prod.isAlarm()) { - string += " (Alarm)"; + proximityAlarmDlg.setCloseCallback(new ICloseCallback() { + + @Override + public void dialogClosed(Object returnValue) { + AlarmAlertProduct prod = (AlarmAlertProduct) returnValue; + prod = aapList.set(index - 1, prod); + if (proximityAlarmDlg.haveOkEvent()) { + String string = ""; + if (prod.isAlarm()) { + string += " (Alarm)"; + } + if (!"".equals(prod.getSearchString())) { + string += " \"" + prod.getSearchString() + + "\""; + } + aaList.setItem(index, prod.getProductId() + + string); + paList.deselectAll(); + aaList.select(index); + aaList.showSelection(); + changeSaveState(true); + } } - if (!"".equals(prod.getSearchString())) { - string += " \"" + prod.getSearchString() + "\""; - } - aaList.setItem(index, prod.getProductId() + string); - paList.deselectAll(); - aaList.select(index); - aaList.showSelection(); - changeSaveState(true); - } + }); + proximityAlarmDlg.open(); } else if (paList.getSelectionIndex() != -1) { // User might change selection while dialog is displayed. - int index = paList.getSelectionIndex(); + final int index = paList.getSelectionIndex(); proximityAlarmDlg = new NewAlarmDlg(shell, "PROXIMITY", papList.get(index - 1)); - AlarmAlertProduct prod = papList.set(index - 1, - (AlarmAlertProduct) proximityAlarmDlg.open()); - if (proximityAlarmDlg.haveOkEvent()) { - paList.setItem( - paList.getSelectionIndex(), - prod.getProductId() - + " " - + prod.getAlarmType() - + " " - + prod.getActionCmd() - + " " - + AlarmAlertFunctions - .buildDistance(prod)); - aaList.deselectAll(); - paList.select(index); - paList.showSelection(); - changeSaveState(true); - } + proximityAlarmDlg.setCloseCallback(new ICloseCallback() { + + @Override + public void dialogClosed(Object returnValue) { + AlarmAlertProduct prod = (AlarmAlertProduct) returnValue; + prod = papList.set(index - 1, prod); + if (proximityAlarmDlg.haveOkEvent()) { + paList.setItem( + paList.getSelectionIndex(), + prod.getProductId() + + " " + + prod.getAlarmType() + + " " + + prod.getActionCmd() + + " " + + AlarmAlertFunctions + .buildDistance(prod)); + aaList.deselectAll(); + paList.select(index); + paList.showSelection(); + changeSaveState(true); + } + } + }); + proximityAlarmDlg.open(); } } }); diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/NewAlarmDlg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/NewAlarmDlg.java index 6712202717..749ece219b 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/NewAlarmDlg.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/NewAlarmDlg.java @@ -55,6 +55,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * Sep 10, 2009 mnash Initial creation * Jun 08, 2010 5851 cjeanbap Properly stop alarm/alert observer listener; shellComp is null. * Oct 31, 2011 8510 rferrel made PRIMARY_MODEL and add check for nonblank productID. + * Sep 20, 2012 1196 rferrel No longer Blocks * * * @author mnash @@ -71,8 +72,7 @@ public class NewAlarmDlg extends CaveSWTDialog { e.text = e.text.toUpperCase(); } }; - - + private Combo alarmAlert; private Combo actionCmd; @@ -108,8 +108,8 @@ public class NewAlarmDlg extends CaveSWTDialog { */ protected NewAlarmDlg(Shell parentShell, String alarm_or_alert, AlarmAlertProduct product) { - super(parentShell, CAVE.PERSPECTIVE_INDEPENDENT | SWT.PRIMARY_MODAL - | SWT.RESIZE); + super(parentShell, SWT.PRIMARY_MODAL | SWT.RESIZE, + CAVE.PERSPECTIVE_INDEPENDENT | CAVE.DO_NOT_BLOCK); if ("PROXIMITY".equals(alarm_or_alert)) { productType = ProductType.Proximity_Alarm; setText("New Proximity Alarm Product"); @@ -187,13 +187,13 @@ public class NewAlarmDlg extends CaveSWTDialog { */ private Text createProductIdField(Composite prods, String initValue) { Text prodIdField = new Text(prods, SWT.SINGLE | SWT.BORDER); - if(initValue != null) { + if (initValue != null) { prodIdField.setText(initValue); } prodIdField.addVerifyListener(productIdVerifier); return prodIdField; } - + private void createAlarmDialog() { Composite prods = new Composite(shellComp, SWT.NONE); GridLayout prodLayout = new GridLayout(3, false); @@ -208,8 +208,8 @@ public class NewAlarmDlg extends CaveSWTDialog { prodLabelData = new GridData(SWT.FILL, SWT.DEFAULT, true, false); prodId.setLayoutData(prodLabelData); - productId = createProductIdField(prods,prod.getProductId()); - + productId = createProductIdField(prods, prod.getProductId()); + prodLabelData = new GridData(SWT.FILL, SWT.DEFAULT, true, false); prodLabelData.grabExcessHorizontalSpace = true; prodLabelData.widthHint = 150; @@ -260,8 +260,8 @@ public class NewAlarmDlg extends CaveSWTDialog { prodId.setText("Product ID:"); prodLabelData = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - - productId = createProductIdField(prods,prod.getProductId()); + + productId = createProductIdField(prods, prod.getProductId()); productId.setLayoutData(prodLabelData); // separator @@ -468,7 +468,7 @@ public class NewAlarmDlg extends CaveSWTDialog { } else { prod.setSearchString(searchString.getText()); prod.setAlarm(alarmCheck.getSelection()); - if(alarmCheck.getSelection()) { + if (alarmCheck.getSelection()) { prod.setAlarmType("Alarm"); } else { prod.setAlarmType("Alert"); From 9d87d39ca0a701c72405f24ff6c7d6b93ea6395e Mon Sep 17 00:00:00 2001 From: Roger Ferrel Date: Mon, 24 Sep 2012 09:31:00 -0500 Subject: [PATCH 7/8] Issue #1196 Changes for AlarmAlertDlg Change-Id: Icfaf604b064119548898dd100cbd3fba2d1303f7 Former-commit-id: 619acbe3332aee9bb8996cb5c5b82abd4dd5b92c [formerly 619acbe3332aee9bb8996cb5c5b82abd4dd5b92c [formerly c68e9d4f7cfb0e0e9e46c789c69e40e931b2ee2e]] Former-commit-id: 7280dc6167f3f24ee564982aa7f745ad88e6d26f Former-commit-id: 020bcd91eab24e57bb89599811550dfb25a24238 --- .../viz/texteditor/alarmalert/dialogs/AlarmAlertDlg.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertDlg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertDlg.java index 833a0aa8a2..f934a7a059 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertDlg.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertDlg.java @@ -135,7 +135,8 @@ public class AlarmAlertDlg extends CaveSWTDialog { * @param parentShell */ protected AlarmAlertDlg(Shell parentShell) { - super(parentShell, SWT.RESIZE, CAVE.PERSPECTIVE_INDEPENDENT); + super(parentShell, SWT.RESIZE, CAVE.PERSPECTIVE_INDEPENDENT + | CAVE.DO_NOT_BLOCK); setText("(init) Alarm/Alert and Proximity Alarm Products"); } From ec17241f51c284428e604f6fc710cd484ad55fbf Mon Sep 17 00:00:00 2001 From: Roger Ferrel Date: Mon, 24 Sep 2012 12:03:59 -0500 Subject: [PATCH 8/8] Issue #1196 Changes for WarnGenConfirmationDlg. Change-Id: I5abb882d642e0e2c247432f87dbac0f82656c5f3 Former-commit-id: 4b24258c4cfd3c6c55d4440dd00318436322eb55 [formerly 4b24258c4cfd3c6c55d4440dd00318436322eb55 [formerly 60d1f0788345be4b4212704dc7b04e575d8c0fc9]] Former-commit-id: 0ef53ff1b8bf932553e07093fa615e8c0a21c3c5 Former-commit-id: ce8bf085afe6b81717182c0b180e30f2ad6e1e16 --- .../texteditor/dialogs/TextEditorDialog.java | 47 ++++++++++++++----- .../dialogs/WarnGenConfirmationDlg.java | 28 ++--------- 2 files changed, 39 insertions(+), 36 deletions(-) diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java index e7c7366f79..f385e13376 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java @@ -158,7 +158,6 @@ import com.raytheon.viz.texteditor.command.CommandFailedException; import com.raytheon.viz.texteditor.command.CommandHistory; import com.raytheon.viz.texteditor.command.CommandType; import com.raytheon.viz.texteditor.command.ICommand; -import com.raytheon.viz.texteditor.dialogs.WarnGenConfirmationDlg.SessionDelegate; import com.raytheon.viz.texteditor.fax.dialogs.FaxMessageDlg; import com.raytheon.viz.texteditor.fax.dialogs.LdadFaxSitesDlg; import com.raytheon.viz.texteditor.msgs.IAfosBrowserCallback; @@ -4409,22 +4408,36 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, WarnGenConfirmationDlg wgcd = new WarnGenConfirmationDlg(shell, "Problem Detected by QC", qcCheck.getErrorMessage(), "Do you really want to Send?\n", mode); - wgcd.open(new SessionDelegate() { + wgcd.setCloseCallback(new ICloseCallback() { + @Override - public void dialogDismissed(Object dialogResult) { - if (Boolean.TRUE.equals(dialogResult)) - finishSendProduct1(resend, title, mode, + public void dialogClosed(Object returnValue) { + if (Boolean.TRUE.equals(returnValue)) + finishSendProduct(resend, title, mode, productMessage, modeMessage); + } }); + wgcd.open(); return; } } - finishSendProduct1(resend, title, mode, productMessage, modeMessage); + finishSendProduct(resend, title, mode, productMessage, modeMessage); } - private void finishSendProduct1(final boolean resend, String title, + /** + * This finishes preparing to send a product as part of normal compleation + * of sendProduct or as part of the call back when there is a problem with + * the WarnGen being sent. + * + * @param resend + * @param title + * @param mode + * @param productMessage + * @param modeMessage + */ + private void finishSendProduct(final boolean resend, String title, CAVEMode mode, StringBuilder productMessage, StringBuilder modeMessage) { Pattern p = Pattern.compile(".\\%[s]."); @@ -4459,16 +4472,26 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, WarnGenConfirmationDlg wgcd = new WarnGenConfirmationDlg(shell, title, productMessage.toString(), modeMessage.toString(), mode); - wgcd.open(new SessionDelegate() { + wgcd.setCloseCallback(new ICloseCallback() { + @Override - public void dialogDismissed(Object dialogResult) { - if (Boolean.TRUE.equals(dialogResult)) - finishSendProduct2(resend, result); + public void dialogClosed(Object returnValue) { + if (Boolean.TRUE.equals(returnValue)) { + warngenCloseCallback(resend, result); + } } }); + wgcd.open(); } - private void finishSendProduct2(boolean resend, boolean result) { + /** + * This is used by finishedSendProduct as the call back to the warnGen + * confirmaiton Dialog. + * + * @param resend + * @param result + */ + private void warngenCloseCallback(boolean resend, boolean result) { // DR14553 (make upper case in product) String body = textEditor.getText().toUpperCase(); diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/WarnGenConfirmationDlg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/WarnGenConfirmationDlg.java index 0b6c343ac1..0465df0876 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/WarnGenConfirmationDlg.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/WarnGenConfirmationDlg.java @@ -23,8 +23,6 @@ package com.raytheon.viz.texteditor.dialogs; import java.io.InputStream; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Image; @@ -51,6 +49,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * 10Aug2010 2187 cjeanbap Removed warnGenFlag. * 10Nov2011 11552 rferrel returnvalue no longer null * 08/20/2012 DR 15340 D. Friedman Use callbacks for closing + * 09/24/2012 1196 rferrel Refactored to use close callback + * added to CaveSWTDialog. * * * @@ -69,17 +69,11 @@ public class WarnGenConfirmationDlg extends CaveSWTDialog { private String IMAGE_TEST = "res/images/twsTest.gif"; private String IMAGE_PRACTICE = "res/images/twsPractice.gif"; - - public static interface SessionDelegate { - void dialogDismissed(Object result); - } - - private SessionDelegate sessionDelegate; protected WarnGenConfirmationDlg(Shell parentShell, String title, String productMessage, String modeMessage, CAVEMode mode) { - super(parentShell, SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL, - CAVE.NONE | CAVE.DO_NOT_BLOCK); + super(parentShell, SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL, CAVE.NONE + | CAVE.DO_NOT_BLOCK); setText(title); @@ -88,13 +82,6 @@ public class WarnGenConfirmationDlg extends CaveSWTDialog { this.mode = mode; setReturnValue(Boolean.FALSE); } - - public void open(SessionDelegate sessionDelegate) { - if (sessionDelegate != null && isOpen()) - throw new RuntimeException(String.format("Dialog \"%s\" already open", getText())); - this.sessionDelegate = sessionDelegate; - super.open(); - } @Override protected void initializeComponents(Shell shell) { @@ -103,13 +90,6 @@ public class WarnGenConfirmationDlg extends CaveSWTDialog { createImage(mainComposite); createMessageLabel(mainComposite); createButtonRow(mainComposite); - shell.addDisposeListener(new DisposeListener() { - @Override - public void widgetDisposed(DisposeEvent e) { - if (sessionDelegate != null) - sessionDelegate.dialogDismissed(getReturnValue()); - } - }); } private void createImage(Composite mainComposite) {