Fixed #1114 - Implement markers for references in property sheet
authorp.ciardelli <p.ciardelli@localhost>
Tue, 29 Sep 2009 09:53:00 +0000 (09:53 +0000)
committerp.ciardelli <p.ciardelli@localhost>
Tue, 29 Sep 2009 09:53:00 +0000 (09:53 +0000)
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/propertysheet/MarkersDialog.java
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/propertysheet/name/TaxonBasePropertySource.java
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/propertysheet/reference/ReferencePropertySource.java
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/propertysheet/reference/ReferenceSearchDescriptor.java

index c60e92760696f222160ab4f41e9f67a49de2495b..a280b17d22b44cf0405eacd64a33aed16dd2455c 100644 (file)
@@ -46,7 +46,6 @@ public class MarkersDialog extends TitleAreaDialog {
        private CheckboxTableViewer tableViewer;\r
        private Button removeButton;\r
        private Set<Marker> markers = new HashSet<Marker>();\r
-       private Button okButton;\r
 \r
        /**\r
         * @param parentShell\r
@@ -59,15 +58,7 @@ public class MarkersDialog extends TitleAreaDialog {
                this.markers.addAll(entity.getMarkers());\r
                \r
        }\r
-       \r
-       /* (non-Javadoc)\r
-        * @see org.eclipse.jface.window.Window#open()\r
-        */\r
-       @Override\r
-       public int open() {\r
-               return super.open();\r
-       }\r
-       \r
+               \r
        /* (non-Javadoc)\r
         * @see org.eclipse.jface.dialogs.TitleAreaDialog#createContents(org.eclipse.swt.widgets.Composite)\r
         */\r
@@ -98,7 +89,7 @@ public class MarkersDialog extends TitleAreaDialog {
                gridLayout.numColumns = 2;\r
                composite.setLayout(gridLayout);\r
        \r
-               tableViewer = CheckboxTableViewer.newCheckList(composite, SWT.NULL);\r
+               tableViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER);\r
                GridData tableLayoutData = new GridData(SWT.FILL, SWT.FILL, true, false);\r
                tableLayoutData.heightHint = 300;\r
                tableViewer.getTable().setLayoutData(tableLayoutData);\r
@@ -108,7 +99,7 @@ public class MarkersDialog extends TitleAreaDialog {
                \r
                tableViewer.addSelectionChangedListener(new ISelectionChangedListener () {\r
                        public void selectionChanged(SelectionChangedEvent event) {\r
-                               setRemovedEnabled(true);\r
+                               setRemoveEnabled(true);\r
                        }\r
                });\r
                                \r
@@ -141,7 +132,7 @@ public class MarkersDialog extends TitleAreaDialog {
                                removeSelectedMarker();\r
                        }\r
                });\r
-               setRemovedEnabled(false);\r
+               setRemoveEnabled(false);\r
                        \r
                populateMarkers();\r
                \r
@@ -149,6 +140,14 @@ public class MarkersDialog extends TitleAreaDialog {
        }\r
        \r
        \r
+       /**\r
+        * \r
+        */\r
+       private void selectAuthor() {\r
+               // TODO Auto-generated method stub\r
+               \r
+       }\r
+\r
        /**\r
         * \r
         */\r
@@ -194,7 +193,7 @@ public class MarkersDialog extends TitleAreaDialog {
        /**\r
         * \r
         */\r
-       protected void setRemovedEnabled(boolean enabled) {\r
+       protected void setRemoveEnabled(boolean enabled) {\r
                removeButton.setEnabled(enabled);               \r
        }\r
 \r
@@ -252,7 +251,7 @@ public class MarkersDialog extends TitleAreaDialog {
        }\r
        \r
     protected void createButtonsForButtonBar(Composite parent) {\r
-        okButton = createButton(parent, IDialogConstants.OK_ID,\r
+        createButton(parent, IDialogConstants.OK_ID,\r
                 IDialogConstants.OK_LABEL, true);\r
         createButton(parent, IDialogConstants.CANCEL_ID,\r
                 IDialogConstants.CANCEL_LABEL, false);\r
index 356aa434a11f22e90f3eae208bc533047863b968..a6a6c06006093d3ec5eb45e8aff54a0e4423e493 100644 (file)
@@ -57,7 +57,7 @@ public class TaxonBasePropertySource implements ICdmBasePropertySource {
        public static final String P_ID_TAXONSEC = "P_ID_TAXONSEC";\r
        public static final String P_ID_TYPES = "P_ID_TYPES";   \r
        public static final String P_ID_DOUBTFUL = "P_ID_DOUBTFUL";\r
-       public static final String P_ID_MARKERS = "P_ID_MARKERS";\r
+       public static final String P_ID_TAXON_MARKERS = "P_ID_TAXON_MARKERS";\r
        public static final String P_ID_EXTENSIONS = "P_ID_EXTENSIONS";\r
        public static final String P_ID_TAXON_ANNOTATIONS = "P_ID_TAXON_ANNOTATIONS";\r
        \r
@@ -66,7 +66,7 @@ public class TaxonBasePropertySource implements ICdmBasePropertySource {
        public static final String P_TAXONSEC = "Secundum";\r
        public String P_TYPES = "Name Types";\r
        public static final String P_DOUBTFUL = "Doubtful?";\r
-       public static final String P_MARKERS = "Markers";\r
+       public static final String P_TAXON_MARKERS = "Markers";\r
        public static final String P_EXTENSIONS = "Extensions";\r
        public static final String P_TAXON_ANNOTATIONS = "Annotations";\r
 \r
@@ -88,7 +88,7 @@ public class TaxonBasePropertySource implements ICdmBasePropertySource {
                addDescriptor(P_ID_TYPES);\r
                addDescriptor(P_ID_DOUBTFUL);   \r
                addDescriptor(P_ID_TAXON_ANNOTATIONS);\r
-               addDescriptor(P_ID_MARKERS);            \r
+               addDescriptor(P_ID_TAXON_MARKERS);              \r
                addDescriptor(P_ID_EXTENSIONS);         \r
        }\r
 \r
@@ -122,9 +122,9 @@ public class TaxonBasePropertySource implements ICdmBasePropertySource {
                                                        new String[] {"no", "yes"}));\r
                }\r
                \r
-               if (id.equals(P_ID_MARKERS)) {\r
+               if (id.equals(P_ID_TAXON_MARKERS)) {\r
                        descriptors.addElement(\r
-                                       new MarkersPropertyDescriptor(P_ID_MARKERS, P_MARKERS, taxonBase));                     \r
+                                       new MarkersPropertyDescriptor(P_ID_TAXON_MARKERS, P_TAXON_MARKERS, taxonBase));                 \r
                }\r
 \r
                if (id.equals(P_ID_EXTENSIONS)) {\r
@@ -236,7 +236,7 @@ public class TaxonBasePropertySource implements ICdmBasePropertySource {
                        }\r
                }\r
                \r
-               if (id.equals(P_ID_MARKERS)) {\r
+               if (id.equals(P_ID_TAXON_MARKERS)) {\r
                        return new MarkerPropertySource(taxonBase);\r
                }\r
 \r
index a47214ef037ea2673e6f5832e69927aa31302b13..d8d7a794ee7e1dbd03cdf1547d3b892806fe69fb 100644 (file)
@@ -62,6 +62,8 @@ import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
 import eu.etaxonomy.taxeditor.model.Resources;\r
 import eu.etaxonomy.taxeditor.model.TimeHelper;\r
 import eu.etaxonomy.taxeditor.propertysheet.ICdmBasePropertySource;\r
+import eu.etaxonomy.taxeditor.propertysheet.MarkerPropertySource;\r
+import eu.etaxonomy.taxeditor.propertysheet.MarkersPropertyDescriptor;\r
 import eu.etaxonomy.taxeditor.propertysheet.TimePeriodPropertySource;\r
 import eu.etaxonomy.taxeditor.propertysheet.YearValidator;\r
 \r
@@ -144,6 +146,7 @@ public class ReferencePropertySource implements ICdmBasePropertySource {
        public static final String P_ID_PROTECT_CACHE = "P_ID_PROTECT_CACHE";\r
        public static final String P_ID_ABSTRACT = "P_ID_ABSTRACT";\r
        public static final String P_ID_INREFERENCE = "P_ID_INREFERENCE";\r
+       public static final String P_ID_REFERENCE_MARKERS = "P_ID_REFERENCE_MARKERS";\r
                \r
     // Property display keys\r
        public static final String P_SEARCH = "Search";\r
@@ -180,6 +183,7 @@ public class ReferencePropertySource implements ICdmBasePropertySource {
        public static final String P_NOTE = "Note";\r
        public static final String P_ABSTRACT = "Abstract";\r
        public static final String P_INREFERENCE = "In Reference";\r
+       public static final String P_REFERENCE_MARKERS = "Markers";\r
        \r
        protected static HashMap<Class<?>, String> referenceTypeMap = null;\r
 \r
@@ -240,7 +244,6 @@ public class ReferencePropertySource implements ICdmBasePropertySource {
                } else {\r
                        reference = HibernateProxyHelper.deproxy(reference, ReferenceBase.class);\r
                }\r
-//             this.reference = CdmBase.deproxy(object, clazz)reference;\r
                this.reference = reference;\r
 \r
                initDescriptors();\r
@@ -355,6 +358,7 @@ public class ReferencePropertySource implements ICdmBasePropertySource {
                }\r
                \r
                displayFields.add(P_ID_ABSTRACT);\r
+               displayFields.add(P_ID_REFERENCE_MARKERS);\r
                \r
                // There was a problem with duplicate descriptors in the above code\r
                List<String> displayFieldsTemp = new ArrayList<String>();\r
@@ -559,13 +563,23 @@ public class ReferencePropertySource implements ICdmBasePropertySource {
                                                        new PropertyDescriptor(P_ID_ABSTRACT, P_ABSTRACT) :\r
                                                        new TextPropertyDescriptor(P_ID_ABSTRACT, P_ABSTRACT));                 \r
                }\r
+               \r
+               // Markers\r
+               if (id.equals(P_ID_REFERENCE_MARKERS)) {\r
+                       descriptors.addElement(\r
+                                                       new MarkersPropertyDescriptor(P_ID_REFERENCE_MARKERS, P_REFERENCE_MARKERS, reference));\r
+               }\r
        }\r
 \r
        /**\r
         * @return\r
         */\r
        private boolean isMultiPageTaxonEditorActive() {\r
-               IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();\r
+               IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();\r
+               if (window == null) {\r
+                       return false;\r
+               }\r
+               IEditorPart editor = window.getActivePage().getActiveEditor();\r
                return (editor instanceof MultiPageTaxonEditor);\r
        }\r
 \r
@@ -836,6 +850,10 @@ public class ReferencePropertySource implements ICdmBasePropertySource {
                        Institution school = ((Thesis) reference).getSchool();\r
                        return school == null ? "" : CdmUtils.Nz(school.getName());     \r
                }\r
+               \r
+               if (id.equals(P_ID_REFERENCE_MARKERS)) {\r
+                       return new MarkerPropertySource(reference);\r
+               }\r
                                \r
                return "";\r
        }\r
index f6f7297d24da6bc79fd3ce80c5a0ae54b4614f20..fc7c333e3cb9d034233382b955da5f02534bf6ee 100644 (file)
@@ -17,10 +17,6 @@ import org.eclipse.swt.widgets.Control;
 import org.eclipse.ui.PlatformUI;\r
 import org.eclipse.ui.views.properties.PropertyDescriptor;\r
 \r
-import eu.etaxonomy.cdm.model.reference.Book;\r
-import eu.etaxonomy.cdm.model.reference.Journal;\r
-import eu.etaxonomy.cdm.model.reference.PrintSeries;\r
-import eu.etaxonomy.cdm.model.reference.Proceedings;\r
 import eu.etaxonomy.cdm.model.reference.ReferenceBase;\r
 import eu.etaxonomy.cdm.model.reference.ReferenceType;\r
 import eu.etaxonomy.taxeditor.dialogs.filteredSelection.FilteredReferenceSelectionDialog;\r
@@ -79,26 +75,12 @@ abstract public class ReferenceSearchDescriptor extends PropertyDescriptor {
     }\r
         \r
     /**\r
-     * Hacky bullshit until reference types are fully enabled. Assumes the required type\r
-     * is one of the in-reference types: Book, Journal, Series, Proceedings.\r
      * \r
         * @param reference\r
         * @return\r
         */\r
        protected boolean isRequiredType(ReferenceBase reference) {\r
-               if (ReferenceType.Book.equals(requiredType) && !(reference instanceof Book)) {\r
-                       return false;\r
-               }\r
-               if (ReferenceType.Journal.equals(requiredType) && !(reference instanceof Journal)) {\r
-                       return false;\r
-               }\r
-               if (ReferenceType.PrintSeries.equals(requiredType) && !(reference instanceof PrintSeries)) {\r
-                       return false;\r
-               }\r
-               if (ReferenceType.Proceedings.equals(requiredType) && !(reference instanceof Proceedings)) {\r
-                       return false;\r
-               }\r
-               return true;\r
+               return reference.getType().equals(requiredType);\r
        }\r
 \r
        abstract protected void saveReference(ReferenceBase<?> reference);      \r