From 15cf4b6e74ef197dd3ff1d99fb0a5fdcd5120c6f Mon Sep 17 00:00:00 2001 From: Roger Ferrel Date: Tue, 16 Oct 2012 09:16:44 -0500 Subject: [PATCH 1/3] Issue #1229 Changes to non-blocking ImageBlinkDialog. Change-Id: Ifec323bfc7c44b928d0d135c346c3536fe7ceb96 Former-commit-id: cfa177f554e089933e90175e858d6b6616ac1f69 [formerly a4cb0a13d49525f8a486fbc41c701829597aee3f] [formerly b139d0fc247e6881b363fd447e5ba1ec1f9bcecb] [formerly 4792c77aabf57099ef8ccffa0b30471c47f28195 [formerly b139d0fc247e6881b363fd447e5ba1ec1f9bcecb [formerly b6e7c9d63de65a9523448ff691db6f88f7514f52]]] Former-commit-id: 4792c77aabf57099ef8ccffa0b30471c47f28195 Former-commit-id: 5203a1254e4b97bd8db278d747dcfaee59bc3526 [formerly 06a7728662b31f8f0e1a133b3a3f4617454a98cc] Former-commit-id: 23baab80e8903b1623a6da432b7e695447c20a91 --- .../viz/d2d/ui/dialogs/ImageBlinkDialog.java | 37 ++++++++++++++----- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/ImageBlinkDialog.java b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/ImageBlinkDialog.java index f49d385070..fad38bdba8 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/ImageBlinkDialog.java +++ b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/ImageBlinkDialog.java @@ -52,7 +52,7 @@ import com.raytheon.viz.ui.dialogs.colordialog.ColorData; import com.raytheon.viz.ui.dialogs.colordialog.IColorBarAction; /** - * TODO Add Description + * This is a dialog to determine what range of a rendered display should blink. * *
  * 
@@ -60,6 +60,8 @@ import com.raytheon.viz.ui.dialogs.colordialog.IColorBarAction;
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Sep 13, 2010            mschenke     Initial creation
+ * Oct 16, 2012 1229       rferrel     Updated to use bringToTop to
+ *                                      activate existing dialog.
  * 
  * 
* @@ -92,18 +94,36 @@ public class ImageBlinkDialog extends CaveSWTDialog implements private static Map, ImageBlinkDialog> dialogMap = new HashMap, ImageBlinkDialog>(); + /** + * If needed creates an instance of this dialog and associates it with the + * resource and opens the dialog or activates the dialog if one already + * exists for the resource. + * + * @param rates + * @param currRate + * @param resource + * @param rscProps + * @param displays + */ public static synchronized void openDialog(float[] rates, float currRate, AbstractVizResource resource, ResourceProperties rscProps, D2DMapRenderableDisplay[] displays) { ImageBlinkDialog dlg = dialogMap.get(resource); - if (dlg == null) { + if (dlg == null || dlg.getShell() == null || dlg.isDisposed()) { dlg = new ImageBlinkDialog(new Shell(Display.getCurrent()), rates, currRate, resource, rscProps, displays); dialogMap.put(resource, dlg); + dlg.open(); + } else { + dlg.bringToTop(); } - dlg.open(); } + /** + * Removes the dialog associated with the resource. + * + * @param resource + */ public static synchronized void removeDialog( AbstractVizResource resource) { dialogMap.remove(resource); @@ -146,10 +166,8 @@ public class ImageBlinkDialog extends CaveSWTDialog implements @Override public void widgetDisposed(DisposeEvent e) { removeDialog(resource); - resource - .unregisterListener((IDisposeListener) ImageBlinkDialog.this); - resource - .unregisterListener((IPaintListener) ImageBlinkDialog.this); + resource.unregisterListener((IDisposeListener) ImageBlinkDialog.this); + resource.unregisterListener((IPaintListener) ImageBlinkDialog.this); } }); Composite mainComp = new Composite(shell, SWT.NONE); @@ -186,9 +204,8 @@ public class ImageBlinkDialog extends CaveSWTDialog implements cbo.add(BlinkToggleAction.NO_BLINK); - cbo - .setText(rate == BlinkToggleAction.NO_BLINK_VALUE ? BlinkToggleAction.NO_BLINK - : "" + rate); + cbo.setText(rate == BlinkToggleAction.NO_BLINK_VALUE ? BlinkToggleAction.NO_BLINK + : "" + rate); cbo.addSelectionListener(new SelectionAdapter() { @Override From 957066f1669d74dbf66ffd56e39b2044774ea667 Mon Sep 17 00:00:00 2001 From: Roger Ferrel Date: Tue, 16 Oct 2012 10:26:36 -0500 Subject: [PATCH 2/3] Issue #1229 Changes for non-blocking AlterBundleDlg. Change-Id: Icea110c4ff66360e2d406a1f2966cf6851fbddc1 Former-commit-id: 132e821d514bb371aceecfe144a8cdc532003249 [formerly 7e3068734e4769c54886de0dc9581a471763f0b4] [formerly 59f21825ae5e6195302d2a7344b5e90dc1c15d7c] [formerly acb0ca9c6fc5f0aa99b40ef946c60462b4056040 [formerly 59f21825ae5e6195302d2a7344b5e90dc1c15d7c [formerly fa1a55648d6d98104b0861db5e45c5de73612a09]]] Former-commit-id: acb0ca9c6fc5f0aa99b40ef946c60462b4056040 Former-commit-id: e7f79630554b65039b699f71e9a8036e8636084c [formerly 4ea86be01dfd0753cef3065efca97e137cb6cb96] Former-commit-id: 83ebc25c2645e034a1a905c4129494c97ac01b0f --- .../ui/dialogs/procedures/AlterBundleDlg.java | 15 ++--- .../ui/dialogs/procedures/HistoryListDlg.java | 48 ++++++++++++--- .../ui/dialogs/procedures/ProcedureDlg.java | 59 +++++++++++++------ 3 files changed, 87 insertions(+), 35 deletions(-) diff --git a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/AlterBundleDlg.java b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/AlterBundleDlg.java index a2b2ec49b7..ed80b11e6f 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/AlterBundleDlg.java +++ b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/AlterBundleDlg.java @@ -66,7 +66,8 @@ import com.raytheon.viz.ui.widgets.MenuButton; * trying to perform a load. * Jul 31, 2012 #875 rferrel Use MenuButton to organize entries * in menus. - * Oct 03, 2012 #1248 rferrel Bundle change listners added. + * Oct 03, 2012 #1248 rferrel Bundle change listeners added. + * Oct 16, 2012 #1229 rferrel Made dialog non-blocking. * * * @@ -74,16 +75,16 @@ import com.raytheon.viz.ui.widgets.MenuButton; * @version 1.0 */ public class AlterBundleDlg extends CaveSWTDialog { - private static final transient IUFStatusHandler statusHandler = UFStatus + private final transient IUFStatusHandler statusHandler = UFStatus .getHandler(AlterBundleDlg.class); - private static final String Top_MENU_KEY = ""; + private final String Top_MENU_KEY = ""; - private static final String MENU_SEP = IAlterBundleContributor.MENU_SEPARATOR; + private final String MENU_SEP = IAlterBundleContributor.MENU_SEPARATOR; - private static final String MI_SEP = IAlterBundleContributor.MI_SEPARATOR; + private final String MI_SEP = IAlterBundleContributor.MI_SEPARATOR; - private static final int MENU_SEP_LEN = MENU_SEP.length(); + private final int MENU_SEP_LEN = MENU_SEP.length(); private static class AlterBundleEntry { @@ -110,7 +111,7 @@ public class AlterBundleDlg extends CaveSWTDialog { private Map menuButtonMap; protected AlterBundleDlg(Bundle bundle, Shell parentShell) { - super(parentShell); + super(parentShell, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK); setText("Alter Bundle on Loading"); this.bundle = bundle; diff --git a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/HistoryListDlg.java b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/HistoryListDlg.java index 9270ef9196..312ed82b01 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/HistoryListDlg.java +++ b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/HistoryListDlg.java @@ -50,10 +50,28 @@ import com.raytheon.viz.ui.UiUtil; import com.raytheon.viz.ui.actions.LoadSerializedXml; import com.raytheon.viz.ui.actions.SaveBundle; import com.raytheon.viz.ui.dialogs.CaveSWTDialog; +import com.raytheon.viz.ui.dialogs.ICloseCallback; import com.raytheon.viz.ui.editor.AbstractEditor; +/** + * Dialog to get user options on history to display. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ *                                     Initial creation
+ * Oct 16, 2012 1229       rferrel     Changes for non-blocking AlterBundleDlg.
+ * 
+ * 
+ * + * @author rferrel + * @version 1.0 + */ public class HistoryListDlg extends CaveSWTDialog { - private static final transient IUFStatusHandler statusHandler = UFStatus + private final transient IUFStatusHandler statusHandler = UFStatus .getHandler(HistoryListDlg.class); private List dataList; @@ -72,6 +90,8 @@ public class HistoryListDlg extends CaveSWTDialog { private Button closeBtn; + private AlterBundleDlg alterDlg; + public HistoryListDlg(Shell parent) { super(parent, SWT.DIALOG_TRIM | SWT.RESIZE); setText("History List"); @@ -273,7 +293,7 @@ public class HistoryListDlg extends CaveSWTDialog { closeBtn.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - shell.dispose(); + close(); } }); } @@ -284,14 +304,24 @@ public class HistoryListDlg extends CaveSWTDialog { } try { - Bundle b = HistoryList.getInstance().getBundle( - dataList.getSelectionIndex(), false); - AlterBundleDlg dlg = new AlterBundleDlg(b, getParent()); - b = (Bundle) dlg.open(); + if (mustCreate(alterDlg)) { + Bundle b = HistoryList.getInstance().getBundle( + dataList.getSelectionIndex(), false); + alterDlg = new AlterBundleDlg(b, getShell()); + alterDlg.setCloseCallback(new ICloseCallback() { - if (b != null) { - // Load was issued in alterBundleDlg - loadAlterBundle(b); + @Override + public void dialogClosed(Object returnValue) { + if (returnValue instanceof Bundle) { + // Load was issued in alterBundleDlg + Bundle b = (Bundle) returnValue; + loadAlterBundle(b); + } + } + }); + alterDlg.open(); + } else { + alterDlg.bringToTop(); } } catch (VizException e) { final String err = "Error altering bundle"; diff --git a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/ProcedureDlg.java b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/ProcedureDlg.java index cd0eae8c30..6323ab2da1 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/ProcedureDlg.java +++ b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/ProcedureDlg.java @@ -82,6 +82,7 @@ import com.raytheon.viz.ui.HistoryList; import com.raytheon.viz.ui.UiUtil; import com.raytheon.viz.ui.actions.SaveBundle; import com.raytheon.viz.ui.dialogs.CaveSWTDialog; +import com.raytheon.viz.ui.dialogs.ICloseCallback; import com.raytheon.viz.ui.editor.AbstractEditor; /** @@ -89,20 +90,22 @@ import com.raytheon.viz.ui.editor.AbstractEditor; * Dialog for loading or modifying procedures. * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
- *
+ *                                     Initial Creation
+ * Oct 16, 2012 1229       rferrel     Changes for non-blocking AlterBundleDlg.
+ * 
  * 
- * + * * @author unknown * @version 1.0 */ public class ProcedureDlg extends CaveSWTDialog { - private static final transient IUFStatusHandler statusHandler = UFStatus + private final transient IUFStatusHandler statusHandler = UFStatus .getHandler(ProcedureDlg.class); public static final String ORIGINAL = "Original Location"; @@ -131,9 +134,9 @@ public class ProcedureDlg extends CaveSWTDialog { private Button firstNextBtn; - private static final String FIRST = "First"; + private final String FIRST = "First"; - private static final String NEXT = "Next"; + private final String NEXT = "Next"; private Button loadBtn; @@ -167,6 +170,8 @@ public class ProcedureDlg extends CaveSWTDialog { private final java.util.List bundles; + private AlterBundleDlg alterDlg; + private ProcedureDlg(String fileName, Procedure p, Shell parent) { // Win32 super(parent, SWT.DIALOG_TRIM | SWT.RESIZE, CAVE.INDEPENDENT_SHELL @@ -877,19 +882,34 @@ public class ProcedureDlg extends CaveSWTDialog { return; } try { - BundlePair bp = new BundlePair(); - bp.name = bundles.get(dataList.getSelectionIndex()).name; - bp.xml = bundles.get(dataList.getSelectionIndex()).xml; - Bundle b = Bundle.unmarshalBundle(bp.xml, null); + if (mustCreate(alterDlg)) { + final BundlePair bp = new BundlePair(); + bp.name = bundles.get(dataList.getSelectionIndex()).name; + bp.xml = bundles.get(dataList.getSelectionIndex()).xml; + Bundle b = Bundle.unmarshalBundle(bp.xml, null); - AlterBundleDlg dlg = new AlterBundleDlg(b, getParent()); - b = (Bundle) dlg.open(); + alterDlg = new AlterBundleDlg(b, getShell()); + alterDlg.setCloseCallback(new ICloseCallback() { - if (b != null) { - // Load was issued in alterBundleDlg - bp.xml = b.toXML(); - saveProcedure(); - load(b); + @Override + public void dialogClosed(Object returnValue) { + if (returnValue instanceof Bundle) { + Bundle b = (Bundle) returnValue; + try { + // Load was issued in alterBundleDlg + bp.xml = b.toXML(); + saveProcedure(); + load(b); + } catch (VizException e) { + final String err = "Error altering bundle"; + statusHandler.handle(Priority.PROBLEM, err, e); + } + } + } + }); + alterDlg.open(); + } else { + alterDlg.bringToTop(); } } catch (VizException e) { final String err = "Error altering bundle"; @@ -1033,7 +1053,8 @@ public class ProcedureDlg extends CaveSWTDialog { } /** - * Get the ProcedureDlg for the given fileName. If the fileName is null or if there is no open dialog, create a new ProcedureDlg. + * Get the ProcedureDlg for the given fileName. If the fileName is null or + * if there is no open dialog, create a new ProcedureDlg. * * @param fileName * @param p From f7672f3d8339fa706d2cb37433f79ed59c35206b Mon Sep 17 00:00:00 2001 From: Roger Ferrel Date: Tue, 16 Oct 2012 11:01:07 -0500 Subject: [PATCH 3/3] Issue #1229 Changes for non-blocking HistoryListDlg. Change-Id: Iffd288fed390121dfec770fd451c028ca78face2 Former-commit-id: 688ca6d6b971316c32fb1e5748e6b2663efac823 [formerly 4c69b818b4e988d8177a6cdb2c47c3122ff2af1a] [formerly 46eafd72e7403c6bb9213503db5eb310f558bb63] [formerly 23db6f4981e5b78fae0eb1f8cb66d22de150cebd [formerly 46eafd72e7403c6bb9213503db5eb310f558bb63 [formerly d8c36ff080bf42da11ab4d770fd022a6e2359f4f]]] Former-commit-id: 23db6f4981e5b78fae0eb1f8cb66d22de150cebd Former-commit-id: e81c7998176598be7e0b6e94bc4c5dbad22ba1c5 [formerly 5a6d2af7c8f9103f728caba3efec64d9528325f9] Former-commit-id: cad15f8b9674ac537d2a573b2b9964750a902957 --- .../uf/viz/d2d/ui/actions/ShowHistoryList.java | 12 +++++++++--- .../d2d/ui/dialogs/procedures/HistoryListDlg.java | 3 ++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/ShowHistoryList.java b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/ShowHistoryList.java index 2bd23785f7..62951b3a00 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/ShowHistoryList.java +++ b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/ShowHistoryList.java @@ -38,6 +38,7 @@ import com.raytheon.uf.viz.d2d.ui.dialogs.procedures.HistoryListDlg; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Sep 13, 2007 chammack Initial Creation. + * Oct 16, 2012 1229 rferrel Changes for non-blocking HistoryListDlg. * * * @@ -46,6 +47,8 @@ import com.raytheon.uf.viz.d2d.ui.dialogs.procedures.HistoryListDlg; */ public class ShowHistoryList extends AbstractHandler { + private HistoryListDlg dialog; + /* * (non-Javadoc) * @@ -55,9 +58,12 @@ public class ShowHistoryList extends AbstractHandler { */ @Override public Object execute(ExecutionEvent event) throws ExecutionException { - HistoryListDlg dlg = new HistoryListDlg( - HandlerUtil.getActiveShell(event)); - dlg.open(); + if (dialog == null || dialog.getShell() == null || dialog.isDisposed()) { + dialog = new HistoryListDlg(HandlerUtil.getActiveShell(event)); + dialog.open(); + } else { + dialog.bringToTop(); + } return null; } diff --git a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/HistoryListDlg.java b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/HistoryListDlg.java index 312ed82b01..eb1edf11b5 100644 --- a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/HistoryListDlg.java +++ b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/HistoryListDlg.java @@ -64,6 +64,7 @@ import com.raytheon.viz.ui.editor.AbstractEditor; * ------------ ---------- ----------- -------------------------- * Initial creation * Oct 16, 2012 1229 rferrel Changes for non-blocking AlterBundleDlg. + * Oct 16, 2012 1229 rferrel Make dialog non-blocking. * * * @@ -93,7 +94,7 @@ public class HistoryListDlg extends CaveSWTDialog { private AlterBundleDlg alterDlg; public HistoryListDlg(Shell parent) { - super(parent, SWT.DIALOG_TRIM | SWT.RESIZE); + super(parent, SWT.DIALOG_TRIM | SWT.RESIZE, CAVE.DO_NOT_BLOCK); setText("History List"); try {