Issue #2088 Non-blocking ColorScaleMgrDlg and ColorChooserDlg.
Change-Id: I6f14726a466780e0dbab13d8b64fa2c55acf55d0 Former-commit-id:bcfe29ffeb
[formerlye73559b871
] [formerlyd5e66e410d
] [formerlybcfe29ffeb
[formerlye73559b871
] [formerlyd5e66e410d
] [formerlyf3bdbde9d3
[formerlyd5e66e410d
[formerly 108c5a4957b6d3ab50eacd5792122f7cd2ff3cba]]]] Former-commit-id:f3bdbde9d3
Former-commit-id:dc01673b13
[formerly44724d9487
] [formerly 2c591fb8750544921169d97733aea020a1760e66 [formerly696885dc4b
]] Former-commit-id: 544f386fbd37410b6480e9f28944dc4523aac519 [formerlyb82c76157c
] Former-commit-id:9f1f91258f
This commit is contained in:
parent
ee0718d7e6
commit
a9e593136c
5 changed files with 253 additions and 197 deletions
|
@ -34,6 +34,7 @@ import com.raytheon.viz.hydrocommon.HydroDisplayManager;
|
|||
import com.raytheon.viz.hydrocommon.colorscalemgr.ColorScaleMgrDlg;
|
||||
import com.raytheon.viz.hydrocommon.colorscalemgr.HydroColorManager;
|
||||
import com.raytheon.viz.hydrocommon.colorscalemgr.NamedColorSetGroup;
|
||||
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||
|
||||
/**
|
||||
* Action for unimplemented features. To be used temporarily until final
|
||||
|
@ -47,6 +48,7 @@ import com.raytheon.viz.hydrocommon.colorscalemgr.NamedColorSetGroup;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 6/27/06 lvenable Initial Creation.
|
||||
* 04/07/2010 4671 mpduff Have the map update upon closure of the dialog.
|
||||
* 07/02/2013 2088 rferrel Changes for non-blocking ColorScaleMgrDlg.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -60,30 +62,45 @@ public class ColorScaleMgrAction extends AbstractHandler {
|
|||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
|
||||
String username = LocalizationManager.getInstance().getCurrentUser();
|
||||
if (colorScaleDlg == null || colorScaleDlg.isDisposed()) {
|
||||
String username = LocalizationManager.getInstance()
|
||||
.getCurrentUser();
|
||||
|
||||
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getShell();
|
||||
colorScaleDlg = new ColorScaleMgrDlg(shell, username);
|
||||
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getShell();
|
||||
colorScaleDlg = new ColorScaleMgrDlg(shell, username);
|
||||
|
||||
HydroColorManager colorManager = HydroColorManager.getInstance();
|
||||
NamedColorSetGroup ncsg = colorManager.getDefaultColorSetGroup();
|
||||
colorManager.populateDefaultColorUseSets(ncsg.getColorGroupArray());
|
||||
colorManager.readColorValuesFromDatabase();
|
||||
HydroColorManager colorManager = HydroColorManager.getInstance();
|
||||
NamedColorSetGroup ncsg = colorManager.getDefaultColorSetGroup();
|
||||
colorManager.populateDefaultColorUseSets(ncsg.getColorGroupArray());
|
||||
colorManager.readColorValuesFromDatabase();
|
||||
|
||||
colorScaleDlg.setTitle("Hydroview Color Scale Manager - User: "
|
||||
+ username);
|
||||
colorScaleDlg.setColorManager(colorManager);
|
||||
boolean dataChanged = (Boolean) colorScaleDlg.open();
|
||||
colorScaleDlg = null;
|
||||
colorScaleDlg.setTitle("Hydroview Color Scale Manager - User: "
|
||||
+ username);
|
||||
colorScaleDlg.setColorManager(colorManager);
|
||||
colorScaleDlg.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
HydroDisplayManager displayManager = HydroDisplayManager.getInstance();
|
||||
displayManager.setColorChanged(dataChanged);
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
if (returnValue instanceof Boolean) {
|
||||
boolean dataChanged = ((Boolean) returnValue)
|
||||
.booleanValue();
|
||||
colorScaleDlg = null;
|
||||
HydroDisplayManager displayManager = HydroDisplayManager
|
||||
.getInstance();
|
||||
displayManager.setColorChanged(dataChanged);
|
||||
|
||||
// redraw the main display
|
||||
displayManager.setDataChanged(dataChanged);
|
||||
StationDisplay sd = StationDisplay.getInstance();
|
||||
sd.redraw();
|
||||
// redraw the main display
|
||||
displayManager.setDataChanged(dataChanged);
|
||||
StationDisplay sd = StationDisplay.getInstance();
|
||||
sd.redraw();
|
||||
}
|
||||
}
|
||||
});
|
||||
colorScaleDlg.open();
|
||||
} else {
|
||||
colorScaleDlg.bringToTop();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -19,23 +19,6 @@
|
|||
**/
|
||||
package com.raytheon.viz.hydrocommon.colorscalemgr;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 8, 2008 mschenke Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mschenke
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
|
@ -47,7 +30,6 @@ 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.Dialog;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
@ -56,25 +38,26 @@ import org.eclipse.swt.widgets.TableColumn;
|
|||
import org.eclipse.swt.widgets.TableItem;
|
||||
|
||||
import com.raytheon.viz.hydrocommon.data.ColorNameData;
|
||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||
|
||||
// TODO : Needs to extend CaveSWTDialog...
|
||||
|
||||
public class ColorChooserDlg extends Dialog {
|
||||
/**
|
||||
* Dialog shell.
|
||||
*/
|
||||
private Shell shell;
|
||||
|
||||
/**
|
||||
* The display control.
|
||||
*/
|
||||
private Display display;
|
||||
|
||||
/**
|
||||
* Return value when the shell is disposed.
|
||||
*/
|
||||
private String returnColorName = null;
|
||||
|
||||
/**
|
||||
* Dialog to select a color by name.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 8, 2008 mschenke Initial creation
|
||||
* Jul 1, 2013 2088 rferrel Now extends CaveSWTDialog and made non-blocking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mschenke
|
||||
* @version 1.0
|
||||
*/
|
||||
public class ColorChooserDlg extends CaveSWTDialog {
|
||||
/**
|
||||
* Control font.
|
||||
*/
|
||||
|
@ -96,18 +79,20 @@ public class ColorChooserDlg extends Dialog {
|
|||
* Dialog title information.
|
||||
*/
|
||||
public ColorChooserDlg(Shell parent) {
|
||||
super(parent, 0);
|
||||
super(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL,
|
||||
CAVE.DO_NOT_BLOCK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Open method used to display the dialog.
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @return True/False.
|
||||
* @see
|
||||
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
|
||||
* .eclipse.swt.widgets.Shell)
|
||||
*/
|
||||
public String open() {
|
||||
Shell parent = getParent();
|
||||
display = parent.getDisplay();
|
||||
shell = new Shell(parent, SWT.DIALOG_TRIM);
|
||||
@Override
|
||||
protected void initializeComponents(Shell shell) {
|
||||
setReturnValue(null);
|
||||
shell.setText("Color Chooser");
|
||||
|
||||
// Create the main layout for the shell.
|
||||
|
@ -119,19 +104,16 @@ public class ColorChooserDlg extends Dialog {
|
|||
|
||||
// Initialize all of the controls and layouts
|
||||
initializeComponents();
|
||||
}
|
||||
|
||||
shell.pack();
|
||||
|
||||
shell.open();
|
||||
while (!shell.isDisposed()) {
|
||||
if (!display.readAndDispatch()) {
|
||||
display.sleep();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed()
|
||||
*/
|
||||
@Override
|
||||
protected void disposed() {
|
||||
controlFont.dispose();
|
||||
|
||||
return returnColorName;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -144,6 +126,9 @@ public class ColorChooserDlg extends Dialog {
|
|||
createBottomButtons();
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup Color Table.
|
||||
*/
|
||||
private void createColorTable() {
|
||||
Color c = null;
|
||||
|
||||
|
@ -164,6 +149,7 @@ public class ColorChooserDlg extends Dialog {
|
|||
TableColumn column2 = new TableColumn(colorTable, SWT.NONE);
|
||||
|
||||
List<ColorNameData> colorNames = DbRGBColors.getAllColors();
|
||||
Display display = getDisplay();
|
||||
|
||||
for (ColorNameData colorName : colorNames) {
|
||||
if (colorName.getColorValue() != null) {
|
||||
|
@ -184,6 +170,9 @@ public class ColorChooserDlg extends Dialog {
|
|||
column2.pack();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create control buttons in the bottom composite.
|
||||
*/
|
||||
private void createBottomButtons() {
|
||||
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
Composite mainButtonComp = new Composite(shell, SWT.NONE);
|
||||
|
@ -201,8 +190,8 @@ public class ColorChooserDlg extends Dialog {
|
|||
okBtn.setLayoutData(gd);
|
||||
okBtn.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
returnColorName = getSelectedColorName();
|
||||
shell.dispose();
|
||||
setReturnValue(getSelectedColorName());
|
||||
close();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -212,12 +201,17 @@ public class ColorChooserDlg extends Dialog {
|
|||
cancelBtn.setLayoutData(gd);
|
||||
cancelBtn.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
returnColorName = null;
|
||||
shell.dispose();
|
||||
setReturnValue(null);
|
||||
close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get selected color name or null if none selected.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String getSelectedColorName() {
|
||||
int index = colorTable.getSelectionIndex();
|
||||
if (index < 0)
|
||||
|
@ -228,6 +222,12 @@ public class ColorChooserDlg extends Dialog {
|
|||
return ti.getText(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the initial color color table index; must be done prior to opening
|
||||
* the dialog.
|
||||
*
|
||||
* @param index
|
||||
*/
|
||||
public void setSelected(int index) {
|
||||
selectedIndex = index;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.eclipse.swt.events.ModifyEvent;
|
|||
import org.eclipse.swt.events.ModifyListener;
|
||||
import org.eclipse.swt.events.MouseAdapter;
|
||||
import org.eclipse.swt.events.MouseEvent;
|
||||
import org.eclipse.swt.events.MouseListener;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
|
@ -57,6 +58,7 @@ import com.raytheon.uf.viz.core.exception.VizException;
|
|||
import com.raytheon.viz.hydrocommon.data.ColorValueData;
|
||||
import com.raytheon.viz.hydrocommon.datamanager.HydroDBDataManager;
|
||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||
|
||||
/**
|
||||
* Color Scale Manager dialog.
|
||||
|
@ -69,6 +71,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* 23 Feb 2011 5400 lbousaidi fixed issues in color/value bar
|
||||
* 11 Mar 2013 15065 lbousaidi fixed issue with both color legend
|
||||
* disappearing after save
|
||||
* 01 Jul 2013 2088 rferrel Changes for non-blocking dialogs.
|
||||
* </pre>
|
||||
*
|
||||
* @author lvenable
|
||||
|
@ -76,16 +79,21 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
*
|
||||
*/
|
||||
public class ColorScaleMgrDlg extends CaveSWTDialog {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
private final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(ColorScaleMgrDlg.class);
|
||||
|
||||
private static final String OFFICE = "Office";
|
||||
private final String OFFICE = "Office";
|
||||
|
||||
private static final String DEFAULT = "Default";
|
||||
private final String DEFAULT = "Default";
|
||||
|
||||
private static final String OFFICE_DEFAULT = "default";
|
||||
private final String OFFICE_DEFAULT = "default";
|
||||
|
||||
private static final String USER = "User";
|
||||
private final String USER = "User";
|
||||
|
||||
/**
|
||||
* Allow only a single instance of the dialog.
|
||||
*/
|
||||
private ColorChooserDlg colorDlg;
|
||||
|
||||
/**
|
||||
* User's name.
|
||||
|
@ -240,6 +248,21 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
|
|||
|
||||
private Button saveAsUserBtn, saveAsOfficeBtn;
|
||||
|
||||
/**
|
||||
* Common mouse listener for labels in the Color Value Label Bar.
|
||||
*/
|
||||
private final MouseListener lableMouseListener = new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseDown(MouseEvent e) {
|
||||
Label lbl = (Label) e.getSource();
|
||||
ColorValueLabels cvl = (ColorValueLabels) lbl.getData();
|
||||
updateEditControlsValueSelected(cvl);
|
||||
updateEditControlsColorSelected(cvl);
|
||||
String source = getSource();
|
||||
changeColor(cvl.getRgbColor(), source);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
@ -249,7 +272,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
|
|||
* User's name.
|
||||
*/
|
||||
public ColorScaleMgrDlg(Shell parent, String userName) {
|
||||
super(parent, SWT.DIALOG_TRIM | SWT.RESIZE);
|
||||
super(parent, SWT.DIALOG_TRIM | SWT.RESIZE, CAVE.DO_NOT_BLOCK);
|
||||
|
||||
this.userName = userName;
|
||||
}
|
||||
|
@ -352,13 +375,6 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
|
|||
*/
|
||||
private Composite createBrowseColorSetComp(Composite parentComp) {
|
||||
|
||||
// gd = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
// Label messageLbl = new Label(mainBrowseComp, SWT.NONE);
|
||||
// messageLbl.setText("Browse controls not implemented yet...");
|
||||
// messageLbl.setLayoutData(gd);
|
||||
|
||||
// TODO, get help from Lee on laying out data
|
||||
|
||||
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
Composite topControlComp = new Composite(parentComp, SWT.NONE);
|
||||
GridLayout gl = new GridLayout(1, false);
|
||||
|
@ -920,7 +936,6 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
|
|||
|
||||
updateColorValueLabelBar();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
|
||||
mb.setText("Error");
|
||||
mb.setMessage("Not a valid entry:\n\n" + valueTF.getText());
|
||||
|
@ -1179,20 +1194,11 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
|
|||
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||
Label c1 = new Label(parent, SWT.BORDER);
|
||||
c1.setLayoutData(gd);
|
||||
|
||||
c1.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseDown(MouseEvent e) {
|
||||
Label lbl = (Label) e.getSource();
|
||||
updateEditControlsValueSelected(e);
|
||||
updateEditControlsColorSelected(e);
|
||||
String source = getSource();
|
||||
changeColor(lbl.getBackground().getRGB(), source);
|
||||
}
|
||||
});
|
||||
c1.addMouseListener(lableMouseListener);
|
||||
|
||||
data.setColorLabel(c1);
|
||||
data.changeLabelColor(rgb);
|
||||
c1.setData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1231,14 +1237,10 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
|
|||
Label lbl = new Label(parent, SWT.BORDER | SWT.CENTER);
|
||||
lbl.setText(text);
|
||||
lbl.setLayoutData(gd);
|
||||
lbl.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseDown(MouseEvent e) {
|
||||
updateEditControlsValueSelected(e);
|
||||
}
|
||||
});
|
||||
lbl.addMouseListener(lableMouseListener);
|
||||
|
||||
data.setValueLbl(lbl);
|
||||
lbl.setData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1344,24 +1346,13 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
|
|||
* @param e
|
||||
* Mouse event.
|
||||
*/
|
||||
private void updateEditControlsValueSelected(MouseEvent e) {
|
||||
Label lbl = (Label) e.getSource();
|
||||
|
||||
for (int i = 0; i < colorValLblArray.size(); i++) {
|
||||
if (colorValLblArray.get(i).valueLblIsEqual(lbl)) {
|
||||
if (currentColor != null) {
|
||||
currentColor.dispose();
|
||||
}
|
||||
|
||||
currentColor = new Color(getDisplay(), colorValLblArray.get(i)
|
||||
.getRgbColor());
|
||||
colorLbl.setBackground(currentColor);
|
||||
|
||||
valueTF.setText(colorValLblArray.get(i).getValueText());
|
||||
|
||||
break;
|
||||
}
|
||||
private void updateEditControlsColorSelected(ColorValueLabels cvl) {
|
||||
if (currentColor != null) {
|
||||
currentColor.dispose();
|
||||
}
|
||||
|
||||
currentColor = new Color(getDisplay(), cvl.getRgbColor());
|
||||
colorLbl.setBackground(currentColor);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1372,15 +1363,8 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
|
|||
* @param e
|
||||
* Mouse event.
|
||||
*/
|
||||
private void updateEditControlsColorSelected(MouseEvent e) {
|
||||
Label lbl = (Label) e.getSource();
|
||||
|
||||
for (int i = 0; i < colorValLblArray.size(); i++) {
|
||||
if (colorValLblArray.get(i).colorLblIsEqual(lbl)) {
|
||||
valueTF.setText(colorValLblArray.get(i).getValueText());
|
||||
break;
|
||||
}
|
||||
}
|
||||
private void updateEditControlsValueSelected(ColorValueLabels cvl) {
|
||||
valueTF.setText(cvl.getValueText());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1605,13 +1589,35 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
|
|||
* @param rgbColor
|
||||
* current color
|
||||
*/
|
||||
private void changeColor(RGB rgbColor, String source) {
|
||||
// Create the color dialog
|
||||
ColorChooserDlg colorDlg = new ColorChooserDlg(shell);
|
||||
private void changeColor(final RGB rgbColor, final String source) {
|
||||
|
||||
colorDlg.setSelected(DbRGBColors.getIndexOf(rgbColor));
|
||||
if (colorDlg == null || colorDlg.isDisposed()) {
|
||||
// Create the color dialog
|
||||
colorDlg = new ColorChooserDlg(shell);
|
||||
|
||||
String val = colorDlg.open();
|
||||
colorDlg.setSelected(DbRGBColors.getIndexOf(rgbColor));
|
||||
colorDlg.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
updateColorVal(rgbColor, source, (String) returnValue);
|
||||
colorDlg = null;
|
||||
}
|
||||
});
|
||||
colorDlg.open();
|
||||
} else {
|
||||
colorDlg.bringToTop();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update to user's selected color value.
|
||||
*
|
||||
* @param rgbColor
|
||||
* @param source
|
||||
* @param val
|
||||
*/
|
||||
private void updateColorVal(RGB rgbColor, String source, String val) {
|
||||
RGB rgb = null;
|
||||
if (val != null) {
|
||||
rgb = RGBColors.getRGBColor(val);
|
||||
|
@ -1804,7 +1810,8 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
|
|||
+ colorManager.getDescription(dataType),
|
||||
colorScaleSets);
|
||||
} catch (VizException e) {
|
||||
e.printStackTrace();
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"Error getting Color Value Data: ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1832,7 +1839,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
|
|||
closeBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
shell.dispose();
|
||||
close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1945,7 +1952,8 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
|
|||
try {
|
||||
manager.putData(cvd);
|
||||
} catch (VizException e1) {
|
||||
e1.printStackTrace();
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"Error saving Color Value Data: ", e1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1968,7 +1976,8 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
|
|||
try {
|
||||
manager.deleteRecord(cvd);
|
||||
} catch (VizException e1) {
|
||||
e1.printStackTrace();
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"Error deleting Color Value Data: ", e1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1994,6 +2003,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
|
|||
updateUsedColorValueLabelBar();
|
||||
updateUsedColorSetGroupText();
|
||||
updateSaveDataTypeCombo();
|
||||
valueTF.setText("");
|
||||
}
|
||||
|
||||
private void changeDuration() {
|
||||
|
@ -2045,7 +2055,6 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
|
|||
// 0. Collect data to delete (user, dataType, duration
|
||||
String dataType = dataTypeCbo.getText();
|
||||
String duration = selectedDurationInSeconds.toString();
|
||||
String dataTypeKey = duration + "_" + dataType;
|
||||
java.util.List<ColorScaleData> data = editColorData
|
||||
.getUsedColorScaleDataArray(source, duration + "_" + dataType);
|
||||
ColorValueData cvd = new ColorValueData();
|
||||
|
@ -2060,19 +2069,12 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
|
|||
try {
|
||||
manager.deleteRecord(cvd);
|
||||
} catch (VizException e) {
|
||||
e.printStackTrace();
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"Error deleting Color Value Data: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Update editColorData
|
||||
// if (cvd.getThresholdValue().equals("-9999.0")) {
|
||||
// editColorData.deleteColorValue(source, dataTypeKey, -9999.0);
|
||||
// } else if (cvd.getThresholdValue().equals("-8888.0")) {
|
||||
// editColorData.deleteColorValue(source, dataTypeKey, -8888.0);
|
||||
// } else {
|
||||
// editColorData.deleteColorValue(source, dataTypeKey, Double
|
||||
// .parseDouble(cvd.getThresholdValue()));
|
||||
// }
|
||||
boolean dataLeft = true;
|
||||
if (source.equals(DEFAULT)) {
|
||||
createDefaultData();
|
||||
|
@ -2080,10 +2082,6 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
|
|||
dataLeft = createColorData(source);
|
||||
}
|
||||
|
||||
// ColorDataTypeSets cdts = editColorData.getColorDataTypeSets(source);
|
||||
// cdts.addDataTypeColorSets(duration + "_" + dataType, null);
|
||||
// editColorData.addSource(source, cdts);
|
||||
|
||||
// 3. Update dialog
|
||||
boolean rval = false;
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.Map;
|
|||
import com.raytheon.uf.common.dataquery.db.QueryResultRow;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* A sub-class of HydroDBData for handling data for color values.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -32,6 +32,7 @@ import com.raytheon.uf.common.dataquery.db.QueryResultRow;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 10, 2008 mschenke Initial creation
|
||||
* Jul 01, 2013 2088 rferrel Part of non-blocking dialogs fixed Comparable.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -40,7 +41,7 @@ import com.raytheon.uf.common.dataquery.db.QueryResultRow;
|
|||
*/
|
||||
|
||||
public class ColorValueData extends HydroDBData implements IHydroDBData,
|
||||
Comparable {
|
||||
Comparable<ColorValueData> {
|
||||
|
||||
private static final String databaseName = "colorvalue";
|
||||
|
||||
|
@ -107,17 +108,34 @@ public class ColorValueData extends HydroDBData implements IHydroDBData,
|
|||
setColorName(getDBValue("color_name", data, dataMap, ""));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.hydrocommon.data.IHydroDBData#getConstrainedSelectStatement
|
||||
* ()
|
||||
*/
|
||||
@Override
|
||||
public String getConstrainedSelectStatement() {
|
||||
return String.format(constSelectStmtString, userId, applicationName,
|
||||
colorUseName, duration);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.hydrocommon.data.IHydroDBData#getDeleteStatement()
|
||||
*/
|
||||
@Override
|
||||
public String getDeleteStatement() {
|
||||
return String.format(deleteStmtString, getPKStatement());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.hydrocommon.data.IHydroDBData#getExistsStatement()
|
||||
*/
|
||||
@Override
|
||||
public String getExistsStatement() {
|
||||
return String.format(existsStmtString, getPKStatement());
|
||||
|
@ -130,17 +148,32 @@ public class ColorValueData extends HydroDBData implements IHydroDBData,
|
|||
colorName);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.hydrocommon.data.IHydroDBData#getPKStatement()
|
||||
*/
|
||||
@Override
|
||||
public String getPKStatement() {
|
||||
return String.format(pkStmtString, userId, applicationName,
|
||||
colorUseName, duration, thresholdValue);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.hydrocommon.data.IHydroDBData#getSelectStatement()
|
||||
*/
|
||||
@Override
|
||||
public String getSelectStatement() {
|
||||
return selectStmtString;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.hydrocommon.data.IHydroDBData#getUpdateStatement()
|
||||
*/
|
||||
@Override
|
||||
public String getUpdateStatement() {
|
||||
return String.format(updateStmtString, userId, applicationName,
|
||||
|
@ -204,17 +237,16 @@ public class ColorValueData extends HydroDBData implements IHydroDBData,
|
|||
this.colorName = colorName;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(Object o) {
|
||||
if (o instanceof ColorValueData) {
|
||||
double l = Double.parseDouble(getThresholdValue());
|
||||
double r = Double.parseDouble(((ColorValueData) o)
|
||||
.getThresholdValue());
|
||||
if (l > r) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
public int compareTo(ColorValueData o) {
|
||||
Double left = new Double(getThresholdValue());
|
||||
Double right = new Double(o.getThresholdValue());
|
||||
return left.compareTo(right);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import com.raytheon.viz.mpe.ui.MPEDisplayManager;
|
|||
import com.raytheon.viz.mpe.ui.colors.MPEColorManager;
|
||||
import com.raytheon.viz.mpe.ui.rsc.MPEFieldResource;
|
||||
import com.raytheon.viz.mpe.ui.rsc.MPEFieldResourceData;
|
||||
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
|
@ -43,6 +44,7 @@ import com.raytheon.viz.mpe.ui.rsc.MPEFieldResourceData;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 5, 2008 mschenke Initial creation
|
||||
* Apr 18, 2013 1920 mpduff Set new ColorMap.
|
||||
* Jul 02, 2013 2088 rferrel Changes for non-blocking ColorScaleMgrDlg.
|
||||
* </pre>
|
||||
*
|
||||
* @author mschenke
|
||||
|
@ -56,40 +58,47 @@ public class MPEColorScaleMgrAction extends AbstractHandler {
|
|||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
|
||||
String username = LocalizationManager.getInstance().getCurrentUser();
|
||||
if (colorScaleDlg == null || colorScaleDlg.isDisposed()) {
|
||||
String username = LocalizationManager.getInstance()
|
||||
.getCurrentUser();
|
||||
|
||||
System.out.println("***** Username = >" + username + "<");
|
||||
|
||||
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getShell();
|
||||
if (colorScaleDlg == null) {
|
||||
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getShell();
|
||||
colorScaleDlg = new ColorScaleMgrDlg(shell, username);
|
||||
colorScaleDlg.setTitle("MPE Color Scale Manager - User: "
|
||||
+ username);
|
||||
colorScaleDlg.setColorManager(new MPEColorManager());
|
||||
colorScaleDlg.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
colorScaleDlg = null;
|
||||
|
||||
MPEFieldResource displayedFieldResource = MPEDisplayManager
|
||||
.getCurrent().getDisplayedFieldResource();
|
||||
|
||||
if (displayedFieldResource != null) {
|
||||
MPEFieldResourceData resourceData = displayedFieldResource
|
||||
.getResourceData();
|
||||
displayedFieldResource
|
||||
.getCapability(ColorMapCapability.class)
|
||||
.setColorMapParameters(
|
||||
MPEDisplayManager.createColorMap(
|
||||
resourceData.getCvUseString(),
|
||||
resourceData
|
||||
.getDurationInHours(),
|
||||
resourceData.getDataUnits(),
|
||||
resourceData.getDisplayUnits()));
|
||||
DisplayFieldData dt = MPEDisplayManager.getCurrent()
|
||||
.getDisplayFieldType();
|
||||
|
||||
MPEDisplayManager.getCurrent().displayFieldData(dt);
|
||||
}
|
||||
}
|
||||
});
|
||||
colorScaleDlg.open();
|
||||
colorScaleDlg = null;
|
||||
} else {
|
||||
colorScaleDlg.open();
|
||||
}
|
||||
|
||||
MPEFieldResource displayedFieldResource = MPEDisplayManager
|
||||
.getCurrent().getDisplayedFieldResource();
|
||||
|
||||
if (displayedFieldResource != null) {
|
||||
MPEFieldResourceData resourceData = displayedFieldResource
|
||||
.getResourceData();
|
||||
displayedFieldResource.getCapability(ColorMapCapability.class)
|
||||
.setColorMapParameters(
|
||||
MPEDisplayManager.createColorMap(
|
||||
resourceData.getCvUseString(),
|
||||
resourceData.getDurationInHours(),
|
||||
resourceData.getDataUnits(),
|
||||
resourceData.getDisplayUnits()));
|
||||
DisplayFieldData dt = MPEDisplayManager.getCurrent()
|
||||
.getDisplayFieldType();
|
||||
|
||||
MPEDisplayManager.getCurrent().displayFieldData(dt);
|
||||
colorScaleDlg.bringToTop();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
Loading…
Add table
Reference in a new issue