Issue #1298 Changes for non-blocking SetDeltaDialog and removal of unused class ShowISCInfoDlg.

Change-Id: Icc9482b5e1063d6a4dcc33c106a582e8a460a6d0

Former-commit-id: 9ec6ee1fe4 [formerly 6f6b9dd21a] [formerly 1e8dfdc857] [formerly 9ec6ee1fe4 [formerly 6f6b9dd21a] [formerly 1e8dfdc857] [formerly b421a30116 [formerly 1e8dfdc857 [formerly 149198a0ab46b58518edb02c1bfb19e2f432726c]]]]
Former-commit-id: b421a30116
Former-commit-id: dce9814cc7 [formerly 1272837397] [formerly 9fb3810dd061a915575be1fa8b5d2e12821cf89c [formerly d646f32d6e]]
Former-commit-id: 598844707b6924bafba9f9d28c39f879556aa343 [formerly 3eb1da1b66]
Former-commit-id: 295c73d59e
This commit is contained in:
Roger Ferrel 2012-11-13 13:18:57 -06:00
parent b61234656b
commit 318a56771a
4 changed files with 38 additions and 230 deletions

View file

@ -59,6 +59,7 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
* Feb 18, 2007 njensen Initial creation.
* 05Aug2008 #1407 ebabin Dim delta button for wx/discrete types.
* Oct 25, 2012 #1287 rferrel Code clean up part of non-blocking dialog.
* Oct 13, 2012 #1298 rferrel Changes for non-blocking SetDeltaDialog.
* </pre>
*
* @author njensen
@ -94,8 +95,6 @@ public class EditActionsDialog extends CaveJFACEDialog implements
private IActivatedParmChangedListener parmChanged;
private SetDeltaDialog deltaDialog;
private DataManager dataManager;
private Parm parm;
@ -104,8 +103,6 @@ public class EditActionsDialog extends CaveJFACEDialog implements
private Button deltaButton;
// private LocalizationFile baseLF;
/**
* Constructor
*
@ -327,15 +324,7 @@ public class EditActionsDialog extends CaveJFACEDialog implements
}
private void showDeltaDialog() {
Shell shell = getParentShell();
if (deltaDialog == null) {
deltaDialog = new SetDeltaDialog(shell, dataManager);
deltaDialog.setBlockOnOpen(true);
deltaDialog.open();
deltaDialog = null;
}
SetDeltaDialog.openDialog();
}
private void showPickupDialog() {

View file

@ -31,6 +31,7 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Scale;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
import com.raytheon.viz.gfe.Activator;
import com.raytheon.viz.gfe.core.DataManager;
@ -42,7 +43,7 @@ import com.raytheon.viz.gfe.smarttool.SmartUtil;
import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
/**
* TODO Add Description
* Dialog to adjust a grid's delta value.
*
* <pre>
*
@ -51,6 +52,7 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 16, 2011 dgilling Initial creation
* Nov 13, 2012 1298 rferrel Code clean up for non-blocking dialog.
*
* </pre>
*
@ -61,9 +63,11 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
public class SetDeltaDialog extends CaveJFACEDialog implements
IDisplayedParmListChangedListener, IActivatedParmChangedListener {
private final static int ADJUST_DOWN = 97;
private static SetDeltaDialog dialog;
private final static int ADJUST_UP = 98;
private final int ADJUST_DOWN = 97;
private final int ADJUST_UP = 98;
private DataManager dataManager;
@ -79,8 +83,6 @@ public class SetDeltaDialog extends CaveJFACEDialog implements
private Text entryField;
private int returnCode = IDialogConstants.CANCEL_ID;
private float origValue;
private float res;
@ -117,7 +119,27 @@ public class SetDeltaDialog extends CaveJFACEDialog implements
}
};
public SetDeltaDialog(Shell parent, DataManager dataManager) {
/**
* Allow only one instance of the dialog to exist at any given time.
*/
public static void openDialog() {
if (dialog == null) {
Shell parent = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
DataManager dataManager = DataManager.getCurrentInstance();
dialog = new SetDeltaDialog(parent, dataManager);
dialog.setBlockOnOpen(false);
}
dialog.open();
}
/**
* Private use the static method openDialog.
*
* @param parent
* @param dataManager
*/
private SetDeltaDialog(Shell parent, DataManager dataManager) {
super(parent);
this.setShellStyle(SWT.DIALOG_TRIM | SWT.RESIZE);
this.dataManager = dataManager;
@ -142,7 +164,7 @@ public class SetDeltaDialog extends CaveJFACEDialog implements
*/
@Override
protected void buttonPressed(int buttonId) {
returnCode = buttonId;
setReturnCode(buttonId);
if (buttonId == ADJUST_UP) {
setNewDelta();
SmartUtil.runTool(SmartToolConstants.ADJUST_UP);
@ -154,16 +176,6 @@ public class SetDeltaDialog extends CaveJFACEDialog implements
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.window.Window#getReturnCode()
*/
@Override
public int getReturnCode() {
return returnCode;
}
/*
* (non-Javadoc)
*
@ -268,6 +280,7 @@ public class SetDeltaDialog extends CaveJFACEDialog implements
this);
dataManager.getSpatialDisplayManager()
.removeActivatedParmChangedListener(this);
SetDeltaDialog.dialog = null;
return super.close();
}

View file

@ -1,190 +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.isc;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
/**
* Dialog containing the results of the Show_ISC_Info smart tool
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 08/28/09 1995 bphillip Initial creation
*
* </pre>
*
* @author bphillip
* @version 1
*/
public class ShowISCInfoDlg extends CaveSWTDialog {
/** Text used for color coding */
private static final String OK_TXT = "OK";
/** Text used for color coding */
private static final String IGNORED_TXT = "IGNORED";
/** Text used for color coding */
private static final String FAILED_TXT = "FAILED";
/** The resulting text from the Show_ISC_Info smart tool */
private String text;
/** The font used for displaying the text */
private Font textFont;
/** Custom color for coloring the IGNORED items */
private Color darkOrange;
/** Text box containing the text */
private StyledText textBox;
/**
* Creates a new dialog
*
* @param parentShell
* The shell
* @param text
* The text from Show_ISC_Info smart tool
*/
public ShowISCInfoDlg(Shell parentShell, String text) {
super(parentShell, SWT.DIALOG_TRIM | SWT.RESIZE);
setText("ISC Discrepancy Info");
if (text == null) {
this.text = "";
} else {
this.text = text;
}
}
@Override
protected void disposed() {
textFont.dispose();
darkOrange.dispose();
}
@Override
protected void initializeComponents(Shell shell) {
textFont = new Font(getDisplay(), "Monospace", 8, SWT.NORMAL);
darkOrange = new Color(getDisplay(), 255, 102, 0);
// Initialize all of the controls and layouts
createTextArea();
createBottomButton();
colorText();
}
/**
* Creates the text area and populates the text
*/
private void createTextArea() {
Composite listComp = new Composite(shell, SWT.NONE);
GridLayout gl = new GridLayout(1, false);
listComp.setLayout(gl);
listComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.widthHint = 500;
gd.heightHint = 200;
textBox = new StyledText(listComp, SWT.BORDER | SWT.V_SCROLL);
textBox.setEditable(false);
textBox.setText(text);
textBox.setFont(textFont);
textBox.setLayoutData(gd);
}
/**
* Creates the close button
*/
private void createBottomButton() {
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
Composite buttonComp = new Composite(shell, SWT.NONE);
buttonComp.setLayout(new GridLayout(1, false));
buttonComp.setLayoutData(gd);
int buttonWidth = 120;
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
gd.widthHint = buttonWidth;
Button closeBtn = new Button(buttonComp, SWT.PUSH);
closeBtn.setText("Close");
closeBtn.setLayoutData(gd);
closeBtn.setForeground(getDisplay().getSystemColor(SWT.COLOR_RED));
closeBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
shell.dispose();
}
});
}
/**
* Colors the text according to rules
*/
private void colorText() {
int startLineIndex = 0;
int numLines = textBox.getLineCount();
String tmpStr = null;
for (int i = 0; i < numLines; i++) {
startLineIndex = textBox.getOffsetAtLine(i);
tmpStr = textBox.getLine(i);
if (tmpStr.endsWith(OK_TXT)) {
StyleRange sr = new StyleRange(startLineIndex
+ tmpStr.lastIndexOf(OK_TXT), OK_TXT.length(),
getDisplay().getSystemColor(SWT.COLOR_DARK_GREEN), null);
textBox.setStyleRange(sr);
} else if (tmpStr.endsWith(IGNORED_TXT)) {
StyleRange sr = new StyleRange(startLineIndex
+ tmpStr.lastIndexOf(IGNORED_TXT),
IGNORED_TXT.length(), darkOrange, null);
textBox.setStyleRange(sr);
} else if (tmpStr.endsWith(FAILED_TXT)) {
StyleRange sr = new StyleRange(startLineIndex
+ tmpStr.lastIndexOf(FAILED_TXT), FAILED_TXT.length(),
getDisplay().getSystemColor(SWT.COLOR_RED), null);
textBox.setStyleRange(sr);
}
}
}
}

View file

@ -98,6 +98,7 @@ import com.raytheon.viz.ui.input.InputAdapter;
* 05Aug2008 #1405 ebabin Fix fo delta not displaying after first use.
* 06/03/2011 #8919 rferrel No longer display color bar when
* VisMode is GRAPHIC
* 11/13/20112 #1298 rferrel Changes for non-blocking SetDeltaDialog.
*
* </pre>
*
@ -109,8 +110,8 @@ public class GFEColorbarResource extends
IContextMenuProvider, IPickupValueChangedListener,
IDisplayModeChangedListener, IMessageClient,
IDisplayedParmListChangedListener {
public static final double HEIGHT = 25.0;
public static final double HEIGHT = 25.0;
private class GFEColorbarInputHandler extends InputAdapter {
@ -388,7 +389,7 @@ public class GFEColorbarResource extends
// Construct a bar that is HEIGHT pixels high
double height = HEIGHT * screenExtent.getHeight()
/ paintProps.getCanvasBounds().height;
/ paintProps.getCanvasBounds().height;
PixelExtent pe = new PixelExtent(screenExtent.getMinX(),
screenExtent.getMaxX(), screenExtent.getMinY(),
@ -403,7 +404,7 @@ public class GFEColorbarResource extends
// erase the whole colorbar to a black background
target.drawShadedRect(pe, ColorUtil.BLACK, 1.0, null);
target.drawRect(pe, GFEColorbarResource.COLORBAR_GRAY, 2.0f, 1.0f);
if (currentParm == null) {
return;
}
@ -530,12 +531,7 @@ public class GFEColorbarResource extends
}
private void showDeltaDialog() {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
SetDeltaDialog deltaDialog = new SetDeltaDialog(shell, dManager);
deltaDialog.setBlockOnOpen(true);
deltaDialog.open();
SetDeltaDialog.openDialog();
}
private void showPickupDialog() {