Issue #1298 Changes for non-blocking TimeShiftDialog.

Change-Id: I60f60daee3b25fec2dabd09dd44c85bd3e57160c

Former-commit-id: a6f06c265b [formerly 1d67e245aa] [formerly 7af20b6130 [formerly 1deeb17d498a883af24fe983b7967918b3c3deb9]]
Former-commit-id: 7af20b6130
Former-commit-id: 406de0548d
This commit is contained in:
Roger Ferrel 2012-10-30 08:27:25 -05:00
parent 6dae6015f9
commit 8fba446977
2 changed files with 42 additions and 29 deletions

View file

@ -38,6 +38,7 @@ import com.raytheon.viz.gfe.dialogs.TimeShiftDialog;
* Feb 27, 2008 Eric Babin Initial Creation
* 05Aug2008 1383 ebabin Fix for time shift not working.
* Apr 9, 2009 1288 rjpeter Removed explicit refresh of SpatialDisplayManager.
* Oct 30, 2012 1298 rferrel Changes for non-blocking TimeShiftDialog.
*
* </pre>
*
@ -46,6 +47,7 @@ import com.raytheon.viz.gfe.dialogs.TimeShiftDialog;
*/
public class ShowTimeShiftDialog extends AbstractHandler {
private TimeShiftDialog dialog;
/*
* (non-Javadoc)
@ -57,14 +59,20 @@ public class ShowTimeShiftDialog extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
DataManager dm = DataManager.getCurrentInstance();
if (dm != null) {
if (dm == null) {
return null;
}
if (dialog == null || dialog.getShell() == null || dialog.isDisposed()) {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
TimeShiftDialog dialog = new TimeShiftDialog(shell, dm);
dialog.setBlockOnOpen(true);
dialog = new TimeShiftDialog(shell, dm);
dialog.setBlockOnOpen(false);
dialog.open();
} else {
dialog.bringToTop();
}
return null;

View file

@ -29,9 +29,13 @@ import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.edex.util.MathUtil;
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.core.DataManager;
import com.raytheon.viz.gfe.core.parm.Parm;
import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
@ -45,6 +49,7 @@ import com.raytheon.viz.ui.widgets.LabeledScale;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 26, 2008 Eric Babin Initial Creation
* Oct 30, 2012 1298 rferrel Code clean up for non-blocking dialog.
*
* </pre>
*
@ -53,7 +58,10 @@ import com.raytheon.viz.ui.widgets.LabeledScale;
*/
public class TimeShiftDialog extends CaveJFACEDialog {
private static final int SECONDS_PER_HOUR = 3600;
private final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(TimeShiftDialog.class);
private final int SECONDS_PER_HOUR = 3600;
private Composite top;
@ -69,15 +77,22 @@ public class TimeShiftDialog extends CaveJFACEDialog {
public TimeShiftDialog(Shell parent, DataManager dataManager) {
super(parent);
this.setShellStyle(SWT.TITLE | SWT.MODELESS | SWT.CLOSE);
this.setShellStyle(SWT.DIALOG_TRIM | SWT.MODELESS);
this.dataManager = dataManager;
}
@Override
protected Control createDialogArea(Composite parent) {
top = (Composite) super.createDialogArea(parent);
initializeComponents();
Parm[] parms = this.dataManager.getParmManager().getSelectedParms();
if (parms == null || parms.length == 0) {
Label label = new Label(top, SWT.CENTER);
GridData gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
label.setLayoutData(gd);
label.setText("No Grids selected.");
} else {
initializeComponents();
}
return top;
}
@ -167,14 +182,18 @@ public class TimeShiftDialog extends CaveJFACEDialog {
*/
@Override
protected void okPressed() {
// Tell the dataManager about the time shift
// LogStream.logUse("Time Shift", selection, self.__secondsToShift)
int secondsToShift = (int) formatter.getScaledValue(intervalScale
.getSelection())
* SECONDS_PER_HOUR;
this.dataManager.getParmOp().timeShift(secondsToShift,
copyButton.getSelection());
if (formatter != null) {
// Tell the dataManager about the time shift
int secondsToShift = (int) formatter.getScaledValue(intervalScale
.getSelection()) * SECONDS_PER_HOUR;
if (statusHandler.isPriorityEnabled(Priority.DEBUG)) {
statusHandler.handle(Priority.DEBUG,
"Time Shift " + copyButton.getSelection() + " "
+ secondsToShift);
}
this.dataManager.getParmOp().timeShift(secondsToShift,
copyButton.getSelection());
}
super.okPressed();
}
@ -201,13 +220,6 @@ public class TimeShiftDialog extends CaveJFACEDialog {
return (number + offset) * scale;
}
/**
* @return the offset
*/
public int getOffset() {
return offset;
}
/**
* @param offset
* the offset to set
@ -216,13 +228,6 @@ public class TimeShiftDialog extends CaveJFACEDialog {
this.offset = offset;
}
/**
* @return the scale
*/
public int getScale() {
return scale;
}
/**
* @param scale
* the scale to set