Checkin to see if everything works w A-Eins.
authorp.ciardelli <p.ciardelli@localhost>
Wed, 21 May 2008 16:18:44 +0000 (16:18 +0000)
committerp.ciardelli <p.ciardelli@localhost>
Wed, 21 May 2008 16:18:44 +0000 (16:18 +0000)
.gitattributes
eclipseprojects/eu.etaxonomy.taxeditor/META-INF/MANIFEST.MF
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/TaxEditorPlugin.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/NameEditorView.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/NameViewer.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/TaxonomicTreeViewer.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/nameviewersupport/TaxonCompositeFactory.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/propertysheetsupport/BotanicalNamePropertySource.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/propertysheetsupport/NonViralNamePropertySource.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/propertysheetsupport/PropertySourceAdapter.java [new file with mode: 0644]
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/propertysheetsupport/ZoologicalNamePropertySource.java [new file with mode: 0644]

index 4c1d3476f5c40436c0c298aeffe2f61dabfc373e..b6a188d4152b03b86afc2f31fc5b8683ec3b0e35 100644 (file)
@@ -455,4 +455,6 @@ eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/propertys
 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/propertysheetsupport/PropertySheetContentProvider.java -text
 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/propertysheetsupport/PropertySheetValueEditingSupport.java -text
 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/propertysheetsupport/PropertySheetValueLabelProvider.java -text
+eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/propertysheetsupport/PropertySourceAdapter.java -text
 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/propertysheetsupport/SourceViewerConfig.java -text
+eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/propertysheetsupport/ZoologicalNamePropertySource.java -text
index 37d3eaddd751aa0f3016ab06e691b8a3c6d506a5..4d39ad7b110e11db9aeecdcd8588612e5865f56c 100644 (file)
@@ -13,9 +13,9 @@ Require-Bundle: org.eclipse.ui,
  org.eclipse.ui.forms,
  org.eclipse.core.resources,
  org.eclipse.ui.views,
- eu.etaxonomy.cdmLibrary,
  org.eclipse.pde.source,
- org.eclipse.ui.ide
+ org.eclipse.ui.ide,
+ eu.etaxonomy.cdmLibrary
 Eclipse-LazyStart: true
 Export-Package: com.swtdesigner,
  eu.etaxonomy.taxeditor,
index 87e5c6a344013e0044df22d679e243c2283c663a..4b2278f9bdbbf2a243f7d51fe9af3834e1013c94 100644 (file)
@@ -21,7 +21,6 @@ import org.eclipse.core.databinding.observable.set.WritableSet;
 import org.eclipse.core.runtime.IPath;\r
 import org.eclipse.core.runtime.Path;\r
 import org.eclipse.jface.preference.IPreferenceStore;\r
-import org.eclipse.jface.preference.PreferenceConverter;\r
 import org.eclipse.jface.resource.ImageDescriptor;\r
 import org.eclipse.jface.resource.ImageRegistry;\r
 import org.eclipse.swt.graphics.Image;\r
@@ -34,6 +33,7 @@ import eu.etaxonomy.cdm.database.DataSourceNotFoundException;
 import eu.etaxonomy.cdm.database.DbSchemaValidation;\r
 import eu.etaxonomy.cdm.model.agent.Person;\r
 import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;\r
+import eu.etaxonomy.cdm.model.common.TermVocabulary;\r
 import eu.etaxonomy.cdm.model.common.init.TermNotFoundException;\r
 import eu.etaxonomy.cdm.model.name.BotanicalName;\r
 import eu.etaxonomy.cdm.model.name.NameRelationshipType;\r
@@ -74,7 +74,7 @@ public class TaxEditorPlugin extends AbstractUIPlugin {
                logger.trace("Trace");\r
                \r
                boolean initDatastore = false;\r
-//             initDatastore = true;\r
+               initDatastore = true;\r
                if (initDatastore)\r
                        initDatastore();\r
                else {\r
@@ -314,9 +314,9 @@ public class TaxEditorPlugin extends AbstractUIPlugin {
        /* ***************************************************************************************\r
                        NOMENCLATURAL STATUS\r
        ************************************************************************************** */       \r
-       OrderedTermVocabulary<NomenclaturalStatusType> nomStatusVocabulary = null;\r
+       TermVocabulary<NomenclaturalStatusType> nomStatusVocabulary = null;\r
        \r
-       public OrderedTermVocabulary<NomenclaturalStatusType> getNomStatusVocabulary() {\r
+       public TermVocabulary<NomenclaturalStatusType> getNomStatusVocabulary() {\r
                if (nomStatusVocabulary == null) {\r
                        nomStatusVocabulary = cdmApp.getNameService().getStatusTypeVocabulary();\r
                }\r
@@ -326,9 +326,9 @@ public class TaxEditorPlugin extends AbstractUIPlugin {
        /* ***************************************************************************************\r
                        NAME RELATIONS\r
        ************************************************************************************** */       \r
-       OrderedTermVocabulary<NameRelationshipType> nameRelationshipTypeVocabulary = null;\r
+       TermVocabulary<NameRelationshipType> nameRelationshipTypeVocabulary = null;\r
        \r
-       public OrderedTermVocabulary<NameRelationshipType> getNameRelationshipTypeVocabulary() {\r
+       public TermVocabulary<NameRelationshipType> getNameRelationshipTypeVocabulary() {\r
        if (nameRelationshipTypeVocabulary == null) {\r
                nameRelationshipTypeVocabulary = cdmApp.getNameService().getNameRelationshipTypeVocabulary();\r
        }\r
index 0f8d68af73990ef4eb263a85fa52baada9590814..f7fa6b1de50d44f0ecf776f30b99001c37368cc5 100644 (file)
@@ -37,7 +37,6 @@ import org.eclipse.ui.part.EditorPart;
 import org.eclipse.ui.views.properties.IPropertySheetPage;\r
 import org.eclipse.ui.views.properties.PropertySheetPage;\r
 \r
-import eu.etaxonomy.cdm.model.name.BotanicalName;\r
 import eu.etaxonomy.cdm.model.name.HomotypicalGroup;\r
 import eu.etaxonomy.cdm.model.name.NonViralName;\r
 import eu.etaxonomy.cdm.model.name.Rank;\r
@@ -49,8 +48,8 @@ import eu.etaxonomy.taxeditor.view.nameviewersupport.GroupComposite;
 import eu.etaxonomy.taxeditor.view.nameviewersupport.NameComposite;\r
 import eu.etaxonomy.taxeditor.view.nameviewersupport.SimpleSelectionProvider;\r
 import eu.etaxonomy.taxeditor.view.nameviewersupport.TaxonCompositeFactory;\r
-import eu.etaxonomy.taxeditor.view.propertysheetsupport.BotanicalNamePropertySource;\r
 import eu.etaxonomy.taxeditor.view.propertysheetsupport.CustomSortPropertySheetEntry;\r
+import eu.etaxonomy.taxeditor.view.propertysheetsupport.PropertySourceAdapter;\r
 \r
 /**\r
  * @author p.ciardelli\r
@@ -106,7 +105,8 @@ public class NameEditorView extends EditorPart implements IAdaptable {
                this.getSite().setSelectionProvider(provider);\r
                provider.setSelection(\r
                                new StructuredSelection(\r
-                                               new BotanicalNamePropertySource((BotanicalName) taxon.getName())));\r
+                                               new PropertySourceAdapter(taxon.getName()).getPropertySource()\r
+               ));\r
                taxonCompositeFactory.setSelectionProvider(provider);\r
        }\r
 \r
index 0971bc7f21f63670a9c8b612e0dae71b061547ec..5007d26794439ecfe90400515c2c615e71d7ae86 100644 (file)
@@ -63,9 +63,7 @@ public class NameViewer extends SourceViewer {
        }\r
 \r
        public void setShowError(boolean hasProblem) {\r
-                       \r
-               hasProblem = false;\r
-               \r
+                               \r
                String text = this.getTextWidget().getText();\r
                \r
                Iterator<Annotation> annotations = this.getAnnotationModel().getAnnotationIterator();\r
@@ -75,13 +73,10 @@ public class NameViewer extends SourceViewer {
                                this.getAnnotationModel().removeAnnotation(annotation);\r
                }\r
                \r
-               // Failed attempt to get multi-line squigglies drawn\r
                if (hasProblem && text.length() > 0) {\r
-                       for (int i = 1; i <= this.getTextWidget().getLineCount(); i++) {\r
-                               this.getAnnotationModel().addAnnotation(\r
-                                               new ErrorAnnotation(i, "Could not parse."), \r
-                                               new Position(0, text.length()));\r
-                       }\r
+                       this.getAnnotationModel().addAnnotation(\r
+                                       new ErrorAnnotation(0, "Could not parse."), \r
+                                       new Position(0, text.length()));\r
                }\r
        }\r
        \r
index c697eba621a634a99e0cc459b6231e25fcc2e3f8..d70a92a22d16ecb3e3dcf4c4767433eae8d7d05d 100644 (file)
@@ -57,10 +57,11 @@ import org.eclipse.ui.PlatformUI;
 import com.swtdesigner.ResourceManager;\r
 \r
 import eu.etaxonomy.cdm.model.name.BotanicalName;\r
+import eu.etaxonomy.cdm.model.name.NonViralName;\r
 import eu.etaxonomy.cdm.model.name.TaxonNameBase;\r
 import eu.etaxonomy.cdm.model.taxon.Taxon;\r
 import eu.etaxonomy.cdm.model.taxon.TaxonBase;\r
-import eu.etaxonomy.cdm.strategy.parser.TaxonNameParserBotanicalNameImpl;\r
+import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl;\r
 import eu.etaxonomy.taxeditor.TaxEditorPlugin;\r
 import eu.etaxonomy.taxeditor.controller.ActionAddQuickName;\r
 import eu.etaxonomy.taxeditor.controller.ActionDeleteTaxon;\r
@@ -303,9 +304,11 @@ public class TaxonomicTreeViewer extends TreeViewer {
                                } else {\r
                                        // Set Taxon's TitleCache, save it to CDM\r
 //                                     taxon.getName().setTitleCache((String) value);\r
-                                       TaxonNameParserBotanicalNameImpl.NewInstance().parseFullName\r
-                                                       ((BotanicalName) taxon.getName(), (String) value, \r
-                                                       null, true);\r
+                                       NonViralNameParserImpl parser = NonViralNameParserImpl.NewInstance();\r
+                                       NonViralName nonViralName = (NonViralName) taxon.getName();\r
+                                       if (nonViralName != null) {\r
+                                               parser.parseFullName(nonViralName, (String) value, null, true);\r
+                                       }\r
                                        new ActionSaveTaxon(taxon).run();\r
                                }\r
                        }\r
index 21a4391fa8df80da373e4626641b00706fc86d70..8adbe2198d5afd2ca7afb96999d6273900174b64 100644 (file)
@@ -26,20 +26,22 @@ import org.eclipse.swt.widgets.Menu;
 import org.eclipse.swt.widgets.MenuItem;\r
 import org.eclipse.swt.widgets.Shell;\r
 import org.eclipse.ui.forms.IManagedForm;\r
+import org.eclipse.ui.views.properties.IPropertySource;\r
 \r
-import eu.etaxonomy.cdm.model.name.BotanicalName;\r
 import eu.etaxonomy.cdm.model.name.HomotypicalGroup;\r
 import eu.etaxonomy.cdm.model.name.NameRelationshipType;\r
+import eu.etaxonomy.cdm.model.name.NomenclaturalCode;\r
+import eu.etaxonomy.cdm.model.name.NonViralName;\r
 import eu.etaxonomy.cdm.model.name.TaxonNameBase;\r
 import eu.etaxonomy.cdm.model.taxon.Synonym;\r
 import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;\r
 import eu.etaxonomy.cdm.model.taxon.Taxon;\r
 import eu.etaxonomy.cdm.model.taxon.TaxonBase;\r
-import eu.etaxonomy.cdm.strategy.parser.TaxonNameParserBotanicalNameImpl;\r
+import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl;\r
 import eu.etaxonomy.taxeditor.TaxEditorPlugin;\r
 import eu.etaxonomy.taxeditor.view.MoveDialogView;\r
 import eu.etaxonomy.taxeditor.view.NameViewer;\r
-import eu.etaxonomy.taxeditor.view.propertysheetsupport.BotanicalNamePropertySource;\r
+import eu.etaxonomy.taxeditor.view.propertysheetsupport.PropertySourceAdapter;\r
 \r
 /**\r
  * @author p.ciardelli\r
@@ -157,11 +159,12 @@ public class TaxonCompositeFactory {
                                        if (!(data instanceof TaxonBase)) {\r
                                                return;\r
                                        }\r
-                                       TaxonNameBase<TaxonNameBase> taxonNameBase = ((TaxonBase) data).getName();\r
-                                       if (taxonNameBase instanceof BotanicalName) {\r
-                                               \r
-                                               BotanicalNamePropertySource propertySource = \r
-                                                               new BotanicalNamePropertySource((BotanicalName) taxonNameBase);\r
+                                       TaxonNameBase taxonNameBase = ((TaxonBase) data).getName();\r
+//                                     if (taxonNameBase instanceof BotanicalName) {\r
+//                                             \r
+//                                             BotanicalNamePropertySource propertySource = \r
+//                                                             new BotanicalNamePropertySource((BotanicalName) taxonNameBase);\r
+                                               IPropertySource propertySource = new PropertySourceAdapter(taxonNameBase).getPropertySource(); \r
                                                selectionProvider.setSelection(\r
                                                                new StructuredSelection(propertySource));\r
 //                                             propertySource.addPropertyChangeListener(new PropertyChangeListener() {\r
@@ -185,7 +188,7 @@ public class TaxonCompositeFactory {
 //                                                     }\r
 //                                                     \r
 //                                             });\r
-                                       }\r
+//                                     }\r
                                        \r
                                }\r
                        });\r
@@ -399,9 +402,11 @@ public class TaxonCompositeFactory {
 \r
                        @Override\r
                        public void handleSplitText(String text) {\r
-                               TaxonNameParserBotanicalNameImpl parser = TaxonNameParserBotanicalNameImpl.NewInstance();\r
-                               BotanicalName name = parser.parseFullReference(text, null);\r
-                                                                       \r
+                               NonViralNameParserImpl parser = NonViralNameParserImpl.NewInstance();\r
+                               NomenclaturalCode nomCode = null;\r
+                               NonViralName name = parser.parseFullReference(text, nomCode, null); \r
+                               logger.warn(name.getClass().getSimpleName());\r
+                               \r
                                SynonymRelationship synonymRelation = taxon.addHeterotypicSynonymName(name);\r
                                Synonym synonym = synonymRelation.getSynonym();\r
                                GroupComposite newGroupComposite = createGroupComposite(parent, synonym.getName().getHomotypicalGroup());\r
@@ -415,9 +420,16 @@ public class TaxonCompositeFactory {
 \r
                        @Override\r
                        public void parse(String text) {\r
-                               TaxonNameParserBotanicalNameImpl.NewInstance().parseFullName\r
-                                               ((BotanicalName) data.getName(), text, null, true);\r
-                               nameViewer.setShowError(data.getName().getHasProblem());\r
+                               \r
+                               TaxonBase taxonBase = (TaxonBase) nameComposite.getData();\r
+                               \r
+                               NonViralNameParserImpl parser = NonViralNameParserImpl.NewInstance();\r
+                               NonViralName nonViralName = (NonViralName) taxonBase.getName();\r
+                               if (nonViralName != null) {\r
+                                       parser.parseFullName(nonViralName, text, null, true);\r
+                                       nameViewer.setShowError(nonViralName.getHasProblem());\r
+                                       logger.warn(nonViralName.getClass().getSimpleName());\r
+                               }\r
                        }\r
                        \r
                });\r
index 694b176df7bd7c8bc8b0ba39003f7e9dedf8ed8b..40fed0efad5123a32d3305fc61bb3892826182e4 100644 (file)
@@ -1,17 +1,56 @@
+/**\r
+* Copyright (C) 2007 EDIT\r
+* European Distributed Institute of Taxonomy \r
+* http://www.e-taxonomy.eu\r
+* \r
+* The contents of this file are subject to the Mozilla Public License Version 1.1\r
+* See LICENSE.TXT at the top of this package for the full license terms.\r
+*/\r
+\r
 package eu.etaxonomy.taxeditor.view.propertysheetsupport;\r
 \r
-import eu.etaxonomy.cdm.model.name.NonViralName;\r
+import org.apache.log4j.Logger;\r
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;\r
+\r
+import eu.etaxonomy.cdm.model.name.BotanicalName;\r
 \r
 /**\r
- * Property source for Botanical Name entries.\r
+ * Property source for BotanicalName entries.\r
  *  \r
  * @author p.ciardelli\r
- *\r
+ * @created 21.05.2008\r
+ * @version 1.0\r
  */\r
 public class BotanicalNamePropertySource extends NonViralNamePropertySource {\r
-\r
-       public BotanicalNamePropertySource(NonViralName name) {\r
+       private static final Logger logger = Logger\r
+                       .getLogger(BotanicalNamePropertySource.class);\r
+       \r
+    // Property unique keys\r
+       public static final String P_ID_REFERENCEYEAR = "referenceyear";        \r
+    // Property display keys\r
+       public static final String P_REFERENCEYEAR = "099:Reference Year";      \r
+       \r
+       public BotanicalNamePropertySource(BotanicalName name) {\r
                super(name);\r
-               // TODO Auto-generated constructor stub\r
+               addDescriptor(P_ID_REFERENCEYEAR);\r
+       }\r
+               \r
+       protected void addDescriptor(String id) {\r
+               if (id.equals(P_ID_REFERENCEYEAR)) {\r
+                       descriptors.addElement(\r
+                                       new TextPropertyDescriptor(P_ID_REFERENCEYEAR, P_REFERENCEYEAR));\r
+               }\r
+               super.addDescriptor(id);\r
+       }\r
+       \r
+       @Override\r
+       public Object getPropertyValue(Object id) {\r
+        if (id.equals(P_ID_NOMENCLATURAL_CODE)) {\r
+               return 1;\r
+        }\r
+        if (id.equals(P_ID_REFERENCEYEAR)) {\r
+               return subEmptyForNull(name.getReferenceYear());\r
+        }\r
+               return super.getPropertyValue(id);\r
        }\r
 }
\ No newline at end of file
index 4503b458dd1e8a08e0f6d9941fe809ae4c167430..3c192a2e773cbadc55294c9ce6d502e8b50b5d95 100644 (file)
@@ -27,6 +27,7 @@ import org.eclipse.ui.views.properties.TextPropertyDescriptor;
 \r
 import eu.etaxonomy.cdm.model.common.Annotation;\r
 import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;\r
+import eu.etaxonomy.cdm.model.common.TermVocabulary;\r
 import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;\r
 import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;\r
 import eu.etaxonomy.cdm.model.name.NonViralName;\r
@@ -71,6 +72,7 @@ public class NonViralNamePropertySource implements IPropertySource {
        public static final String P_ID_NOMENCLATURAL_CODE = "nomenclaturalcode";\r
        public static final String P_ID_NOMENCLATURAL_REF = "nomenclaturalref";\r
        public static final String P_ID_NOMENCLATURAL_MICROREF = "nomenclaturalmicroref";\r
+       public static final String P_ID_REFERENCEYEAR = "referenceyear";\r
        \r
     // Property display keys\r
        // Note: for an explanation of the sorting prefixes ("04:"), \r
@@ -112,8 +114,7 @@ public class NonViralNamePropertySource implements IPropertySource {
                \r
                // Get terms from rank vocabulary\r
                List<Rank> ranksList = new ArrayList<Rank>();\r
-               ranksList.addAll(rankVocabulary.getTerms());\r
-                               \r
+               ranksList.addAll(rankVocabulary.getOrderedTerms(null));\r
                // Populate ranks menu labels \r
                List<String> ranksMenuList = new ArrayList<String>();\r
                for (Rank rank : ranksList) {\r
@@ -126,15 +127,15 @@ public class NonViralNamePropertySource implements IPropertySource {
                \r
                // Convert rank lists to array\r
                ranks = ranksList.toArray(new Rank[ranksList.size()]);\r
-               P_RANK_MENU = ranksMenuList.toArray(new String[ranksMenuList.size()]);  \r
+               P_RANK_MENU = ranksMenuList.toArray(new String[ranksMenuList.size()]);\r
        }\r
        \r
-       static String[] P_NOMENCLATURALCODE_MENU = new String[] { "ICBN", "ICZN" };\r
+       static String[] P_NOMENCLATURALCODE_MENU = new String[] { "ICZN", "ICBN" };\r
 \r
        // ***********************************************************\r
        //              NOMENCLATURAL STATUS\r
        // ***********************************************************\r
-       static OrderedTermVocabulary<NomenclaturalStatusType> nomStatusVocabulary = \r
+       static TermVocabulary<NomenclaturalStatusType> nomStatusVocabulary = \r
                        TaxEditorPlugin.getDefault().getNomStatusVocabulary();\r
        static NomenclaturalStatusType[] nomStatusTypes = null;\r
        static String[] P_NOMSTATUS_MENU = null;\r
@@ -142,7 +143,7 @@ public class NonViralNamePropertySource implements IPropertySource {
                \r
                // Get terms from nom status vocabulary\r
                List<NomenclaturalStatusType> nomStatusTypesList = new ArrayList<NomenclaturalStatusType>();\r
-               nomStatusTypesList.addAll(TaxEditorPlugin.getDefault().getNomStatusVocabulary().getTerms());\r
+               nomStatusTypesList.addAll(nomStatusVocabulary.getTerms());\r
                \r
 //             // Populate nom status type menu labels \r
                List<String> nomStatusTypesMenuList = new ArrayList<String>();\r
@@ -180,9 +181,7 @@ public class NonViralNamePropertySource implements IPropertySource {
         *  \r
         * @param id\r
         */\r
-       private void addDescriptor(String id) {\r
-               name.getNomenclaturalMicroReference();\r
-               name.getNomenclaturalReference();\r
+       protected void addDescriptor(String id) {\r
                if (id.equals(P_ID_PARSED)) {\r
                        descriptors.addElement(\r
                                        new PropertyDescriptor(P_ID_PARSED, P_PARSED));\r
@@ -291,24 +290,6 @@ public class NonViralNamePropertySource implements IPropertySource {
                                        new TextPropertyDescriptor(P_ID_NOMENCLATURAL_MICROREF,P_NOMENCLATURAL_MICROREF));\r
                }\r
        }\r
-\r
-       private PropertyChangeListener taxonChangeListener = new PropertyChangeListener() {\r
-               public void propertyChange(PropertyChangeEvent arg0) {\r
-                       \r
-               }\r
-       };      \r
-       \r
-       private void addPropertyChangeListener(String id) {\r
-               if (id.equals(P_ID_TITLECACHE)) {\r
-                       this.name.addPropertyChangeListener("titleCache", new PropertyChangeListener() {\r
-\r
-                               @Override\r
-                               public void propertyChange(PropertyChangeEvent evt) {\r
-//                                     System.out.println(evt.getPropertyName());\r
-                               }\r
-                       });\r
-               }\r
-       }\r
        \r
        /**\r
         * Constructor for top level property fields. All fields that are not subfields\r
@@ -323,12 +304,10 @@ public class NonViralNamePropertySource implements IPropertySource {
                        String parentid, String[] keys) {\r
                this.name = name;\r
                this.parentid = parentid;\r
-               this.propertyChangeSupport = new PropertyChangeSupport(name);\r
+//             this.propertyChangeSupport = new PropertyChangeSupport(name);\r
                for (String key : keys) {\r
                        addDescriptor(key);\r
-                       addPropertyChangeListener(key);\r
                }\r
-               name.addPropertyChangeListener("specificEpithet", taxonChangeListener);\r
        }\r
 \r
        @Override\r
@@ -344,8 +323,9 @@ public class NonViralNamePropertySource implements IPropertySource {
 \r
        @Override\r
        public Object getPropertyValue(Object id) {\r
-        if (id.equals(P_ID_PARSED)) \r
+        if (id.equals(P_ID_PARSED)) {\r
                        return name.getHasProblem() == true ? "problem" : "parsed" ;\r
+        }\r
                if (id.equals(P_ID_RANK)) {\r
                if (this.name.getRank() == null) {\r
                        return 0;\r
@@ -441,7 +421,7 @@ public class NonViralNamePropertySource implements IPropertySource {
         }\r
         if (id.equals(P_ID_NOMENCLATURAL_CODE)) {\r
                // TODO put in logic "if BotanicalName / ZoologicalName ..."\r
-               return 0;\r
+               return 1;\r
         }\r
         if (id.equals(P_ID_NOMENCLATURAL_REF)) {\r
                INomenclaturalReference nomenclaturalReference = (INomenclaturalReference) name.getNomenclaturalReference();\r
@@ -502,7 +482,7 @@ public class NonViralNamePropertySource implements IPropertySource {
         * @param string\r
         * @return\r
         */\r
-       private String subEmptyForNull(String string) {\r
+       protected String subEmptyForNull(String string) {\r
                if (string == null)\r
                        return "";\r
                return string;\r
diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/propertysheetsupport/PropertySourceAdapter.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/propertysheetsupport/PropertySourceAdapter.java
new file mode 100644 (file)
index 0000000..dd3462d
--- /dev/null
@@ -0,0 +1,48 @@
+/**\r
+* Copyright (C) 2007 EDIT\r
+* European Distributed Institute of Taxonomy \r
+* http://www.e-taxonomy.eu\r
+* \r
+* The contents of this file are subject to the Mozilla Public License Version 1.1\r
+* See LICENSE.TXT at the top of this package for the full license terms.\r
+*/\r
+\r
+package eu.etaxonomy.taxeditor.view.propertysheetsupport;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.eclipse.ui.views.properties.IPropertySource;\r
+\r
+import eu.etaxonomy.cdm.model.name.BotanicalName;\r
+import eu.etaxonomy.cdm.model.name.NonViralName;\r
+import eu.etaxonomy.cdm.model.name.TaxonNameBase;\r
+import eu.etaxonomy.cdm.model.name.ZoologicalName;\r
+\r
+/**\r
+ * Returns a property source appropriate to the selected object. \r
+ * \r
+ * @author p.ciardelli\r
+ * @created 21.05.2008\r
+ * @version 1.0\r
+ */\r
+public class PropertySourceAdapter {\r
+       private static final Logger logger = Logger\r
+                       .getLogger(PropertySourceAdapter.class);\r
+       \r
+       private TaxonNameBase taxonNameBase;\r
+\r
+       public PropertySourceAdapter(TaxonNameBase taxonNameBase) {\r
+               this.taxonNameBase = taxonNameBase;\r
+       }\r
+\r
+       public IPropertySource getPropertySource() {\r
+               Class clazz = taxonNameBase.getClass();\r
+               logger.warn("Requesting property source for a " + clazz);\r
+               if (clazz == BotanicalName.class) {\r
+                       return new BotanicalNamePropertySource((BotanicalName) taxonNameBase);\r
+               }\r
+               if (clazz == ZoologicalName.class) {\r
+                       return new ZoologicalNamePropertySource((ZoologicalName) taxonNameBase);\r
+               }               \r
+               return new NonViralNamePropertySource((NonViralName) taxonNameBase);\r
+       }\r
+}\r
diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/propertysheetsupport/ZoologicalNamePropertySource.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/propertysheetsupport/ZoologicalNamePropertySource.java
new file mode 100644 (file)
index 0000000..8268f67
--- /dev/null
@@ -0,0 +1,55 @@
+/**\r
+* Copyright (C) 2007 EDIT\r
+* European Distributed Institute of Taxonomy \r
+* http://www.e-taxonomy.eu\r
+* \r
+* The contents of this file are subject to the Mozilla Public License Version 1.1\r
+* See LICENSE.TXT at the top of this package for the full license terms.\r
+*/\r
+\r
+package eu.etaxonomy.taxeditor.view.propertysheetsupport;\r
+\r
+import org.apache.log4j.Logger;\r
+\r
+import eu.etaxonomy.cdm.model.name.ZoologicalName;\r
+\r
+/**\r
+ * Property source for ZoologicalName entries.\r
+ *  \r
+ * @author p.ciardelli\r
+ * @created 21.05.2008\r
+ * @version 1.0\r
+ */\r
+public class ZoologicalNamePropertySource extends NonViralNamePropertySource {\r
+       private static final Logger logger = Logger\r
+                       .getLogger(ZoologicalNamePropertySource.class);\r
+\r
+       private ZoologicalName zoologicalName;\r
+       \r
+    // Property unique keys\r
+       public static final String P_ID_PUBLICATIONYEAR = "publicationyear";\r
+    // Property display keys\r
+       public static final String P_PUBLICATIONYEAR = "099:Publication Year";\r
+               \r
+       public ZoologicalNamePropertySource(ZoologicalName name) {\r
+               super(name);\r
+               this.zoologicalName = name;\r
+               addDescriptor(P_ID_PUBLICATIONYEAR);\r
+       }\r
+\r
+       @Override\r
+       public Object getPropertyValue(Object id) {\r
+        if (id.equals(P_ID_NOMENCLATURAL_CODE)) {\r
+               return 0;\r
+        }\r
+        if (id.equals(P_ID_PUBLICATIONYEAR)) {\r
+               String publicationYear = Integer.toString(zoologicalName.getPublicationYear());\r
+               if (publicationYear.equals("0")) {\r
+                       return "";\r
+               } else {\r
+                       return publicationYear;\r
+               }\r
+        }\r
+               return super.getPropertyValue(id);\r
+       }\r
+}\r