Issue #1578 Changes for non-blocking PDC_SaveDlg.
Change-Id: I29228892970a5349c352a34880087afe48a339da Former-commit-id:ad2639601e
[formerlyad2639601e
[formerly 0ea655d32be4e0e13bdade510bcc6979d6da3799]] Former-commit-id:d4660004f3
Former-commit-id:bb84fe5f68
This commit is contained in:
parent
e92666cc43
commit
62eb1a3cdf
2 changed files with 64 additions and 30 deletions
|
@ -37,6 +37,9 @@ import org.eclipse.swt.widgets.Layout;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
import org.eclipse.swt.widgets.Text;
|
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.uf.viz.core.exception.VizException;
|
import com.raytheon.uf.viz.core.exception.VizException;
|
||||||
import com.raytheon.viz.hydro.pointdatacontrol.data.PointDataPreset;
|
import com.raytheon.viz.hydro.pointdatacontrol.data.PointDataPreset;
|
||||||
import com.raytheon.viz.hydro.pointdatacontrol.db.PDCDataManager;
|
import com.raytheon.viz.hydro.pointdatacontrol.db.PDCDataManager;
|
||||||
|
@ -50,6 +53,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* 29 NOV 2007 373 lvenable Initial creation
|
* 29 NOV 2007 373 lvenable Initial creation
|
||||||
|
* 07 FEB 2013 1578 rferrel Changes for non-blocking dialog.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -58,17 +62,26 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class PDC_SaveDlg extends CaveSWTDialog {
|
public class PDC_SaveDlg extends CaveSWTDialog {
|
||||||
private static final String PRESET_ERROR_TITLE = "Invalid Value";
|
private final IUFStatusHandler statusHandler = UFStatus
|
||||||
|
.getHandler(PDC_SaveDlg.class);
|
||||||
|
|
||||||
private static final String PRESET_ID_ERROR = "Invalid Preset Identifier.";
|
/** Tile for Warning message dialog. */
|
||||||
|
private final String PRESET_ERROR_TITLE = "Invalid Value";
|
||||||
|
|
||||||
private static final String PRESET_DESC_ERROR = "Invalid Preset Description.";
|
/** Message when invalid new ID. */
|
||||||
|
private final String PRESET_ID_ERROR = "Invalid Preset Identifier.";
|
||||||
|
|
||||||
private static final String PRESET_RANK_ERROR = "Invalid Preset Rank.";
|
/** Message when invalid new description. */
|
||||||
|
private final String PRESET_DESC_ERROR = "Invalid Preset Description.";
|
||||||
|
|
||||||
private static final String ERROR_TITLE = "Error Occurred";
|
/** Message when invalid new rank. */
|
||||||
|
private final String PRESET_RANK_ERROR = "Invalid Preset Rank.";
|
||||||
|
|
||||||
private static final String SAVE_ERROR_MESSAGE = "An error occurred during the save function.";
|
/** Tile for Error dialog when save fails. */
|
||||||
|
private final String ERROR_TITLE = "Error Occurred";
|
||||||
|
|
||||||
|
/** Error message when save fails. */
|
||||||
|
private final String SAVE_ERROR_MESSAGE = "An error occurred during the save function.";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Current information unique ID.
|
* Current information unique ID.
|
||||||
|
@ -123,13 +136,18 @@ public class PDC_SaveDlg extends CaveSWTDialog {
|
||||||
*/
|
*/
|
||||||
public PDC_SaveDlg(Shell parent, int selection,
|
public PDC_SaveDlg(Shell parent, int selection,
|
||||||
PointDataControlDlg parentDialog) {
|
PointDataControlDlg parentDialog) {
|
||||||
super(parent);
|
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
|
||||||
setText("Save Preset Options");
|
setText("Save Preset Options");
|
||||||
|
|
||||||
this.selection = selection;
|
this.selection = selection;
|
||||||
this.parentDialog = parentDialog;
|
this.parentDialog = parentDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Layout constructShellLayout() {
|
protected Layout constructShellLayout() {
|
||||||
// Create the main layout for the shell.
|
// Create the main layout for the shell.
|
||||||
|
@ -139,6 +157,13 @@ public class PDC_SaveDlg extends CaveSWTDialog {
|
||||||
return mainLayout;
|
return mainLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
|
||||||
|
* .eclipse.swt.widgets.Shell)
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void initializeComponents(Shell shell) {
|
protected void initializeComponents(Shell shell) {
|
||||||
setReturnValue(false);
|
setReturnValue(false);
|
||||||
|
@ -230,7 +255,7 @@ public class PDC_SaveDlg extends CaveSWTDialog {
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
boolean status = saveData();
|
boolean status = saveData();
|
||||||
if (status) {
|
if (status) {
|
||||||
shell.dispose();
|
close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -243,7 +268,7 @@ public class PDC_SaveDlg extends CaveSWTDialog {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
setReturnValue(false);
|
setReturnValue(false);
|
||||||
shell.dispose();
|
close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -277,8 +302,8 @@ public class PDC_SaveDlg extends CaveSWTDialog {
|
||||||
newRankTF.setText("");
|
newRankTF.setText("");
|
||||||
}
|
}
|
||||||
} catch (VizException e) {
|
} catch (VizException e) {
|
||||||
// TODO Auto-generated catch block
|
statusHandler.handle(Priority.PROBLEM,
|
||||||
e.printStackTrace();
|
"Problem populating text fields: ", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,30 +316,33 @@ public class PDC_SaveDlg extends CaveSWTDialog {
|
||||||
PointDataPreset presetNode = new PointDataPreset();
|
PointDataPreset presetNode = new PointDataPreset();
|
||||||
boolean matchFound = false;
|
boolean matchFound = false;
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
String prefix = "";
|
||||||
|
|
||||||
/* Check for valid values */
|
/* Check for valid values */
|
||||||
String editedPresetId = newUniqueIdTF.getText().trim();
|
String editedPresetId = newUniqueIdTF.getText().trim();
|
||||||
if ((editedPresetId == null) || (editedPresetId.length() == 0)) {
|
if ((editedPresetId == null) || (editedPresetId.length() == 0)) {
|
||||||
MessageDialog.openWarning(shell, PRESET_ERROR_TITLE,
|
sb.append(PRESET_ID_ERROR);
|
||||||
PRESET_ID_ERROR);
|
prefix = "\n";
|
||||||
return false;
|
|
||||||
}
|
|
||||||
String editedDesc = newDescTF.getText().trim();
|
|
||||||
if ((editedDesc == null) || (editedDesc.length() == 0)) {
|
|
||||||
MessageDialog.openWarning(shell, PRESET_ERROR_TITLE,
|
|
||||||
PRESET_DESC_ERROR);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int rank;
|
String editedDesc = newDescTF.getText().trim();
|
||||||
|
if ((editedDesc == null) || (editedDesc.length() == 0)) {
|
||||||
|
sb.append(prefix).append(PRESET_DESC_ERROR);
|
||||||
|
prefix = "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
int rank = -1;
|
||||||
try {
|
try {
|
||||||
rank = Integer.parseInt(newRankTF.getText().trim());
|
rank = Integer.parseInt(newRankTF.getText().trim());
|
||||||
} catch (NumberFormatException nfe) {
|
} catch (NumberFormatException nfe) {
|
||||||
MessageDialog.openWarning(shell, PRESET_ERROR_TITLE,
|
sb.append(prefix).append(PRESET_RANK_ERROR);
|
||||||
PRESET_RANK_ERROR);
|
|
||||||
return false;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
MessageDialog.openWarning(shell, PRESET_ERROR_TITLE,
|
sb.append(prefix).append(PRESET_RANK_ERROR);
|
||||||
PRESET_RANK_ERROR);
|
}
|
||||||
|
|
||||||
|
if (sb.length() > 0) {
|
||||||
|
MessageDialog.openWarning(shell, PRESET_ERROR_TITLE, sb.toString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,11 +384,11 @@ public class PDC_SaveDlg extends CaveSWTDialog {
|
||||||
dataManager.insertPreset(presetNode);
|
dataManager.insertPreset(presetNode);
|
||||||
}
|
}
|
||||||
} catch (VizException e) {
|
} catch (VizException e) {
|
||||||
e.printStackTrace();
|
statusHandler.handle(Priority.PROBLEM, "Save Error: ", e);
|
||||||
success = false;
|
success = false;
|
||||||
MessageDialog.openError(shell, ERROR_TITLE, SAVE_ERROR_MESSAGE);
|
MessageDialog.openError(shell, ERROR_TITLE, SAVE_ERROR_MESSAGE);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
e.printStackTrace();
|
statusHandler.handle(Priority.PROBLEM, "Save Error: ", e);
|
||||||
success = false;
|
success = false;
|
||||||
MessageDialog.openError(shell, ERROR_TITLE, SAVE_ERROR_MESSAGE);
|
MessageDialog.openError(shell, ERROR_TITLE, SAVE_ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,6 +105,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||||
* for the "30 minutes Instantaneous" rainfall map .
|
* for the "30 minutes Instantaneous" rainfall map .
|
||||||
* 04 Dec 2012 15602 wkwock Fix Hrs hour capped at 100.
|
* 04 Dec 2012 15602 wkwock Fix Hrs hour capped at 100.
|
||||||
* 07 Feb 2013 1578 rferrel Changes for non-blocking FilteringDlg.
|
* 07 Feb 2013 1578 rferrel Changes for non-blocking FilteringDlg.
|
||||||
|
* Changes for non-blocking PDC_SaveDlg.
|
||||||
* (TODO More code clean up when this dialog is converted.)
|
* (TODO More code clean up when this dialog is converted.)
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
|
@ -178,6 +179,9 @@ public class PointDataControlDlg extends CaveSWTDialog {
|
||||||
/** Filter dialog for Data Source . */
|
/** Filter dialog for Data Source . */
|
||||||
private FilteringDlg dataSourceDlg;
|
private FilteringDlg dataSourceDlg;
|
||||||
|
|
||||||
|
/** Dialog to save preset options */
|
||||||
|
private PDC_SaveDlg saveDlg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Stack Composite.
|
* The Stack Composite.
|
||||||
*/
|
*/
|
||||||
|
@ -1966,8 +1970,10 @@ public class PointDataControlDlg extends CaveSWTDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openSaveDialog() {
|
private void openSaveDialog() {
|
||||||
PDC_SaveDlg saveDlg = new PDC_SaveDlg(shell,
|
if (saveDlg == null) {
|
||||||
selPresetCbo.getSelectionIndex(), this);
|
saveDlg = new PDC_SaveDlg(shell, selPresetCbo.getSelectionIndex(),
|
||||||
|
this);
|
||||||
|
}
|
||||||
saveDlg.open();
|
saveDlg.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue