Issue #2867 Better validation of image export frame range.
Former-commit-id:e75b961db5
[formerly 6a3a62b913de1d508fb0d470d06a8be4a61918a3] Former-commit-id:cc8b71fbdf
This commit is contained in:
parent
eaa570c3f2
commit
9c82499818
2 changed files with 47 additions and 9 deletions
|
@ -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,14 +378,28 @@ 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);
|
||||
mb.setText("Invalid Range");
|
||||
mb.setMessage("The frame range is invalid, please enter a valid range");
|
||||
mb.open();
|
||||
return false;
|
||||
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.\n" + message
|
||||
+ ".\nPlease enter a valid range");
|
||||
mb.open();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
String path = options.getFileLocation().getAbsolutePath();
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue