Issue #1298 Changes for non-blocking ContourDialog and removal of ButtonEntryDialog.

Change-Id: I6151274f455066c03db49618d6b5801248d48527

Former-commit-id: 0c544da917 [formerly c67543535ff38b777f14df1f41d96dbdacddeb09]
Former-commit-id: 7c8f48fcb5
This commit is contained in:
Roger Ferrel 2012-10-30 15:19:08 -05:00
parent 92fd247ccc
commit c0b480bc7f
3 changed files with 17 additions and 206 deletions

View file

@ -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.
*
* <pre>
*
@ -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.
*
* </pre>
*
@ -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();
}
}
/*

View file

@ -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
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 16, 2012 jdynina Initial creation
*
* </pre>
*
* @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<String,String[]> inputMap;
private String inputText = "";
private String[] selections;
public ButtonEntryDialog(Shell parentShell, String title, HashMap<String,String[]> 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();
}
});
}
}

View file

@ -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.
*
* <pre>
*
@ -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.
*
* </pre>
*
@ -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;