diff --git a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/threshold/FogAlgorithmMgr.java b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/threshold/FogAlgorithmMgr.java
index 40dc738bfd..894de02f4f 100644
--- a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/threshold/FogAlgorithmMgr.java
+++ b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/threshold/FogAlgorithmMgr.java
@@ -29,39 +29,76 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
+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.uf.viz.monitor.filename.DefaultFilenameMgr;
import com.raytheon.uf.viz.monitor.fog.xml.FogMonitorAlgorithmXML;
+/**
+ * Fog Algorithm Threshold Manager
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * Dec 3, 2012 1351 skorolev Cleaned code
+ *
+ *
+ *
+ * @author
+ * @version 1.0
+ */
public class FogAlgorithmMgr {
- private static FogAlgorithmMgr classInstance;
+ private final IUFStatusHandler statusHandler = UFStatus
+ .getHandler(FogAlgorithmMgr.class);
+
+ /** Fog Algorithm Threshold Manager instance **/
+ private final static FogAlgorithmMgr classInstance = new FogAlgorithmMgr();
+
+ /** Default Algorithm Threshold file name **/
private final String defaultAlgFilename = "FogMonitorAlgThresh.xml";
+ /** Current Algorithm Threshold full file path **/
private String currFullPathAndFileName;
+ /** Algorithm Threshold XML **/
private FogMonitorAlgorithmXML algXML;
+ /** Default File Manager **/
private DefaultFilenameMgr defaultFileNameMgr;
+ /**
+ * Gets instance of Fog Algorithm Threshold Manager.
+ *
+ * @return
+ */
+ public static FogAlgorithmMgr getInstance() {
+ return classInstance;
+ }
+
+ /**
+ * Constructor
+ */
private FogAlgorithmMgr() {
init();
}
- public static FogAlgorithmMgr getInstance() {
- if (classInstance == null) {
- classInstance = new FogAlgorithmMgr();
- }
-
- return classInstance;
- }
-
+ /**
+ * Fog Algorithm Threshold Manager initialization.
+ */
private void init() {
defaultFileNameMgr = new DefaultFilenameMgr(getDefaultFileNamePath());
defaultFileNameMgr.readXmlConfig();
-
readInDefaultXML();
}
+ /**
+ * Reads default Threshold XML file.
+ */
private void readInDefaultXML() {
if (defaultFileNameMgr.getDefaultThresholdFilename() != null
&& defaultFileNameMgr.getDefaultThresholdFilename().length() > 0) {
@@ -80,28 +117,39 @@ public class FogAlgorithmMgr {
}
}
+ /**
+ * Gets path of current Algorithm Threshold file
+ *
+ * @return file path
+ */
public String getAlgorithmThresholdPath() {
- String fs = String.valueOf(File.separatorChar);
+ String fs = IPathManager.SEPARATOR;
StringBuilder sb = new StringBuilder();
-
sb.append("fog").append(fs);
sb.append("algorithm").append(fs);
-
return sb.toString();
}
+ /**
+ * Gets path of default Algorithm Threshold file
+ *
+ * @return file path
+ */
public String getDefaultFileNamePath() {
- String fs = String.valueOf(File.separatorChar);
+ String fs = IPathManager.SEPARATOR;
StringBuilder sb = new StringBuilder();
-
sb.append("fog").append(fs);
sb.append("threshold").append(fs);
sb.append("display").append(fs);
sb.append("defaultThresh").append(fs);
-
return sb.toString();
}
+ /**
+ * Sets default Algorithm Threshold file path.
+ *
+ * @param fileName
+ */
public void setDefaultAlgorithmFileName(String fileName) {
if (fileName == null) {
defaultFileNameMgr.setDefaultThresholdFilename("");
@@ -109,11 +157,9 @@ public class FogAlgorithmMgr {
+ defaultAlgFilename;
return;
}
-
if (fileName.endsWith(".xml") == false) {
fileName.concat(".xml");
}
-
if (fileName.compareTo(defaultAlgFilename) == 0) {
defaultFileNameMgr.setDefaultThresholdFilename("");
} else {
@@ -121,83 +167,102 @@ public class FogAlgorithmMgr {
}
}
+ /**
+ * Reads Algorithm Threshold XML.
+ */
public void readAlgorithmXml() {
try {
algXML = null;
IPathManager pm = PathManagerFactory.getPathManager();
File path = pm.getStaticFile(currFullPathAndFileName);
-
- System.out.println("**** readAlgorithmXml() path = " + path);
-
algXML = JAXB.unmarshal(path, FogMonitorAlgorithmXML.class);
} catch (Exception e) {
- e.printStackTrace();
+ statusHandler.handle(Priority.ERROR, e.getMessage());
}
}
+ /**
+ * Menu option Save as... Algorithm Threshold XML file.
+ *
+ * @param newFileName
+ */
public void saveAlgorithmXmlAs(String newFileName) {
if (newFileName.trim().compareTo(defaultAlgFilename) == 0) {
return;
}
-
currFullPathAndFileName = getAlgorithmThresholdPath() + newFileName;
saveAlgorithmXml();
}
+ /**
+ * Menu option Save... Algorithm Threshold XML file.
+ */
public void saveAlgorithmXml() {
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext context = pm.getContext(
LocalizationType.CAVE_STATIC, LocalizationLevel.SITE);
LocalizationFile locFile = pm.getLocalizationFile(context,
currFullPathAndFileName);
-
if (locFile.getFile().getParentFile().exists() == false) {
- System.out.println("Creating new directory");
-
- if (locFile.getFile().getParentFile().mkdirs() == false) {
- System.out.println("Could not create new directory...");
- }
+ locFile.getFile().getParentFile().mkdirs();
}
-
try {
- System.out.println("saveAlgorithmXml() -- "
- + locFile.getFile().getAbsolutePath());
JAXB.marshal(algXML, locFile.getFile());
locFile.save();
} catch (Exception e) {
- e.printStackTrace();
+ statusHandler.handle(Priority.ERROR, e.getMessage());
}
}
+ /**
+ * Menu option Delete... Algorithm Threshold XML file.
+ */
public void deleteCurrentAlgorithmFile() {
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext context = pm.getContext(
LocalizationType.CAVE_STATIC, LocalizationLevel.SITE);
LocalizationFile locFile = pm.getLocalizationFile(context,
currFullPathAndFileName);
-
try {
if (locFile != null) {
locFile.delete();
}
} catch (Exception e) {
- e.printStackTrace();
+ statusHandler.handle(Priority.ERROR, e.getMessage());
}
}
+ /**
+ * Menu option Load... Algorithm Threshold XML file.
+ *
+ * @param fileName
+ */
public void loadAlgorithmThreashold(String fileName) {
currFullPathAndFileName = getAlgorithmThresholdPath() + fileName;
readAlgorithmXml();
}
+ /**
+ * Menu option Load default... Algorithm Threshold XML file.
+ */
public void loadDefaultAlgorithmData() {
readInDefaultXML();
}
+ /**
+ * Gets default Algorithm Threshold XML file name.
+ *
+ * @return defaultAlgFilename
+ */
public String getDefaultAlgorithmFileName() {
return defaultAlgFilename;
}
+ /**
+ * Gets Algorithm Threshold XML.
+ *
+ * @return algXML
+ */
public FogMonitorAlgorithmXML getAlgorithmXML() {
return algXML;
}
diff --git a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/actions/FogAlgoConfigAction.java b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/actions/FogAlgoConfigAction.java
index 095a9493be..1e50b68b3b 100644
--- a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/actions/FogAlgoConfigAction.java
+++ b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/actions/FogAlgoConfigAction.java
@@ -28,7 +28,7 @@ import org.eclipse.ui.PlatformUI;
import com.raytheon.uf.viz.monitor.fog.ui.dialogs.FogMonThreshSetupDlg;
/**
- * The Fog Monitor Action
+ * The Fog Algorithm Configuration Action.
*
*
*
@@ -36,6 +36,7 @@ import com.raytheon.uf.viz.monitor.fog.ui.dialogs.FogMonThreshSetupDlg;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 19 2009 3963 dhladky Initial creation.
+ * Nov 29 2012 1351 skorolev Changes for non-blocking dialog.
*
*
*
@@ -43,23 +44,17 @@ import com.raytheon.uf.viz.monitor.fog.ui.dialogs.FogMonThreshSetupDlg;
* @version 1.0
*/
-public class FogAlgoConfigAction extends AbstractHandler
-{
- private FogMonThreshSetupDlg fogThreshSetup;
+public class FogAlgoConfigAction extends AbstractHandler {
+ private FogMonThreshSetupDlg fogAlgoSetupDlg;
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
-
- Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
-
- if (fogThreshSetup == null)
- {
- fogThreshSetup = new FogMonThreshSetupDlg(shell);
- fogThreshSetup.open();
- fogThreshSetup = null;
+ if (fogAlgoSetupDlg == null) {
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getShell();
+ fogAlgoSetupDlg = new FogMonThreshSetupDlg(shell);
}
-
+ fogAlgoSetupDlg.open();
return null;
}
-
}
\ No newline at end of file
diff --git a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonThreshSetupDlg.java b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonThreshSetupDlg.java
index 6068e857cf..ef819ed5fd 100644
--- a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonThreshSetupDlg.java
+++ b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonThreshSetupDlg.java
@@ -22,6 +22,8 @@ package com.raytheon.uf.viz.monitor.fog.ui.dialogs;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
@@ -33,15 +35,18 @@ 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.Layout;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Scale;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.common.localization.LocalizationFile;
+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.uf.viz.monitor.fog.Activator;
import com.raytheon.uf.viz.monitor.fog.FogMonitor;
import com.raytheon.uf.viz.monitor.fog.listeners.IFogResourceListener;
@@ -50,89 +55,125 @@ import com.raytheon.uf.viz.monitor.fog.ui.dialogs.ThresholdCanvas.RangeEnum;
import com.raytheon.uf.viz.monitor.fog.ui.dialogs.ThresholdData.Threshold;
import com.raytheon.uf.viz.monitor.ui.dialogs.LoadSaveDeleteSelectDlg;
import com.raytheon.uf.viz.monitor.ui.dialogs.LoadSaveDeleteSelectDlg.DialogType;
+import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
+import com.raytheon.viz.ui.dialogs.ICloseCallback;
-public class FogMonThreshSetupDlg extends Dialog {
- /**
- * Dialog shell.
- */
- private Shell shell;
+/**
+ * Fog Monitor threshold algorithm setting dialog.
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * Nov 29, 2012 1351 skorolev Changes for non-blocking dialog.
+ *
+ *
+ *
+ * @author
+ * @version 1.0
+ */
+public class FogMonThreshSetupDlg extends CaveSWTDialog {
- /**
- * The display control.
- */
- private Display display;
+ private final IUFStatusHandler statusHandler = UFStatus
+ .getHandler(FogMonThreshSetupDlg.class);
- /**
- * Return value when the shell is disposed.
- */
- private Boolean returnValue = false;
-
- /**
- * Control font.
- */
+ /** Control font. **/
private Font controlFont;
+ /** Fog Product **/
private Button fogProductRdo;
+ /** VIS (normalized count) **/
private Button visRdo;
+ /** Y_lo boundary **/
private Button yLoRdo;
+ /** R_lo boundary **/
private Button rLoRdo;
+ /** R_hi boundary **/
private Button rHiRdo;
+ /** Y_hi boundary **/
private Button yHiRdo;
+ /** Undo **/
private Button undoBtn;
+ /** Redo **/
private Button redoBtn;
+ /** Threshold Canvas **/
private ThresholdCanvas threshCanvas;
+ /** max Cloud Temperature Threshold Scale **/
private Scale maxCloudTempScale;
+ /** Ice Snow vs Fog Threshold Scale **/
private Scale iceSnowVsFogScale;
+ /** Ice Snow vs Fog Threshold check box **/
private Button iceSnowVsFogChk;
+ /** Cool Fog vs Warm Surface Threshold Scale **/
private Scale coolFogVsWarmSurfScale;
+ /** Cool Fog vs Warm Surface Threshold check box **/
private Button coolFogVsWarmSurfChk;
+ /** daytime Smooth Threshold Scale **/
private Scale daytimeSmoothScale;
+ /** daytime Smooth Threshold check box **/
private Button daytimeSmoothChk;
+ /** adjacency Threshold Scale **/
private Scale adjacencyThreshScale;
+ /** Adjacency Threshold check box **/
private Button adjacencyThreshChk;
+ /** twilight Angle Threshold Scale **/
private Scale twilightAngleScale;
+ /** twilight Angle Threshold check box **/
private Button twilightAngleChk;
+ /** fractal Dimension Scale **/
private Scale fractalDimScale;
+ /** fractal Dimension check box **/
private Button fractalDimChk;
+ /** max Cloud Temperature Threshold image **/
private Image maxCloudTempImg;
+ /** Ice Snow vs Fog Threshold image **/
private Image iceSnowVsFogImg;
+ /** Cool Fog vs Warm Surface Threshold image **/
private Image coolFogVsWarmSurfImg;
+ /** daytime Smooth Threshold image **/
private Image daytimeSmoothImg;
+ /** Adjacency Threshold image **/
private Image adjacencyThreshImg;
+ /** twilight Angle image **/
private Image twilightAngleImg;
+ /** fractal Dimension image **/
private Image fractalDimImg;
+ /** Threshold Data **/
private ThresholdData thresholdData;
- private HashMap scaleLblMap;
+ /** Scale labels map **/
+ private Map scaleLblMap;
/** gateway to fog monitor **/
private FogMonitor fog = null;
@@ -141,7 +182,19 @@ public class FogMonThreshSetupDlg extends Dialog {
private FogAlgorithmMgr fam = null;
/** Array of fogAlg listeners **/
- private ArrayList fogListeners = new ArrayList();
+ private List fogListeners = new ArrayList();
+
+ /** Menu option Open... **/
+ private LoadSaveDeleteSelectDlg openDlg;
+
+ /** Menu option Save as ... **/
+ private LoadSaveDeleteSelectDlg saveDlg;
+
+ /** Menu option Delete... **/
+ private LoadSaveDeleteSelectDlg deleteDlg;
+
+ /** Menu option Select... **/
+ private LoadSaveDeleteSelectDlg selectDlg;
/**
* Constructor.
@@ -150,42 +203,36 @@ public class FogMonThreshSetupDlg extends Dialog {
* Parent shell.
*/
public FogMonThreshSetupDlg(Shell parent) {
- super(parent, 0);
+ super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK
+ | CAVE.INDEPENDENT_SHELL);
+ setText("Fog Monitor Threshold Setup");
fam = FogAlgorithmMgr.getInstance();
fog = FogMonitor.getInstance();
this.addFogListener(fog);
}
- /**
- * Open method used to display the dialog.
+ /*
+ * (non-Javadoc)
*
- * @return True/False.
+ * @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
*/
- public Object open() {
- Shell parent = getParent();
- display = parent.getDisplay();
- shell = new Shell(parent, SWT.DIALOG_TRIM);
- shell.setText("Fog Monitor Threshold Setup");
-
+ @Override
+ protected Layout constructShellLayout() {
// Create the main layout for the shell.
GridLayout mainLayout = new GridLayout(1, false);
mainLayout.marginHeight = 1;
mainLayout.marginWidth = 1;
mainLayout.verticalSpacing = 1;
- shell.setLayout(mainLayout);
-
- // Initialize all of the controls and layouts
- initializeComponents();
-
- shell.pack();
-
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
+ return mainLayout;
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed()
+ */
+ @Override
+ protected void disposed() {
controlFont.dispose();
maxCloudTempImg.dispose();
iceSnowVsFogImg.dispose();
@@ -194,64 +241,58 @@ public class FogMonThreshSetupDlg extends Dialog {
adjacencyThreshImg.dispose();
twilightAngleImg.dispose();
fractalDimImg.dispose();
-
this.removeFogAlgListener(fog);
-
- return returnValue;
}
/**
- * Initialize the components on the display.
+ * @param shell
*/
- private void initializeComponents() {
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
+ * .eclipse.swt.widgets.Shell)
+ */
+ @Override
+ protected void initializeComponents(Shell shell) {
scaleLblMap = new HashMap();
-
controlFont = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL);
createImages();
thresholdData = new ThresholdData();
-
createMenu();
-
createTopRadioControls();
createThresholdControls();
-
addSeparator(shell);
addSeparator(shell);
-
createScaleControls();
-
updateDataControls();
}
+ /**
+ * Creates the Menu.
+ */
private void createMenu() {
Menu menuBar = new Menu(shell, SWT.BAR);
-
createFileMenu(menuBar);
-
shell.setMenuBar(menuBar);
}
/**
- * Create the File menu.
+ * Creates the File menu.
*
* @param menuBar
* Menu bar.
*/
private void createFileMenu(Menu menuBar) {
- // -------------------------------------
- // Create the file menu
- // -------------------------------------
MenuItem fileMenuItem = new MenuItem(menuBar, SWT.CASCADE);
fileMenuItem.setText("&File");
-
// Create the File menu item with a File "dropdown" menu
Menu fileMenu = new Menu(menuBar);
fileMenuItem.setMenu(fileMenu);
-
// -------------------------------------------------
// Create all the items in the File dropdown menu
// -------------------------------------------------
-
// Configure menu item
MenuItem openMI = new MenuItem(fileMenu, SWT.NONE);
openMI.setText("Open...");
@@ -310,17 +351,19 @@ public class FogMonThreshSetupDlg extends Dialog {
});
new MenuItem(fileMenu, SWT.SEPARATOR);
-
// Exit menu item
MenuItem exitMI = new MenuItem(fileMenu, SWT.NONE);
exitMI.setText("Exit");
exitMI.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
- shell.dispose();
+ close();
}
});
}
+ /**
+ * Creates Top Radio Controls
+ */
private void createTopRadioControls() {
Composite radioBtnComp = new Composite(shell, SWT.NONE);
GridLayout gl = new GridLayout(2, false);
@@ -345,22 +388,23 @@ public class FogMonThreshSetupDlg extends Dialog {
});
}
+ /**
+ * Creates Threshold Controls
+ */
private void createThresholdControls() {
threshCanvas = new ThresholdCanvas(shell);
-
/*
* Add the Y_lo/R_lo/R_hi/Y_hi radio buttons.
*/
Composite loHiComp = new Composite(shell, SWT.NONE);
loHiComp.setLayout(new GridLayout(4, true));
- loHiComp
- .setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
+ loHiComp.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
yLoRdo = new Button(loHiComp, SWT.RADIO);
yLoRdo.setText("Y_lo");
yLoRdo.setSelection(true);
yLoRdo.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
- yLoRdo.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
+ yLoRdo.setBackground(getDisplay().getSystemColor(SWT.COLOR_YELLOW));
yLoRdo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
threshCanvas.setThresholdRange(ThresholdCanvas.RangeEnum.YLo);
@@ -370,7 +414,7 @@ public class FogMonThreshSetupDlg extends Dialog {
rLoRdo = new Button(loHiComp, SWT.RADIO);
rLoRdo.setText("R_lo");
rLoRdo.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
- rLoRdo.setBackground(display.getSystemColor(SWT.COLOR_RED));
+ rLoRdo.setBackground(getDisplay().getSystemColor(SWT.COLOR_RED));
rLoRdo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
threshCanvas.setThresholdRange(ThresholdCanvas.RangeEnum.RLo);
@@ -380,7 +424,7 @@ public class FogMonThreshSetupDlg extends Dialog {
rHiRdo = new Button(loHiComp, SWT.RADIO);
rHiRdo.setText("R_hi");
rHiRdo.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
- rHiRdo.setBackground(display.getSystemColor(SWT.COLOR_RED));
+ rHiRdo.setBackground(getDisplay().getSystemColor(SWT.COLOR_RED));
rHiRdo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
threshCanvas.setThresholdRange(ThresholdCanvas.RangeEnum.RHi);
@@ -390,7 +434,7 @@ public class FogMonThreshSetupDlg extends Dialog {
yHiRdo = new Button(loHiComp, SWT.RADIO);
yHiRdo.setText("Y_hi");
yHiRdo.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
- yHiRdo.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
+ yHiRdo.setBackground(getDisplay().getSystemColor(SWT.COLOR_YELLOW));
yHiRdo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
threshCanvas.setThresholdRange(ThresholdCanvas.RangeEnum.YHi);
@@ -464,12 +508,14 @@ public class FogMonThreshSetupDlg extends Dialog {
});
}
+ /**
+ * Creates Scale Controls
+ */
private void createScaleControls() {
Composite controlComp = new Composite(shell, SWT.NONE);
controlComp.setLayout(new GridLayout(3, false));
controlComp.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true,
false));
-
/*
* Create the Maximum Cloud Temperature controls.
*/
@@ -493,17 +539,11 @@ public class FogMonThreshSetupDlg extends Dialog {
maxCloudTempScale = new Scale(maxCloudTempComp, SWT.HORIZONTAL);
maxCloudTempScale.setLayoutData(gd);
- // maxCloudTempSpnr = new Spinner(maxCloudTempComp, SWT.BORDER);
- // maxCloudTempSpnr.setLayoutData(new GridData(50, SWT.DEFAULT));
- //
- // setupControlsDecimal(maxCloudTempScale, maxCloudTempSpnr, thresh);
-
Label tmp = new Label(maxCloudTempComp, SWT.RIGHT);
tmp.setLayoutData(new GridData(50, SWT.DEFAULT));
tmp.setFont(controlFont);
setupControlsDecimalLbl(maxCloudTempScale, tmp, thresh);
-
addSeparator(controlComp);
/*
@@ -529,17 +569,11 @@ public class FogMonThreshSetupDlg extends Dialog {
iceSnowVsFogScale = new Scale(daytimeIceSnowComp, SWT.HORIZONTAL);
iceSnowVsFogScale.setLayoutData(gd);
- // iceSnowVsFogSpnr = new Spinner(daytimeIceSnowComp, SWT.BORDER);
- // iceSnowVsFogSpnr.setLayoutData(new GridData(50, SWT.DEFAULT));
- //
- // setupControlsDecimal(iceSnowVsFogScale, iceSnowVsFogSpnr, thresh);
-
tmp = new Label(daytimeIceSnowComp, SWT.RIGHT);
tmp.setLayoutData(new GridData(50, SWT.DEFAULT));
tmp.setFont(controlFont);
setupControlsDecimalLbl(iceSnowVsFogScale, tmp, thresh);
-
addSeparator(controlComp);
/*
@@ -565,18 +599,11 @@ public class FogMonThreshSetupDlg extends Dialog {
coolFogVsWarmSurfScale = new Scale(coolFogComp, SWT.HORIZONTAL);
coolFogVsWarmSurfScale.setLayoutData(gd);
- // coolFogVsWarmSurfSpnr = new Spinner(coolFogComp, SWT.BORDER);
- // coolFogVsWarmSurfSpnr.setLayoutData(new GridData(50, SWT.DEFAULT));
- //
- // setupControlsDecimal(coolFogVsWarmSurfScale, coolFogVsWarmSurfSpnr,
- // thresh);
-
tmp = new Label(coolFogComp, SWT.RIGHT);
tmp.setLayoutData(new GridData(50, SWT.DEFAULT));
tmp.setFont(controlFont);
setupControlsDecimalLbl(coolFogVsWarmSurfScale, tmp, thresh);
-
addSeparator(controlComp);
/*
@@ -602,17 +629,11 @@ public class FogMonThreshSetupDlg extends Dialog {
daytimeSmoothScale = new Scale(daytimeSmoothComp, SWT.HORIZONTAL);
daytimeSmoothScale.setLayoutData(gd);
- // daytimeSmoothSpnr = new Spinner(daytimeSmoothComp, SWT.BORDER);
- // daytimeSmoothSpnr.setLayoutData(new GridData(50, SWT.DEFAULT));
- //
- // setupControlsDecimal(daytimeSmoothScale, daytimeSmoothSpnr, thresh);
-
tmp = new Label(daytimeSmoothComp, SWT.RIGHT);
tmp.setLayoutData(new GridData(50, SWT.DEFAULT));
tmp.setFont(controlFont);
setupControlsDecimalLbl(daytimeSmoothScale, tmp, thresh);
-
addSeparator(controlComp);
/*
@@ -638,18 +659,11 @@ public class FogMonThreshSetupDlg extends Dialog {
adjacencyThreshScale = new Scale(adjacencyThreshComp, SWT.HORIZONTAL);
adjacencyThreshScale.setLayoutData(gd);
- // adjacencyThreshSpnr = new Spinner(adjacencyThreshComp, SWT.BORDER);
- // adjacencyThreshSpnr.setLayoutData(new GridData(50, SWT.DEFAULT));
- //
- // setupControlsInteger(adjacencyThreshScale, adjacencyThreshSpnr,
- // thresh);
-
tmp = new Label(adjacencyThreshComp, SWT.RIGHT);
tmp.setLayoutData(new GridData(50, SWT.DEFAULT));
tmp.setFont(controlFont);
setupControlsIntegerLbl(adjacencyThreshScale, tmp, thresh);
-
addSeparator(controlComp);
/*
@@ -675,17 +689,11 @@ public class FogMonThreshSetupDlg extends Dialog {
twilightAngleScale = new Scale(twilightAngleComp, SWT.HORIZONTAL);
twilightAngleScale.setLayoutData(gd);
- // twilightAngleSpnr = new Spinner(twilightAngleComp, SWT.BORDER);
- // twilightAngleSpnr.setLayoutData(new GridData(50, SWT.DEFAULT));
-
tmp = new Label(twilightAngleComp, SWT.RIGHT);
tmp.setLayoutData(new GridData(50, SWT.DEFAULT));
tmp.setFont(controlFont);
setupControlsDecimalLbl(twilightAngleScale, tmp, thresh);
-
- // setupControlsDecimal(twilightAngleScale, twilightAngleSpnr, thresh);
-
addSeparator(controlComp);
/*
@@ -711,18 +719,20 @@ public class FogMonThreshSetupDlg extends Dialog {
fractalDimScale = new Scale(fractalDimComp, SWT.HORIZONTAL);
fractalDimScale.setLayoutData(gd);
- // fractalDimSpnr = new Spinner(fractalDimComp, SWT.BORDER);
- // fractalDimSpnr.setLayoutData(new GridData(50, SWT.DEFAULT));
-
tmp = new Label(fractalDimComp, SWT.RIGHT);
tmp.setLayoutData(new GridData(50, SWT.DEFAULT));
tmp.setFont(controlFont);
setupControlsDecimalLbl(fractalDimScale, tmp, thresh);
-
- // setupControlsDecimal(fractalDimScale, fractalDimSpnr, thresh);
}
+ /**
+ * Sets Controls Decimal Label
+ *
+ * @param scale
+ * @param label
+ * @param thresh
+ */
private void setupControlsDecimalLbl(final Scale scale, final Label label,
ThresholdData.Threshold thresh) {
scale.setMinimum(0);
@@ -733,19 +743,29 @@ public class FogMonThreshSetupDlg extends Dialog {
public void widgetSelected(SelectionEvent event) {
ThresholdData.Threshold threshold = (ThresholdData.Threshold) label
.getData();
- label.setText(String.format(" %3.1f",
- thresholdData.calcSpnrValueFromScale(threshold, scale
- .getSelection()) / 10.0));
+ label.setText(String.format(
+ " %3.1f",
+ thresholdData.calcSpnrValueFromScale(threshold,
+ scale.getSelection()) / 10.0));
}
});
label.setData(thresh);
- label.setText(String.format(" %3.1f", thresholdData
- .calcSpnrValueFromScale(thresh, scale.getSelection()) / 10.0));
+ label.setText(String.format(
+ " %3.1f",
+ thresholdData.calcSpnrValueFromScale(thresh,
+ scale.getSelection()) / 10.0));
scaleLblMap.put(scale, label);
}
+ /**
+ * Sets Controls Integer Label
+ *
+ * @param scale
+ * @param label
+ * @param thresh
+ */
private void setupControlsIntegerLbl(final Scale scale, final Label label,
ThresholdData.Threshold thresh) {
scale.setMinimum(0);
@@ -756,70 +776,82 @@ public class FogMonThreshSetupDlg extends Dialog {
public void widgetSelected(SelectionEvent event) {
ThresholdData.Threshold threshold = (ThresholdData.Threshold) label
.getData();
- label.setText(String.format("%3d",
- thresholdData.calcSpnrValueFromScale(threshold, scale
- .getSelection())));
+ label.setText(String.format(
+ "%3d",
+ thresholdData.calcSpnrValueFromScale(threshold,
+ scale.getSelection())));
}
});
-
label.setData(thresh);
- label.setText(String.format("%3d", thresholdData
- .calcSpnrValueFromScale(thresh, scale.getSelection())));
-
+ label.setText(String.format(
+ "%3d",
+ thresholdData.calcSpnrValueFromScale(thresh,
+ scale.getSelection())));
scaleLblMap.put(scale, label);
}
+ /**
+ * Creates Scale Spinner Composites
+ *
+ * @param parentComp
+ * @return
+ */
private Composite createScaleSpinnerComp(Composite parentComp) {
Composite comp = new Composite(parentComp, SWT.NONE);
comp.setLayout(new GridLayout(2, false));
comp.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
-
return comp;
}
+ /**
+ * Adds Separator
+ *
+ * @param parentComp
+ */
private void addSeparator(Composite parentComp) {
GridLayout gl = (GridLayout) parentComp.getLayout();
-
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
gd.horizontalSpan = gl.numColumns;
Label sepLbl = new Label(parentComp, SWT.SEPARATOR | SWT.HORIZONTAL);
sepLbl.setLayoutData(gd);
}
+ /**
+ * Creates Images
+ */
private void createImages() {
ImageDescriptor id = Activator.imageDescriptorFromPlugin(
Activator.PLUGIN_ID, "images/lenticular.png");
maxCloudTempImg = id.createImage();
-
id = Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID,
"images/glacier.png");
iceSnowVsFogImg = id.createImage();
-
id = Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID,
"images/MtStHelen.png");
coolFogVsWarmSurfImg = id.createImage();
-
id = Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID,
"images/man-made.png");
daytimeSmoothImg = id.createImage();
-
id = Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID,
"images/penguin.png");
adjacencyThreshImg = id.createImage();
-
id = Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID,
"images/twilight-angle.png");
twilightAngleImg = id.createImage();
-
id = Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID,
"images/fractal_dim.png");
fractalDimImg = id.createImage();
}
+ /**
+ * Formats Label Value
+ *
+ * @param lbl
+ * @param value
+ */
private void formatLabelValue(Label lbl, int value) {
ThresholdData.Threshold threshold = (ThresholdData.Threshold) lbl
.getData();
-
if (threshold == ThresholdData.Threshold.AdjacencyThresh) {
lbl.setText(String.format("%3d", value));
} else {
@@ -827,9 +859,11 @@ public class FogMonThreshSetupDlg extends Dialog {
}
}
+ /**
+ * Updates Data Controls
+ */
private void updateDataControls() {
FogAlgorithmMgr fam = FogAlgorithmMgr.getInstance();
-
/*
* Threshold canvas (Fog Product & VIS)
*/
@@ -842,9 +876,7 @@ public class FogMonThreshSetupDlg extends Dialog {
int scaleValInt = Integer.MIN_VALUE;
int spnrValFromScale = Integer.MIN_VALUE;
-
Threshold currentThreshold = Threshold.MaxCloudTemp;
-
/*
* Maximum Cloud Temperature
*/
@@ -855,7 +887,6 @@ public class FogMonThreshSetupDlg extends Dialog {
spnrValFromScale = thresholdData.calcSpnrValueFromScale(
currentThreshold, maxCloudTempScale.getSelection());
formatLabelValue(scaleLblMap.get(maxCloudTempScale), spnrValFromScale);
-
/*
* Daytime Ice/Snow vs Fog Threshold
*/
@@ -868,7 +899,6 @@ public class FogMonThreshSetupDlg extends Dialog {
formatLabelValue(scaleLblMap.get(iceSnowVsFogScale), spnrValFromScale);
iceSnowVsFogChk.setSelection(fam.getAlgorithmXML().isIceSnowVsFogOn());
-
/*
* Cool Fog vs Warm Surface Threshold
*/
@@ -880,10 +910,8 @@ public class FogMonThreshSetupDlg extends Dialog {
currentThreshold, coolFogVsWarmSurfScale.getSelection());
formatLabelValue(scaleLblMap.get(coolFogVsWarmSurfScale),
spnrValFromScale);
-
coolFogVsWarmSurfChk.setSelection(fam.getAlgorithmXML()
.isCoolFogVsWarmSurfaceOn());
-
/*
* Daytime Smoothness Threshold
*/
@@ -898,7 +926,6 @@ public class FogMonThreshSetupDlg extends Dialog {
daytimeSmoothChk.setSelection(fam.getAlgorithmXML()
.isDaytimeSmoothThreshOn());
-
/*
* Adjacency Threshold
*/
@@ -914,7 +941,6 @@ public class FogMonThreshSetupDlg extends Dialog {
adjacencyThreshChk.setSelection(fam.getAlgorithmXML()
.isAdjacencyThreshOn());
-
/*
* Twilight Angle Threshold
*/
@@ -926,10 +952,8 @@ public class FogMonThreshSetupDlg extends Dialog {
spnrValFromScale = thresholdData.calcSpnrValueFromScale(
currentThreshold, twilightAngleScale.getSelection());
formatLabelValue(scaleLblMap.get(twilightAngleScale), spnrValFromScale);
-
twilightAngleChk
.setSelection(fam.getAlgorithmXML().isTwilightAngleOn());
-
/*
* Fractal Dimension Threshold
*/
@@ -941,15 +965,15 @@ public class FogMonThreshSetupDlg extends Dialog {
spnrValFromScale = thresholdData.calcSpnrValueFromScale(
currentThreshold, fractalDimScale.getSelection());
formatLabelValue(scaleLblMap.get(fractalDimScale), spnrValFromScale);
-
fractalDimChk
.setSelection(fam.getAlgorithmXML().isFractalDimensionOn());
}
+ /**
+ * Updates Algorithm Data.
+ */
private void updateAlgorithmData() {
-
double tmpVal = Double.NaN;
-
/*
* Fog Product
*/
@@ -962,7 +986,6 @@ public class FogMonThreshSetupDlg extends Dialog {
.setFogProductRHi(fogVals[RangeEnum.RHi.ordinal()]);
fam.getAlgorithmXML()
.setFogProductYHi(fogVals[RangeEnum.YHi.ordinal()]);
-
/*
* VIS values.
*/
@@ -971,37 +994,28 @@ public class FogMonThreshSetupDlg extends Dialog {
fam.getAlgorithmXML().setVisRLo(visVals[RangeEnum.RLo.ordinal()]);
fam.getAlgorithmXML().setVisRHi(visVals[RangeEnum.RHi.ordinal()]);
fam.getAlgorithmXML().setVisYHi(visVals[RangeEnum.YHi.ordinal()]);
-
/*
* Maximum Cloud Temperature
*/
- System.out.println("+++ Max cloud scale value = "
- + maxCloudTempScale.getSelection());
tmpVal = thresholdData.calcSpnrValueFromScale(Threshold.MaxCloudTemp,
maxCloudTempScale.getSelection()) / 10.0;
- System.out.println("+++ tmp value = " + tmpVal);
fam.getAlgorithmXML().setMaxCloudTemp(tmpVal);
-
/*
* Daytime Ice/Snow vs Fog Threshold
*/
tmpVal = thresholdData.calcSpnrValueFromScale(Threshold.IceSnowVsFog,
iceSnowVsFogScale.getSelection()) / 10.0;
fam.getAlgorithmXML().setIceSnowVsFog(tmpVal);
-
fam.getAlgorithmXML().setIceSnowVsFogOn(iceSnowVsFogChk.getSelection());
-
/*
* Cool Fog vs Warm Surface Threshold
*/
tmpVal = thresholdData.calcSpnrValueFromScale(
- Threshold.CoolFogVsWarmSurf, coolFogVsWarmSurfScale
- .getSelection()) / 10.0;
+ Threshold.CoolFogVsWarmSurf,
+ coolFogVsWarmSurfScale.getSelection()) / 10.0;
fam.getAlgorithmXML().setCoolFogVsWarmSurface(tmpVal);
-
fam.getAlgorithmXML().setCoolFogVsWarmSurfaceOn(
coolFogVsWarmSurfChk.getSelection());
-
/*
* Daytime Smoothness Threshold
*/
@@ -1011,7 +1025,6 @@ public class FogMonThreshSetupDlg extends Dialog {
fam.getAlgorithmXML().setDaytimeSmoothThreshOn(
daytimeSmoothChk.getSelection());
-
/*
* Adjacency Threshold
*/
@@ -1021,105 +1034,140 @@ public class FogMonThreshSetupDlg extends Dialog {
fam.getAlgorithmXML().setAdjacencyThreshOn(
adjacencyThreshChk.getSelection());
-
/*
* Twilight Angle Threshold
*/
tmpVal = thresholdData.calcSpnrValueFromScale(Threshold.TwilightAngle,
twilightAngleScale.getSelection()) / 10.0;
fam.getAlgorithmXML().setTwilightAngle(tmpVal);
-
fam.getAlgorithmXML().setTwilightAngleOn(
twilightAngleChk.getSelection());
-
/*
* Fractal Dimension Threshold
*/
tmpVal = thresholdData.calcSpnrValueFromScale(Threshold.FractalDim,
fractalDimScale.getSelection()) / 10.0;
fam.getAlgorithmXML().setFractalDimension(tmpVal);
-
fam.getAlgorithmXML().setFractalDimensionOn(
fractalDimChk.getSelection());
}
+ /**
+ * Open action.
+ */
private void openAction() {
- FogAlgorithmMgr fam = FogAlgorithmMgr.getInstance();
-
- LoadSaveDeleteSelectDlg lsDlg = new LoadSaveDeleteSelectDlg(shell,
- DialogType.OPEN, fam.getAlgorithmThresholdPath(), fam
- .getDefaultAlgorithmFileName());
- LocalizationFile fileName = (LocalizationFile) lsDlg.open();
-
- if (fileName == null) {
- System.out.println("FileName is null...");
- return;
+ if (openDlg == null) {
+ FogAlgorithmMgr fam = FogAlgorithmMgr.getInstance();
+ openDlg = new LoadSaveDeleteSelectDlg(shell, DialogType.OPEN,
+ fam.getAlgorithmThresholdPath(),
+ fam.getDefaultAlgorithmFileName());
+ openDlg.setCloseCallback(new ICloseCallback() {
+ @Override
+ public void dialogClosed(Object returnValue) {
+ if (returnValue instanceof LocalizationFile) {
+ LocalizationFile fileName = (LocalizationFile) returnValue;
+ doOpenFile(fileName);
+ }
+ openDlg = null;
+ }
+ });
}
+ openDlg.open();
+ }
- System.out.println("Selected file absolute path= "
- + fileName.getFile().getAbsolutePath());
- System.out.println("Selected file name = "
- + fileName.getFile().getName());
-
+ /**
+ * Opens selected file.
+ *
+ * @param fileName
+ */
+ private void doOpenFile(LocalizationFile fileName) {
+ FogAlgorithmMgr fam = FogAlgorithmMgr.getInstance();
fam.loadAlgorithmThreashold(fileName.getFile().getName());
updateDataControls();
}
+ /**
+ * Save As Action.
+ */
private void saveAsAction() {
- updateAlgorithmData();
-
- LoadSaveDeleteSelectDlg lsDlg = new LoadSaveDeleteSelectDlg(shell,
- DialogType.SAVE_AS, fam.getAlgorithmThresholdPath(), fam
- .getDefaultAlgorithmFileName());
- LocalizationFile fileName = (LocalizationFile) lsDlg.open();
-
- if (fileName == null) {
- System.out.println("FileName is null...");
- return;
+ if (saveDlg == null) {
+ saveDlg = new LoadSaveDeleteSelectDlg(shell, DialogType.SAVE_AS,
+ fam.getAlgorithmThresholdPath(),
+ fam.getDefaultAlgorithmFileName());
+ saveDlg.setCloseCallback(new ICloseCallback() {
+ @Override
+ public void dialogClosed(Object returnValue) {
+ if (returnValue instanceof LocalizationFile) {
+ LocalizationFile fileName = (LocalizationFile) returnValue;
+ doSaveFileAs(fileName);
+ }
+ saveDlg = null;
+ }
+ });
}
+ saveDlg.open();
+ }
- System.out.println("Selected file absolute path= "
- + fileName.getFile().getAbsolutePath());
- System.out.println("Selected file name = "
- + fileName.getFile().getName());
-
+ /**
+ * Saves selected file.
+ *
+ * @param fileName
+ */
+ private void doSaveFileAs(LocalizationFile fileName) {
+ FogAlgorithmMgr fam = FogAlgorithmMgr.getInstance();
+ updateAlgorithmData();
fam.saveAlgorithmXmlAs(fileName.getFile().getName());
}
+ /**
+ * Select Default Algorithm File Action.
+ */
private void selectDefaultAction() {
- FogAlgorithmMgr fam = FogAlgorithmMgr.getInstance();
-
- LoadSaveDeleteSelectDlg lsDlg = new LoadSaveDeleteSelectDlg(shell,
- DialogType.SELECT_DEFAULT, fam.getAlgorithmThresholdPath(), fam
- .getDefaultAlgorithmFileName());
- LocalizationFile fileName = (LocalizationFile) lsDlg.open();
-
- if (fileName == null) {
- System.out.println("FileName is null...");
- return;
+ if (selectDlg == null) {
+ FogAlgorithmMgr fam = FogAlgorithmMgr.getInstance();
+ selectDlg = new LoadSaveDeleteSelectDlg(shell,
+ DialogType.SELECT_DEFAULT, fam.getAlgorithmThresholdPath(),
+ fam.getDefaultAlgorithmFileName());
+ selectDlg.setCloseCallback(new ICloseCallback() {
+ @Override
+ public void dialogClosed(Object returnValue) {
+ if (returnValue instanceof LocalizationFile) {
+ LocalizationFile fileName = (LocalizationFile) returnValue;
+ doSelectDefault(fileName);
+ }
+ selectDlg = null;
+ }
+ });
}
+ selectDlg.open();
+ }
- System.out.println("Selected file absolute path= "
- + fileName.getFile().getAbsolutePath());
- System.out.println("Selected file name = "
- + fileName.getFile().getName());
-
+ /**
+ * Selects default file.
+ *
+ * @param fileName
+ */
+ private void doSelectDefault(LocalizationFile fileName) {
+ FogAlgorithmMgr fam = FogAlgorithmMgr.getInstance();
fam.setDefaultAlgorithmFileName(fileName.getFile().getName());
}
+ /**
+ * Load Default Algorithm Action.
+ */
private void loadDefaultAction() {
FogAlgorithmMgr fam = FogAlgorithmMgr.getInstance();
fam.loadDefaultAlgorithmData();
updateDataControls();
}
+ /**
+ * Notify Action.
+ */
private void notifyAction() {
-
Display.getDefault().asyncExec(new Runnable() {
public void run() {
- Iterator iter = fogListeners
- .iterator();
-
+ Iterator iter = fogListeners.iterator();
while (iter.hasNext()) {
IFogResourceListener listener = (IFogResourceListener) iter
.next();
@@ -1129,32 +1177,44 @@ public class FogMonThreshSetupDlg extends Dialog {
});
}
+ /**
+ * Delete Action.
+ */
private void deleteAction() {
- FogAlgorithmMgr fam = FogAlgorithmMgr.getInstance();
-
- LoadSaveDeleteSelectDlg lsDlg = new LoadSaveDeleteSelectDlg(shell,
- DialogType.DELETE, fam.getDefaultFileNamePath(), fam
- .getDefaultAlgorithmFileName());
- LocalizationFile fileName = (LocalizationFile) lsDlg.open();
-
- if (fileName == null) {
- return;
+ if (deleteDlg == null) {
+ FogAlgorithmMgr fam = FogAlgorithmMgr.getInstance();
+ deleteDlg = new LoadSaveDeleteSelectDlg(shell, DialogType.DELETE,
+ fam.getDefaultFileNamePath(),
+ fam.getDefaultAlgorithmFileName());
+ deleteDlg.setCloseCallback(new ICloseCallback() {
+ @Override
+ public void dialogClosed(Object returnValue) {
+ if (returnValue instanceof LocalizationFile) {
+ LocalizationFile fileName = (LocalizationFile) returnValue;
+ doDelete(fileName);
+ }
+ deleteDlg = null;
+ }
+ });
}
+ deleteDlg.open();
+ }
- System.out.println("Selected file absolute path= "
- + fileName.getFile().getAbsolutePath());
- System.out.println("Selected file name = "
- + fileName.getFile().getName());
-
+ /**
+ * Deletes current default file.
+ *
+ * @param fileName
+ */
+ private void doDelete(LocalizationFile fileName) {
try {
fileName.delete();
} catch (Exception ex) {
- ex.printStackTrace();
+ statusHandler.handle(Priority.ERROR, ex.getMessage());
}
}
/**
- * add a listener
+ * Adds a listener
*
* @param ifogl
*/
@@ -1163,7 +1223,7 @@ public class FogMonThreshSetupDlg extends Dialog {
}
/**
- * remove a listener
+ * Removes a listener
*
* @param ifogl
*/
@@ -1172,17 +1232,21 @@ public class FogMonThreshSetupDlg extends Dialog {
}
/**
+ * Gets Fog listeners.
+ *
* @return the fogListeners
*/
- public ArrayList getFogListeners() {
+ public List getFogListeners() {
return fogListeners;
}
/**
+ * Sets Fog listeners.
+ *
* @param fogListeners
* the fogListeners to set
*/
- public void setFogListeners(ArrayList fogListeners) {
+ public void setFogListeners(List fogListeners) {
this.fogListeners = fogListeners;
}
}
diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/LoadSaveDeleteSelectDlg.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/LoadSaveDeleteSelectDlg.java
index 65628bc3d8..c6040dff6d 100644
--- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/LoadSaveDeleteSelectDlg.java
+++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/LoadSaveDeleteSelectDlg.java
@@ -38,49 +38,87 @@ import org.eclipse.swt.widgets.Text;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
-import com.raytheon.uf.common.localization.LocalizationFile;
-import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
+import com.raytheon.uf.common.localization.LocalizationFile;
+import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
+/**
+ * File Load/Save/Delete/Select Dialogs.
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * Dec 5, 2012 #1351 skorolev Cleaned code
+ *
+ *
+ *
+ * @author
+ * @version 1.0
+ */
public class LoadSaveDeleteSelectDlg extends CaveSWTDialog {
-
+ /** **/
public static enum DialogType {
OPEN, SAVE_AS, DELETE, SELECT_DEFAULT
};
+ /** Dialog Type **/
private DialogType dialogType;
+ /** Font **/
private Font controlFont;
+ /** Configuration File List **/
private List cfgFileList;
+ /** Selected File **/
private LocalizationFile selectedFile;
+ /** Localization Files **/
private LocalizationFile[] locFiles;
+ /** Localization Files Map **/
private TreeMap locFileMap;
+ /** New file name **/
private Text newFileNameTF;
+ /** Action Button **/
private Button actionBtn;
+ /** File path **/
private String fileNamePath;
+ /** Excluded Name For Saving **/
private String excludedNameForSaving = "";
+ /**
+ * Constructor
+ *
+ * @param parent
+ * @param type
+ * Dialog type
+ * @param fileNamePath
+ * @param excludedNameForSaving
+ */
public LoadSaveDeleteSelectDlg(Shell parent, DialogType type,
String fileNamePath, String excludedNameForSaving) {
super(parent, SWT.TITLE);
+ // TODO add Cave.DO_NOT_BLOCK once all dialogs using this class have
+ // been converted to use close call.
if (type == DialogType.OPEN) {
setText("Load");
} else if (type == DialogType.SAVE_AS) {
setText("Save");
} else if (type == DialogType.SELECT_DEFAULT) {
setText("Select Default");
+ } else if (type == DialogType.DELETE) {
+ setText("Delete");
}
-
dialogType = type;
this.fileNamePath = fileNamePath;
if (excludedNameForSaving != null) {
@@ -88,6 +126,11 @@ public class LoadSaveDeleteSelectDlg extends CaveSWTDialog {
}
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
+ */
@Override
protected Layout constructShellLayout() {
// Create the main layout for the shell.
@@ -98,34 +141,44 @@ public class LoadSaveDeleteSelectDlg extends CaveSWTDialog {
return mainLayout;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed()
+ */
@Override
protected void disposed() {
controlFont.dispose();
setReturnValue(selectedFile);
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
+ * .eclipse.swt.widgets.Shell)
+ */
@Override
protected void initializeComponents(Shell shell) {
locFileMap = new TreeMap();
controlFont = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL);
-
createListControl();
-
// Create the buttons at the bottom of the display.
createBottomButtons();
-
getAvailableConfigFiles();
}
+ /**
+ * Creates List Control.
+ */
private void createListControl() {
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
Composite controlComp = new Composite(shell, SWT.NONE);
controlComp.setLayout(new GridLayout(1, false));
controlComp.setLayoutData(gd);
-
Label listLbl = new Label(controlComp, SWT.NONE);
listLbl.setText("Available Files:");
-
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.widthHint = 400;
gd.heightHint = 400;
@@ -146,24 +199,23 @@ public class LoadSaveDeleteSelectDlg extends CaveSWTDialog {
}
}
});
-
if (dialogType == DialogType.SAVE_AS) {
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
gd.horizontalSpan = ((GridLayout) controlComp.getLayout()).numColumns;
Label sepLbl = new Label(controlComp, SWT.SEPARATOR
| SWT.HORIZONTAL);
sepLbl.setLayoutData(gd);
-
Label newFileLbl = new Label(controlComp, SWT.NONE);
newFileLbl.setText("Enter file name:");
-
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
newFileNameTF = new Text(controlComp, SWT.BORDER);
newFileNameTF.setLayoutData(gd);
-
}
}
+ /**
+ * Creates Bottom Buttons.
+ */
private void createBottomButtons() {
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
Composite mainButtonComp = new Composite(shell, SWT.NONE);
@@ -224,10 +276,12 @@ public class LoadSaveDeleteSelectDlg extends CaveSWTDialog {
});
}
+ /**
+ * Opens Delete confirmation message.
+ */
private void openDeleteSelectAction() {
int selectedIndex = cfgFileList.getSelectionIndex();
String str = cfgFileList.getItem(selectedIndex);
-
if (dialogType == DialogType.DELETE) {
MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION | SWT.YES
| SWT.NO);
@@ -235,32 +289,35 @@ public class LoadSaveDeleteSelectDlg extends CaveSWTDialog {
mb.setMessage("You are about to delete the file:\n\n" + str
+ "\n\nDo you wish to continue?");
int result = mb.open();
-
if (result == SWT.NO) {
return;
}
}
-
selectedFile = locFileMap.get(str);
shell.dispose();
}
+ /**
+ * Save action.
+ */
private void saveAction() {
String fileName = newFileNameTF.getText();
-
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext context = pm.getContext(
LocalizationType.COMMON_STATIC, LocalizationLevel.SITE);
String newFileName = fileNamePath + fileName;
selectedFile = pm.getLocalizationFile(context, newFileName);
-
shell.dispose();
}
+ /**
+ * Validates File Name.
+ *
+ * @return True/False
+ */
private boolean validateFileName() {
StringBuffer strBuf = new StringBuffer(newFileNameTF.getText().trim());
newFileNameTF.setText(strBuf.toString());
-
if (strBuf.length() == 0) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("Warning");
@@ -268,17 +325,14 @@ public class LoadSaveDeleteSelectDlg extends CaveSWTDialog {
mb.open();
return false;
}
-
if (strBuf.toString().matches("[A-Za-z0-9._-]+") == false) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("Warning");
- mb
- .setMessage("File name contains invalid charaters. The file name can only\n"
- + "contain A-Z, a-z, 0-9, or periods, underscores, or dashes.");
+ mb.setMessage("File name contains invalid charaters. The file name can only\n"
+ + "contain A-Z, a-z, 0-9, or periods, underscores, or dashes.");
mb.open();
return false;
}
-
if (strBuf.toString().compareTo(excludedNameForSaving) == 0) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("Warning");
@@ -287,20 +341,16 @@ public class LoadSaveDeleteSelectDlg extends CaveSWTDialog {
mb.open();
return false;
}
-
String[] listItems = cfgFileList.getItems();
-
for (String listItem : listItems) {
int idx = listItem.lastIndexOf("/");
String fn = listItem.substring(idx + 1);
-
if (fn.compareTo(strBuf.toString()) == 0) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.YES
| SWT.NO);
mb.setText("Warning");
- mb
- .setMessage("File name already exists. Do you wish to overwrite\n"
- + "the existing file?.");
+ mb.setMessage("File name already exists. Do you wish to overwrite\n"
+ + "the existing file?.");
int result = mb.open();
if (result == SWT.NO) {
@@ -308,24 +358,23 @@ public class LoadSaveDeleteSelectDlg extends CaveSWTDialog {
}
}
}
-
if (strBuf.toString().endsWith(".xml") == false) {
strBuf.append(".xml");
newFileNameTF.setText(strBuf.toString().trim());
}
-
return true;
}
+ /**
+ * Gets Available Configuration Files.
+ */
private void getAvailableConfigFiles() {
String[] extensions = new String[] { ".xml" };
locFiles = PathManagerFactory.getPathManager().listStaticFiles(
fileNamePath, extensions, false, true);
-
if (locFiles == null) {
return;
}
-
for (int i = 0; i < locFiles.length; i++) {
/*
* Add the available files to the list as long as the file name does
@@ -342,15 +391,12 @@ public class LoadSaveDeleteSelectDlg extends CaveSWTDialog {
locFileMap.put(locFiles[i].getFile().getName(), locFiles[i]);
}
}
-
for (String str : locFileMap.keySet()) {
cfgFileList.add(str);
}
-
if (cfgFileList.getSelectionCount() > 0) {
cfgFileList.setSelection(0);
}
-
if (cfgFileList.getItemCount() == 0) {
if (dialogType == DialogType.DELETE
|| dialogType == DialogType.SELECT_DEFAULT) {
@@ -359,6 +405,11 @@ public class LoadSaveDeleteSelectDlg extends CaveSWTDialog {
}
}
+ /**
+ * Gets Selected File
+ *
+ * @return selectedFile
+ */
public LocalizationFile getSelectedFile() {
return selectedFile;
}