Rough version of images module that doesn't actually save image URLs i.e. Taxon has...
[taxeditor.git] / eclipseprojects / eu.etaxonomy.taxeditor / src / eu / etaxonomy / taxeditor / propertysheet / AnnotationsDialog.java
index fcac62444e41a65ab7c896fe752a8cf739003c81..e67f69c27359e00164db1c34d6ab4d6b4da77a9b 100644 (file)
@@ -30,6 +30,7 @@ import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Table;\r
 import org.eclipse.swt.widgets.Text;\r
 \r
+import eu.etaxonomy.cdm.model.common.AnnotatableEntity;\r
 import eu.etaxonomy.cdm.model.common.Annotation;\r
 \r
 public class AnnotationsDialog extends Dialog {\r
@@ -43,6 +44,7 @@ public class AnnotationsDialog extends Dialog {
        \r
        private WritableList list = new WritableList();\r
        private Annotation selectedAnnotation;\r
+       private AnnotatableEntity entity;\r
 \r
        /**\r
         * Create the dialog\r
@@ -61,8 +63,10 @@ public class AnnotationsDialog extends Dialog {
                this(parent, SWT.NONE);\r
        }\r
 \r
-       public AnnotationsDialog(Shell parent, Set<Annotation> annotations) {\r
+       public AnnotationsDialog(Shell parent, AnnotatableEntity entity) {\r
                this(parent, SWT.NONE);\r
+               this.entity = entity;\r
+               Set<Annotation> annotations = entity.getAnnotations();\r
                for (Annotation annotation : annotations) {\r
                        list.add(annotation);\r
                }\r
@@ -110,8 +114,12 @@ public class AnnotationsDialog extends Dialog {
                addButton.addMouseListener(new MouseAdapter() {\r
                        @Override\r
                        public void mouseDown(MouseEvent e) {\r
+                               if (text.getText().equals("")) {\r
+                                       return;\r
+                               }\r
                                Annotation annotation = Annotation.NewInstance(text.getText(), null);\r
                                list.add(annotation);\r
+                               entity.addAnnotation(annotation);\r
                                text.setText("");\r
                        }\r
                });\r
@@ -121,7 +129,6 @@ public class AnnotationsDialog extends Dialog {
                table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));\r
                table.setLinesVisible(false);\r
                table.setHeaderVisible(false);\r
-//             table.s\r
                new Label(composite, SWT.NONE);\r
 \r
                ObservableListContentProvider providerList = new ObservableListContentProvider();\r
@@ -182,6 +189,7 @@ public class AnnotationsDialog extends Dialog {
                \r
                public void run() {\r
                        list.remove(annotation);\r
+                       entity.removeAnnotation(annotation);\r
                }\r
        }\r
 }
\ No newline at end of file