Version 1.01
authorp.ciardelli <p.ciardelli@localhost>
Thu, 11 Dec 2008 13:05:17 +0000 (13:05 +0000)
committerp.ciardelli <p.ciardelli@localhost>
Thu, 11 Dec 2008 13:05:17 +0000 (13:05 +0000)
.gitattributes
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/ApplicationActionBarAdvisor.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/FreetextPropertiesPerspective.java
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/actions/SaveAllAction.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/io/ImportAction.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/NameComposite.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/NameViewer.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/name/NonViralNamePropertySource.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/name/ScientificNamePropertySource.java [new file with mode: 0644]

index 1c17324462cd6d80b794954754acb3257790cd79..d96a1faa0dfc825acff55d8d87e00832c6ea4f27 100644 (file)
@@ -531,6 +531,7 @@ eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/
 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/name/NameRelationsPropertySource.java -text
 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/name/NomStatusPropertySource.java -text
 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/name/NonViralNamePropertySource.java -text
+eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/name/ScientificNamePropertySource.java -text
 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/name/TaxonBasePropertySource.java -text
 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/name/ZoologicalNamePropertySource.java -text
 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/namerelationswizard/ChooseRelatedNameWizardPage.java -text
index 65110bc34e864cf760afaad4f6e916510878b0b1..c1563d0a324164057d1ca42c7a953ec3cfa6ccb0 100644 (file)
@@ -81,10 +81,10 @@ public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
                
                preferencesAction = ActionFactory.PREFERENCES.create(window);
                
-//             makeImportActions();
+               makeImportActions();
                
-//             exportJaxbAction = new ExportAction(ExportAction.JAXB);
-//             register(exportJaxbAction);
+               exportJaxbAction = new ExportAction(ExportAction.JAXB);
+               register(exportJaxbAction);
        }
 
        private void makeImportActions() {
@@ -105,30 +105,30 @@ public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
                MenuManager fileMenu = new MenuManager("&File",
                                null);
                
-//             // Create submenu for imports
-//             MenuManager importMenu = new MenuManager("Import ...", null);
-//             
-//             // Create submenu for exports
-//             MenuManager exportMenu = new MenuManager("Export as ...", null);
+               // Create submenu for imports
+               MenuManager importMenu = new MenuManager("Import ...", null);
+               
+               // Create submenu for exports
+               MenuManager exportMenu = new MenuManager("Export as ...", null);
 
                // Populate file menu
                menuBar.add(fileMenu);
                fileMenu.add(newNameAction);
                fileMenu.add(saveAction);
                fileMenu.add(undoAction);
-//             fileMenu.add(new Separator());
+               fileMenu.add(new Separator());
 //             fileMenu.add(importMenu);
 //             fileMenu.add(exportMenu);
-               fileMenu.add(new Separator());
+//             fileMenu.add(new Separator());
                fileMenu.add(exitAction);
                
-//             // Populate submenu for imports
-//             for (IAction importAction : importActionList) {
-//                     importMenu.add(importAction);
-//             }
-//
-//             // Populate submenu for exports
-//             exportMenu.add(exportJaxbAction);
+               // Populate submenu for imports
+               for (IAction importAction : importActionList) {
+                       importMenu.add(importAction);
+               }
+
+               // Populate submenu for exports
+               exportMenu.add(exportJaxbAction);
                
                // Populate preferences
                MenuManager preferencesMenu = new MenuManager("&Preferences",
@@ -136,5 +136,4 @@ public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
                menuBar.add(preferencesMenu);
                preferencesMenu.add(preferencesAction);
        }
-
-}
+}
\ No newline at end of file
index 5bc143221fa13524e368f3c2644ff5c67822e97c..b826ac702847178f9bc1289be5d16f9089f99549 100644 (file)
@@ -52,6 +52,7 @@ public class FreetextPropertiesPerspective implements IPerspectiveFactory {
                
                IFolderLayout folderLayoutRight = layout.createFolder("rightfolder", IPageLayout.RIGHT, 0.5f, editorArea);              
                folderLayoutRight.addView(IPageLayout.ID_PROP_SHEET);
+//             folderLayoutRight.addView(IPageLayout.ID_PROBLEM_VIEW);
                
                layout.getViewLayout(IPageLayout.ID_PROP_SHEET).setCloseable(false);
                layout.getViewLayout(IPageLayout.ID_PROP_SHEET);
index 39e7ef12d5958d08ec27d419bfda82dbe0869f08..913a1dda018a7f49ece40437d20c3060273e99cd 100644 (file)
@@ -306,7 +306,7 @@ public class TaxEditorPlugin extends AbstractUIPlugin {
                        list.add(NomenclaturalStatusType.VALID());\r
                        for (NomenclaturalStatusType status : list){\r
                                cdmApp.getTermService().saveTerm(status);\r
-                               logger.warn(status.getRepresentations().size());\r
+//                             logger.warn(status.getRepresentations().size());\r
                        }\r
                }\r
        }\r
index 4da3f6426fa2fb2dd3a80418e788ea5273659856..1028472f298c31ea0558a9bfb75e722a8be770e9 100644 (file)
@@ -434,6 +434,16 @@ public class UiUtil {
                                return type1.getLabel();\r
                        }\r
                }\r
-               return "joemama";\r
+               return "";\r
        }\r
+\r
+       static boolean isSaving = false;\r
+\r
+       public static void setIsSaving(boolean isSavin) {\r
+               isSaving = isSavin;\r
+       }\r
+       \r
+       public static boolean getIsSaving() {\r
+               return isSaving;\r
+       }       \r
 }
\ No newline at end of file
index 89bbc1abc215844c9dec84eafe4073cd537c4127..3c18aab3915e053e39c7f1e6d98b07251ddc2fea 100644 (file)
@@ -52,8 +52,8 @@ public class SaveAllAction implements IWorkbenchWindowActionDelegate {
         * @see IWorkbenchWindowActionDelegate#run
         */
        public void run(IAction action) {
-               
-               TaxEditorPlugin.getDefault();
+
+               UiUtil.setIsSaving(true);
                
                // Get all open windows
                for (IEditorPart taxonEditor : UiUtil.getOpenTaxonEditors()) {
@@ -62,7 +62,7 @@ public class SaveAllAction implements IWorkbenchWindowActionDelegate {
                        if (taxonEditor.isDirty()) {
                                IEditorInput input = taxonEditor.getEditorInput();
                                if (input.getAdapter(Taxon.class) != null) {
-                                       Taxon taxon = (Taxon) input.getAdapter(Taxon.class); // Already trunc'ed
+                                       Taxon taxon = (Taxon) input.getAdapter(Taxon.class);
                                        new SaveTaxonAction(taxon).run();
                                        if (taxonEditor instanceof MultiPageTaxonEditor) {
                                                ((MultiPageTaxonEditor) taxonEditor).setDirtyExtern(false);
@@ -84,6 +84,8 @@ public class SaveAllAction implements IWorkbenchWindowActionDelegate {
                for (Object taxon : TaxEditorPlugin.getDefault().getObservableSessionTaxa()) {
                        CdmUtil.getTaxonService().saveTaxon((Taxon) taxon);
                }
+
+               UiUtil.setIsSaving(false);
        }
 
        /**
index febd4b569268161703e293ea5b953e6ae4b3c266..fcf5ce7b8a2cec8ee0e744fd51063f59bae6057e 100644 (file)
@@ -18,6 +18,7 @@ import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.resource.ImageDescriptor;\r
 import org.eclipse.swt.widgets.FileDialog;\r
 \r
+import eu.etaxonomy.cdm.api.application.CdmApplicationController;\r
 import eu.etaxonomy.cdm.database.ICdmDataSource;\r
 import eu.etaxonomy.cdm.io.common.ImportWrapper;\r
 import eu.etaxonomy.taxeditor.TaxEditorPlugin;\r
@@ -70,14 +71,18 @@ public class ImportAction extends Action {
                String filePath = dialog.open();\r
                file = new File(filePath);\r
                                \r
+               // Get plugin application controller\r
+               CdmApplicationController cdmapp = TaxEditorPlugin.getDefault().getCdmApp();\r
+               \r
                // Get current data source\r
                ICdmDataSource destination = TaxEditorPlugin.getDefault().getCdmDataSource();\r
                \r
                // Format file path \r
                String source = null;\r
                try {\r
-                       source = file.toURI().toURL().toString();\r
-               } catch (MalformedURLException e) {\r
+                       //source = file.toURI().toURL().toString();\r
+                       source = file.toString();\r
+               } catch (/*MalformedURL*/Exception e) {\r
                        MessageDialog.openError(UiUtil.getShell(), title, "File could not be read.");\r
                        return;\r
                }\r
@@ -88,6 +93,7 @@ public class ImportAction extends Action {
                // Tell user whether import was a success or a dismal failure\r
                if (isSuccessfulImport) {\r
                        MessageDialog.openInformation(UiUtil.getShell(), title, "Import successful");\r
+                       UiUtil.getTreeViewer().refresh();\r
                } else {\r
                        MessageDialog.openError(UiUtil.getShell(), title, "Import was unsuccessful.");\r
                }\r
index cc12403bc05dbfd67cf5ecfce4ee5fe70b3308d4..d64ae397df0bc9a09dc1913cb4cb463aafe59e29 100644 (file)
@@ -195,6 +195,10 @@ public class NameComposite extends EditorGroupedComposite {
                                        return;\r
                                }\r
                                \r
+                               if (UiUtil.getIsSaving()) {\r
+                                       return;\r
+                               }\r
+                               \r
                                deactivateParser();\r
                                ((NameViewer) getTextViewer()).setText(name.getFullTitleCache());\r
                                activateParser();\r
@@ -205,7 +209,7 @@ public class NameComposite extends EditorGroupedComposite {
                name.addPropertyChangeListener("fullTitleCache", listener);\r
                name.addPropertyChangeListener("nomenclaturalMicroReference", listener);\r
 \r
-               name.addPropertyChangeListener(ITaxEditorConstants.REFRESH_NAMEVIEWER, listener);\r
+//             name.addPropertyChangeListener(ITaxEditorConstants.REFRESH_NAMEVIEWER, listener);\r
                \r
                StrictReferenceBase reference = (StrictReferenceBase) name.getNomenclaturalReference();\r
                if (reference != null) {\r
index 29d77dbd70ec511bc0410a06bd37bbe827b9c05f..efe49097c8d6c59c4b0711f05185b6ce07f98748 100644 (file)
@@ -13,7 +13,12 @@ import java.util.Iterator;
 \r
 import org.apache.log4j.Logger;\r
 import org.eclipse.core.commands.operations.IUndoContext;\r
+import org.eclipse.core.resources.IMarker;\r
+import org.eclipse.core.resources.IWorkspaceRunnable;\r
+import org.eclipse.core.resources.ResourcesPlugin;\r
 import org.eclipse.core.runtime.Assert;\r
+import org.eclipse.core.runtime.CoreException;\r
+import org.eclipse.core.runtime.IProgressMonitor;\r
 import org.eclipse.jface.text.Document;\r
 import org.eclipse.jface.text.ILineTracker;\r
 import org.eclipse.jface.text.IUndoManager;\r
@@ -21,12 +26,8 @@ import org.eclipse.jface.text.IUndoManagerExtension;
 import org.eclipse.jface.text.Position;\r
 import org.eclipse.jface.text.TextViewerUndoManager;\r
 import org.eclipse.jface.text.source.Annotation;\r
-import org.eclipse.jface.text.source.AnnotationBarHoverManager;\r
 import org.eclipse.jface.text.source.AnnotationModel;\r
 import org.eclipse.jface.text.source.AnnotationPainter;\r
-import org.eclipse.jface.text.source.AnnotationRulerColumn;\r
-import org.eclipse.jface.text.source.CompositeRuler;\r
-import org.eclipse.jface.text.source.DefaultAnnotationHover;\r
 import org.eclipse.jface.text.source.IAnnotationAccess;\r
 import org.eclipse.jface.text.source.SourceViewer;\r
 import org.eclipse.swt.SWT;\r
@@ -138,7 +139,6 @@ public class NameViewer extends SourceViewer {
                        this.getAnnotationModel().addAnnotation(\r
                                        new ErrorAnnotation(0, text), \r
                                        new Position(0, text.length()));                                \r
-                       \r
                }\r
        }\r
 \r
@@ -183,7 +183,27 @@ public class NameViewer extends SourceViewer {
                        \r
                        this.getAnnotationModel().addAnnotation(\r
                                        new ErrorAnnotation(0, text), \r
-                                       new Position(start, length));                                           \r
+                                       new Position(start, length));\r
+                       \r
+                       // Successful test of markers which show up in ProblemView \r
+//                     try {\r
+//                             IWorkspaceRunnable editorMarker = new IWorkspaceRunnable() {\r
+//                                     public void run(IProgressMonitor monitor) throws CoreException { \r
+//                                             IMarker marker = ResourcesPlugin.getWorkspace().getRoot().createMarker(IMarker.PROBLEM);\r
+//                                             marker.setAttribute(IMarker.MESSAGE, "Testeroo");\r
+//                                             marker.setAttribute(IMarker.PRIORITY, IMarker.PRIORITY_HIGH);\r
+//                                             marker.setAttribute(IMarker.LINE_NUMBER, 1);\r
+//                                             marker.setAttribute(IMarker.TRANSIENT, false);\r
+//                                             marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);                                          \r
+//                                     }\r
+//                             };\r
+//                             ResourcesPlugin.getWorkspace().run(editorMarker, null); \r
+//                             \r
+//                     } catch (CoreException e) {\r
+//                             // TODO Auto-generated catch block\r
+//                             e.printStackTrace();\r
+//                     }\r
+                       \r
                }\r
        }\r
        \r
index a489a1f6dc97ab33b065000a4199456fb3bf39d4..ace6784c780ba28c5cc829af447ccdc1e0eaaf78 100644 (file)
@@ -26,7 +26,6 @@ import org.eclipse.ui.views.properties.PropertyDescriptor;
 import org.eclipse.ui.views.properties.TextPropertyDescriptor;\r
 \r
 import eu.etaxonomy.cdm.common.CdmUtils;\r
-import eu.etaxonomy.cdm.model.common.Annotation;\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
@@ -65,13 +64,7 @@ public class NonViralNamePropertySource implements IPropertySource {
        public static final String P_ID_PARSED = "parsed";\r
        public static final String P_ID_RANK = "rank";\r
        public static final String P_ID_TITLECACHE = "titlecache";\r
-       public static final String P_ID_UNINOMIAL = "uninomial";\r
-       public static final String P_ID_INFRAGENERICEP = "infragenericep";\r
-       public static final String P_ID_SPECIESEP = "speciesep";\r
-       public static final String P_ID_INFRASPECIFICEP = "infraspecificep";\r
-       public static final String P_ID_APPENDEDPHRASE = "appendedphrase";\r
        public static final String P_ID_HOMOTYPICALGROUP = "homogroup";\r
-       public static final String P_ID_AUTHORSHIPCACHE = "authorshipcache";\r
        public static final String P_ID_NAMERELATIONS = "namerelations";\r
        public static final String P_ID_TYPE = "type";\r
        public static final String P_ID_ANNOTATIONS = "annotations";\r
@@ -91,13 +84,7 @@ public class NonViralNamePropertySource implements IPropertySource {
        public static final String P_PARSED = "00:Parsing Status";\r
        public static final String P_RANK = "02:Rank";\r
        public static final String P_TITLECACHE = "03:Name Cache";\r
-       public static final String P_UNINOMIAL = "04:Uninomial";\r
-       public static final String P_INFRAGENERICEP = "05:Infrageneric Epithet";\r
-       public static final String P_SPECIESEP = "06:Specific Epithet";\r
-       public static final String P_INFRASPECIFICEP = "07:Infraspecific Epithet";\r
-       public static final String P_APPENDEDPHRASE = "09:Appended Phrase";\r
        public static final String P_HOMOTYPICALGROUP = "09:Homotypical Group";\r
-       public static final String P_AUTHORSHIPCACHE = "08:Authorship";\r
        public static final String P_NAMERELATIONS = "11:Name Relations";\r
        public static final String P_TYPE = "12:Type";\r
        public static final String P_ANNOTATIONS = "14:Annotations";\r
@@ -221,43 +208,7 @@ public class NonViralNamePropertySource implements IPropertySource {
                        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
+                               \r
                // Homotypical group\r
                if (id.equals(P_ID_HOMOTYPICALGROUP)) {\r
                        descriptors.addElement(\r
@@ -402,44 +353,25 @@ public class NonViralNamePropertySource implements IPropertySource {
         if (id.equals(P_ID_TITLECACHE)) {\r
                \r
                // If the name has not been parsed, only show the title cache\r
-//             if (name.getHasProblem()) {\r
                if (name.getRank() == null) {\r
                        return CdmUtils.Nz(name.getTitleCache());\r
                } else {\r
-                       return new NonViralNamePropertySource(name, P_ID_TITLECACHE, getNameFields());\r
+                       \r
+                       // Create property source for submenu\r
+                       ScientificNamePropertySource nameFieldsPropertySource = new ScientificNamePropertySource(name);\r
+                       \r
+                       // Add listener to notify name of all changes to nom. reference\r
+                       nameFieldsPropertySource.addPropertyChangeListener(new PropertyChangeListener() {\r
+                               public void propertyChange(PropertyChangeEvent evt) {\r
+//                                     if (evt.getNewValue() instanceof INomenclaturalReference) {\r
+//                                             name.setNomenclaturalReference((INomenclaturalReference) evt.getNewValue());\r
+//                                     }\r
+                               }\r
+                       });\r
+                       return nameFieldsPropertySource;\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
+                \r
                // Homotypical group        \r
         if (id.equals(P_ID_HOMOTYPICALGROUP)) {\r
                        return CdmUtils.Nz(name.getHomotypicalGroup().getUuid().toString());\r
@@ -550,39 +482,6 @@ public class NonViralNamePropertySource implements IPropertySource {
         return null;\r
        }\r
  \r
-       /**\r
-        * The fields displayed under the title cache are dependent on rank.\r
-        * \r
-        * @return\r
-        */\r
-       private String[] getNameFields() {\r
-               \r
-               // An unparsed name has no name fields, only a cache. \r
-               //      Therefore, if rank is null, the name is unparsed.\r
-               if (name.getRank() == null) {\r
-                       return null;\r
-               }\r
-               \r
-       List<String> nameFields = new ArrayList<String>();\r
-       nameFields.add(P_ID_UNINOMIAL);\r
-       if (name.isSupraGeneric() || name.isGenus()) { // Rank is higher than GENUS or equals GENUS\r
-       }\r
-       else if (name.isInfraGeneric()) { // lower than GENUS and higher than SPECIES\r
-               nameFields.add(P_ID_INFRAGENERICEP);\r
-       }   \r
-       else if (name.isSpecies()) { // Rank equals SPECIES\r
-               nameFields.add(P_ID_SPECIESEP);\r
-       }\r
-       else if (name.isInfraSpecific()) { // Rank is lower than SPECIES\r
-               nameFields.add(P_ID_SPECIESEP);\r
-               nameFields.add(P_ID_INFRASPECIFICEP);\r
-       } else {\r
-               nameFields.add(P_ID_SPECIESEP);\r
-       }\r
-       nameFields.add(P_ID_AUTHORSHIPCACHE);\r
-       nameFields.add(P_ID_APPENDEDPHRASE);\r
-       return nameFields.toArray(new String[nameFields.size()]);\r
-       }\r
        \r
        private Object formatDate(Date date) {\r
                return String.format("%1$tm-%1$td-%1$tY %1$tH:%1$tM:%1$tS", date);\r
@@ -611,38 +510,7 @@ public class NonViralNamePropertySource implements IPropertySource {
                        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.setProtectedAuthorshipCache(true);\r
-                       name.setAuthorshipCache((String) value);\r
-        }\r
-        \r
+                       \r
                // Nomenclatural status        \r
         if (id.equals(P_ID_NOMSTATUS)) {\r
                NomenclaturalStatus nomStatus;\r
@@ -689,7 +557,7 @@ public class NonViralNamePropertySource implements IPropertySource {
                        name.setFullTitleCache(name.generateFullTitle(), false);\r
         }\r
                \r
-               name.firePropertyChange(ITaxEditorConstants.REFRESH_NAMEVIEWER, null, null);\r
+//             name.firePropertyChange(ITaxEditorConstants.REFRESH_NAMEVIEWER, null, null);\r
                \r
        }\r
 \r
diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/name/ScientificNamePropertySource.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/name/ScientificNamePropertySource.java
new file mode 100644 (file)
index 0000000..80e8d17
--- /dev/null
@@ -0,0 +1,329 @@
+/**\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.propertysheet.name;\r
+\r
+import java.beans.PropertyChangeListener;\r
+import java.beans.PropertyChangeSupport;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+import java.util.Vector;\r
+\r
+import org.apache.log4j.Logger;\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
+import org.eclipse.ui.views.properties.PropertyDescriptor;\r
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;\r
+\r
+import eu.etaxonomy.cdm.common.CdmUtils;\r
+import eu.etaxonomy.cdm.model.name.NonViralName;\r
+import eu.etaxonomy.taxeditor.ITaxEditorConstants;\r
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;\r
+\r
+/**\r
+ * @author p.ciardelli\r
+ * @created 03.11.2008\r
+ * @version 1.0\r
+ */\r
+public class ScientificNamePropertySource implements IPropertySource {\r
+       private static final Logger logger = Logger\r
+                       .getLogger(ScientificNamePropertySource.class);\r
+\r
+       NonViralName name;\r
+       \r
+    // Property unique keys\r
+       public static final String P_ID_SEARCH = "P_ID_SEARCH";\r
+       public static final String P_ID_EDITABLECACHE = "P_ID_EDITABLECACHE";   \r
+       public static final String P_ID_UNINOMIAL = "P_ID_UNINOMIAL";\r
+       public static final String P_ID_INFRAGENERICEP = "P_ID_INFRAGENERICEP";\r
+       public static final String P_ID_INFRASPECIFICEP = "P_ID_INFRASPECIFICEP";\r
+       public static final String P_ID_SPECIESEP = "P_ID_SPECIESEP";\r
+       public static final String P_ID_PROTECT_CACHE = "P_ID_PROTECT_CACHE";\r
+       public static final String P_ID_APPENDEDPHRASE = "P_ID_APPENDEDPHRASE";\r
+       public static final String P_ID_AUTHORSHIPCACHE = "P_ID_AUTHORSHIPCACHE";\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_UNINOMIAL = "04:Uninomial";\r
+       public static final String P_INFRAGENERICEP = "05:Infrageneric Epithet";\r
+       public static final String P_INFRASPECIFICEP = "07:Infraspecific Epithet";\r
+       public static final String P_SPECIESEP = "06:Specific Epithet";\r
+       public static final String P_AUTHORSHIPCACHE = "08:Authorship";\r
+       public static final String P_APPENDEDPHRASE = "09:Appended Phrase";\r
+               \r
+       private static final int CACHE_NOT_PROTECTED = 0;\r
+       private static final int CACHE_PROTECTED = 1;   \r
+                       \r
+       public ScientificNamePropertySource(NonViralName name) {\r
+               \r
+               // Default type of ReferenceBase is Generic\r
+               if (name == null) {\r
+                       name = PreferencesUtil.getInstanceOfPreferredNameClass();\r
+               }               \r
+               this.name = name;\r
+\r
+               initDescriptors();\r
+       }\r
+\r
+       protected void initDescriptors() {\r
+               \r
+               List<String> displayFields = new ArrayList<String>();\r
+                       \r
+               // Cache fields\r
+//             displayFields.add(P_ID_SEARCH);\r
+//             displayFields.add(P_ID_EDITABLECACHE);\r
+//             displayFields.add(P_ID_PROTECT_CACHE);\r
+               \r
+               // Uninomial\r
+       displayFields.add(P_ID_UNINOMIAL);\r
+       \r
+       if (name.isSupraGeneric() || name.isGenus()) { // Rank is higher than GENUS or equals GENUS\r
+       }\r
+       else if (name.isInfraGeneric()) { // lower than GENUS and higher than SPECIES\r
+               displayFields.add(P_ID_INFRAGENERICEP);\r
+       }   \r
+       else if (name.isSpecies()) { // Rank equals SPECIES\r
+               displayFields.add(P_ID_SPECIESEP);\r
+       }\r
+       else if (name.isInfraSpecific()) { // Rank is lower than SPECIES\r
+               displayFields.add(P_ID_SPECIESEP);\r
+               displayFields.add(P_ID_INFRASPECIFICEP);\r
+       } else {\r
+               displayFields.add(P_ID_SPECIESEP);\r
+       }\r
+       displayFields.add(P_ID_AUTHORSHIPCACHE);\r
+       displayFields.add(P_ID_APPENDEDPHRASE);\r
+    \r
+               \r
+               for (String field : displayFields) {\r
+                       addDescriptor(field);\r
+               }\r
+       }\r
+\r
+       protected Vector<PropertyDescriptor> descriptors = new Vector<PropertyDescriptor>();\r
+       \r
+       protected void addDescriptor(String id) {\r
+               \r
+               // Reference search\r
+               if (id.equals(P_ID_SEARCH)) {\r
+//                     descriptors.addElement(\r
+//                                     new ReferenceSearchDescriptor(P_ID_SEARCH, P_SEARCH, getSearchType()) {\r
+//                                             protected void saveReference(ReferenceBase reference) {\r
+//                                                     setPropertyValue(P_ID_SEARCH, reference);\r
+//                                             }\r
+//                     });\r
+               }\r
+               \r
+               // Editable cache\r
+               if (id.equals(P_ID_EDITABLECACHE)) {\r
+                       descriptors.addElement(\r
+                                       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
+               // 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
+\r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()\r
+        */\r
+       public Object getEditableValue() {\r
+               return CdmUtils.Nz(name.getTitleCache());\r
+       }\r
+\r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()\r
+        */\r
+       public IPropertyDescriptor[] getPropertyDescriptors() {\r
+               return (IPropertyDescriptor[]) descriptors.toArray(\r
+                new IPropertyDescriptor[descriptors.size()]);\r
+       }\r
+\r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)\r
+        */\r
+       public Object getPropertyValue(Object id) {\r
+                               \r
+               // Editable cache\r
+               if (id.equals(P_ID_EDITABLECACHE)) {\r
+                       return (CdmUtils.Nz(name.getTitleCache()));\r
+               }\r
+               \r
+               // Protect cache?\r
+               if (id.equals(P_ID_PROTECT_CACHE)) {\r
+                       if (name.isProtectedTitleCache()) {\r
+                               return CACHE_PROTECTED;\r
+                       } else {\r
+                               return CACHE_NOT_PROTECTED;\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
+\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
+               return "";\r
+       }\r
+\r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)\r
+        */\r
+       public boolean isPropertySet(Object id) {\r
+               return false;\r
+       }\r
+\r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)\r
+        */\r
+       public void resetPropertyValue(Object id) {}\r
+\r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)\r
+        */\r
+       public void setPropertyValue(Object id, Object value) {\r
+               \r
+               // Search result\r
+               if (id.equals(P_ID_SEARCH)) {\r
+                       if (value instanceof NonViralName) {\r
+                               name = (NonViralName) value;\r
+                       }\r
+               }\r
+\r
+               // Protect cache? \r
+               if (id.equals(P_ID_PROTECT_CACHE)) {\r
+                       if (((Integer) value).intValue() == CACHE_PROTECTED) {\r
+                               name.setProtectedTitleCache(true);\r
+                       } else {\r
+                               name.setProtectedTitleCache(false);\r
+                       }\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.setProtectedAuthorshipCache(true);\r
+                       name.setAuthorshipCache((String) value);\r
+        }\r
+        \r
+               // Editable cache\r
+               if (id.equals(P_ID_EDITABLECACHE)) {\r
+                       name.setTitleCache((String) value);\r
+               } else {\r
+                       name.setTitleCache(name.generateTitle(), name.isProtectedTitleCache());\r
+               }\r
+               \r
+               propertyChangeSupport.firePropertyChange(ITaxEditorConstants.PROPERTY_SHEET_CHANGE, null, name);\r
+       }\r
+       \r
+\r
+       public String toString() {\r
+               return CdmUtils.Nz(name.getTitleCache());\r
+       }\r
+\r
+       private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);\r
+       \r
+       public void addPropertyChangeListener(\r
+                       PropertyChangeListener listener) {\r
+               propertyChangeSupport.addPropertyChangeListener(listener);\r
+       }\r
+}
\ No newline at end of file