Type module largely complete.
authorp.ciardelli <p.ciardelli@localhost>
Wed, 4 Mar 2009 13:03:15 +0000 (13:03 +0000)
committerp.ciardelli <p.ciardelli@localhost>
Wed, 4 Mar 2009 13:03:15 +0000 (13:03 +0000)
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/MenuConstants.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/operations/name/ChangeConceptRelationOperation.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/name/TaxonBasePropertySource.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/type/TypeCollectionPropertySource.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/type/wizard/ChooseTypeDesignationWizardPage.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/type/wizard/ListTypeWizardPage.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/type/wizard/TypeDesignationWizard.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/type/wizard/TypeListWizard.java

index 129682681cfd64f27f3ef0048e3abc8ecb2ad264..085909c4c66bb07cede7a9a8d7371b1e6f4a35f2 100644 (file)
@@ -40,12 +40,12 @@ public class MenuConstants {
                taxonEditorMenu.add(new Separator());                   \r
                taxonEditorMenu.add(new CreateMisappliedNameAction());\r
                \r
-//             MenuManager subMenu = new MenuManager("Create concept relation");\r
-//             for (TaxonRelationshipType type : \r
-//                             CdmSessionDataRepository.getDefault().getConceptRelationshipTypes()) {\r
-//                     subMenu.add(new CreateConceptRelationAction(type));\r
-//             }\r
-//             taxonEditorMenu.add(subMenu);\r
+               MenuManager subMenu = new MenuManager("Create concept relation");\r
+               for (TaxonRelationshipType type : \r
+                               CdmSessionDataRepository.getDefault().getConceptRelationshipTypes()) {\r
+                       subMenu.add(new CreateConceptRelationAction(type));\r
+               }\r
+               taxonEditorMenu.add(subMenu);\r
                taxonEditorMenu.add(new Separator());\r
                taxonEditorMenu.add(new MoveTaxonDialogAction());\r
                taxonEditorMenu.add(new ChangeTaxonToSynonymAction());\r
index e744ca4876c3ddbde3bdbfaa8db0b6780094d35d..a2d3963798f0328678a321b246f750abb4d94ec7 100644 (file)
@@ -38,7 +38,7 @@ public class ChangeConceptRelationOperation extends AbstractEditorOperation {
                        IUndoContext undoContext, Taxon taxon, Taxon relatedTaxon, TaxonRelationshipType type) {\r
                super(label, undoContext, taxon);\r
                this.relatedTaxon = relatedTaxon;\r
-               //this.oldRelationshipType = relatedTaxon.get\r
+//             this.oldRelationshipType = relatedTaxon.get\r
                this.newRelationshipType = type;\r
        }\r
        \r
index 85f9e7c666f4e7802d5c44b9179933691d685dd0..64fc6ebc76229b6db96e493030551965d4817b34 100644 (file)
@@ -29,6 +29,7 @@ import eu.etaxonomy.cdm.model.taxon.TaxonBase;
 import eu.etaxonomy.taxeditor.propertysheet.reference.IReferenceSearch;\r
 import eu.etaxonomy.taxeditor.propertysheet.reference.ReferencePropertySource;\r
 import eu.etaxonomy.taxeditor.propertysheet.reference.ReferenceSearchDescriptor;\r
+import eu.etaxonomy.taxeditor.propertysheet.type.TypeCollectionPropertySource;\r
 import eu.etaxonomy.taxeditor.propertysheet.type.TypePropertyDescriptor;\r
 \r
 /**\r
@@ -157,6 +158,12 @@ public class TaxonBasePropertySource implements IPropertySource {
                        return secPropertySource;\r
                }\r
                \r
+               if (id.equals(P_ID_TYPES)) {\r
+                       if (taxon.getName() != null) {\r
+                               return new TypeCollectionPropertySource(taxon.getName(), taxon.getName().getSpecimenTypeDesignations());\r
+                       }\r
+               }\r
+               \r
                return null;\r
        }\r
 \r
index 6f0183cabde03fe4831a6980caea2657aac2a067..ba0ebe620403f1e1940f9dcf60d5c858b9d259a0 100644 (file)
@@ -14,8 +14,8 @@ import org.apache.log4j.Logger;
 \r
 import eu.etaxonomy.cdm.model.name.NameRelationship;\r
 import eu.etaxonomy.cdm.model.name.NameRelationshipType;\r
+import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;\r
 import eu.etaxonomy.cdm.model.name.TaxonNameBase;\r
-import eu.etaxonomy.cdm.model.name.ZoologicalName;\r
 import eu.etaxonomy.taxeditor.controller.GlobalController;\r
 import eu.etaxonomy.taxeditor.propertysheet.CollectionPropertySource;\r
 \r
@@ -24,60 +24,42 @@ public class TypeCollectionPropertySource extends CollectionPropertySource {
                        .getLogger(TypeCollectionPropertySource.class);\r
        \r
        private TaxonNameBase name;\r
-       private boolean isZoological = false;\r
 \r
        public TypeCollectionPropertySource(TaxonNameBase name, Collection collection) {\r
                super(collection);\r
                this.name = name;\r
-               if (name instanceof ZoologicalName) {\r
-                       isZoological = true;\r
-               }\r
        }\r
        \r
        @Override\r
        protected String getItemDisplayName(Object item) {\r
-               String itemDisplayName = "";\r
+               String str = "";\r
                \r
-               if (item instanceof NameRelationship) {\r
-                       \r
-                       NameRelationship nameRelation = (NameRelationship) item;\r
+               if (item instanceof SpecimenTypeDesignation) {\r
                        \r
-                       if (nameRelation.getFromName() instanceof ZoologicalName &&\r
-                                       nameRelation.getToName() instanceof ZoologicalName) {\r
-                               isZoological = true;    \r
-                       }\r
+                       SpecimenTypeDesignation typeDesignation = (SpecimenTypeDesignation) item;\r
                        \r
-                       if (nameRelation.getType() != null) {\r
-                               \r
-                               NameRelationshipType type = nameRelation.getType();\r
-                               String label = GlobalController.getNameRelationLabelType(type);\r
-                               if (isZoological && \r
-                                               nameRelation.getType().equals(NameRelationshipType.BASIONYM())) {\r
-                                       label = "original combination";\r
-                               }\r
-                               itemDisplayName = label;\r
-                       } else {\r
-                               itemDisplayName = "Relation has no type";\r
+                       if (typeDesignation.getTypeStatus() != null) {\r
+                               str = typeDesignation.getTypeStatus().getLabel();\r
                        }\r
                }\r
-               return itemDisplayName;\r
+               return str;\r
        }\r
 \r
        @Override\r
        public Object getPropertyValue(Object id) {\r
-               if (id instanceof NameRelationship) {\r
-                       TaxonNameBase relatedName;\r
-                       String nameValue;\r
-                       if (((NameRelationship) id).getFromName().equals(name)) {\r
-                               relatedName = ((NameRelationship) id).getToName();\r
-                               nameValue = relatedName.getTitleCache();\r
+               String str = "";\r
+               \r
+               if (id instanceof SpecimenTypeDesignation) {\r
+                       \r
+                       SpecimenTypeDesignation typeDesignation = (SpecimenTypeDesignation) id;\r
+                                               \r
+                       if (typeDesignation.getTypeSpecimen() != null) {\r
+                               str = typeDesignation.getTypeSpecimen().getTitleCache();\r
                        } else {\r
-                               relatedName = ((NameRelationship) id).getFromName();\r
-                               nameValue = "to " + relatedName.getTitleCache();\r
+                               str = "UNDEFINED";\r
                        }\r
-                       return nameValue;\r
                }\r
-               return null;\r
+               return str;\r
        }\r
 \r
        @Override\r
index 6544b905abc4e6184d65a41a3b2cb05d3d0c0f52..21e68d97d3b1ae450e1cf882b0bf8b466585de60 100644 (file)
@@ -27,7 +27,6 @@ import eu.etaxonomy.cdm.model.common.TermVocabulary;
 import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;\r
 import eu.etaxonomy.cdm.model.name.TaxonNameBase;\r
 import eu.etaxonomy.cdm.model.name.TypeDesignationStatus;\r
-import eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase;\r
 import eu.etaxonomy.cdm.model.occurrence.Specimen;\r
 import eu.etaxonomy.taxeditor.model.CdmSessionDataRepository;\r
 \r
@@ -39,16 +38,15 @@ import eu.etaxonomy.taxeditor.model.CdmSessionDataRepository;
 public class ChooseTypeDesignationWizardPage extends WizardPage {\r
        private static Logger logger = Logger\r
                        .getLogger(ChooseTypeDesignationWizardPage.class);\r
-       \r
+\r
+       private TaxonNameBase name;     \r
        private SpecimenTypeDesignation typeDesignation;\r
+       \r
        private CCombo statusCombo;\r
-\r
        private Text txtDesignationType;\r
 \r
        private TypeDesignationStatus[] typeStatusArray;\r
 \r
-       private TaxonNameBase name;\r
-\r
        /**\r
         * @param typeDesignation\r
         */\r
@@ -91,7 +89,7 @@ public class ChooseTypeDesignationWizardPage extends WizardPage {
                        String label = typeStatus.getLabel();\r
                        typeStatusArray[i] = typeStatus;\r
                        \r
-                       if (typeDesignation != null) {\r
+                       if (typeDesignation != null && typeDesignation.getTypeStatus() != null) {\r
                                if (typeStatus.equals(typeDesignation.getTypeStatus())) {\r
                                        selectedIndex = i;\r
                                }\r
@@ -151,13 +149,13 @@ public class ChooseTypeDesignationWizardPage extends WizardPage {
         if (complete) {\r
                \r
                TypeDesignationStatus status = typeStatusArray[statusCombo.getSelectionIndex()];\r
-//             String specimenText = txtDesignationType.getText();\r
                \r
                Specimen specimen;\r
                if (typeDesignation == null || typeDesignation.getTypeSpecimen() == null) {\r
-                       specimen = Specimen.NewInstance();      \r
+                       specimen = Specimen.NewInstance();\r
+                       typeDesignation.setTypeSpecimen(specimen);\r
                } else {\r
-                       specimen = (Specimen) typeDesignation.getTypeSpecimen();\r
+                       specimen = (Specimen) typeDesignation.getTypeSpecimen(); // Next version (or 3 or 4 version from now) - this or something like this will return specimen: \r
                }\r
                specimen.setTitleCache(txtDesignationType.getText());\r
                \r
@@ -165,11 +163,6 @@ public class ChooseTypeDesignationWizardPage extends WizardPage {
                        name.addSpecimenTypeDesignation(specimen, status, null, null, null, true, true);\r
                } else {\r
                        typeDesignation.setTypeStatus(status);\r
-               \r
-//                     if (typeDesignation.getTypeSpecimen() == null) {\r
-//                             typeDesignation.setTypeSpecimen(Specimen.NewInstance());\r
-//                     }\r
-//                     typeDesignation.getTypeSpecimen().setTitleCache(specimenText);\r
                }\r
         }\r
     }\r
index 98386f6f53b9c00b62a7d59ef8187034a77e20b7..6c2c20d45292ee875c438c3f709aceae01e93053 100644 (file)
@@ -51,12 +51,11 @@ public class ListTypeWizardPage extends WizardPage {
        /**\r
         * @param name\r
         */\r
-       public ListTypeWizardPage(TaxonNameBase name) {\r
+       public ListTypeWizardPage(TaxonNameBase name, WritableList typeDesignationsList) {\r
                super("");\r
                this.name = name;\r
                \r
-//             this.typeDesignationsList.addAll(name.getSpecimenTypeDesignations());\r
-               createDesignationList();\r
+               this.typeDesignationsList = typeDesignationsList;\r
 \r
                setTitle("Type designations for \""\r
                                + CdmUtil.getDisplayName(name) + "\".");\r
@@ -69,7 +68,6 @@ public class ListTypeWizardPage extends WizardPage {
        private Button btnRemove;\r
        private Button btnEdit;\r
 \r
-       private boolean isZoological = false;\r
        private SpecimenTypeDesignation typeDesignation;\r
        private TableViewer tableViewer;\r
 \r
@@ -84,6 +82,13 @@ public class ListTypeWizardPage extends WizardPage {
 \r
                btnEdit = new Button(container, SWT.NONE);\r
                btnEdit.setText("Edit ...");\r
+               btnEdit.addSelectionListener(new SelectionAdapter() {\r
+                       public void widgetSelected(SelectionEvent e) {\r
+                               if (getSelectedTypeDesignation() != null) {     \r
+                                       createTypeDesignationWizard(getSelectedTypeDesignation());\r
+                               }\r
+                       }\r
+               });\r
 \r
                btnRemove = new Button(container, SWT.NONE);\r
                btnRemove.setText("Remove");\r
@@ -171,18 +176,17 @@ public class ListTypeWizardPage extends WizardPage {
        }\r
        \r
        private void createTypeDesignationWizard(SpecimenTypeDesignation typeDesignation) {\r
-               Wizard wizard = new TypeDesignationWizard(typeDesignation, name);\r
+               Wizard wizard = new TypeDesignationWizard(typeDesignation, name, typeDesignationsList);\r
                \r
                WizardDialog dialog = new WizardDialog(GlobalController.getShell(), wizard);\r
                dialog.create();\r
-               if (dialog.open() == Window.OK) {\r
-                       createDesignationList();\r
-               }\r
+               dialog.open();\r
+//             if (dialog.open() == Window.OK) ...\r
        }\r
 \r
        protected void setEnableTypeDesignationButtons(boolean enabled) {\r
                btnRemove.setEnabled(enabled);\r
-               btnEdit.setEnabled(false);\r
+               btnEdit.setEnabled(enabled);\r
        }\r
 \r
        private Image getTypeDesignationImage(SpecimenTypeDesignation typeDesignation) {\r
@@ -202,10 +206,4 @@ public class ListTypeWizardPage extends WizardPage {
                \r
                return str;\r
        }\r
-       \r
-       private void createDesignationList() {\r
-               this.typeDesignationsList.clear();\r
-               this.typeDesignationsList.addAll(name.getSpecimenTypeDesignations());\r
-       }\r
-\r
 }\r
index 1bd5f489303c33d1c9f798c0de07431b8a109df8..f1dd411d2cb0aa08117f3a9b65c47d5ee89a5a22 100644 (file)
@@ -10,6 +10,7 @@
 package eu.etaxonomy.taxeditor.propertysheet.type.wizard;\r
 \r
 import org.apache.log4j.Logger;\r
+import org.eclipse.core.databinding.observable.list.WritableList;\r
 import org.eclipse.jface.wizard.Wizard;\r
 import org.eclipse.jface.wizard.WizardPage;\r
 \r
@@ -22,20 +23,43 @@ import eu.etaxonomy.cdm.model.name.TaxonNameBase;
  * @version 1.0\r
  */\r
 public class TypeDesignationWizard extends Wizard {\r
+       \r
        private static Logger logger = Logger\r
                        .getLogger(TypeDesignationWizard.class);\r
        \r
        private SpecimenTypeDesignation typeDesignation;\r
        private TaxonNameBase name;\r
+       private WritableList typeDesignationsList;\r
 \r
+       public class TemporarySpecimenTypeDesignation extends\r
+                       SpecimenTypeDesignation {\r
+               TemporarySpecimenTypeDesignation() {\r
+                       super();\r
+               }\r
+       }\r
+       \r
        private WizardPage chooseNamePage;\r
 \r
        /**\r
         * @param typeDesignation\r
+        * @param typeDesignationsList \r
         */\r
-       public TypeDesignationWizard(SpecimenTypeDesignation typeDesignation, TaxonNameBase name) {\r
-               this.typeDesignation = typeDesignation;\r
+       public TypeDesignationWizard(SpecimenTypeDesignation typeDesignation, TaxonNameBase name, WritableList typeDesignationsList) {\r
+\r
                this.name = name;\r
+               if (typeDesignation == null) {\r
+                       createEmptyTypeDesignation();\r
+               } else {\r
+                       this.typeDesignation = typeDesignation;\r
+               }\r
+               this.typeDesignationsList = typeDesignationsList;\r
+       }\r
+\r
+       /**\r
+        * \r
+        */\r
+       private void createEmptyTypeDesignation() {\r
+               typeDesignation = new TemporarySpecimenTypeDesignation(); \r
        }\r
 \r
        /* (non-Javadoc)\r
@@ -54,6 +78,10 @@ public class TypeDesignationWizard extends Wizard {
                \r
                chooseNamePage.setPageComplete(true);\r
                \r
+               // Remove then re-add in case any name editing has taken place\r
+               typeDesignationsList.remove(typeDesignation);\r
+               typeDesignationsList.add(typeDesignation);\r
+               \r
                return true;\r
        }\r
 }\r
index e1b42ab476a52d855ba02b3dd02aac5aead9024b..0eaaaf9fb37bb45dc1453f0b53ee6b7f18fb7a99 100644 (file)
 package eu.etaxonomy.taxeditor.propertysheet.type.wizard;\r
 \r
 import org.apache.log4j.Logger;\r
+import org.eclipse.core.databinding.observable.list.WritableList;\r
 import org.eclipse.jface.wizard.IWizardPage;\r
 import org.eclipse.jface.wizard.Wizard;\r
 \r
+import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;\r
 import eu.etaxonomy.cdm.model.name.TaxonNameBase;\r
+import eu.etaxonomy.cdm.model.occurrence.Specimen;\r
 \r
 /**\r
  * @author p.ciardelli\r
@@ -24,17 +27,23 @@ public class TypeListWizard extends Wizard {
        private static Logger logger = Logger.getLogger(TypeListWizard.class);\r
 \r
        private TaxonNameBase name;\r
+       private WritableList typeDesignationsList;\r
        \r
        /**\r
         * @param name\r
         */\r
        public TypeListWizard(TaxonNameBase name) {\r
                super();\r
+               \r
                this.name = name;\r
+               this.typeDesignationsList = new WritableList();\r
+               if (name != null) {\r
+                       this.typeDesignationsList.addAll(name.getSpecimenTypeDesignations());\r
+               }\r
        }\r
 \r
        public void addPages(){\r
-               IWizardPage chooseTypePage = new ListTypeWizardPage(name);\r
+               IWizardPage chooseTypePage = new ListTypeWizardPage(name, typeDesignationsList);\r
        addPage(chooseTypePage);\r
        }\r
        \r
@@ -43,6 +52,30 @@ public class TypeListWizard extends Wizard {
         */\r
        @Override\r
        public boolean performFinish() {\r
+               \r
+               if (name != null) {\r
+                       \r
+                       // Remove all designations\r
+                       for (Object typeDesignation : name.getSpecimenTypeDesignations()) {\r
+                               if (typeDesignation instanceof SpecimenTypeDesignation) {\r
+                                       name.removeTypeDesignation((SpecimenTypeDesignation) typeDesignation);\r
+                               }\r
+                       }\r
+                       \r
+                       // Then re-add them from list\r
+                       for (Object typeDesignation : typeDesignationsList) {\r
+                               if (typeDesignation instanceof SpecimenTypeDesignation) {\r
+                                       name.addSpecimenTypeDesignation(\r
+                                               (Specimen) ((SpecimenTypeDesignation) typeDesignation).getTypeSpecimen(),\r
+                                               ((SpecimenTypeDesignation) typeDesignation).getTypeStatus(),\r
+                                               ((SpecimenTypeDesignation) typeDesignation).getCitation(),\r
+                                               ((SpecimenTypeDesignation) typeDesignation).getCitationMicroReference(),\r
+                                               ((SpecimenTypeDesignation) typeDesignation).getOriginalNameString(),\r
+                                               ((SpecimenTypeDesignation) typeDesignation).isNotDesignated(),\r
+                                               false);\r
+                               }                               \r
+                       }\r
+               }\r
                return true;\r
        }\r
 }\r