Issue #1287 Changes for non-blocking SampleSetDialog.
Change-Id: I6b3eab5386418f9303190892f1a746d63a82ce65 Former-commit-id:538ce87115
[formerly8af2d4a404
] [formerlyaf299023e2
[formerly 622b739d6e1352aacb96b7dd0f797f2b43fe5847]] Former-commit-id:af299023e2
Former-commit-id:3eb28edd6c
This commit is contained in:
parent
b2fa80a987
commit
463e648808
4 changed files with 165 additions and 141 deletions
|
@ -35,10 +35,9 @@ import com.raytheon.uf.common.dataplugin.gfe.sample.SampleId;
|
|||
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.viz.gfe.Activator;
|
||||
import com.raytheon.viz.gfe.constants.StatusConstants;
|
||||
import com.raytheon.viz.gfe.core.DataManager;
|
||||
import com.raytheon.viz.gfe.dialogs.SampleSetDialog;
|
||||
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||
|
||||
/**
|
||||
* Action for launching delete samples dialog.
|
||||
|
@ -49,6 +48,7 @@ import com.raytheon.viz.gfe.dialogs.SampleSetDialog;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 7, 2008 Eric Babin Initial Creation
|
||||
* 22JUL2008 #1275. Eric Babin Remove inadvertent dispose on parent shell.
|
||||
* Oct 24, 2012 #1287 rferrel Changes for non-blocking SampleSetDialog.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -57,7 +57,10 @@ import com.raytheon.viz.gfe.dialogs.SampleSetDialog;
|
|||
*/
|
||||
|
||||
public class ShowDeleteSampleSetDialog extends AbstractHandler {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(ShowDeleteSampleSetDialog.class);
|
||||
private final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(ShowDeleteSampleSetDialog.class);
|
||||
|
||||
private SampleSetDialog dialog;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
@ -68,44 +71,65 @@ public class ShowDeleteSampleSetDialog extends AbstractHandler {
|
|||
*/
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
ArrayList<SampleId> sampleIdList = DataManager.getCurrentInstance()
|
||||
.getSampleSetManager().getInventoryAsList();
|
||||
if (dialog == null || dialog.getShell() == null || dialog.isDisposed()) {
|
||||
ArrayList<SampleId> sampleIdList = DataManager.getCurrentInstance()
|
||||
.getSampleSetManager().getInventoryAsList();
|
||||
|
||||
Collections.sort(sampleIdList, new Comparator<SampleId>() {
|
||||
Collections.sort(sampleIdList, new Comparator<SampleId>() {
|
||||
|
||||
@Override
|
||||
public int compare(SampleId o1, SampleId o2) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
@Override
|
||||
public int compare(SampleId o1, SampleId o2) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getShell();
|
||||
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getShell();
|
||||
|
||||
SampleSetDialog dialog = new SampleSetDialog(shell, sampleIdList,
|
||||
SampleSetDialog.DELETE);
|
||||
dialog = new SampleSetDialog(shell, sampleIdList,
|
||||
SampleSetDialog.DELETE);
|
||||
|
||||
dialog.setBlockOnOpen(true);
|
||||
dialog.open();
|
||||
if (dialog.getReturnCode() != Window.CANCEL
|
||||
dialog.setBlockOnOpen(false);
|
||||
dialog.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
if (returnValue instanceof Integer) {
|
||||
int returnCode = (Integer) returnValue;
|
||||
doDialogClose(returnCode);
|
||||
}
|
||||
dialog = null;
|
||||
}
|
||||
});
|
||||
dialog.open();
|
||||
} else {
|
||||
dialog.bringToTop();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void doDialogClose(int returnCode) {
|
||||
if (returnCode != Window.CANCEL
|
||||
&& dialog.getSelectedSampleIdIndexes() != null) {
|
||||
ArrayList<SampleId> sampleIdList = dialog.getSamples();
|
||||
SampleId id = sampleIdList
|
||||
.get(dialog.getSelectedSampleIdIndexes()[0]);
|
||||
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getShell();
|
||||
|
||||
if (MessageDialog.openConfirm(shell, "Delete sample set",
|
||||
"Delete selected sample set?")) {
|
||||
if (DataManager.getCurrentInstance().getSampleSetManager()
|
||||
.deleteSampleSet(id)) {
|
||||
statusHandler.handle(Priority.EVENTA, id.getName()
|
||||
+ ", Sample set deleted successfully");
|
||||
+ ", Sample set deleted successfully");
|
||||
} else {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error deleting sample set, " + id.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,10 +31,14 @@ import org.eclipse.swt.widgets.Shell;
|
|||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.gfe.sample.SampleId;
|
||||
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.viz.gfe.GFEException;
|
||||
import com.raytheon.viz.gfe.core.DataManager;
|
||||
import com.raytheon.viz.gfe.core.ISampleSetManager;
|
||||
import com.raytheon.viz.gfe.dialogs.SampleSetDialog;
|
||||
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||
|
||||
/**
|
||||
* Action to launch sampele set dialog.
|
||||
|
@ -45,6 +49,7 @@ import com.raytheon.viz.gfe.dialogs.SampleSetDialog;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 7, 2008 Eric Babin Initial Creation
|
||||
* Apr 9, 2009 1288 rjpeter Removed explicit refresh of SpatialDisplayManager.
|
||||
* Oct 24, 2012 1287 rferrel Changes for non-blocking SampleSetDialog.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -53,14 +58,12 @@ import com.raytheon.viz.gfe.dialogs.SampleSetDialog;
|
|||
*/
|
||||
|
||||
public class ShowLoadSampleSetDialog extends AbstractHandler {
|
||||
private final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(ShowLoadSampleSetDialog.class);
|
||||
|
||||
// SampleRenderable sample;
|
||||
private SampleSetDialog dialog;
|
||||
|
||||
// public ShowLoadSampleSetDialog() {
|
||||
//
|
||||
// super();
|
||||
// this.sample = new SampleRenderable();
|
||||
// }
|
||||
private DataManager dm;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
@ -71,96 +74,80 @@ public class ShowLoadSampleSetDialog extends AbstractHandler {
|
|||
*/
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
|
||||
DataManager dm = DataManager.getCurrentInstance();
|
||||
if (dm == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getShell();
|
||||
|
||||
ArrayList<SampleId> sampleIdList = dm.getSampleSetManager()
|
||||
.getInventoryAsList();
|
||||
|
||||
Collections.sort(sampleIdList, new Comparator<SampleId>() {
|
||||
|
||||
@Override
|
||||
public int compare(SampleId o1, SampleId o2) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
if (dialog == null || dialog.getShell() == null || dialog.isDisposed()) {
|
||||
dm = DataManager.getCurrentInstance();
|
||||
if (dm == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
});
|
||||
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getShell();
|
||||
|
||||
SampleSetDialog dialog = new SampleSetDialog(shell, sampleIdList,
|
||||
SampleSetDialog.LOAD);
|
||||
ArrayList<SampleId> sampleIdList = dm.getSampleSetManager()
|
||||
.getInventoryAsList();
|
||||
|
||||
dialog.setBlockOnOpen(true);
|
||||
dialog.open();
|
||||
if (dialog.getReturnCode() != Window.CANCEL
|
||||
&& dialog.getSelectedSampleIdIndexes() != null) {
|
||||
if (dialog.getReturnCode() == SampleSetDialog.OK) {
|
||||
if (dialog.getType() == SampleSetDialog.LOAD) {
|
||||
for (int i = 0; i < dialog.getSelectedSampleIdIndexes().length; i++) {
|
||||
SampleId id = sampleIdList.get(dialog
|
||||
.getSelectedSampleIdIndexes()[i]);
|
||||
try {
|
||||
dm.getSampleSetManager().loadSampleSet(id,
|
||||
ISampleSetManager.SampleSetLoadMode.ADD);
|
||||
} catch (GFEException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else if (dialog.getType() == SampleSetDialog.SAVE) {
|
||||
dm.getSampleSetManager().saveActiveSampleSet(
|
||||
new SampleId(dialog.getSampleName()));
|
||||
}
|
||||
if (dialog.getType() == SampleSetDialog.DELETE) {
|
||||
for (int i = 0; i < dialog.getSelectedSampleIdIndexes().length; i++) {
|
||||
SampleId id = sampleIdList.get(dialog
|
||||
.getSelectedSampleIdIndexes()[i]);
|
||||
dm.getSampleSetManager().deleteSampleSet(id);
|
||||
}
|
||||
}
|
||||
} else if (dialog.getReturnCode() == SampleSetDialog.REMOVE) {
|
||||
for (int i = 0; i < dialog.getSelectedSampleIdIndexes().length; i++) {
|
||||
SampleId id = sampleIdList.get(dialog
|
||||
.getSelectedSampleIdIndexes()[i]);
|
||||
try {
|
||||
dm.getSampleSetManager().loadSampleSet(id,
|
||||
ISampleSetManager.SampleSetLoadMode.REMOVE);
|
||||
} catch (GFEException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Collections.sort(sampleIdList, new Comparator<SampleId>() {
|
||||
|
||||
@Override
|
||||
public int compare(SampleId o1, SampleId o2) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
|
||||
} else if (dialog.getReturnCode() == SampleSetDialog.REPLACE) {
|
||||
for (int i = 0; i < dialog.getSelectedSampleIdIndexes().length; i++) {
|
||||
SampleId id = sampleIdList.get(dialog
|
||||
.getSelectedSampleIdIndexes()[i]);
|
||||
try {
|
||||
dm.getSampleSetManager().loadSampleSet(id,
|
||||
ISampleSetManager.SampleSetLoadMode.REPLACE);
|
||||
} catch (GFEException e) {
|
||||
e.printStackTrace();
|
||||
});
|
||||
|
||||
dialog = new SampleSetDialog(shell, sampleIdList,
|
||||
SampleSetDialog.LOAD);
|
||||
|
||||
dialog.setBlockOnOpen(false);
|
||||
dialog.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
if (returnValue instanceof Integer) {
|
||||
int returnCode = (Integer) returnValue;
|
||||
doDialogClosed(returnCode);
|
||||
}
|
||||
dialog = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
dialog.open();
|
||||
} else {
|
||||
dialog.bringToTop();
|
||||
}
|
||||
// refresh();
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.tools.AbstractTool#refresh()
|
||||
*/
|
||||
// @Override
|
||||
// protected void refresh() {
|
||||
// IEditorPart part = VizApp.getCurrentEditor();
|
||||
// if (part instanceof AbstractEditor) {
|
||||
// ((AbstractEditor) part).refresh();
|
||||
// }
|
||||
// }
|
||||
private void doDialogClosed(int returnCode) {
|
||||
if (returnCode != Window.CANCEL
|
||||
&& dialog.getSelectedSampleIdIndexes() != null) {
|
||||
ArrayList<SampleId> sampleIdList = dialog.getSamples();
|
||||
ISampleSetManager.SampleSetLoadMode mode = null;
|
||||
switch (returnCode) {
|
||||
case SampleSetDialog.OK:
|
||||
mode = ISampleSetManager.SampleSetLoadMode.ADD;
|
||||
break;
|
||||
case SampleSetDialog.REMOVE:
|
||||
mode = ISampleSetManager.SampleSetLoadMode.REMOVE;
|
||||
break;
|
||||
case SampleSetDialog.REPLACE:
|
||||
mode = ISampleSetManager.SampleSetLoadMode.REPLACE;
|
||||
break;
|
||||
default:
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Load unknow return code: " + returnCode);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int index : dialog.getSelectedSampleIdIndexes()) {
|
||||
SampleId id = sampleIdList.get(index);
|
||||
try {
|
||||
dm.getSampleSetManager().loadSampleSet(id, mode);
|
||||
} catch (GFEException e) {
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"Load failed for mode: " + mode.toString(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ import java.util.Comparator;
|
|||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.jface.window.Window;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
|
@ -34,6 +33,7 @@ import com.raytheon.uf.common.dataplugin.gfe.sample.SampleId;
|
|||
import com.raytheon.viz.gfe.core.DataManager;
|
||||
import com.raytheon.viz.gfe.core.ISampleSetManager;
|
||||
import com.raytheon.viz.gfe.dialogs.SampleSetDialog;
|
||||
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||
|
||||
/**
|
||||
* Action to show save sample set dialog.
|
||||
|
@ -43,6 +43,7 @@ import com.raytheon.viz.gfe.dialogs.SampleSetDialog;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 7, 2008 Eric Babin Initial Creation
|
||||
* Oct 24, 2012 1287 rferrel Changes for non-blocking SampleSetDialog.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -51,54 +52,62 @@ import com.raytheon.viz.gfe.dialogs.SampleSetDialog;
|
|||
*/
|
||||
|
||||
public class ShowSaveSampleSetDialog extends AbstractHandler {
|
||||
private SampleSetDialog dialog;
|
||||
|
||||
private ISampleSetManager sampleMgr;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
|
||||
* @see
|
||||
* org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands
|
||||
* .ExecutionEvent)
|
||||
*/
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
if (dialog == null || dialog.getShell() == null || dialog.isDisposed()) {
|
||||
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getShell();
|
||||
|
||||
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getShell();
|
||||
sampleMgr = DataManager.getCurrentInstance().getSampleSetManager();
|
||||
|
||||
ISampleSetManager sampleMgr = DataManager.getCurrentInstance()
|
||||
.getSampleSetManager();
|
||||
ArrayList<SampleId> sampleIdList = sampleMgr.getInventoryAsList();
|
||||
Collections.sort(sampleIdList, new Comparator<SampleId>() {
|
||||
|
||||
ArrayList<SampleId> sampleIdList = sampleMgr.getInventoryAsList();
|
||||
Collections.sort(sampleIdList, new Comparator<SampleId>() {
|
||||
@Override
|
||||
public int compare(SampleId o1, SampleId o2) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(SampleId o1, SampleId o2) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
dialog = new SampleSetDialog(shell, sampleIdList,
|
||||
SampleSetDialog.SAVE);
|
||||
|
||||
SampleSetDialog dialog = new SampleSetDialog(shell, sampleIdList,
|
||||
SampleSetDialog.SAVE);
|
||||
dialog.setBlockOnOpen(false);
|
||||
dialog.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
dialog.setBlockOnOpen(true);
|
||||
dialog.open();
|
||||
|
||||
if (dialog.getReturnCode() != Window.CANCEL
|
||||
&& dialog.getSelectedSampleIdIndexes() != null) {
|
||||
|
||||
if (dialog.getReturnCode() == SampleSetDialog.OK) {
|
||||
if (dialog.getType() == SampleSetDialog.LOAD) {
|
||||
} else if (dialog.getType() == SampleSetDialog.SAVE) {
|
||||
if (dialog.getSampleName() != null) {
|
||||
sampleMgr.saveActiveSampleSet(new SampleId(dialog
|
||||
.getSampleName()));
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
if (returnValue instanceof Integer) {
|
||||
int returnCode = (Integer) returnValue;
|
||||
doDialogClose(returnCode);
|
||||
}
|
||||
dialog = null;
|
||||
}
|
||||
if (dialog.getType() == SampleSetDialog.DELETE) {
|
||||
}
|
||||
} else if (dialog.getReturnCode() == SampleSetDialog.REMOVE) {
|
||||
} else if (dialog.getReturnCode() == SampleSetDialog.REPLACE) {
|
||||
}
|
||||
});
|
||||
dialog.open();
|
||||
} else {
|
||||
dialog.bringToTop();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void doDialogClose(int returnCode) {
|
||||
if ((returnCode == SampleSetDialog.OK)
|
||||
&& (dialog.getSelectedSampleIdIndexes() != null)
|
||||
&& (dialog.getSampleName() != null)) {
|
||||
sampleMgr.saveActiveSampleSet(new SampleId(dialog.getSampleName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 7, 2008 Eric Babin Initial Creation
|
||||
* Oct 24, 2012 1287 rferrel Code clean up for non-blocking dialog.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -84,11 +85,11 @@ public class SampleSetDialog extends CaveJFACEDialog {
|
|||
|
||||
private int returnCode = OK;
|
||||
|
||||
private int type = 1;
|
||||
private int type = CANCEL;
|
||||
|
||||
public SampleSetDialog(Shell parent, ArrayList<SampleId> samples, int type) {
|
||||
super(parent);
|
||||
this.setShellStyle(SWT.TITLE | SWT.MODELESS | SWT.CLOSE);
|
||||
this.setShellStyle(SWT.DIALOG_TRIM | SWT.MODELESS);
|
||||
this.samples = samples;
|
||||
this.type = type;
|
||||
}
|
||||
|
@ -221,4 +222,7 @@ public class SampleSetDialog extends CaveJFACEDialog {
|
|||
this.sampleName = sampleName;
|
||||
}
|
||||
|
||||
public ArrayList<SampleId> getSamples() {
|
||||
return samples;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue