Issue #1229 Changes for non-blocking ProcedureListDlg.
Change-Id: I5c955c9d07e104809e2a72de0f5ec998f13d797f Former-commit-id:2a3905d036
[formerly1dc188fb3b
] [formerly1a1f1a0601
] [formerlyd51ba247d1
[formerly1a1f1a0601
[formerly ea4c2898013df2107ebded11aa1561035eaf8a00]]] Former-commit-id:d51ba247d1
Former-commit-id: a72f8583c7b5401510e3347f30a766d38722275a [formerly85f8c1f282
] Former-commit-id:3682a16ad2
This commit is contained in:
parent
8ae9c27a96
commit
d488733f34
4 changed files with 108 additions and 71 deletions
|
@ -25,8 +25,13 @@ import org.eclipse.core.commands.ExecutionException;
|
|||
import org.eclipse.ui.handlers.HandlerUtil;
|
||||
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException;
|
||||
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.d2d.ui.dialogs.procedures.ProcedureListDlg;
|
||||
import com.raytheon.uf.viz.d2d.ui.dialogs.procedures.ProcedureListDlg.Mode;
|
||||
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||
|
||||
/**
|
||||
* DeleteAWIPSProcedure
|
||||
|
@ -41,6 +46,7 @@ import com.raytheon.uf.viz.d2d.ui.dialogs.procedures.ProcedureListDlg.Mode;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Sep 13, 2007 chammack Initial Creation.
|
||||
* Jul 8, 2008 #1183 chammack Migrate to new localization
|
||||
* Oct 16, 2012 #1229 rferrel Changes for non-blocking ProcedureListDlg.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -48,6 +54,10 @@ import com.raytheon.uf.viz.d2d.ui.dialogs.procedures.ProcedureListDlg.Mode;
|
|||
* @version 1
|
||||
*/
|
||||
public class DeleteAWIPSProcedure extends AbstractHandler {
|
||||
private final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(DeleteAWIPSProcedure.class);
|
||||
|
||||
private ProcedureListDlg listDlg;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
@ -58,19 +68,31 @@ public class DeleteAWIPSProcedure extends AbstractHandler {
|
|||
*/
|
||||
@Override
|
||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||
ProcedureListDlg listDlg = new ProcedureListDlg("Delete Procedure",
|
||||
if (listDlg == null || listDlg.getShell() == null
|
||||
|| listDlg.isDisposed()) {
|
||||
listDlg = new ProcedureListDlg("Delete Procedure",
|
||||
HandlerUtil.getActiveShell(event), Mode.DELETE);
|
||||
listDlg.open();
|
||||
listDlg.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
LocalizationFile selectedFile = listDlg.getSelectedFile();
|
||||
if (selectedFile != null && selectedFile.exists()) {
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
if (returnValue instanceof LocalizationFile) {
|
||||
LocalizationFile selectedFile = (LocalizationFile) returnValue;
|
||||
try {
|
||||
selectedFile.delete();
|
||||
} catch (Exception e) {
|
||||
throw new ExecutionException("Error deleting procedure: "
|
||||
+ selectedFile.getName(), e);
|
||||
} catch (LocalizationOpFailedException e) {
|
||||
statusHandler.handle(
|
||||
Priority.PROBLEM,
|
||||
"Error deleting procedure: "
|
||||
+ selectedFile.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
listDlg.open();
|
||||
} else {
|
||||
listDlg.bringToTop();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import com.raytheon.uf.viz.d2d.ui.dialogs.procedures.OpenProcedureListDlg;
|
|||
import com.raytheon.uf.viz.d2d.ui.dialogs.procedures.ProcedureDlg;
|
||||
import com.raytheon.viz.ui.VizWorkbenchManager;
|
||||
import com.raytheon.viz.ui.actions.LoadSerializedXml;
|
||||
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||
|
||||
/**
|
||||
* OpenAWIPSProcedure
|
||||
|
@ -45,6 +46,7 @@ import com.raytheon.viz.ui.actions.LoadSerializedXml;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Sep 13, 2007 chammack Initial Creation.
|
||||
* Oct 16, 2012 1229 rferrel Change to use ProcedureDlg.displayDialog.
|
||||
* Oct 16, 2012 1229 rferrel Changes for non-blocking ProcedureListDlg.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -64,23 +66,28 @@ public class OpenAWIPSProcedure extends AbstractHandler {
|
|||
*/
|
||||
@Override
|
||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||
if (dialog != null) {
|
||||
dialog.open();
|
||||
return null;
|
||||
}
|
||||
|
||||
if (dialog == null || dialog.getShell() == null || dialog.isDisposed()) {
|
||||
dialog = new OpenProcedureListDlg(HandlerUtil.getActiveShell(event));
|
||||
dialog.open();
|
||||
dialog.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
LocalizationFile selectedFile = dialog.getSelectedFile();
|
||||
dialog = null;
|
||||
if (selectedFile != null) {
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
if (returnValue instanceof LocalizationFile) {
|
||||
LocalizationFile selectedFile = (LocalizationFile) returnValue;
|
||||
File f = selectedFile.getFile();
|
||||
Procedure p = (Procedure) LoadSerializedXml.deserialize(f);
|
||||
ProcedureDlg.displayDialog(
|
||||
LocalizationUtil.extractName(selectedFile.getName()), p,
|
||||
VizWorkbenchManager.getInstance().getCurrentWindow()
|
||||
.getShell());
|
||||
Procedure p = (Procedure) LoadSerializedXml
|
||||
.deserialize(f);
|
||||
ProcedureDlg.displayDialog(LocalizationUtil
|
||||
.extractName(selectedFile.getName()), p,
|
||||
VizWorkbenchManager.getInstance()
|
||||
.getCurrentWindow().getShell());
|
||||
}
|
||||
dialog = null;
|
||||
}
|
||||
});
|
||||
dialog.open();
|
||||
} else {
|
||||
dialog.bringToTop();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -98,6 +98,7 @@ import com.raytheon.viz.ui.editor.AbstractEditor;
|
|||
* Initial Creation
|
||||
* Oct 16, 2012 1229 rferrel Changes for non-blocking AlterBundleDlg.
|
||||
* Oct 16, 2012 1229 rferrel Changes to have displayDialog method.
|
||||
* Oct 16, 2012 1229 rferrel Changes for non-blocking ProcedureListDlg.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -173,6 +174,8 @@ public class ProcedureDlg extends CaveSWTDialog {
|
|||
|
||||
private AlterBundleDlg alterDlg;
|
||||
|
||||
private ProcedureListDlg saveAsDlg;
|
||||
|
||||
private ProcedureDlg(String fileName, Procedure p, Shell parent) {
|
||||
// Win32
|
||||
super(parent, SWT.DIALOG_TRIM | SWT.RESIZE, CAVE.INDEPENDENT_SHELL
|
||||
|
@ -919,15 +922,16 @@ public class ProcedureDlg extends CaveSWTDialog {
|
|||
}
|
||||
|
||||
private void showSaveAsDlg() {
|
||||
ProcedureListDlg dlg = new ProcedureListDlg("Save Procedure As...",
|
||||
shell, ProcedureListDlg.Mode.SAVE);
|
||||
dlg.open();
|
||||
if (mustCreate(saveAsDlg)) {
|
||||
saveAsDlg = new ProcedureListDlg("Save Procedure As...", shell,
|
||||
ProcedureListDlg.Mode.SAVE);
|
||||
|
||||
String fn = dlg.getSelectedFileName();
|
||||
if (fn == null) {
|
||||
return;
|
||||
}
|
||||
saveAsDlg.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
String fn = saveAsDlg.getSelectedFileName();
|
||||
if (fn != null) {
|
||||
ProcedureDlg oldDlg = getDialog(fn);
|
||||
|
||||
if (oldDlg != null) {
|
||||
|
@ -937,13 +941,20 @@ public class ProcedureDlg extends CaveSWTDialog {
|
|||
// Update mapping to new file name.
|
||||
synchronized (openDialogs) {
|
||||
openDialogs.remove(fileName);
|
||||
openDialogs.put(fn, this);
|
||||
openDialogs.put(fn, ProcedureDlg.this);
|
||||
}
|
||||
|
||||
frozen = dlg.isFrozen();
|
||||
frozen = saveAsDlg.isFrozen();
|
||||
fileName = fn;
|
||||
saveProcedure();
|
||||
}
|
||||
}
|
||||
});
|
||||
saveAsDlg.open();
|
||||
} else {
|
||||
saveAsDlg.bringToTop();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm save dialog, for if the user hasn't saved the procedure but tries
|
||||
|
|
|
@ -56,7 +56,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
|
||||
/**
|
||||
*
|
||||
* A dialog which displays a list of procedures for opening, saving, or deleting.
|
||||
* A dialog which displays a list of procedures for opening, saving, or
|
||||
* deleting.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -67,6 +68,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* ??? Initial creation
|
||||
* 07/31/2012 DR 15036 D. Friedman Ensure current user's procedures
|
||||
* are visible.
|
||||
* 10/16/2012 1229 rferrel Made dialog non-blocking.
|
||||
* </pre>
|
||||
*
|
||||
* @author unknown
|
||||
|
@ -80,8 +82,6 @@ public class ProcedureListDlg extends CaveSWTDialog {
|
|||
|
||||
private Text procedureTF;
|
||||
|
||||
private LocalizationFile selectedFile;
|
||||
|
||||
private TreeViewer treeViewer;
|
||||
|
||||
private Button okBtn;
|
||||
|
@ -103,7 +103,7 @@ public class ProcedureListDlg extends CaveSWTDialog {
|
|||
private final Mode mode;
|
||||
|
||||
public ProcedureListDlg(String title, Shell parent, Mode mode) {
|
||||
super(parent, SWT.DIALOG_TRIM | SWT.RESIZE); // Win32
|
||||
super(parent, SWT.DIALOG_TRIM | SWT.RESIZE, CAVE.DO_NOT_BLOCK); // Win32
|
||||
setText(title);
|
||||
|
||||
this.mode = mode;
|
||||
|
@ -343,7 +343,8 @@ public class ProcedureListDlg extends CaveSWTDialog {
|
|||
public void run() {
|
||||
TreeItem[] items = treeViewer.getTree().getItems();
|
||||
if (items != null && items.length > 0)
|
||||
treeViewer.getTree().showItem(items[items.length - 1]);
|
||||
treeViewer.getTree().showItem(
|
||||
items[items.length - 1]);
|
||||
treeViewer.reveal(find);
|
||||
}
|
||||
});
|
||||
|
@ -401,7 +402,7 @@ public class ProcedureListDlg extends CaveSWTDialog {
|
|||
cancelBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
shell.dispose();
|
||||
close();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -420,13 +421,6 @@ public class ProcedureListDlg extends CaveSWTDialog {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the fileName
|
||||
*/
|
||||
public LocalizationFile getSelectedFile() {
|
||||
return selectedFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the fileName
|
||||
*/
|
||||
|
@ -492,21 +486,22 @@ public class ProcedureListDlg extends CaveSWTDialog {
|
|||
+ " already exists. Overwrite anyways?");
|
||||
if (result == true) {
|
||||
fileName = procedureTF.getText();
|
||||
shell.dispose();
|
||||
close();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fileName = procedureTF.getText();
|
||||
shell.dispose();
|
||||
close();
|
||||
}
|
||||
} else if (mode == Mode.OPEN) {
|
||||
fileName = procedureTF.getText();
|
||||
if (tmp instanceof ProcedureTree) {
|
||||
// it must be a procedure tree, that is what the content
|
||||
// provider uses internally
|
||||
selectedFile = ((ProcedureTree) tmp).getFile();
|
||||
LocalizationFile selectedFile = ((ProcedureTree) tmp).getFile();
|
||||
setReturnValue(selectedFile);
|
||||
}
|
||||
shell.dispose();
|
||||
close();
|
||||
} else if (mode == Mode.DELETE) {
|
||||
|
||||
TreeItem[] selection = treeViewer.getTree().getSelection();
|
||||
|
@ -520,9 +515,11 @@ public class ProcedureListDlg extends CaveSWTDialog {
|
|||
if (tmp instanceof ProcedureTree) {
|
||||
// it must be a procedure tree, that is what the content
|
||||
// provider uses internally
|
||||
selectedFile = ((ProcedureTree) tmp).getFile();
|
||||
LocalizationFile selectedFile = ((ProcedureTree) tmp)
|
||||
.getFile();
|
||||
setReturnValue(selectedFile);
|
||||
}
|
||||
shell.dispose();
|
||||
close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue