From: preecej Date: Tue, 18 Sep 2012 17:14:51 +0000 (+0000) Subject: Two tickets in progress: Trac #149, 188. X-Git-Url: http://gitweb.planteome.org/?a=commitdiff_plain;h=71c8ac995038b4deb9f383653ad5baf1eb6ab3b2;p=old-jaiswallab-svn%2F.git Two tickets in progress: Trac #149, 188. Save and Close not done yet. Object clearing associated with file-switching is improved, but not complete. svn path=/; revision=378 --- diff --git a/Annotation/resources/config/actions.mac.properties b/Annotation/resources/config/actions.mac.properties index c42bb52..cd6e904 100644 --- a/Annotation/resources/config/actions.mac.properties +++ b/Annotation/resources/config/actions.mac.properties @@ -15,16 +15,18 @@ OpenExperimentAction.dialog.text=Open an experiment file 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... @@ -48,7 +50,11 @@ action.PrintAction.text=&Print@Command+P 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 diff --git a/Annotation/resources/config/actions.properties b/Annotation/resources/config/actions.properties index 13cda9b..e55b5ce 100644 --- a/Annotation/resources/config/actions.properties +++ b/Annotation/resources/config/actions.properties @@ -15,6 +15,8 @@ OpenExperimentAction.dialog.text=Open an experiment file 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 @@ -24,7 +26,7 @@ action.SaveAction.text=&Save@Ctrl+S 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... @@ -49,7 +51,11 @@ action.PrintAction.text=&Print@Ctrl+P 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 diff --git a/Annotation/resources/config/application.mac.properties b/Annotation/resources/config/application.mac.properties index 489d794..5bea222 100644 --- a/Annotation/resources/config/application.mac.properties +++ b/Annotation/resources/config/application.mac.properties @@ -16,6 +16,7 @@ PrefsDialog.foreground-color.text=Foreground color for markup 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 diff --git a/Annotation/resources/config/application.properties b/Annotation/resources/config/application.properties index dcab278..ec7e641 100644 --- a/Annotation/resources/config/application.properties +++ b/Annotation/resources/config/application.properties @@ -18,6 +18,7 @@ PrefsDialog.foreground-color.text=Foreground color for markup 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 diff --git a/Annotation/src/ie/dcu/apps/ist/AppPrefs.java b/Annotation/src/ie/dcu/apps/ist/AppPrefs.java index fabc554..be17d9b 100644 --- a/Annotation/src/ie/dcu/apps/ist/AppPrefs.java +++ b/Annotation/src/ie/dcu/apps/ist/AppPrefs.java @@ -22,6 +22,7 @@ public class AppPrefs { 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 { diff --git a/Annotation/src/ie/dcu/apps/ist/AppWindow.java b/Annotation/src/ie/dcu/apps/ist/AppWindow.java index 0b5b49f..1919489 100644 --- a/Annotation/src/ie/dcu/apps/ist/AppWindow.java +++ b/Annotation/src/ie/dcu/apps/ist/AppWindow.java @@ -148,6 +148,7 @@ public class AppWindow extends ApplicationWindow implements FileDropListener { 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); @@ -308,6 +309,7 @@ public class AppWindow extends ApplicationWindow implements FileDropListener { 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"); @@ -353,7 +355,7 @@ public class AppWindow extends ApplicationWindow implements FileDropListener { enhancer.hookApplicationMenu(Display.getDefault(), quitListener, aboutAction, prefAction); } - + return bar; } diff --git a/Annotation/src/ie/dcu/apps/ist/actions/ActionManager.java b/Annotation/src/ie/dcu/apps/ist/actions/ActionManager.java index b1897f8..3f6e109 100644 --- a/Annotation/src/ie/dcu/apps/ist/actions/ActionManager.java +++ b/Annotation/src/ie/dcu/apps/ist/actions/ActionManager.java @@ -60,6 +60,7 @@ public class ActionManager { 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)); diff --git a/Annotation/src/ie/dcu/apps/ist/actions/CloseAction.java b/Annotation/src/ie/dcu/apps/ist/actions/CloseAction.java new file mode 100644 index 0000000..6c3fe1a --- /dev/null +++ b/Annotation/src/ie/dcu/apps/ist/actions/CloseAction.java @@ -0,0 +1,49 @@ +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; + } +} diff --git a/Annotation/src/ie/dcu/apps/ist/dialogs/PrefsDialog.java b/Annotation/src/ie/dcu/apps/ist/dialogs/PrefsDialog.java index 9ea4eeb..e2d453a 100644 --- a/Annotation/src/ie/dcu/apps/ist/dialogs/PrefsDialog.java +++ b/Annotation/src/ie/dcu/apps/ist/dialogs/PrefsDialog.java @@ -67,7 +67,10 @@ public class PrefsDialog { 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); @@ -92,7 +95,10 @@ public class PrefsDialog { // Load confirm exit loadBool(Keys.CONFIRM_EXIT, true); - + + // Load confirm exit + loadBool(Keys.CONFIRM_CLOSE, true); + // Load enable feedback loadBool(Keys.ENABLE_FEEDBACK, true); @@ -340,8 +346,12 @@ public class PrefsDialog { } else if (key.equals(Keys.CONFIRM_EXIT)) { storeBool(key); + + } else if (key.equals(Keys.CONFIRM_CLOSE)) { + + storeBool(key); } - + } diff --git a/Annotation/src/ie/dcu/apps/ist/dialogs/SaveReminderDialog.java b/Annotation/src/ie/dcu/apps/ist/dialogs/SaveReminderDialog.java new file mode 100644 index 0000000..ea70c94 --- /dev/null +++ b/Annotation/src/ie/dcu/apps/ist/dialogs/SaveReminderDialog.java @@ -0,0 +1,25 @@ +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?"); +} diff --git a/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java b/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java index 2483b25..a85b5ed 100644 --- a/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java +++ b/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java @@ -260,13 +260,22 @@ public class SegmentationView extends Composite { 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 segMasks = view.getContext().getSegmentationMasks(); - if (segMasks.size() > 0) - segMasks.clear(); + //ArrayList 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 } } diff --git a/Annotation/src/ie/dcu/segment/SegmentationContext.java b/Annotation/src/ie/dcu/segment/SegmentationContext.java index 682a021..90cd1dc 100644 --- a/Annotation/src/ie/dcu/segment/SegmentationContext.java +++ b/Annotation/src/ie/dcu/segment/SegmentationContext.java @@ -129,6 +129,11 @@ public class SegmentationContext { return FileUtils.replaceExtension(name, EXTENSION); } + public final void nullifySegments() { + currentSegmentMask = null; + annotations.clear(); + } + /** * Returns the current annotations that have been applied to the image. *