Merge "Issue #2312 Add extra frame selection option to GFE image export. Change-Id: Ic62448c703e59a5318f361e141de7ffb65055f74" into development

Former-commit-id: 3c66905edb02585a0276698c1286f97a4e22b4b7
This commit is contained in:
Nate Jensen 2014-01-22 17:04:21 -06:00 committed by Gerrit Code Review
commit afed92f3ce
7 changed files with 209 additions and 7 deletions

View file

@ -308,7 +308,7 @@ public class ImageExportDialog extends CaveSWTDialog {
options.setFrameSelection(FrameSelection.ALL);
} else if (currentFramesButton.getSelection()) {
options.setFrameSelection(FrameSelection.CURRENT);
} else {
} else if (selectedFramesButton.getSelection()) {
options.setFrameSelection(FrameSelection.USER);
try {
int from = Integer.parseInt(framesFromText.getText()) - 1;
@ -350,7 +350,7 @@ public class ImageExportDialog extends CaveSWTDialog {
try {
double delayS = Double
.parseDouble(lastFrameDwellText.getText());
int delay = (int) (delayS / TimeUtil.MILLIS_PER_SECOND);
int delay = (int) (delayS * TimeUtil.MILLIS_PER_SECOND);
options.setLastFrameDwell(delay);
} catch (NumberFormatException e) {
invalidNumberMessage(lastFrameDwellText, "last frame dwell");

View file

@ -134,9 +134,7 @@ public class ExportImageHandler extends AbstractImageCaptureHandler {
options.setFileLocation(new File(path));
} else {
/* Advanced dialog */
ImageExportDialog dialog = new ImageExportDialog(shell, options);
if (dialog.open() == null) {
if (openOptionsDialog(shell, options) == false) {
return null;
}
}
@ -167,6 +165,16 @@ public class ExportImageHandler extends AbstractImageCaptureHandler {
return null;
}
/**
* Open an image dialog
*
* @return false if the user canceled, true otherwise.
*/
protected boolean openOptionsDialog(Shell shell, ImageExportOptions options) {
ImageExportDialog dialog = new ImageExportDialog(shell, options);
return dialog.open() != null;
}
public void saveImages(IProgressMonitor monitor,
ImageExportOptions options, List<BufferedImage> images) {
monitor.beginTask("Saving Images", images.size());

View file

@ -27,7 +27,7 @@ import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.uf.viz.core.datastructure.LoopProperties;
/**
* Configuration options taht control how an image is exported.
* Configuration options that control how an image is exported.
*
* <pre>
*

View file

@ -32,7 +32,8 @@ Require-Bundle: org.eclipse.ui,
com.raytheon.uf.common.colormap;bundle-version="1.12.1174",
com.google.guava;bundle-version="1.0.0",
com.raytheon.uf.common.style;bundle-version="1.0.0",
com.raytheon.uf.common.activetable
com.raytheon.uf.common.activetable,
com.raytheon.uf.viz.image.export;bundle-version="1.14.0"
Bundle-ActivationPolicy: lazy
Export-Package: com.raytheon.viz.gfe,
com.raytheon.viz.gfe.constants,

View file

@ -974,6 +974,15 @@
definitionId="com.raytheon.viz.gfe.inGFEActionSet">
</reference>
</activeWhen>
</handler>
<handler
class="com.raytheon.viz.gfe.export.image.GfeExportImageHandler"
commandId="com.raytheon.uf.viz.image.export.save">
<activeWhen>
<reference
definitionId="com.raytheon.viz.gfe.inGFEActionSet">
</reference>
</activeWhen>
</handler>
</extension>
<extension point="com.raytheon.uf.viz.core.resource">

View file

@ -0,0 +1,54 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.gfe.export.image;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.viz.image.export.dialog.ImageExportDialog;
import com.raytheon.uf.viz.image.export.handler.ExportImageHandler;
import com.raytheon.uf.viz.image.export.options.ImageExportOptions;
/**
* A custom {@link ExportImageHandler} for GFE which allows it to add options to
* the dialog.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Jan 22, 2014 2312 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
* @see GfeImageExportDialog
*/
public class GfeExportImageHandler extends ExportImageHandler {
@Override
protected boolean openOptionsDialog(Shell shell, ImageExportOptions options) {
ImageExportDialog dialog = new GfeImageExportDialog(shell, options);
return dialog.open() != null;
}
}

View file

@ -0,0 +1,130 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.gfe.export.image;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.time.TimeRange;
import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.IDescriptor.FramesInfo;
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
import com.raytheon.uf.viz.image.export.dialog.ImageExportDialog;
import com.raytheon.uf.viz.image.export.options.ImageExportOptions;
import com.raytheon.uf.viz.image.export.options.ImageExportOptions.FrameSelection;
import com.raytheon.viz.gfe.core.DataManager;
import com.raytheon.viz.gfe.core.DataManagerUIFactory;
import com.raytheon.viz.gfe.core.parm.ParmOp;
import com.raytheon.viz.ui.EditorUtil;
/**
* A custom {@link ImageExportDialog} for GFE which adds on option to use the
* Grid Manager Selected Time Range.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Jan 22, 2014 2312 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class GfeImageExportDialog extends ImageExportDialog {
protected Button selectedFrameRangeButton;
public GfeImageExportDialog(Shell parentShell, ImageExportOptions options) {
super(parentShell, options);
}
@Override
protected void initializeFramesGroup(Group group) {
super.initializeFramesGroup(group);
selectedFrameRangeButton = new Button(group, SWT.RADIO);
selectedFrameRangeButton.setText("Grid Manager Selected Time Range");
GridData gridData = new GridData();
gridData.horizontalSpan = 5;
selectedFrameRangeButton.setLayoutData(gridData);
}
@Override
protected void okPressed() {
if (selectedFrameRangeButton.getSelection()) {
DataManager dataManager = DataManagerUIFactory.getCurrentInstance();
ParmOp parmOp = dataManager.getParmOp();
TimeRange selectedRange = parmOp.getSelectionTimeRange();
if (selectedRange == null || !selectedRange.isValid()) {
MessageBox mb = new MessageBox(getShell(), SWT.ICON_ERROR
| SWT.OK);
mb.setText("No Time Range Selected");
mb.setMessage("No Time Range is selected, select a time range in the grid manager.");
mb.open();
return;
}
IDisplayPaneContainer container = EditorUtil
.getActiveVizContainer();
IDisplayPane pane = container.getActiveDisplayPane();
IRenderableDisplay renderableDispaly = pane.getRenderableDisplay();
IDescriptor descriptor = renderableDispaly.getDescriptor();
FramesInfo fi = descriptor.getFramesInfo();
DataTime[] times = fi.getFrameTimes();
int start = -1;
int end = -1;
for (int i = 0; i < times.length; i += 1) {
if (times[i] == null) {
continue;
}
TimeRange validRange = times[i].getValidPeriod();
if (selectedRange.overlaps(validRange)) {
if (start == -1) {
start = i;
}
end = i;
} else if (start != -1) {
break;
}
}
if (start == -1) {
MessageBox mb = new MessageBox(getShell(), SWT.ICON_ERROR
| SWT.OK);
mb.setText("Invalid Selection");
mb.setMessage("The selected time range does not contain any data, choose a new range.");
mb.open();
return;
}
options.setFrameSelection(FrameSelection.USER);
options.setFirstFrameIndex(start);
options.setLastFrameIndex(end + 1);
}
super.okPressed();
}
}