Issue #1196 Changes for AlarmAlertSaveLoadDlg.
Change-Id: I9baab44a7c5c97af86ea7446e265a873444fc47e Former-commit-id:34cd5b61cf
[formerlyfd248ac744
] [formerly34cd5b61cf
[formerlyfd248ac744
] [formerly407bd9f25e
[formerly 80b29e5da16e908ed2855ee5c645b911e054e7f7]]] Former-commit-id:407bd9f25e
Former-commit-id:79f1dff095
[formerlycdd02b9000
] Former-commit-id:9440bbced2
This commit is contained in:
parent
116a5993ec
commit
a561d7d601
2 changed files with 81 additions and 69 deletions
|
@ -57,6 +57,7 @@ import com.raytheon.viz.texteditor.alarmalert.util.AAPACombined;
|
||||||
import com.raytheon.viz.texteditor.alarmalert.util.AlarmAlertFunctions;
|
import com.raytheon.viz.texteditor.alarmalert.util.AlarmAlertFunctions;
|
||||||
import com.raytheon.viz.texteditor.alarmalert.util.AlarmAlertLists;
|
import com.raytheon.viz.texteditor.alarmalert.util.AlarmAlertLists;
|
||||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||||
|
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||||
import com.raytheon.viz.ui.dialogs.ModeListener;
|
import com.raytheon.viz.ui.dialogs.ModeListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -69,6 +70,7 @@ import com.raytheon.viz.ui.dialogs.ModeListener;
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Sep 9, 2009 mnash Initial creation
|
* Sep 9, 2009 mnash Initial creation
|
||||||
* Oct 31,2011 8510 rferrel Cleaned up code made more robust
|
* Oct 31,2011 8510 rferrel Cleaned up code made more robust
|
||||||
|
* Sep 20,2011 1196 rferrel Change dialogs so they do not block.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -178,8 +180,6 @@ public class AlarmAlertDlg extends CaveSWTDialog {
|
||||||
|
|
||||||
preOpened();
|
preOpened();
|
||||||
|
|
||||||
// shell.open();
|
|
||||||
|
|
||||||
opened();
|
opened();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,29 +270,14 @@ public class AlarmAlertDlg extends CaveSWTDialog {
|
||||||
// open dialog
|
// open dialog
|
||||||
AlarmAlertSaveLoadDlg dialog = new AlarmAlertSaveLoadDlg(shell,
|
AlarmAlertSaveLoadDlg dialog = new AlarmAlertSaveLoadDlg(shell,
|
||||||
SaveOrLoad.SAVE);
|
SaveOrLoad.SAVE);
|
||||||
dialog.open();
|
dialog.setCloseCallback(new ICloseCallback() {
|
||||||
String fname = dialog.getFileName();
|
|
||||||
fname = validateFileName(fname);
|
|
||||||
// AlarmAlertFunctions.validateName(fname);
|
|
||||||
|
|
||||||
if (fname != null && !fname.isEmpty()) {
|
@Override
|
||||||
setShellText(fname);
|
public void dialogClosed(Object returnValue) {
|
||||||
setLastFile(fname);
|
doSaveAs(returnValue.toString());
|
||||||
// save alert products
|
|
||||||
LocalizationFile lFile = AlarmAlertFunctions.getFile(
|
|
||||||
AlarmAlertFunctions.initUserLocalization(), fname);
|
|
||||||
if (lFile != null) {
|
|
||||||
AlarmAlertFunctions.saveAlarms(
|
|
||||||
aapList.subList(siteAdminNumberAA - 1,
|
|
||||||
aapList.size()),
|
|
||||||
papList.subList(siteAdminNumberPA - 1,
|
|
||||||
papList.size()), lFile);
|
|
||||||
} else {
|
|
||||||
statusHandler.handle(Priority.SIGNIFICANT,
|
|
||||||
"Null localization file", new VizException(
|
|
||||||
"Null localization file"));
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
dialog.open();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -303,43 +288,72 @@ public class AlarmAlertDlg extends CaveSWTDialog {
|
||||||
// open dialog
|
// open dialog
|
||||||
AlarmAlertSaveLoadDlg dialog = new AlarmAlertSaveLoadDlg(shell,
|
AlarmAlertSaveLoadDlg dialog = new AlarmAlertSaveLoadDlg(shell,
|
||||||
SaveOrLoad.LOAD);
|
SaveOrLoad.LOAD);
|
||||||
dialog.open();
|
dialog.setCloseCallback(new ICloseCallback() {
|
||||||
// load file
|
|
||||||
String fname = dialog.getFileName();
|
|
||||||
fname = validateFileName(fname);
|
|
||||||
// AlarmAlertFunctions.validateName(fname);
|
|
||||||
if (fname != null && !fname.isEmpty()) {
|
|
||||||
|
|
||||||
// load alert products
|
@Override
|
||||||
LocalizationFile lFile = AlarmAlertFunctions.getFile(
|
public void dialogClosed(Object returnValue) {
|
||||||
AlarmAlertFunctions.initUserLocalization(), fname);
|
doLoad(returnValue.toString());
|
||||||
if (lFile != null) {
|
|
||||||
File file = lFile.getFile();
|
|
||||||
setShellText(fname);
|
|
||||||
setLastFile(fname);
|
|
||||||
currentFile = file;
|
|
||||||
AAPACombined combined = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
combined = AlarmAlertFunctions.loadFile(file);
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
combined = AlarmAlertFunctions
|
|
||||||
.createDefaultAAPACombined();
|
|
||||||
}
|
|
||||||
if (combined != null) {
|
|
||||||
populateLists(combined.getAaList(),
|
|
||||||
combined.getPaList());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
statusHandler.handle(Priority.SIGNIFICANT,
|
|
||||||
"Null localization file", new VizException(
|
|
||||||
"Null localization file"));
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
dialog.open();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void doSaveAs(String fname) {
|
||||||
|
fname = validateFileName(fname);
|
||||||
|
// AlarmAlertFunctions.validateName(fname);
|
||||||
|
|
||||||
|
if (fname != null && !fname.isEmpty()) {
|
||||||
|
setShellText(fname);
|
||||||
|
setLastFile(fname);
|
||||||
|
// save alert products
|
||||||
|
LocalizationFile lFile = AlarmAlertFunctions.getFile(
|
||||||
|
AlarmAlertFunctions.initUserLocalization(), fname);
|
||||||
|
if (lFile != null) {
|
||||||
|
AlarmAlertFunctions.saveAlarms(
|
||||||
|
aapList.subList(siteAdminNumberAA - 1, aapList.size()),
|
||||||
|
papList.subList(siteAdminNumberPA - 1, papList.size()),
|
||||||
|
lFile);
|
||||||
|
} else {
|
||||||
|
statusHandler.handle(Priority.SIGNIFICANT,
|
||||||
|
"Null localization file", new VizException(
|
||||||
|
"Null localization file"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doLoad(String fname) {
|
||||||
|
fname = validateFileName(fname);
|
||||||
|
// AlarmAlertFunctions.validateName(fname);
|
||||||
|
if (fname != null && !fname.isEmpty()) {
|
||||||
|
|
||||||
|
// load alert products
|
||||||
|
LocalizationFile lFile = AlarmAlertFunctions.getFile(
|
||||||
|
AlarmAlertFunctions.initUserLocalization(), fname);
|
||||||
|
if (lFile != null) {
|
||||||
|
File file = lFile.getFile();
|
||||||
|
setShellText(fname);
|
||||||
|
setLastFile(fname);
|
||||||
|
currentFile = file;
|
||||||
|
AAPACombined combined = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
combined = AlarmAlertFunctions.loadFile(file);
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
combined = AlarmAlertFunctions.createDefaultAAPACombined();
|
||||||
|
}
|
||||||
|
if (combined != null) {
|
||||||
|
populateLists(combined.getAaList(), combined.getPaList());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
statusHandler.handle(Priority.SIGNIFICANT,
|
||||||
|
"Null localization file", new VizException(
|
||||||
|
"Null localization file"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the buttons right below the menu
|
* Create the buttons right below the menu
|
||||||
*/
|
*/
|
||||||
|
@ -602,11 +616,11 @@ public class AlarmAlertDlg extends CaveSWTDialog {
|
||||||
lists.getFilteredProducts().clear();
|
lists.getFilteredProducts().clear();
|
||||||
lists.getFilteredProducts().addAll(aapList);
|
lists.getFilteredProducts().addAll(aapList);
|
||||||
lists.getFilteredProducts().addAll(papList);
|
lists.getFilteredProducts().addAll(papList);
|
||||||
|
|
||||||
LocalizationFile lFile = AlarmAlertFunctions.getFile(
|
LocalizationFile lFile = AlarmAlertFunctions.getFile(
|
||||||
AlarmAlertFunctions.initUserLocalization(),
|
AlarmAlertFunctions.initUserLocalization(),
|
||||||
currentFile.getName());
|
currentFile.getName());
|
||||||
|
|
||||||
AlarmAlertFunctions.saveAlarms(
|
AlarmAlertFunctions.saveAlarms(
|
||||||
aapList.subList(siteAdminNumberAA - 1, aapList.size()),
|
aapList.subList(siteAdminNumberAA - 1, aapList.size()),
|
||||||
papList.subList(siteAdminNumberPA - 1, papList.size()), lFile);
|
papList.subList(siteAdminNumberPA - 1, papList.size()), lFile);
|
||||||
|
|
|
@ -58,6 +58,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||||
* AWIPS2 DR Work
|
* AWIPS2 DR Work
|
||||||
* 07/25/2012 953 jkorman Modified file "search" to return LocalizationFile
|
* 07/25/2012 953 jkorman Modified file "search" to return LocalizationFile
|
||||||
* instead of File so references are deleted in all locations.
|
* instead of File so references are deleted in all locations.
|
||||||
|
* 09/20/2012 1196 rferrel Setup fileName now in return value for
|
||||||
|
* use with close callback.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -74,8 +76,6 @@ public class AlarmAlertSaveLoadDlg extends CaveSWTDialog {
|
||||||
|
|
||||||
private Composite shellComp;
|
private Composite shellComp;
|
||||||
|
|
||||||
private static AlarmAlertSaveLoadDlg saveLoadDlg = null;
|
|
||||||
|
|
||||||
private static String fileName = "";
|
private static String fileName = "";
|
||||||
|
|
||||||
private SaveOrLoad saveLoad;
|
private SaveOrLoad saveLoad;
|
||||||
|
@ -91,7 +91,7 @@ public class AlarmAlertSaveLoadDlg extends CaveSWTDialog {
|
||||||
*/
|
*/
|
||||||
protected AlarmAlertSaveLoadDlg(Shell parentShell, SaveOrLoad saveLoad) {
|
protected AlarmAlertSaveLoadDlg(Shell parentShell, SaveOrLoad saveLoad) {
|
||||||
super(parentShell, SWT.APPLICATION_MODAL | SWT.CLOSE | SWT.TITLE,
|
super(parentShell, SWT.APPLICATION_MODAL | SWT.CLOSE | SWT.TITLE,
|
||||||
CAVE.PERSPECTIVE_INDEPENDENT);
|
CAVE.PERSPECTIVE_INDEPENDENT | CAVE.DO_NOT_BLOCK);
|
||||||
if (saveLoad == SaveOrLoad.SAVE) {
|
if (saveLoad == SaveOrLoad.SAVE) {
|
||||||
setText("Save Lists As...");
|
setText("Save Lists As...");
|
||||||
} else {
|
} else {
|
||||||
|
@ -148,7 +148,7 @@ public class AlarmAlertSaveLoadDlg extends CaveSWTDialog {
|
||||||
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||||
lists.setLayoutData(gd);
|
lists.setLayoutData(gd);
|
||||||
LocalizationContext lc = AlarmAlertFunctions.initUserLocalization();
|
LocalizationContext lc = AlarmAlertFunctions.initUserLocalization();
|
||||||
|
|
||||||
// Get a list of localization files!
|
// Get a list of localization files!
|
||||||
LocalizationFile[] fList = PathManagerFactory.getPathManager()
|
LocalizationFile[] fList = PathManagerFactory.getPathManager()
|
||||||
.listFiles(lc, "alarms", new String[] { "xml" }, false, true);
|
.listFiles(lc, "alarms", new String[] { "xml" }, false, true);
|
||||||
|
@ -191,7 +191,12 @@ public class AlarmAlertSaveLoadDlg extends CaveSWTDialog {
|
||||||
loadButton.addSelectionListener(new SelectionAdapter() {
|
loadButton.addSelectionListener(new SelectionAdapter() {
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
// Set the filename to be returned through getFileName()
|
// Set the filename to be returned through getFileName()
|
||||||
fileName = lists.getSelection()[0];
|
if (lists.getSelectionCount() > 0) {
|
||||||
|
fileName = lists.getSelection()[0];
|
||||||
|
} else {
|
||||||
|
fileName = "";
|
||||||
|
}
|
||||||
|
setReturnValue(fileName);
|
||||||
shell.close();
|
shell.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -285,6 +290,7 @@ public class AlarmAlertSaveLoadDlg extends CaveSWTDialog {
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
// Set the filename to be returned through getFileName()
|
// Set the filename to be returned through getFileName()
|
||||||
fileName = textBox.getText();
|
fileName = textBox.getText();
|
||||||
|
setReturnValue(fileName);
|
||||||
shell.close();
|
shell.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -311,12 +317,4 @@ public class AlarmAlertSaveLoadDlg extends CaveSWTDialog {
|
||||||
public String getFileName() {
|
public String getFileName() {
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param args
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) {
|
|
||||||
saveLoadDlg = new AlarmAlertSaveLoadDlg(new Shell(), SaveOrLoad.LOAD);
|
|
||||||
saveLoadDlg.open();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue