Issue #2867 Better validation of image export frame range.

Former-commit-id: 6a3a62b913de1d508fb0d470d06a8be4a61918a3
This commit is contained in:
Ben Steffensmeier 2014-03-10 15:23:57 -05:00
parent 2f75103635
commit cc8b71fbdf
2 changed files with 47 additions and 9 deletions

View file

@ -53,6 +53,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Jan 20, 2014 2312 bsteffen Initial creation
* Mar 10, 2014 2867 bsteffen Better frame range validation.
*
* </pre>
*
@ -169,7 +170,8 @@ public class ImageExportDialog extends CaveSWTDialog {
gridData.widthHint = 24;
framesFromText.setLayoutData(gridData);
framesFromText.setEnabled(selectedFramesButton.getSelection());
framesFromText.setText(String.valueOf(options.getFirstFrameIndex() + 1));
framesFromText
.setText(String.valueOf(options.getFirstFrameIndex() + 1));
new Label(group, SWT.NONE).setText("to:");
framesToText = new Text(group, SWT.BORDER);
gridData = new GridData();
@ -376,15 +378,29 @@ public class ImageExportDialog extends CaveSWTDialog {
}
protected boolean validate() {
if (options.getFrameSelection() == FrameSelection.USER
&& (options.getFirstFrameIndex() > options.getLastFrameIndex() || options
.getLastFrameIndex() < 0)) {
MessageBox mb = new MessageBox(getShell(), SWT.ICON_ERROR | SWT.OK);
if (options.getFrameSelection() == FrameSelection.USER) {
String message = null;
if ((options.getFirstFrameIndex() < options.getMinFrameIndex())) {
message = "The first frame cannot be less than "
+ (options.getMinFrameIndex() + 1);
} else if ((options.getLastFrameIndex() > options
.getMaxFrameIndex() + 1)) {
message = "The last frame cannot be greater than than "
+ (options.getMaxFrameIndex() + 1);
} else if ((options.getFirstFrameIndex() > options
.getLastFrameIndex())) {
message = "The last frame must be after the first frame";
}
if (message != null) {
MessageBox mb = new MessageBox(getShell(), SWT.ICON_ERROR
| SWT.OK);
mb.setText("Invalid Range");
mb.setMessage("The frame range is invalid, please enter a valid range");
mb.setMessage("The frame range is invalid.\n" + message
+ ".\nPlease enter a valid range");
mb.open();
return false;
}
}
String path = options.getFileLocation().getAbsolutePath();
String suffix = path.substring(path.lastIndexOf('.') + 1);

View file

@ -36,6 +36,7 @@ import com.raytheon.uf.viz.core.datastructure.LoopProperties;
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Jan 20, 2014 2312 bsteffen Initial creation
* Mar 10, 2014 2867 bsteffen Better frame range validation.
*
* </pre>
*
@ -88,6 +89,10 @@ public class ImageExportOptions {
private int lastFrameIndex = 0;
private int minFrameIndex = 0;
private int maxFrameIndex = 0;
/** first frame dwell time in ms */
private int firstFrameDwell = 700;
@ -145,6 +150,22 @@ public class ImageExportOptions {
this.firstFrameDwell = firstFrameDwell;
}
public int getMinFrameIndex() {
return minFrameIndex;
}
public void setMinFrameIndex(int minFrameIndex) {
this.minFrameIndex = minFrameIndex;
}
public int getMaxFrameIndex() {
return maxFrameIndex;
}
public void setMaxFrameIndex(int maxFrameIndex) {
this.maxFrameIndex = maxFrameIndex;
}
public int getLastFrameDwell() {
return lastFrameDwell;
}
@ -166,6 +187,7 @@ public class ImageExportOptions {
int frameCount = container.getActiveDisplayPane().getDescriptor()
.getFramesInfo().getFrameCount();
lastFrameIndex = Math.max(frameCount - 1, 0);
maxFrameIndex = lastFrameIndex;
}
public void populate(LoopProperties loopProperties) {