Issue #1287 Changes for non-blocking AutoSaveIntervalDialog.
Change-Id: I5ea021d0658e68553542c88c8850fea4b9de696b Former-commit-id:04755d4801
[formerly2048a41563
] [formerly3e852fc9b5
] [formerly04755d4801
[formerly2048a41563
] [formerly3e852fc9b5
] [formerly17085ba699
[formerly3e852fc9b5
[formerly d1601fee5b3de86e0120553d17ee18cf0b482e63]]]] Former-commit-id:17085ba699
Former-commit-id:05bcf19c11
[formerly1ce417b106
] [formerly f7c0825e14808bc4206e2079a6f326e86e2d6e11 [formerly6b9f409486
]] Former-commit-id: f586d6ac7f7381c925f4555a168a5ddc5dfa1240 [formerly2ac417247f
] Former-commit-id:7f59b9efa1
This commit is contained in:
parent
e41a96d0f3
commit
d0222e73c4
1 changed files with 41 additions and 24 deletions
|
@ -30,6 +30,7 @@ import org.eclipse.ui.PlatformUI;
|
||||||
import com.raytheon.viz.gfe.core.DataManager;
|
import com.raytheon.viz.gfe.core.DataManager;
|
||||||
import com.raytheon.viz.gfe.dialogs.AutoSaveIntervalDialog;
|
import com.raytheon.viz.gfe.dialogs.AutoSaveIntervalDialog;
|
||||||
import com.raytheon.viz.gfe.jobs.AutoSaveJob;
|
import com.raytheon.viz.gfe.jobs.AutoSaveJob;
|
||||||
|
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action for launching auto save dialog
|
* Action for launching auto save dialog
|
||||||
|
@ -40,6 +41,7 @@ import com.raytheon.viz.gfe.jobs.AutoSaveJob;
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Jan 23, 2008 Eric Babin Initial Creation
|
* Jan 23, 2008 Eric Babin Initial Creation
|
||||||
* Jul 8, 2008 randerso reworked
|
* Jul 8, 2008 randerso reworked
|
||||||
|
* Oct 23, 2012 1287 rferrel Changes for non-blocking AutoSaveIntervalDialog.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -47,6 +49,7 @@ import com.raytheon.viz.gfe.jobs.AutoSaveJob;
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
public class ShowAutoSaveIntervalDialog extends AbstractHandler {
|
public class ShowAutoSaveIntervalDialog extends AbstractHandler {
|
||||||
|
private AutoSaveIntervalDialog dialog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -58,36 +61,50 @@ public class ShowAutoSaveIntervalDialog extends AbstractHandler {
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (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
|
@Override
|
||||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||||
|
|
||||||
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
if (dialog == null || dialog.getShell() == null || dialog.isDisposed()) {
|
||||||
.getShell();
|
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||||
|
.getShell();
|
||||||
|
|
||||||
int interval = AutoSaveJob.getInterval();
|
int interval = AutoSaveJob.getInterval();
|
||||||
boolean autoSaveEnabled = interval > 0;
|
boolean autoSaveEnabled = interval > 0;
|
||||||
if (!autoSaveEnabled) {
|
if (!autoSaveEnabled) {
|
||||||
interval = AutoSaveJob.MAX_INTERVAL;
|
interval = AutoSaveJob.MAX_INTERVAL;
|
||||||
}
|
|
||||||
|
|
||||||
AutoSaveIntervalDialog dialog = new AutoSaveIntervalDialog(shell,
|
|
||||||
interval, autoSaveEnabled);
|
|
||||||
dialog.setBlockOnOpen(true);
|
|
||||||
dialog.open();
|
|
||||||
|
|
||||||
if (dialog.getReturnCode() == Window.OK) {
|
|
||||||
// update
|
|
||||||
if (dialog.isAutoSaveEnabled()) {
|
|
||||||
interval = dialog.getCurrentInterval();
|
|
||||||
AutoSaveJob.setInterval(interval);
|
|
||||||
DataManager.enableAutoSave();
|
|
||||||
} else {
|
|
||||||
AutoSaveJob.setInterval(0);
|
|
||||||
DataManager.disableAutoSave();
|
|
||||||
}
|
}
|
||||||
} // else do nothing...
|
dialog = new AutoSaveIntervalDialog(shell, interval,
|
||||||
|
autoSaveEnabled);
|
||||||
|
dialog.setBlockOnOpen(false);
|
||||||
|
dialog.setCloseCallback(new ICloseCallback() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dialogClosed(Object returnValue) {
|
||||||
|
if (returnValue instanceof Integer) {
|
||||||
|
int returnCode = (Integer) returnValue;
|
||||||
|
if (returnCode == Window.OK) {
|
||||||
|
// update
|
||||||
|
if (dialog.isAutoSaveEnabled()) {
|
||||||
|
int interval = dialog.getCurrentInterval();
|
||||||
|
AutoSaveJob.setInterval(interval);
|
||||||
|
DataManager.enableAutoSave();
|
||||||
|
} else {
|
||||||
|
AutoSaveJob.setInterval(0);
|
||||||
|
DataManager.disableAutoSave();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialog.open();
|
||||||
|
} else {
|
||||||
|
dialog.bringToTop();
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue