BUG was experiencing lazyloader errors when retrieving name relation labels. All...
authorp.ciardelli <p.ciardelli@localhost>
Fri, 28 Nov 2008 15:45:29 +0000 (15:45 +0000)
committerp.ciardelli <p.ciardelli@localhost>
Fri, 28 Nov 2008 15:45:29 +0000 (15:45 +0000)
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/TaxEditorPlugin.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/UiUtil.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/namerelationswizard/ListNameRelationsWizardPage.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/reference/ReferencePropertySource.java

index eea284637ea78d8c414f656137865130d717bcb4..39e7ef12d5958d08ec27d419bfda82dbe0869f08 100644 (file)
@@ -51,6 +51,7 @@ import eu.etaxonomy.cdm.api.service.IDescriptionService;
 import eu.etaxonomy.cdm.api.service.INameService;\r
 import eu.etaxonomy.cdm.api.service.IReferenceService;\r
 import eu.etaxonomy.cdm.api.service.ITaxonService;\r
+import eu.etaxonomy.cdm.api.service.ITermService;\r
 import eu.etaxonomy.cdm.database.CdmDataSource;\r
 import eu.etaxonomy.cdm.database.DataSourceNotFoundException;\r
 import eu.etaxonomy.cdm.database.DbSchemaValidation;\r
@@ -278,6 +279,35 @@ public class TaxEditorPlugin extends AbstractUIPlugin {
        public void startTransaction() {\r
                if (cdmApp != null) {\r
                        txStatus = cdmApp.startTransaction();\r
+                       \r
+                       // Workaround - nom statii were causing a lazy loading error\r
+                       List<NomenclaturalStatusType> list = new ArrayList<NomenclaturalStatusType>();\r
+                       list.add(NomenclaturalStatusType.SUPERFLUOUS());\r
+                       list.add(NomenclaturalStatusType.NUDUM());\r
+                       list.add(NomenclaturalStatusType.ILLEGITIMATE());\r
+                       list.add(NomenclaturalStatusType.INVALID());\r
+                       list.add(NomenclaturalStatusType.CONSERVED());\r
+                       list.add(NomenclaturalStatusType.ALTERNATIVE());\r
+                       list.add(NomenclaturalStatusType.REJECTED());\r
+                       list.add(NomenclaturalStatusType.REJECTED_PROP());\r
+                       list.add(NomenclaturalStatusType.PROVISIONAL());\r
+                       list.add(NomenclaturalStatusType.SUBNUDUM());\r
+                       list.add(NomenclaturalStatusType.OPUS_UTIQUE_OPPR());\r
+                       list.add(NomenclaturalStatusType.AMBIGUOUS());\r
+                       list.add(NomenclaturalStatusType.DOUBTFUL());\r
+                       list.add(NomenclaturalStatusType.CONFUSUM());\r
+                       list.add(NomenclaturalStatusType.UTIQUE_REJECTED());\r
+                       list.add(NomenclaturalStatusType.CONSERVED_PROP());\r
+                       list.add(NomenclaturalStatusType.LEGITIMATE());\r
+                       list.add(NomenclaturalStatusType.NOVUM());\r
+                       list.add(NomenclaturalStatusType.ORTHOGRAPHY_CONSERVED());\r
+                       list.add(NomenclaturalStatusType.SANCTIONED());\r
+                       list.add(NomenclaturalStatusType.COMBINATION_INVALID());\r
+                       list.add(NomenclaturalStatusType.VALID());\r
+                       for (NomenclaturalStatusType status : list){\r
+                               cdmApp.getTermService().saveTerm(status);\r
+                               logger.warn(status.getRepresentations().size());\r
+                       }\r
                }\r
        }\r
 \r
@@ -709,6 +739,10 @@ public class TaxEditorPlugin extends AbstractUIPlugin {
                }\r
                return nomStatusVocabulary;\r
        }\r
+       \r
+       public void setNomStatusVocabulary(TermVocabulary<NomenclaturalStatusType> statii) {\r
+               nomStatusVocabulary = statii;\r
+       }\r
 \r
        /***************************************************************************\r
         * NAME RELATIONS\r
@@ -719,6 +753,13 @@ public class TaxEditorPlugin extends AbstractUIPlugin {
                if (nameRelationshipTypeVocabulary == null) {\r
                        nameRelationshipTypeVocabulary = getCdmApp().getNameService()\r
                                        .getNameRelationshipTypeVocabulary();\r
+                       \r
+                       // Add all terms manually to transaction\r
+                       ITermService termService = getCdmApp().getTermService();\r
+                       for (NameRelationshipType type : nameRelationshipTypeVocabulary) {\r
+                               termService.saveTerm(type);\r
+                       }\r
+                       \r
                }\r
                return nameRelationshipTypeVocabulary;\r
        }\r
index 8d9c5a0d8f9fd38e37d00fd1c67aacffd0caac95..431ef850bfbfe91a4a6ae7a17cd75a4c82ab8511 100644 (file)
@@ -20,7 +20,6 @@ import org.eclipse.jface.preference.IPreferenceStore;
 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.Display;\r
 import org.eclipse.swt.widgets.Shell;\r
 import org.eclipse.swt.widgets.Tree;\r
 import org.eclipse.swt.widgets.TreeItem;\r
@@ -39,8 +38,10 @@ import org.eclipse.ui.operations.IWorkbenchOperationSupport;
 import org.eclipse.ui.views.properties.PropertySheet;\r
 import org.eclipse.ui.views.properties.PropertySheetPage;\r
 \r
+import eu.etaxonomy.cdm.model.common.TermVocabulary;\r
 import eu.etaxonomy.cdm.model.description.Feature;\r
 import eu.etaxonomy.cdm.model.name.BotanicalName;\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.Rank;\r
@@ -49,7 +50,6 @@ import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.taxeditor.editor.CompositeBorderDecorator;\r
 import eu.etaxonomy.taxeditor.editor.EditorGroupComposite;\r
 import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;\r
-import eu.etaxonomy.taxeditor.editor.WarningAnnotation;\r
 import eu.etaxonomy.taxeditor.model.CdmUtil;\r
 import eu.etaxonomy.taxeditor.model.NameEditorInput;\r
 import eu.etaxonomy.taxeditor.navigation.TaxonomicTreeView;\r
@@ -73,6 +73,7 @@ public class UiUtil {
        public static IViewPart getPropertySheet() {\r
                for (IViewReference reference : getActivePage().getViewReferences()) {\r
                        if (reference.getId().equals(IPageLayout.ID_PROP_SHEET)) {\r
+                               logger.warn(reference.getView(false).getSite().getPart().getTitle());\r
                                return reference.getView(false);\r
                        }\r
                }\r
@@ -165,11 +166,12 @@ public class UiUtil {
        /**\r
         * @param input\r
         * @param editorId\r
+        * @return \r
         * @throws PartInitException\r
         */\r
-       public static void openEditor(IEditorInput input, String editorId)\r
+       public static IEditorPart openEditor(IEditorInput input, String editorId)\r
                        throws PartInitException {\r
-               getActivePage().openEditor(input, editorId);\r
+               return getActivePage().openEditor(input, editorId);\r
        }\r
 \r
        /**\r
@@ -634,4 +636,21 @@ public class UiUtil {
                \r
                paintPropertySheetRow(id, color, true);\r
        }\r
+\r
+       /**\r
+        * Get the name out of the session's name relations vocabulary, not directly\r
+        * from the object. \r
+        * \r
+        * @param type\r
+        * @return\r
+        */\r
+       public static String getNameRelationLabelType(NameRelationshipType type) {\r
+               TermVocabulary<NameRelationshipType> vocab = TaxEditorPlugin.getDefault().getNameRelationshipTypeVocabulary();\r
+               for (NameRelationshipType type1 : vocab) {\r
+                       if (type1.equals(type)) {\r
+                               return type1.getLabel();\r
+                       }\r
+               }\r
+               return "joemama";\r
+       }\r
 }
\ No newline at end of file
index a990f280c4ea63eb6109f55833db6391329797be..08853523348d149fee5492adbd8f519b55984162 100644 (file)
@@ -37,6 +37,7 @@ import eu.etaxonomy.cdm.model.name.TaxonNameBase;
 import eu.etaxonomy.cdm.model.name.ZoologicalName;\r
 import eu.etaxonomy.taxeditor.ITaxEditorConstants;\r
 import eu.etaxonomy.taxeditor.TaxEditorPlugin;\r
+import eu.etaxonomy.taxeditor.UiUtil;\r
 import eu.etaxonomy.taxeditor.actions.cdm.DeleteNameRelationAction;\r
 import eu.etaxonomy.taxeditor.actions.ui.OpenNameRelationWizardAction;\r
 import eu.etaxonomy.taxeditor.model.CdmUtil;\r
@@ -221,7 +222,8 @@ public class ListNameRelationsWizardPage extends WizardPage {
                                        nameRelationship.getType().equals(NameRelationshipType.BASIONYM())) {\r
                                type = "original combination";\r
                        } else {\r
-                               type = nameRelationship.getType().getLabel();\r
+//                             type = nameRelationship.getType().getLabel();\r
+                               type = UiUtil.getNameRelationLabelType(nameRelationship.getType());\r
                        }\r
                }\r
                if (nameRelationship.getToName() == null) {\r
index 7d24dfccf9a8af0fc5b68215a523d304f10f3f72..5bd2a1704f0a29f4a40536a48c9c0c5c960cfd96 100644 (file)
@@ -23,7 +23,6 @@ import java.util.Set;
 import java.util.Vector;\r
 \r
 import org.apache.log4j.Logger;\r
-import org.eclipse.jface.dialogs.MessageDialog;\r
 import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor;\r
 import org.eclipse.ui.views.properties.IPropertyDescriptor;\r
 import org.eclipse.ui.views.properties.IPropertySource;\r
@@ -41,7 +40,6 @@ import eu.etaxonomy.cdm.model.reference.BookSection;
 import eu.etaxonomy.cdm.model.reference.CdDvd;\r
 import eu.etaxonomy.cdm.model.reference.Database;\r
 import eu.etaxonomy.cdm.model.reference.Generic;\r
-import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;\r
 import eu.etaxonomy.cdm.model.reference.InProceedings;\r
 import eu.etaxonomy.cdm.model.reference.Journal;\r
 import eu.etaxonomy.cdm.model.reference.Map;\r
@@ -58,7 +56,6 @@ import eu.etaxonomy.cdm.model.reference.StrictReferenceBase;
 import eu.etaxonomy.cdm.model.reference.Thesis;\r
 import eu.etaxonomy.cdm.model.reference.WebPage;\r
 import eu.etaxonomy.taxeditor.ITaxEditorConstants;\r
-import eu.etaxonomy.taxeditor.UiUtil;\r
 import eu.etaxonomy.taxeditor.model.CdmUtil;\r
 import eu.etaxonomy.taxeditor.propertysheet.TimePeriodPropertySource;\r
 import eu.etaxonomy.taxeditor.propertysheet.YearValidator;\r
@@ -110,7 +107,6 @@ public class ReferencePropertySource implements IPropertySource {
        public static final String P_ID_REFERENCETYPE = "P_ID_REFERENCETYPE";\r
        public static final String P_ID_AUTHORTEAM = "P_ID_AUTHORTEAM";\r
        public static final String P_ID_YEAR = "P_ID_YEAR";\r
-       public static final String P_ID_CITATION = "P_ID_CITATION";\r
        public static final String P_ID_URI = "P_ID_URI";\r
        public static final String P_ID_DATEPUBLISHED = "P_ID_DATEPUBLISHED";\r
        public static final String P_ID_TITLE = "P_ID_TITLE";\r
@@ -145,30 +141,32 @@ public class ReferencePropertySource implements IPropertySource {
        public static final String P_ID_EPRINT = "P_ID_EPRINT";\r
        public static final String P_ID_NOTE = "P_ID_NOTE";\r
        public static final String P_ID_CROSSREF = "P_ID_CROSSREF";\r
+       public static final String P_ID_PROTECT_CACHE = "P_ID_PROTECT_CACHE";\r
                \r
     // Property display keys\r
        public static final String P_SEARCH = "001:Search";\r
        public static final String P_EDITABLECACHE = "002:Editable Cache";\r
+       public static final String P_PROTECT_CACHE = "0020:Protect Cache from overwriting?";\r
        public static final String P_REFERENCETYPE = "003:Reference Type";\r
        public static final String P_AUTHORTEAM = "01:Author Team (Cache)";\r
        public static final String P_YEAR = "02:Year";\r
        public static final String P_DATEPUBLISHED = "03:Date Published";\r
-       public static final String P_CITATION = "04:Citation";\r
-       public static final String P_URI = "05:URI";\r
        public static final String P_TITLE = "06:Title";\r
        public static final String P_INJOURNAL = "07:In Journal";\r
-       public static final String P_PAGES = "09:Pages";\r
-       public static final String P_SERIES = "10:Series";\r
-       public static final String P_VOLUME = "11:Volume";\r
+       public static final String P_VOLUME = "10:Volume";\r
+       public static final String P_EDITION = "110:Edition";\r
+       public static final String P_SERIES = "11:Series";\r
+       public static final String P_PAGES = "110:Pages";\r
        public static final String P_EDITOR = "12:Editor";\r
-       public static final String P_PLACEPUBLISHED = "13:Place Published";\r
-       public static final String P_PUBLISHER = "14:Publisher";\r
+       public static final String P_PUBLISHER = "13:Publisher";\r
+       public static final String P_PLACEPUBLISHED = "14:Place Published";\r
        public static final String P_ISSN = "15:ISSN";\r
        public static final String P_INSTITUTION = "16:Institution";\r
        public static final String P_SCHOOL = "17:School";\r
        public static final String P_INSERIES = "18:In Series";\r
        public static final String P_SERIESPART = "19:Series Part";\r
        public static final String P_ISBN = "20:ISBN";\r
+       public static final String P_URI = "201:URI";\r
        public static final String P_ORGANIZATION = "21:Organization";\r
        public static final String P_PRINTEDUNIT = "22:Printed Unit";\r
        public static final String P_INBOOK = "23:In Book";\r
@@ -177,7 +175,6 @@ public class ReferencePropertySource implements IPropertySource {
        public static final String P_JOURNAL = "26:Journal";\r
        public static final String P_BOOKTITLE = "27:Book Title";\r
        public static final String P_CHAPTER = "28:Chapter";\r
-       public static final String P_EDITION = "29:Edition";\r
        public static final String P_NUMBER = "30:Number";\r
        public static final String P_ANNOTE = "31:Annote";\r
        public static final String P_ADDRESS = "32:Address";\r
@@ -191,6 +188,9 @@ public class ReferencePropertySource implements IPropertySource {
        protected static HashMap<Class, String> referenceTypeMap = null;\r
        \r
        private static final String[] P_BIBTEX_ENTRYTYPE_MENU = new String[] {"ARTICLE", "BOOK", "BOOKLET", "INBOOK", "INCOLLECTION", "PROCEEDINGS", "INPROCEEDINGS", "CONFERENCE", "MANUAL", "MASTERTHESIS", "PHDTHESIS", "TECHREPORT", "UNPUBLISHED", "MISC"};\r
+\r
+       private static final int CACHE_NOT_PROTECTED = 0;\r
+       private static final int CACHE_PROTECTED = 1;   \r
        \r
        protected void populateReferenceTypes() {\r
                \r
@@ -248,9 +248,9 @@ public class ReferencePropertySource implements IPropertySource {
                \r
                // ReferenceBase fields\r
                displayFields.add(P_ID_SEARCH);\r
-               displayFields.add(P_ID_EDITABLECACHE);          \r
+               displayFields.add(P_ID_EDITABLECACHE);\r
+               displayFields.add(P_ID_PROTECT_CACHE);\r
                displayFields.add(P_ID_AUTHORTEAM);\r
-               displayFields.add(P_ID_CITATION);\r
                displayFields.add(P_ID_URI);\r
                \r
                Class referenceClass = reference.getClass();\r
@@ -407,6 +407,13 @@ public class ReferencePropertySource implements IPropertySource {
                                        new TextPropertyDescriptor(P_ID_EDITABLECACHE, P_EDITABLECACHE));\r
                }\r
                \r
+               // Protect cache?\r
+               if (id.equals(P_ID_PROTECT_CACHE)) {\r
+                       descriptors.addElement(\r
+                                       new ComboBoxPropertyDescriptor(P_ID_PROTECT_CACHE, P_PROTECT_CACHE, \r
+                                                       new String[] {"no", "yes"}));\r
+               }\r
+               \r
                // Reference type\r
                if (id.equals(P_ID_REFERENCETYPE)) {\r
                        descriptors.addElement(createReferenceTypeDescriptor());\r
@@ -456,13 +463,7 @@ public class ReferencePropertySource implements IPropertySource {
                        yearDescriptor.setValidator(new YearValidator());\r
                        descriptors.addElement(yearDescriptor);                 \r
                } \r
-               \r
-               // Citation\r
-               if (id.equals(P_ID_CITATION)) {\r
-                       descriptors.addElement(\r
-                                       new PropertyDescriptor(P_ID_CITATION, P_CITATION));                     \r
-               }\r
-               \r
+                               \r
                // URI\r
                if (id.equals(P_ID_URI)) {\r
                        descriptors.addElement(\r
@@ -638,6 +639,20 @@ public class ReferencePropertySource implements IPropertySource {
                        return 0;\r
                }\r
 \r
+               // Editable cache\r
+               if (id.equals(P_ID_EDITABLECACHE)) {\r
+                       return (CdmUtils.Nz(reference.getTitleCache()));\r
+               }\r
+               \r
+               // Protect cache?\r
+               if (id.equals(P_ID_PROTECT_CACHE)) {\r
+                       if (reference.isProtectedTitleCache()) {\r
+                               return CACHE_PROTECTED;\r
+                       } else {\r
+                               return CACHE_NOT_PROTECTED;\r
+                       }\r
+               }\r
+               \r
                // Author Team: for now, just edit the cache\r
                // TODO AuthorTeamPropertySource\r
                if (id.equals(P_ID_AUTHORTEAM)) {\r
@@ -655,11 +670,6 @@ public class ReferencePropertySource implements IPropertySource {
                        return CdmUtils.Nz(reference.getYear());\r
                }\r
                \r
-               // Citation\r
-               if (id.equals(P_ID_CITATION)) {\r
-                       return CdmUtils.Nz(reference.getCitation());\r
-               }\r
-               \r
                // URI\r
                if (id.equals(P_ID_URI)) {\r
                        return CdmUtils.Nz(reference.getUri());\r
@@ -868,12 +878,22 @@ public class ReferencePropertySource implements IPropertySource {
         */\r
        public void setPropertyValue(Object id, Object value) {\r
                \r
+               // Search result\r
                if (id.equals(P_ID_SEARCH)) {\r
                        if (value instanceof ReferenceBase) {\r
                                reference = (ReferenceBase) value;\r
                        }\r
                }\r
-               \r
+\r
+               // Protect cache? \r
+               if (id.equals(P_ID_PROTECT_CACHE)) {\r
+                       if (((Integer) value).intValue() == CACHE_PROTECTED) {\r
+                               reference.setProtectedTitleCache(true);\r
+                       } else {\r
+                               reference.setProtectedTitleCache(false);\r
+                       }\r
+               }\r
+                               \r
                // Reference Type\r
                if (id.equals(P_ID_REFERENCETYPE)) {\r
                        \r
@@ -1044,6 +1064,13 @@ public class ReferencePropertySource implements IPropertySource {
 \r
                        }\r
                }\r
+\r
+               // Editable cache\r
+               if (id.equals(P_ID_EDITABLECACHE)) {\r
+                       reference.setTitleCache((String) value);\r
+               } else {\r
+                       reference.setTitleCache(reference.generateTitle(), reference.isProtectedTitleCache());\r
+               }\r
                \r
                propertyChangeSupport.firePropertyChange(ITaxEditorConstants.PROPERTY_SHEET_CHANGE, null, reference);\r
        }\r