Got rid of Year property, made "+ DatePublished" field editable in format "xxxx[...
authorp.ciardelli <p.ciardelli@localhost>
Wed, 19 Nov 2008 17:50:13 +0000 (17:50 +0000)
committerp.ciardelli <p.ciardelli@localhost>
Wed, 19 Nov 2008 17:50:13 +0000 (17:50 +0000)
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/model/CdmUtil.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/TimePeriodPropertySource.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/YearValidator.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/name/NonViralNamePropertySource.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/reference/NomenclaturalReferencePropertySource.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/reference/ReferencePropertySource.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/reference/ReferenceSearchDescriptor.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/reference/SingleRefTypePropertySource.java

index 27531efb1ddeb9d00f0bf92cd09f1586255d5557..55033094f7af4a90fbb9e10cce3ca144a6733140 100644 (file)
@@ -423,16 +423,15 @@ public class CdmUtil {
        }\r
        \r
        /**\r
-        * Checks whether a String is either a valid year \r
-        *  or two valid years\r
-        * with the format "XXXX-XXXX". \r
+        * Converts a <code>String</code> whose format is either a valid year \r
+        * or two valid years with the format "XXXX-XXXX" into a TimePeriod. \r
         *\r
         * @see #getValidYear(String yearStr)\r
         * @param refYear\r
         * @return\r
         * @throws NumberFormatException\r
         */\r
-       public static TimePeriod getDatePublished(String refYear) throws NumberFormatException {\r
+       public static TimePeriod convertTimePeriod(String refYear) throws NumberFormatException {\r
                \r
                if (refYear == null || ("").equals(refYear)){\r
                        return null;\r
index 967a6f9f6beccc94fb54145cefb2d5190cc12453..a4ee263b2db9d8fb5ef9620d72d7732c70e94ff2 100644 (file)
@@ -115,13 +115,6 @@ public class TimePeriodPropertySource implements IPropertySource {
         }\r
     }\r
 \r
-    /* (non-Javadoc)\r
-     * Method declared on IPropertySource\r
-     */\r
-    public Object getEditableValue() {\r
-        return "";\r
-    }\r
-\r
     /* (non-Javadoc)\r
      * Method declared on IPropertySource\r
      */\r
@@ -229,13 +222,27 @@ public class TimePeriodPropertySource implements IPropertySource {
        return integer;\r
     }\r
     \r
-    /**\r
-     * The value as displayed in the Property Sheet.\r
-     * @return java.lang.String\r
+    /* (non-Javadoc)\r
+     * Method declared on IPropertySource\r
      */\r
-    public String toString() {\r
-       return "";\r
-    }  \r
+    public Object getEditableValue() {\r
+       if (timePeriod == null) {\r
+               return "";\r
+       }\r
+       return timePeriod.getYear();\r
+    }\r
+    \r
+//    /**\r
+//     * The value as displayed in the Property Sheet.\r
+//     * @return java.lang.String\r
+//     */\r
+//    public String toString() {\r
+//     if (timePeriod == null) {\r
+//             return "";\r
+//     }\r
+//     return timePeriod.getYear();\r
+//     \r
+//    }        \r
 \r
        private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);\r
        \r
index 6c7535ae9e1f263a148d0b00bc104843c90e075a..c34a7b0f329a08c464b78b2332d2223cf57e62a7 100644 (file)
@@ -34,7 +34,7 @@ public class YearValidator implements ICellEditorValidator {
                        return null;\r
                }\r
                try {\r
-                       TimePeriod datePublished = CdmUtil.getDatePublished(year);\r
+                       TimePeriod datePublished = CdmUtil.convertTimePeriod(year);\r
                } catch (NumberFormatException e) {\r
                        return "Year must be between 1750 and 2030. Two years can also be given in the format 'xxxx-xxxx'.";\r
                }\r
index bcf4c9a695e1549f06d8e2c17fceed1ee649f1e6..54388a1a215a45e75a49b08aec863de675427c3b 100644 (file)
@@ -114,8 +114,9 @@ public class NonViralNamePropertySource implements IPropertySource {
        public static final String P_NOMENCLATURAL_REF = "09:Nomenclatural Reference";\r
        public static final String P_NOMENCLATURAL_MICROREF = "10:Micro Reference";\r
        \r
-       protected static final String[] TOP_LEVEL_PROPERTIES = new String[] {P_ID_PARSED, P_ID_RANK, P_ID_TITLECACHE,  \r
-                       P_ID_ANNOTATIONS, P_ID_NOMSTATUS, P_ID_NAMERELATIONS, P_ID_UUID, P_ID_NOMENCLATURAL_REF,\r
+       protected static final String[] TOP_LEVEL_PROPERTIES = new String[] {\r
+                       P_ID_PARSED, P_ID_RANK, P_ID_TITLECACHE, P_ID_ANNOTATIONS, P_ID_NOMSTATUS, \r
+                       P_ID_NAMERELATIONS, P_ID_UUID, P_ID_NOMENCLATURAL_REF, P_ID_NOMENCLATURAL_MICROREF,\r
                        P_ID_TYPE, P_ID_CREATED, P_ID_CREATEDBY, P_ID_NOMENCLATURAL_CODE };     \r
        \r
        // ***********************************************************\r
@@ -196,10 +197,14 @@ public class NonViralNamePropertySource implements IPropertySource {
         * @param id\r
         */\r
        protected void addDescriptor(String id) {\r
+               \r
+               // Parsed: reports whether parsing was successful\r
                if (id.equals(P_ID_PARSED)) {\r
                        descriptors.addElement(\r
                                        new PropertyDescriptor(P_ID_PARSED, P_PARSED));\r
                }\r
+               \r
+               // Rank menu\r
                if (id.equals(P_ID_RANK)) {\r
                        if (ranks == null) {\r
                                populateRanks();\r
@@ -207,38 +212,56 @@ public class NonViralNamePropertySource implements IPropertySource {
                        descriptors.addElement(\r
                                        new ComboBoxPropertyDescriptor(P_ID_RANK, P_RANK, P_RANK_MENU));\r
                }\r
+               \r
+               // Title cache\r
                if (id.equals(P_ID_TITLECACHE)) {\r
                        descriptors.addElement(\r
                                        new PropertyDescriptor(P_ID_TITLECACHE, P_TITLECACHE));\r
                }\r
+               \r
+               // Uninomial (aka Genus)\r
                if (id.equals(P_ID_UNINOMIAL)) {\r
                        descriptors.addElement(\r
                                        new TextPropertyDescriptor(P_ID_UNINOMIAL, P_UNINOMIAL));\r
                }\r
+               \r
+               // Infrageneric epithet\r
                if (id.equals(P_ID_INFRAGENERICEP)) {\r
                        descriptors.addElement(\r
                                        new TextPropertyDescriptor(P_ID_INFRAGENERICEP, P_INFRAGENERICEP));\r
                }\r
+               \r
+               // Specific epithet\r
                if (id.equals(P_ID_SPECIESEP)) {\r
                        descriptors.addElement(\r
                                        new TextPropertyDescriptor(P_ID_SPECIESEP, P_SPECIESEP));\r
                }\r
+               \r
+               // Infraspecific epithet\r
                if (id.equals(P_ID_INFRASPECIFICEP)) {\r
                        descriptors.addElement(\r
                                        new TextPropertyDescriptor(P_ID_INFRASPECIFICEP, P_INFRASPECIFICEP));\r
                }\r
+               \r
+               // Appended phrase\r
                if (id.equals(P_ID_APPENDEDPHRASE)) {\r
                        descriptors.addElement(\r
                                        new TextPropertyDescriptor(P_ID_APPENDEDPHRASE, P_APPENDEDPHRASE));\r
                }\r
+               \r
+               // Authorship cache\r
                if (id.equals(P_ID_AUTHORSHIPCACHE)) {\r
                        descriptors.addElement(\r
                                        new TextPropertyDescriptor(P_ID_AUTHORSHIPCACHE, P_AUTHORSHIPCACHE));\r
                }\r
+               \r
+               // Homotypical group\r
                if (id.equals(P_ID_HOMOTYPICALGROUP)) {\r
                        descriptors.addElement(\r
                                        new PropertyDescriptor(P_ID_HOMOTYPICALGROUP, P_HOMOTYPICALGROUP));\r
                }\r
+               \r
+               // Name relations, listed in custom property descriptor\r
                if (id.equals(P_ID_NAMERELATIONS)) {\r
                        descriptors.addElement(\r
                                        new NameRelationsPropertyDescriptor(P_ID_NAMERELATIONS, P_NAMERELATIONS, name) {\r
@@ -249,10 +272,13 @@ public class NonViralNamePropertySource implements IPropertySource {
                        );\r
                };\r
                \r
+               // Type\r
                if (id.equals(P_ID_TYPE)) {\r
                        descriptors.addElement(\r
                                        new PropertyDescriptor(P_ID_TYPE, P_TYPE));\r
                }\r
+               \r
+               // Annotations, listed in custom property descriptor\r
                if (id.equals(P_ID_ANNOTATIONS)) {\r
                        descriptors.addElement(\r
                                        new AnnotationsPropertyDescriptor(P_ID_ANNOTATIONS, P_ANNOTATIONS, name) {\r
@@ -263,6 +289,8 @@ public class NonViralNamePropertySource implements IPropertySource {
                                        }\r
                        );\r
                };\r
+               \r
+               // Nomenclatural status\r
                if (id.equals(P_ID_NOMSTATUS)) {\r
                        if (nomStatusTypes == null) {\r
                                populateNomStatusTypes();\r
@@ -270,32 +298,44 @@ public class NonViralNamePropertySource implements IPropertySource {
                        descriptors.addElement(\r
                                        new ComboBoxPropertyDescriptor(P_ID_NOMSTATUS, P_NOMSTATUS, P_NOMSTATUS_MENU));\r
                }               \r
+               \r
+               // UUID\r
                if (id.equals(P_ID_UUID)) {\r
                        descriptors.addElement(\r
                                        new PropertyDescriptor(P_ID_UUID, P_UUID));\r
                }\r
+               \r
+               // Markers\r
                if (id.equals(P_ID_MARKERS)) {\r
                        descriptors.addElement(\r
                                        new PropertyDescriptor(P_ID_MARKERS, P_MARKERS));\r
                }\r
+               \r
+               // Taxon bases referring to this name\r
                if (id.equals(P_ID_NUM_OF_BASES)) {\r
                        descriptors.addElement(\r
                                        new PropertyDescriptor(P_ID_NUM_OF_BASES, P_NUM_OF_BASES));\r
                }\r
+               \r
+               // Object created when\r
                if (id.equals(P_ID_CREATED)) {\r
                        descriptors.addElement(\r
                                        new PropertyDescriptor(P_ID_CREATED, P_CREATED));\r
                }\r
+               \r
+               // Object created by\r
                if (id.equals(P_ID_CREATEDBY)) {\r
                        descriptors.addElement(\r
                                        new PropertyDescriptor(P_ID_CREATEDBY, P_CREATEDBY));\r
                }\r
                \r
+               // Nomenclatural code used by parser\r
                if (id.equals(P_ID_NOMENCLATURAL_CODE)) {\r
                        descriptors.addElement(\r
                                        new PropertyDescriptor(P_ID_NOMENCLATURAL_CODE, P_NOMENCLATURAL_CODE));\r
                }\r
                \r
+               // Nomenclatural reference\r
                if (id.equals(P_ID_NOMENCLATURAL_REF)) {\r
                        descriptors.addElement(\r
                                        new ReferenceSearchDescriptor(P_ID_NOMENCLATURAL_REF, P_NOMENCLATURAL_REF, IReferenceSearch.NOMREF) {\r
@@ -306,8 +346,10 @@ public class NonViralNamePropertySource implements IPropertySource {
                                                                MessageDialog.openError(UiUtil.getShell(), "Reference type error", "The selected reference cannot be used as a nomenclatural reference.");\r
                                                        }\r
                                                }\r
-                                       });\r
+                       });\r
                }\r
+               \r
+               // Microreference\r
                if (id.equals(P_ID_NOMENCLATURAL_MICROREF)) {\r
                        descriptors.addElement(\r
                                        new TextPropertyDescriptor(P_ID_NOMENCLATURAL_MICROREF,P_NOMENCLATURAL_MICROREF));\r
@@ -342,9 +384,13 @@ public class NonViralNamePropertySource implements IPropertySource {
        }\r
 \r
        public Object getPropertyValue(Object id) {\r
+               \r
+               // Parsed: reports whether parsing was successful               \r
         if (id.equals(P_ID_PARSED)) {\r
                        return name.getHasProblem() == true ? "problem" : "parsed" ;\r
         }\r
+        \r
+               // Rank menu        \r
                if (id.equals(P_ID_RANK)) {\r
                if (this.name.getRank() == null) {\r
                        return 0;\r
@@ -357,6 +403,8 @@ public class NonViralNamePropertySource implements IPropertySource {
                }\r
                return 0;\r
         }\r
+               \r
+               // Title cache          \r
         if (id.equals(P_ID_TITLECACHE)) {\r
                \r
                // If the name has not been parsed, only show the title cache\r
@@ -367,30 +415,48 @@ public class NonViralNamePropertySource implements IPropertySource {
                        return new NonViralNamePropertySource(name, P_ID_TITLECACHE, getNameFields());\r
                }\r
         }\r
+        \r
+               // Uninomial (aka Genus)        \r
                if (id.equals(P_ID_UNINOMIAL)) {\r
                        return CdmUtils.Nz(name.getGenusOrUninomial());\r
                }\r
+               \r
+               // Infrageneric epithet         \r
         if (id.equals(P_ID_INFRAGENERICEP)) {\r
                        return CdmUtils.Nz(name.getInfraGenericEpithet());\r
         }\r
+        \r
+               // Specific epithet        \r
         if (id.equals(P_ID_SPECIESEP)) {\r
                        return CdmUtils.Nz(name.getSpecificEpithet());\r
         }\r
+        \r
+               // Infraspecific epithet        \r
         if (id.equals(P_ID_INFRASPECIFICEP)) {\r
                        return CdmUtils.Nz(name.getInfraSpecificEpithet());\r
         }\r
+        \r
+               // Appended phrase        \r
         if (id.equals(P_ID_APPENDEDPHRASE)) {\r
                return CdmUtils.Nz(name.getAppendedPhrase());\r
         }\r
+        \r
+               // Authorship cache        \r
         if (id.equals(P_ID_AUTHORSHIPCACHE)) {\r
                        return CdmUtils.Nz(name.getAuthorshipCache());\r
         }\r
+        \r
+               // Homotypical group        \r
         if (id.equals(P_ID_HOMOTYPICALGROUP)) {\r
                        return CdmUtils.Nz(name.getHomotypicalGroup().getUuid().toString());\r
         }\r
+        \r
+               // Annotations, listed in custom property descriptor        \r
         if (id.equals(P_ID_ANNOTATIONS)) {\r
                        return new AnnotationPropertySource(name.getAnnotations());\r
         }\r
+        \r
+               // Nomenclatural status        \r
         if (id.equals(P_ID_NOMSTATUS)) {\r
 //                     return new NomStatusPropertySource(name.getStatus());\r
 //             if (this.name.getRank() == null) return 0;\r
@@ -408,22 +474,33 @@ public class NonViralNamePropertySource implements IPropertySource {
                }\r
                return 0;                       \r
         }\r
+        \r
+               // Name relations, popup to edit list        \r
         if (id.equals(P_ID_NAMERELATIONS)) {\r
                        return new NameRelationsPropertySource(name, name.getNameRelations());\r
         }\r
-        // TODO Button to link to type module\r
+        \r
+               // Type\r
         if (id.equals(P_ID_TYPE)) {\r
                        return "";\r
         }\r
+        \r
+               // UUID        \r
         if (id.equals(P_ID_UUID)) {\r
                        return CdmUtils.Nz(name.getUuid().toString());\r
         }\r
+        \r
+               // Markers        \r
         if (id.equals(P_ID_MARKERS)) {\r
                        return new MarkersPropertySource(name.getMarkers());\r
         }\r
+\r
+               // Taxon bases referring to this name        \r
         if (id.equals(P_ID_NUM_OF_BASES)) {\r
                        return name.getTaxonBases().size();\r
         }\r
+        \r
+               // Object created by        \r
         if (id.equals(P_ID_CREATED)) {\r
                if (name.getCreated() == null) {\r
                        return "";\r
@@ -431,6 +508,8 @@ public class NonViralNamePropertySource implements IPropertySource {
                        return formatDate(name.getCreated().toDate());\r
                }\r
         }\r
+        \r
+               // Object created when        \r
         if (id.equals(P_ID_CREATEDBY)) {\r
                if (name.getCreatedBy() == null) {\r
                        return "";\r
@@ -438,10 +517,14 @@ public class NonViralNamePropertySource implements IPropertySource {
                        return CdmUtils.Nz(name.getCreatedBy().generateTitle());\r
                }\r
         }\r
+        \r
+               // Nomenclatural code used by parser        \r
         if (id.equals(P_ID_NOMENCLATURAL_CODE)) {\r
                // Only shown if extending classes don't handle P_ID_NOMENCLATURAL_CODE \r
                return "none (nonviral name)";\r
         }\r
+        \r
+               // Nomenclatural reference        \r
         if (id.equals(P_ID_NOMENCLATURAL_REF)) {\r
                \r
                ReferenceBase nomRef = (ReferenceBase) name.getNomenclaturalReference();\r
@@ -465,6 +548,8 @@ public class NonViralNamePropertySource implements IPropertySource {
                        return nomRefPropertySource;\r
                \r
         }\r
+        \r
+               // Microreference        \r
         if (id.equals(P_ID_NOMENCLATURAL_MICROREF)) {\r
                        return CdmUtils.Nz(name.getNomenclaturalMicroReference());\r
         }\r
@@ -527,28 +612,43 @@ public class NonViralNamePropertySource implements IPropertySource {
                //      listener.\r
                name.firePropertyChange(ITaxEditorConstants.PROPERTY_SHEET_CHANGE, null, null);\r
                \r
+               // Rank menu            \r
                if (id.equals(P_ID_RANK)) {\r
                        int index = ((Integer) value).intValue();\r
                        name.setRank(ranks[index]);\r
         }\r
+               \r
+               // Uninomial (aka Genus)                \r
                if (id.equals(P_ID_UNINOMIAL)) {\r
                        name.setGenusOrUninomial((String) value);\r
                }\r
+               \r
+               // Infrageneric epithet         \r
         if (id.equals(P_ID_INFRAGENERICEP)) {\r
                        name.setInfraGenericEpithet((String) value);\r
         }\r
+        \r
+               // Specific epithet        \r
         if (id.equals(P_ID_SPECIESEP)) {\r
                        name.setSpecificEpithet((String) value);\r
         }\r
+        \r
+               // Infraspecific epithet        \r
         if (id.equals(P_ID_INFRASPECIFICEP)) {\r
                        name.setInfraSpecificEpithet((String) value);\r
         }\r
+        \r
+               // Appended phrase        \r
         if (id.equals(P_ID_APPENDEDPHRASE)) {\r
                        name.setAppendedPhrase((String) value);\r
         }\r
+        \r
+               // Authorship cache        \r
         if (id.equals(P_ID_AUTHORSHIPCACHE)) {\r
                        name.setAuthorshipCache((String) value);\r
         }\r
+        \r
+               // Annotations        \r
         if (id.equals(P_ID_ANNOTATIONS)) {\r
                if (value instanceof Set) {\r
                        \r
@@ -569,9 +669,7 @@ public class NonViralNamePropertySource implements IPropertySource {
                        \r
                }\r
         }\r
-        if (id.equals(P_ID_NAMERELATIONS)) {\r
-               // TODO set name relations\r
-        }\r
+               // Nomenclatural status        \r
         if (id.equals(P_ID_NOMSTATUS)) {\r
                NomenclaturalStatus nomStatus;\r
                        int index = ((Integer) value).intValue();\r
@@ -591,14 +689,20 @@ public class NonViralNamePropertySource implements IPropertySource {
                                name.addStatus(nomStatus);\r
                        }\r
         }\r
+        \r
+               // Markers        \r
         if (id.equals(P_ID_MARKERS)) {\r
                // TODO set markers\r
         }\r
+        \r
+               // Nomenclatural reference        \r
         if (id.equals(P_ID_NOMENCLATURAL_REF)) {\r
                if (value instanceof INomenclaturalReference) {\r
                        name.setNomenclaturalReference((INomenclaturalReference) value);\r
                }\r
         }\r
+        \r
+               // Microreference        \r
         if (id.equals(P_ID_NOMENCLATURAL_MICROREF)) {\r
                name.setNomenclaturalMicroReference((String) value);\r
         }\r
index b0333f411e681cd72acc843caf292264f638d54d..12b60011eaef1c6f4de7553b106d5f30bb8205d5 100644 (file)
@@ -9,30 +9,21 @@
 \r
 package eu.etaxonomy.taxeditor.propertysheet.reference;\r
 \r
-import java.util.ArrayList;\r
 import java.util.HashMap;\r
 import java.util.LinkedHashMap;\r
-import java.util.List;\r
 import java.util.Set;\r
 \r
 import org.apache.log4j.Logger;\r
 \r
 import eu.etaxonomy.cdm.model.reference.Article;\r
-import eu.etaxonomy.cdm.model.reference.BibtexReference;\r
 import eu.etaxonomy.cdm.model.reference.Book;\r
 import eu.etaxonomy.cdm.model.reference.BookSection;\r
 import eu.etaxonomy.cdm.model.reference.Generic;\r
-import eu.etaxonomy.cdm.model.reference.PrintedUnitBase;\r
-import eu.etaxonomy.cdm.model.reference.PublicationBase;\r
 import eu.etaxonomy.cdm.model.reference.ReferenceBase;\r
-import eu.etaxonomy.cdm.model.reference.SectionBase;\r
-import eu.etaxonomy.cdm.model.reference.StrictReferenceBase;\r
 \r
 /**\r
- * Quick and dirty subclass of <code>ReferencePropertySource</code>.\r
- * <p>\r
- * TODO: reprogram to only use <code>ReferenceBase</code> classes which implement\r
- * <code>INomenclaturalReference</code>.\r
+ * Subclass of <code>ReferencePropertySource</code> which restricts reference type menu \r
+ * to "Article", "Generic", "Book", "Book Section".\r
  *  \r
  * @author p.ciardelli\r
  * @created 12.11.2008\r
@@ -72,103 +63,4 @@ public class NomenclaturalReferencePropertySource extends
        protected Set<Class> getReferenceClassSet() {\r
                return nomReferenceTypeMap.keySet();\r
        }\r
-       \r
-       protected void initDescriptors() {\r
-               \r
-               List<String> displayFields = new ArrayList<String>();\r
-       \r
-               // Drop-down menu to change reference type\r
-               displayFields.add(P_ID_REFERENCETYPE);\r
-               \r
-               // ReferenceBase fields\r
-               displayFields.add(P_ID_AUTHORTEAM);\r
-               displayFields.add(P_ID_YEAR);\r
-               displayFields.add(P_ID_CITATION);\r
-               displayFields.add(P_ID_URI);\r
-               \r
-               Class referenceClass = reference.getClass();\r
-               \r
-               if (reference instanceof BibtexReference) {\r
-                                               \r
-                       displayFields.add(P_ID_BIBTEX_ENTRYTYPE);\r
-                       displayFields.add(P_ID_JOURNAL);\r
-                       displayFields.add(P_ID_BOOKTITLE);\r
-                       displayFields.add(P_ID_CHAPTER);\r
-                       displayFields.add(P_ID_TITLE);\r
-                       displayFields.add(P_ID_SERIES);\r
-                       displayFields.add(P_ID_EDITION);\r
-                       displayFields.add(P_ID_VOLUME);\r
-                       displayFields.add(P_ID_NUMBER);\r
-                       displayFields.add(P_ID_PAGES);\r
-                       displayFields.add(P_ID_ANNOTE);\r
-                       displayFields.add(P_ID_EDITOR);\r
-                       displayFields.add(P_ID_INSTITUTION);\r
-                       displayFields.add(P_ID_SCHOOL);\r
-                       displayFields.add(P_ID_ORGANIZATION);\r
-                       displayFields.add(P_ID_PUBLISHER);\r
-                       displayFields.add(P_ID_ADDRESS);\r
-                       displayFields.add(P_ID_HOWPUBLISHED);\r
-                       displayFields.add(P_ID_REPORTTYPE);\r
-                       displayFields.add(P_ID_MONTH);\r
-                       displayFields.add(P_ID_EPRINT);\r
-                       displayFields.add(P_ID_NOTE);\r
-                       displayFields.add(P_ID_CROSSREF);\r
-               }\r
-       \r
-               if (reference instanceof StrictReferenceBase) {\r
-                       \r
-                       displayFields.add(P_ID_DATEPUBLISHED);\r
-                       displayFields.add(P_ID_TITLE);\r
-       \r
-                       if (referenceClass == Article.class) {\r
-                               displayFields.add(P_ID_INJOURNAL);\r
-                               displayFields.add(P_ID_PAGES);\r
-                               displayFields.add(P_ID_SERIES);\r
-                               displayFields.add(P_ID_VOLUME);\r
-                       }\r
-       \r
-                       if (referenceClass == Generic.class) {\r
-                               displayFields.add(P_ID_PAGES);\r
-                               displayFields.add(P_ID_SERIES);\r
-                               displayFields.add(P_ID_VOLUME);\r
-                               displayFields.add(P_ID_EDITOR);\r
-                               displayFields.add(P_ID_PLACEPUBLISHED);\r
-                               displayFields.add(P_ID_PUBLISHER);\r
-                       }\r
-                       \r
-                       if (reference instanceof PublicationBase) {\r
-       \r
-                               displayFields.add(P_ID_PLACEPUBLISHED);\r
-                               displayFields.add(P_ID_PUBLISHER);\r
-                               \r
-                               if (reference instanceof PrintedUnitBase) {\r
-                                       \r
-                                       displayFields.add(P_ID_EDITOR);\r
-                                       displayFields.add(P_ID_INSERIES);\r
-                                       displayFields.add(P_ID_PAGES);\r
-                                       displayFields.add(P_ID_SERIESPART);\r
-                                       displayFields.add(P_ID_VOLUME);\r
-                                       \r
-                                       if (referenceClass == Book.class) {\r
-                                               displayFields.add(P_ID_ISBN);\r
-                                               displayFields.add(P_ID_EDITION);\r
-                                       }\r
-                               }\r
-                       }\r
-                       \r
-                       if (reference instanceof SectionBase) {\r
-                               \r
-                               displayFields.add(P_ID_PAGES);  \r
-                               displayFields.add(P_ID_PRINTEDUNIT);\r
-                               \r
-                               if (referenceClass == BookSection.class) {\r
-                                       displayFields.add(P_ID_INBOOK);\r
-                               }\r
-                       }\r
-               }\r
-               \r
-               for (String field : displayFields) {\r
-                       addDescriptor(field);\r
-               }\r
-       }\r
 }\r
index 2be101033871c2884d2c6c000026784c29eb76e6..298d07fe451dfbbe999e9a68d5d1372b60d69135 100644 (file)
@@ -242,7 +242,6 @@ public class ReferencePropertySource implements IPropertySource {
                \r
                // ReferenceBase fields\r
                displayFields.add(P_ID_AUTHORTEAM);\r
-               displayFields.add(P_ID_YEAR);\r
                displayFields.add(P_ID_CITATION);\r
                displayFields.add(P_ID_URI);\r
                \r
@@ -251,9 +250,10 @@ public class ReferencePropertySource implements IPropertySource {
                if (reference instanceof BibtexReference) {\r
                                                \r
                        displayFields.add(P_ID_BIBTEX_ENTRYTYPE);\r
+                       displayFields.add(P_ID_YEAR);\r
                        displayFields.add(P_ID_JOURNAL);\r
                        displayFields.add(P_ID_BOOKTITLE);\r
-                       displayFields.add(P_ID_CHAPTER);\r
+                       displayFields.add(P_ID_CHAPTER);                        \r
                        displayFields.add(P_ID_TITLE);\r
                        displayFields.add(P_ID_SERIES);\r
                        displayFields.add(P_ID_EDITION);\r
@@ -396,28 +396,42 @@ public class ReferencePropertySource implements IPropertySource {
                \r
                // Year\r
                if (id.equals(P_ID_YEAR)) {\r
-//                     TextPropertyDescriptor yearDescriptor = new TextPropertyDescriptor(P_ID_YEAR, P_YEAR) {\r
-//                         public CellEditor createPropertyEditor(Composite parent) {\r
-//                             CellEditor editor = new TextCellEditor(parent);\r
-//                             \r
-//                             // Colors cell yellow upon activation\r
-//                             editor.getControl().setBackground(new Color(Display.getDefault(), WarningAnnotation.WARNING_RGB));\r
-//                             \r
-//                             if (getValidator() != null) {\r
-//                                             editor.setValidator(getValidator());\r
-//                                     }\r
-//                             return editor;\r
-//                         }\r
-//                     };\r
-                       \r
-                       TextPropertyDescriptor yearDescriptor = new TextPropertyDescriptor(P_ID_YEAR, P_YEAR);\r
-                       \r
-                       // BibtexReference.setYear() takes a String, no need for validation\r
-                       if (!(reference instanceof BibtexReference)) {\r
-                               yearDescriptor.setValidator(new YearValidator());\r
-                       }\r
-                       descriptors.addElement(yearDescriptor);         \r
+                       descriptors.addElement(\r
+                                       new TextPropertyDescriptor(P_ID_YEAR, P_YEAR));\r
                }\r
+//             if (id.equals(P_ID_YEAR)) {\r
+////                   TextPropertyDescriptor yearDescriptor = new TextPropertyDescriptor(P_ID_YEAR, P_YEAR) {\r
+////                       public CellEditor createPropertyEditor(Composite parent) {\r
+////                           CellEditor editor = new TextCellEditor(parent);\r
+////                           \r
+////                           // Colors cell yellow upon activation\r
+////                           editor.getControl().setBackground(new Color(Display.getDefault(), WarningAnnotation.WARNING_RGB));\r
+////                           \r
+////                           if (getValidator() != null) {\r
+////                                           editor.setValidator(getValidator());\r
+////                                   }\r
+////                           return editor;\r
+////                       }\r
+////                   };\r
+//                     \r
+//                     TextPropertyDescriptor yearDescriptor = new TextPropertyDescriptor(P_ID_YEAR, P_YEAR);\r
+//                     \r
+//                     // BibtexReference.setYear() takes a String, no need for validation\r
+//                     if (!(reference instanceof BibtexReference)) {\r
+//                             yearDescriptor.setValidator(new YearValidator());\r
+//                     }\r
+//                     descriptors.addElement(yearDescriptor);         \r
+//             }\r
+               \r
+               // Date published\r
+               if (id.equals(P_ID_DATEPUBLISHED)) {\r
+                       \r
+                       // TimePeriodPropertySource returns TimePeriod.getYear() - make this editable\r
+                       TextPropertyDescriptor yearDescriptor = new TextPropertyDescriptor(\r
+                                       P_ID_DATEPUBLISHED, P_DATEPUBLISHED);\r
+                       yearDescriptor.setValidator(new YearValidator());\r
+                       descriptors.addElement(yearDescriptor);                 \r
+               } \r
                \r
                // Citation\r
                if (id.equals(P_ID_CITATION)) {\r
@@ -431,12 +445,6 @@ public class ReferencePropertySource implements IPropertySource {
                                        new TextPropertyDescriptor(P_ID_URI, P_URI));                   \r
                } \r
                \r
-               // Date published\r
-               if (id.equals(P_ID_DATEPUBLISHED)) {\r
-                       descriptors.addElement(\r
-                                       new PropertyDescriptor(P_ID_DATEPUBLISHED, P_DATEPUBLISHED));                   \r
-               } \r
-               \r
                // Title\r
                if (id.equals(P_ID_TITLE)) {\r
                        descriptors.addElement(\r
@@ -875,25 +883,12 @@ public class ReferencePropertySource implements IPropertySource {
                        reference.setUri(uri);\r
                }\r
                \r
-               // Year\r
+               // Year - only set directly by Bibtex refs\r
                if (id.equals(P_ID_YEAR)) {\r
                        String year = (String) value;\r
                        if (reference instanceof BibtexReference) {\r
                                ((BibtexReference) reference).setYear(year);\r
                        }\r
-                       if (reference instanceof StrictReferenceBase) {\r
-                               try {\r
-                                       TimePeriod datePublished = null;\r
-                                       if (!year.equals("")) {\r
-                                               datePublished = CdmUtil.getDatePublished(year);                                         \r
-                                       }\r
-                                       ((StrictReferenceBase) reference).setDatePublished(datePublished);\r
-                               } catch (NumberFormatException e) {\r
-                                       // Validator should prevent this from ever happening ...\r
-                                       return; \r
-                               }\r
-                       }\r
-//                     UiUtil.paintPropertySheetRow(P_DATEPUBLISHED, new Color(Display.getDefault(), WarningAnnotation.WARNING_RGB), true);\r
                }\r
 \r
                // Title: used by StrictReferenceBase\r
@@ -912,7 +907,6 @@ public class ReferencePropertySource implements IPropertySource {
                // Pages\r
                if (id.equals(P_ID_PAGES)) {\r
                        invokeMethod(reference, "setPages", (String) value);\r
-//                     UiUtil.unpaintPropertySheetRow(P_DATEPUBLISHED);\r
                }\r
 \r
                // Series\r
@@ -975,6 +969,42 @@ public class ReferencePropertySource implements IPropertySource {
                        inBook.setTitleCache((String) value);\r
                }\r
                \r
+               // Date published\r
+               if (id.equals(P_ID_DATEPUBLISHED)) {\r
+                       \r
+                       if (!(reference instanceof StrictReferenceBase)) {\r
+                               return;\r
+                       }\r
+                       \r
+                       if (value instanceof String) {\r
+                               String year = (String) value;\r
+                               TimePeriod yearsPublished = null;\r
+                               \r
+                               // If not empty, format is either "xxxx" or "xxxx-xxxx", thanks to validator\r
+                               if (!year.equals("")) {\r
+                                       \r
+                                       // Convert to a TimePeriod\r
+                                       yearsPublished = CdmUtil.convertTimePeriod(year);\r
+                                       \r
+                                       // Update reference's dataPublished field\r
+                                       TimePeriod datePublished = ((StrictReferenceBase) reference).getDatePublished();\r
+                                       \r
+                                       if (datePublished == null) {\r
+                                               ((StrictReferenceBase) reference).setDatePublished(yearsPublished);\r
+                                       } else {\r
+                                               \r
+                                               // Any months or days should be left as is - only update years \r
+                                               datePublished.setStartYear(yearsPublished.getStartYear());\r
+                                               datePublished.setEndYear(yearsPublished.getEndYear());\r
+                                       }\r
+                               } else {\r
+                                       ((StrictReferenceBase) reference).setDatePublished(null);\r
+                               }\r
+                               \r
+\r
+                       }\r
+               }\r
+               \r
                propertyChangeSupport.firePropertyChange(ITaxEditorConstants.PROPERTY_SHEET_CHANGE, null, reference);\r
        }\r
        \r
index e7dca8b1da5808322e97f85c40a129c10897fa2e..8e0cae8471cad4daa7642d6fcf2aa8434cb57d28 100644 (file)
@@ -12,15 +12,12 @@ package eu.etaxonomy.taxeditor.propertysheet.reference;
 import org.apache.log4j.Logger;\r
 import org.eclipse.jface.viewers.CellEditor;\r
 import org.eclipse.jface.viewers.DialogCellEditor;\r
-import org.eclipse.swt.graphics.Color;\r
 import org.eclipse.swt.widgets.Composite;\r
 import org.eclipse.swt.widgets.Control;\r
 import org.eclipse.swt.widgets.Dialog;\r
-import org.eclipse.swt.widgets.Display;\r
 import org.eclipse.ui.views.properties.PropertyDescriptor;\r
 \r
 import eu.etaxonomy.cdm.model.reference.ReferenceBase;\r
-import eu.etaxonomy.taxeditor.editor.WarningAnnotation;\r
 \r
 /**  \r
  * @author p.ciardelli\r
@@ -56,7 +53,6 @@ abstract public class ReferenceSearchDescriptor extends PropertyDescriptor {
                                return null;\r
                        }\r
         };\r
-        editor.getControl().setBackground(new Color(Display.getDefault(), WarningAnnotation.WARNING_RGB));\r
         if (getValidator() != null) {\r
                        editor.setValidator(getValidator());\r
                }\r
index 61f16f015b6cb6758c3526a31612bda2368f3118..b27fc69160350c107e43fc85b1a9bee00d7ae7f8 100644 (file)
@@ -22,7 +22,7 @@ import eu.etaxonomy.cdm.model.reference.ReferenceBase;
  * <code>Article</code>, one of its fields would be a \r
  * <code>SingleRefTypePropertySource</code> restricted to a <code>Journal</code>,\r
  * and the reference type drop-down would be replaced by the non-editable \r
- * value "Journal".   \r
+ * value "Journal".\r
  * \r
  * @author p.ciardelli\r
  * @created 19.11.2008\r