Hello!

To see the file structure, click on "tree".

Note that updates take place every 10 minutes, commits may not be seen immediately.
Two tickets in progress: Trac #149, 188.
authorpreecej <preecej@localhost>
Tue, 18 Sep 2012 17:14:51 +0000 (17:14 +0000)
committerpreecej <preecej@localhost>
Tue, 18 Sep 2012 17:14:51 +0000 (17:14 +0000)
Save and Close not done yet.

Object clearing associated with file-switching is improved, but not complete.

svn path=/; revision=378

12 files changed:
Annotation/resources/config/actions.mac.properties
Annotation/resources/config/actions.properties
Annotation/resources/config/application.mac.properties
Annotation/resources/config/application.properties
Annotation/src/ie/dcu/apps/ist/AppPrefs.java
Annotation/src/ie/dcu/apps/ist/AppWindow.java
Annotation/src/ie/dcu/apps/ist/actions/ActionManager.java
Annotation/src/ie/dcu/apps/ist/actions/CloseAction.java [new file with mode: 0644]
Annotation/src/ie/dcu/apps/ist/dialogs/PrefsDialog.java
Annotation/src/ie/dcu/apps/ist/dialogs/SaveReminderDialog.java [new file with mode: 0644]
Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java
Annotation/src/ie/dcu/segment/SegmentationContext.java

index c42bb524f880f764000b3e9b9cf1de98216b5eb6..cd6e904590b42c1c0b12d936abdff8956b6b3020 100644 (file)
@@ -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
 
index 13cda9b298fd9ba38683213b4f52554670890586..e55b5cea50de504f9882f2d7626139b5153e07a1 100644 (file)
@@ -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
 
index 489d7945a4e74452110210d9171f10bb7f6268d6..5bea2223f386cc76593ed38ab00aad0bf2c36fcc 100644 (file)
@@ -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 
index dcab278ce9f690edbb41cfe236665d6dbd5be29a..ec7e641d1d8264a10c8486d869f1411f12c8cfc0 100644 (file)
@@ -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 
index fabc554c80c543d8032afe44ea456adad8af33df..be17d9ba86bea9be6ef773e8b19f34d862bc29b1 100644 (file)
@@ -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 {
index 0b5b49f23122a7df45560e428826417570f1154b..1919489af61e2b11858cd18e1f93e147c9a5a5df 100644 (file)
@@ -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;
        }
 
index b1897f889b5ca62c569b823443c31720cdc73cbf..3f6e109341bf47919718078f02102495dd8076a7 100644 (file)
@@ -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 (file)
index 0000000..6c3fe1a
--- /dev/null
@@ -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;
+       }
+}
index 9ea4eeb4a3fc808c6726c753f99f02e0fd72cae9..e2d453af48598c3ce34de4faa7201fcb6b5eaf8d 100644 (file)
@@ -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 (file)
index 0000000..ea70c94
--- /dev/null
@@ -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?");
+}
index 2483b250063e72372a6f6badc8fe8e319e3521cf..a85b5ed551f5224537b920a3e23560463577395c 100644 (file)
@@ -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<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
                }
        }
index 682a02139d607ad2ed83eb0ce419ec8f993ad09a..90cd1dccea4d3dab87d03129e47ad731752eacaa 100644 (file)
@@ -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.
         *