Save and Close not done yet.
Object clearing associated with file-switching is improved, but not complete.
svn path=/; revision=378
OpenExperimentAction.dialog.filter.exts=*.exp
OpenExperimentAction.dialog.filter.text=Experiment Files
+CloseAction.dialog.text=Close the current image file
+
# Actions
action.OpenAction.text=&Open...@Command+O
action.OpenAction.image=file:resources/icons/open.png
-action.OpenAction.tooltip=Open image
+action.OpenAction.tooltip=pen image
action.SaveAction.text=&Save@Command+S
action.SaveAction.image=file:resources/icons/save.png
action.SaveAction.tooltip=Save segmentation context
-action.SaveAsAction.text=S&ave As...@Command+Shift+S
+action.SaveAsAction.text=&Save As...@Command+Shift+S
action.SaveAsAction.image=file:resources/icons/save-as.png
action.SaveAsAction.tooltip=Save segmentation context as...
action.PrintAction.image=file:resources/icons/print.png
action.PrintAction.tooltip=Print view
-action.ExitAction.text=E&xit@Command+Q
+action.CloseAction.text=&Close@Command+W
+action.CloseAction.image=file:resources/icons/close.png
+action.CloseAction.tooltip=Close current file
+
+action.ExitAction.text=&Exit@Command+Q
action.ExitAction.image=file:resources/icons/exit.png
action.ExitAction.tooltip=Quit the application
OpenExperimentAction.dialog.filter.exts=*.exp
OpenExperimentAction.dialog.filter.text=Experiment Files
+CloseAction.dialog.text=Close the current image file
+
# Actions
action.OpenAction.text=&Open...@Ctrl+O
action.OpenAction.image=file:resources/icons/open.png
action.SaveAction.image=file:resources/icons/save.png
action.SaveAction.tooltip=Save segmentation context
-action.SaveAsAction.text=S&ave As...@Ctrl+Shift+S
+action.SaveAsAction.text=&Save As...@Ctrl+Shift+S
action.SaveAsAction.image=file:resources/icons/save-as.png
action.SaveAsAction.tooltip=Save segmentation context as...
action.PrintAction.image=file:resources/icons/print.png
action.PrintAction.tooltip=Print view
-action.ExitAction.text=E&xit@Ctrl+Q
+action.CloseAction.text=&Close@Command+W
+action.CloseAction.image=file:resources/icons/close.png
+action.CloseAction.tooltip=Close current file
+
+action.ExitAction.text=&Exit@Ctrl+Q
action.ExitAction.image=file:resources/icons/exit.png
action.ExitAction.tooltip=Quit the application
PrefsDialog.background-color.text=Background color for markup
PrefsDialog.experiment-embedded.text=Show experiment panel embedded in main window
PrefsDialog.confirm-exit.text=Confirm exit when application is closed
+PrefsDialog.confirm-close.text=Remind to save current work when closing file
# Experiment Panel
ExperimentPanel.description.title=Task Description
PrefsDialog.background-color.text=Background color for markup
PrefsDialog.experiment-embedded.text=Show experiment panel embedded in main window
PrefsDialog.confirm-exit.text=Confirm exit when application is closed
+PrefsDialog.confirm-close.text=Remind to save current work when closing file
# Experiment Panel
ExperimentPanel.description.title=Task Description
public static final String BACKGROUND_COLOR = "background-color";
public static final String EXPERIMENT_EMBEDDED = "experiment-embedded";
public static final String CONFIRM_EXIT = "confirm-exit";
+ public static final String CONFIRM_CLOSE = "confirm-close";
}
public interface SupportedTypes {
a.setEnabled(SaveAction.class, ctxAvailable && !experimentMode);
a.setEnabled(SaveAsAction.class, ctxAvailable && !experimentMode);
a.setEnabled(ExportViewAction.class, ctxAvailable && !experimentMode);
+ a.setEnabled(CloseAction.class, ctxAvailable && !experimentMode);
a.setEnabled(ExportTransparentPNGAction.class, ctxAvailable && !experimentMode);
a.setEnabled(PrintAction.class, ctxAvailable && !experimentMode);
a.setEnabled(CopyAction.class, ctxAvailable && !experimentMode);
file.add(new Separator());
file.add(actions.get(PrintAction.class));
file.add(new Separator());*/
+ file.add(actions.get(CloseAction.class));
file.add(actions.get(ExitAction.class));
MenuManager edit = addMenu(bar, "&Edit");
enhancer.hookApplicationMenu(Display.getDefault(),
quitListener, aboutAction, prefAction);
}
-
+
return bar;
}
add(new SaveAsAction(this));
add(new AboutAction(this));
add(new CopyAction(this));
+ add(new CloseAction(this));
add(new ExitAction(this));
add(new ExportViewAction(this));
add(new ExportImageMapAction(this));
--- /dev/null
+package ie.dcu.apps.ist.actions;
+
+import ie.dcu.apps.ist.*;
+import ie.dcu.apps.ist.dialogs.SaveReminderDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+
+/**
+ * Close current image annotation file
+ *
+ * @author Justin Preece
+ */
+public class CloseAction extends AppAction {
+ public CloseAction(ActionManager m) {
+ super(m);
+ }
+
+ @Override
+ public void run() {
+ // call Save Reminder dialog
+ SaveReminderDialog dialog = new SaveReminderDialog(window.getShell());
+ SaveReminderDialog.Result result = dialog.open();
+
+ if (result != null) {
+ /* check return choice in result here and fire appropriate action:
+ * - save now and then close file ("Save now")
+ * - do not save and then close file ("I've already saved my work")
+ * - cancel the close ("Do not close this file")
+ */
+ /*if (confirmClose(window)) {
+ window.close();
+ // TODO: not really; you'll close the file here after a confirmation from the user via the ConfirmSaved dialog
+ System.exit(0);
+ }*/
+ }
+ }
+
+ public static boolean confirmClose(AppWindow window) {
+ boolean confirm = window.getPrefs().get(
+ Boolean.class, AppPrefs.Keys.CONFIRM_CLOSE, true);
+
+ if (confirm) {
+ return MessageDialog.openConfirm(
+ window.getShell(), "Confirm",
+ "Are you sure you want to close this file?");
+ }
+
+ return true;
+ }
+}
createLabel(generalTab, Keys.CONFIRM_EXIT);
createCheckBox(generalTab, Keys.CONFIRM_EXIT);
-
+
+ createLabel(generalTab, Keys.CONFIRM_CLOSE);
+ createCheckBox(generalTab, Keys.CONFIRM_CLOSE);
+
createBanner(generalTab, STATUS);
createLabel(generalTab, Keys.ENABLE_FEEDBACK);
// Load confirm exit
loadBool(Keys.CONFIRM_EXIT, true);
-
+
+ // Load confirm exit
+ loadBool(Keys.CONFIRM_CLOSE, true);
+
// Load enable feedback
loadBool(Keys.ENABLE_FEEDBACK, true);
} else if (key.equals(Keys.CONFIRM_EXIT)) {
storeBool(key);
+
+ } else if (key.equals(Keys.CONFIRM_CLOSE)) {
+
+ storeBool(key);
}
-
+
}
--- /dev/null
+package ie.dcu.apps.ist.dialogs;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Dialog;
+import org.eclipse.swt.widgets.Shell;
+
+public class SaveReminderDialog extends Dialog {
+
+ // Default title
+ private static final String TITLE = "Save Reminder";
+ public class Result {};
+
+ public SaveReminderDialog(Shell shell) {
+ super(shell);
+ setText(TITLE);
+ }
+
+ public Result open() {
+ return null;
+ }
+
+ //return MessageDialog.openConfirm(
+ // window.getShell(), "Save",
+ // "Have you remembered to save your work before closing this file?");
+}
clearTermSynonymTable();
collectionId.setText("");
comment.setText("");
- curatorCombo.deselectAll();
- speciesCombo.deselectAll();
+ //if (curatorCombo.getText() != null) {
+ //curatorCombo.setText(null);
+ curatorCombo.deselectAll();
+ //}
+ //if (speciesCombo.getText() != null) {
+ speciesCombo.deselectAll();
+ //speciesCombo.setText(null);
+ //}
// clear segment data (term labels, layers, image coords)
if (view.getContext() != null) {
- ArrayList<SegmentationMask> segMasks = view.getContext().getSegmentationMasks();
- if (segMasks.size() > 0)
- segMasks.clear();
+ //ArrayList<SegmentationMask> segMasks = view.getContext().getSegmentationMasks();
+ //if (segMasks.size() > 0)
+ // segMasks.clear();
+ this.getContext().nullifySegments();
+ this.getContext().nullifySegments(); // TODO: why twice?
+ this.setContext(null);
SegmentationMask.numberOfLayers = 0; // reset the layer counter for the next image
}
}
return FileUtils.replaceExtension(name, EXTENSION);
}
+ public final void nullifySegments() {
+ currentSegmentMask = null;
+ annotations.clear();
+ }
+
/**
* Returns the current annotations that have been applied to the image.
*