From c0b480bc7fc768779d98b7fa6d298d5f2503b765 Mon Sep 17 00:00:00 2001 From: Roger Ferrel Date: Tue, 30 Oct 2012 15:19:08 -0500 Subject: [PATCH] Issue #1298 Changes for non-blocking ContourDialog and removal of ButtonEntryDialog. Change-Id: I6151274f455066c03db49618d6b5801248d48527 Former-commit-id: 0c544da917015081b7620addfcee9c998bdb3f78 [formerly c67543535ff38b777f14df1f41d96dbdacddeb09] Former-commit-id: 7c8f48fcb57a8fefd811d67d152c76ca3cca9c3e --- .../viz/gfe/actions/SetContourValues.java | 18 +- .../viz/gfe/dialogs/ButtonEntryDialog.java | 195 ------------------ .../viz/gfe/dialogs/ContourDialog.java | 10 +- 3 files changed, 17 insertions(+), 206 deletions(-) delete mode 100644 cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/ButtonEntryDialog.java diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/actions/SetContourValues.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/actions/SetContourValues.java index e2e68b292a..2335e8da27 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/actions/SetContourValues.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/actions/SetContourValues.java @@ -33,7 +33,7 @@ import com.raytheon.viz.gfe.rsc.GFEResource; import com.raytheon.viz.ui.cmenu.AbstractRightClickAction; /** - * TODO Add Description + * Right click action to bring up the Contour dialog. * *
  * 
@@ -41,6 +41,7 @@ import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Jun 5, 2009            randerso     Initial creation
+ * Oct 30, 2012 1298       rferrel     Changes for non-blocking SetContourValues.
  * 
  * 
* @@ -49,6 +50,7 @@ import com.raytheon.viz.ui.cmenu.AbstractRightClickAction; */ public class SetContourValues extends AbstractRightClickAction { + private ContourDialog dialog; /** * Constructor @@ -64,11 +66,15 @@ public class SetContourValues extends AbstractRightClickAction { */ @Override public void run() { - Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() - .getShell(); - ContourDialog contourDialog = new ContourDialog(shell, - ((GFEResource) getSelectedRsc()).getParm()); - contourDialog.open(); + if (dialog == null || dialog.getShell() == null || dialog.isDisposed()) { + Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() + .getShell(); + dialog = new ContourDialog(shell, + ((GFEResource) getSelectedRsc()).getParm()); + dialog.open(); + } else { + dialog.bringToTop(); + } } /* diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/ButtonEntryDialog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/ButtonEntryDialog.java deleted file mode 100644 index d29188fb71..0000000000 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/ButtonEntryDialog.java +++ /dev/null @@ -1,195 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.viz.gfe.dialogs; - -import java.util.HashMap; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.layout.RowLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Dialog; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Shell; - -/** - * TODO Add Description - * - *
- * 
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * May 16, 2012            jdynina     Initial creation
- * 
- * 
- * - * @author jdynina - * @version 1.0 - */ -public class ButtonEntryDialog extends Dialog { - /** - * Dialog shell. - */ - private Shell shell; - - /** - * The display control. - */ - private Display display; - - private String dialogTitle; - - private HashMap inputMap; - - private String inputText = ""; - - private String[] selections; - - public ButtonEntryDialog(Shell parentShell, String title, HashMap map) { - super(parentShell, 0); - - this.dialogTitle = title; - this.inputMap = map; - } - - public String open() { - Shell parent = getParent(); - display = parent.getDisplay(); - shell = new Shell(parent, SWT.DIALOG_TRIM); - - if (dialogTitle != null) { - shell.setText(dialogTitle); - } - - // Create the main layout for the shell. - GridLayout mainLayout = new GridLayout(1, false); - shell.setLayout(mainLayout); - - // Initialize data and all of the controls and layouts - initializeComponents(); - - shell.pack(); - - shell.open(); - while (!shell.isDisposed()) { - if (!display.readAndDispatch()) { - display.sleep(); - } - } - - return inputText; - } - - private void initializeComponents() { - createInputControls(); - createBottomButtons(); - } - - private void createInputControls() { - Composite controlComp = new Composite(shell, SWT.NONE); - GridLayout gl = new GridLayout(inputMap.size(), false); - controlComp.setLayout(gl); - GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, true); - controlComp.setLayoutData(gd); - - selections = new String[inputMap.size()]; - - Listener listener = new Listener () { - public void handleEvent(Event event) { - Button button = (Button)event.widget; - if (!button.getSelection()) return; - - int i = 0; - for (String s : inputMap.keySet()) { - for (String value : inputMap.get(s)) { - if ((value == button.getText()) && - (selections[i] != button.getText())) - selections[i] = button.getText(); - } - i++; - } - } - }; - - - int i = 0; - for (String s : inputMap.keySet()) { - int j = 0; - - Group group = new Group(controlComp, SWT.SHADOW_IN); - group.setText(s); - group.setLayout(new RowLayout(SWT.VERTICAL)); - - for (String value : inputMap.get(s)) { - Button button = new Button(group, SWT.RADIO); - button.setText(value); - if (j == 0) button.setSelection(true); - if (j == 0) selections[i] = value; - button.addListener(SWT.Selection, listener); - j++; - } - i++; - } - } - - private void createBottomButtons() { - Composite buttonComp = new Composite(shell, SWT.NONE); - GridLayout gl = new GridLayout(2, false); - buttonComp.setLayout(gl); - GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - buttonComp.setLayoutData(gd); - - gd = new GridData(SWT.RIGHT, SWT.DEFAULT, true, false); - gd.widthHint = 80; - Button okBtn = new Button(buttonComp, SWT.PUSH); - okBtn.setText("OK"); - okBtn.setLayoutData(gd); - okBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - for (String selection : selections) { - inputText = (inputText + selection + " "); - } - shell.dispose(); - } - }); - - gd = new GridData(SWT.LEFT, SWT.DEFAULT, true, false); - gd.widthHint = 80; - Button cancelBtn = new Button(buttonComp, SWT.PUSH); - cancelBtn.setText("Cancel"); - cancelBtn.setLayoutData(gd); - cancelBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - inputText = null; - shell.dispose(); - } - }); - } -} diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/ContourDialog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/ContourDialog.java index 160f167ba6..a027757c7c 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/ContourDialog.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/ContourDialog.java @@ -34,13 +34,11 @@ import org.eclipse.swt.widgets.Text; 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.viz.gfe.Activator; -import com.raytheon.viz.gfe.constants.StatusConstants; import com.raytheon.viz.gfe.core.parm.Parm; import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; /** - * TODO Add Description + * Dialog for getting contour intervals. * *
  * 
@@ -48,6 +46,7 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Jun 5, 2009            randerso     Initial creation
+ * Oct 30, 2012 1298       rferrel     Code cleanup for non-blocking dialog.
  * 
  * 
* @@ -56,9 +55,10 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; */ public class ContourDialog extends CaveJFACEDialog { - private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(ContourDialog.class); + private final transient IUFStatusHandler statusHandler = UFStatus + .getHandler(ContourDialog.class); - private static final int RESET_ID = IDialogConstants.CLIENT_ID; + private final int RESET_ID = IDialogConstants.CLIENT_ID; private Parm parm;