p2izing the editor
[taxeditor.git] / eclipseprojects / eu.etaxonomy.taxeditor / src / eu / etaxonomy / taxeditor / TaxEditorPlugin.java
index b9e86b0ac2cef5b75355031514f3256288b032e0..d68bfde517954f782ca638c7731b1cb748481810 100644 (file)
 package eu.etaxonomy.taxeditor;\r
 \r
 import java.net.URL;\r
-import java.util.Collection;\r
 import java.util.HashMap;\r
-import java.util.HashSet;\r
-import java.util.Map;\r
-import java.util.ResourceBundle;\r
+import java.util.Locale;\r
 import java.util.Set;\r
-import java.util.UUID;\r
 \r
 import org.apache.log4j.Logger;\r
-import org.eclipse.core.databinding.observable.Realm;\r
-import org.eclipse.core.databinding.observable.list.WritableList;\r
-import org.eclipse.core.databinding.observable.set.IObservableSet;\r
-import org.eclipse.core.databinding.observable.set.WritableSet;\r
 import org.eclipse.core.runtime.FileLocator;\r
 import org.eclipse.core.runtime.IPath;\r
+import org.eclipse.core.runtime.IStatus;\r
+import org.eclipse.core.runtime.MultiStatus;\r
 import org.eclipse.core.runtime.Path;\r
-import org.eclipse.jface.databinding.swt.SWTObservables;\r
-import org.eclipse.jface.preference.IPreferenceStore;\r
+import org.eclipse.core.runtime.Status;\r
+import org.eclipse.jface.dialogs.ErrorDialog;\r
 import org.eclipse.jface.resource.FontRegistry;\r
 import org.eclipse.jface.resource.ImageDescriptor;\r
 import org.eclipse.jface.resource.ImageRegistry;\r
@@ -37,44 +31,27 @@ import org.eclipse.swt.graphics.Font;
 import org.eclipse.swt.graphics.FontData;\r
 import org.eclipse.swt.graphics.Image;\r
 import org.eclipse.swt.widgets.Display;\r
-import org.eclipse.ui.forms.FormColors;\r
+import org.eclipse.swt.widgets.Tree;\r
 import org.eclipse.ui.plugin.AbstractUIPlugin;\r
+import org.eclipse.ui.views.properties.PropertySheetPage;\r
 import org.osgi.framework.BundleContext;\r
-import org.springframework.transaction.TransactionStatus;\r
 \r
 import eu.etaxonomy.cdm.api.application.CdmApplicationController;\r
-import eu.etaxonomy.cdm.api.service.IDescriptionService;\r
-import eu.etaxonomy.cdm.api.service.INameService;\r
-import eu.etaxonomy.cdm.api.service.ITaxonService;\r
-import eu.etaxonomy.cdm.database.CdmDataSource;\r
 import eu.etaxonomy.cdm.database.DataSourceNotFoundException;\r
 import eu.etaxonomy.cdm.database.DbSchemaValidation;\r
 import eu.etaxonomy.cdm.database.ICdmDataSource;\r
-import eu.etaxonomy.cdm.model.agent.Person;\r
-import eu.etaxonomy.cdm.model.common.Language;\r
-import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;\r
-import eu.etaxonomy.cdm.model.common.TermVocabulary;\r
 import eu.etaxonomy.cdm.model.common.init.TermNotFoundException;\r
-import eu.etaxonomy.cdm.model.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.NomenclaturalStatus;\r
-import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;\r
-import eu.etaxonomy.cdm.model.name.Rank;\r
-import eu.etaxonomy.cdm.model.reference.ReferenceBase;\r
-import eu.etaxonomy.cdm.model.taxon.Taxon;\r
-import eu.etaxonomy.taxeditor.model.CdmUtil;\r
-import eu.etaxonomy.taxeditor.navigation.TaxonomicTreeView;\r
-import eu.etaxonomy.taxeditor.navigation.TaxonomicTreeViewer;\r
-\r
+import eu.etaxonomy.taxeditor.controller.GlobalController;\r
+import eu.etaxonomy.taxeditor.datasource.CdmDataSourceRepository;\r
+import eu.etaxonomy.taxeditor.datasource.CdmTransactionController;\r
+import eu.etaxonomy.taxeditor.model.CdmSessionDataRepository;\r
 /**\r
  * The class controlling the plug-in life cycle.\r
  * </p>\r
  * <ul>\r
  *     <li>Initializes datastore as necessary.</li>\r
+ *     <li>Initializes CDM application controller.</li>\r
  *     <li>Initializes default preferences.</li>\r
- *     <li>Gateway to CDM service layer.</li>\r
- *     <li>Stores taxa for application session.</li>\r
  *     <li>Stores registries for colors, fonts, images.</li>\r
  * </ul>\r
  * \r
@@ -98,133 +75,44 @@ public class TaxEditorPlugin extends AbstractUIPlugin {
 //     private DbSchemaValidation dbSchemaValidation = DbSchemaValidation.VALIDATE;\r
        private DbSchemaValidation dbSchemaValidation = DbSchemaValidation.UPDATE;\r
 \r
-       /**\r
-        * The constructor\r
-        */\r
-       public TaxEditorPlugin() {\r
-               logger.fatal("Fatal");\r
-               logger.error("Error");\r
-               logger.debug("Debug");\r
-               logger.info("Info");\r
-               logger.warn("Warn");\r
-               logger.trace("Trace");\r
-       }\r
-\r
        /*\r
         * (non-Javadoc)\r
         * \r
         * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)\r
         */\r
        public void start(BundleContext context) throws Exception {\r
+               \r
                super.start(context);\r
                plugin = this;\r
+                               \r
+               // Check whether this is the first time the application has ever been run\r
+               checkInitialExecution();\r
                \r
-               boolean initDatastore = false;\r
-\r
-               // If the preferences INITIALIZED has not been set, the IF clause\r
-               // will return false, i.e. datastore will be initialized first\r
-               // time the application is run after being installed.\r
-               boolean initialized = getPreferenceStore()\r
-                               .getBoolean(ITaxEditorConstants.INITIALIZED);\r
+               // Initialize application controller\r
+               initApplicationController();\r
                \r
-//             initialized = false; // to re-init db, uncomment this line\r
-               if (!initialized) {\r
-                       logger.warn("Initializing datastore");\r
-                       initDatastore = true;\r
-\r
-                       getPreferenceStore()\r
-                                       .setValue(ITaxEditorConstants.INITIALIZED, true);\r
-               } else {\r
-                       logger.warn("Datastore already initialized");\r
-               }\r
-\r
-               if (initDatastore) {\r
-                       dbSchemaValidation = DbSchemaValidation.CREATE;\r
-//                     initDatastore();\r
-               }\r
-\r
-               cdmApp = getCdmApp();\r
-\r
-//             if (initDatastore) {\r
-//                     initDatastore();\r
-//             }\r
+               // Start a transaction\r
+               CdmTransactionController.startTransaction();\r
                \r
+               // Forgot what this is ...\r
+               Locale locale = new Locale("en", "", "icbn");\r
+               Locale.setDefault(locale);\r
        }\r
 \r
+       \r
        /*\r
         * (non-Javadoc)\r
         * \r
         * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)\r
         */\r
        public void stop(BundleContext context) throws Exception {\r
-               stopTransaction();\r
+               CdmTransactionController.commitTransaction();\r
                plugin = null;\r
                super.stop(context);\r
                \r
                disposeColors();\r
        }\r
        \r
-       void initDatastore() {\r
-\r
-               boolean useSoraya = true;\r
-               // useSoraya = false;\r
-               Taxon genusTaxon;\r
-               if (useSoraya) {\r
-                       genusTaxon = getSorayasGenusTaxon();\r
-               } else {\r
-\r
-                       BotanicalName botanicalName = BotanicalName.NewInstance(Rank\r
-                                       .GENUS());\r
-                       botanicalName.setTitleCache("Hieracium L.");\r
-                       botanicalName.setGenusOrUninomial("Hieracium");\r
-                       botanicalName.setCombinationAuthorTeam(Person.NewInstance());\r
-                       botanicalName.getCombinationAuthorTeam()\r
-                                       .setNomenclaturalTitle("L.");\r
-                       genusTaxon = Taxon.NewInstance(botanicalName, CdmUtil\r
-                                       .getSessionDefaultSec());\r
-\r
-                       BotanicalName botSpecies = BotanicalName\r
-                                       .NewInstance(Rank.SPECIES());\r
-                       botSpecies.setTitleCache("Hieracium asturianum Pau");\r
-                       botSpecies.setGenusOrUninomial("Hieracium");\r
-                       botSpecies.setSpecificEpithet("asturianum");\r
-                       botSpecies.setCombinationAuthorTeam(Person.NewInstance());\r
-                       botSpecies.getCombinationAuthorTeam().setNomenclaturalTitle("Pau");\r
-                       Taxon childTaxon = Taxon.NewInstance(botSpecies, null);\r
-                       childTaxon.setTaxonomicParent(genusTaxon, null, null);\r
-\r
-                       BotanicalName botSpecies2 = BotanicalName.NewInstance(Rank\r
-                                       .SPECIES());\r
-                       botSpecies2.setTitleCache("Hieracium wolffii Zahn");\r
-                       botSpecies2.setGenusOrUninomial("Hieracium");\r
-                       botSpecies2.setSpecificEpithet("wolffii");\r
-                       botSpecies2.setCombinationAuthorTeam(Person.NewInstance());\r
-                       botSpecies2.getCombinationAuthorTeam()\r
-                                       .setNomenclaturalTitle("Zahn");\r
-                       Taxon childTaxon2 = Taxon.NewInstance(botSpecies2, CdmUtil\r
-                                       .getSessionDefaultSec());\r
-                       // childTaxon2.setName(botSpecies2);\r
-                       // childTaxon2.setSec(null);\r
-                       childTaxon2.setTaxonomicParent(genusTaxon, null, null);\r
-\r
-                       // Add some name relations to botSpecies2\r
-                       botSpecies2.addRelationshipFromName(botSpecies,\r
-                                       NameRelationshipType.BASIONYM(), null);\r
-                       botSpecies2.addRelationshipToName(botSpecies, NameRelationshipType\r
-                                       .REPLACED_SYNONYM(), null);\r
-                       logger.warn("Name relations created");\r
-\r
-                       // Add name status to botSpecies2\r
-                       botSpecies2.addStatus(NomenclaturalStatus\r
-                                       .NewInstance(NomenclaturalStatusType.NOVUM()));\r
-                       logger.warn("Nom. status created");\r
-               }\r
-\r
-               getCdmApp().getTaxonService().saveTaxon(genusTaxon);\r
-\r
-               // System.exit(-1);\r
-       }\r
-\r
        /**\r
         * Returns the shared instance\r
         * \r
@@ -234,105 +122,72 @@ public class TaxEditorPlugin extends AbstractUIPlugin {
                return plugin;\r
        }\r
 \r
-       /***************************************************************************\r
-        * CDM SERVICES\r
-        **************************************************************************/\r
-       /**\r
-        * All CDM services are called via the application controller\r
-        */\r
-       private CdmApplicationController cdmApp;\r
-       private TransactionStatus txStatus;\r
-\r
-       public CdmApplicationController getCdmApp() {\r
-               if (cdmApp == null) {\r
-                       try {\r
-                                ICdmDataSource ds =\r
-                                        CdmDataSource.NewH2EmbeddedInstance("cdm", "sa", "");\r
-//                                      CdmDataSource.NewMySqlInstance("192.168.2.10", "cdm_test_andreasM2", "edit", "wp5");\r
-                                \r
-                                // Is this the problem?\r
-                                cdmApp = CdmApplicationController\r
-                                               .NewInstance(ds, dbSchemaValidation);\r
\r
-                                \r
-//                             cdmApp = CdmApplicationController\r
-//                                             .NewInstance(dbSchemaValidation);\r
-\r
-                               startTransaction();\r
-                                Object txStatus = cdmApp.startTransaction();\r
-                               // cdmApp.commitTransaction((TransactionStatus) txStatus);\r
-\r
-                       } catch (DataSourceNotFoundException e) {\r
-                               // TODO Auto-generated catch block\r
-                               e.printStackTrace();\r
-                       } catch (TermNotFoundException e) {\r
-                               // TODO Auto-generated catch block\r
-                               e.printStackTrace();\r
-                       }\r
-               }\r
-               return cdmApp;\r
-       }\r
-\r
-       public void startTransaction() {\r
-               if (cdmApp != null) {\r
-                       txStatus = cdmApp.startTransaction();\r
-               }\r
-       }\r
-\r
-       public void stopTransaction() {\r
-               if (txStatus != null) {\r
-                       cdmApp.commitTransaction(txStatus);\r
-                       txStatus = null;\r
-               }\r
-       }\r
-\r
-       private ITaxonService taxonService;\r
-\r
-       public ITaxonService getTaxonService() {\r
-               if (taxonService == null) {\r
-                       taxonService = getCdmApp().getTaxonService();\r
+       private void checkInitialExecution() {\r
+               \r
+               // Check in the prefs store whether the application (i.e. its default\r
+               //      data source) has been initialized\r
+               boolean initialized = false;\r
+               if (getPreferenceStore().contains(ITaxEditorConstants.INITIALIZED)) {\r
+                       initialized = getPreferenceStore().getBoolean(\r
+                                       ITaxEditorConstants.INITIALIZED);\r
                }\r
-               return taxonService;\r
-       }\r
        \r
-       private INameService nameService;\r
-\r
-       public INameService getNameService() {\r
-               if (nameService == null) {\r
-                       nameService = getCdmApp().getNameService();\r
+               // If not ...\r
+               if (!initialized) {\r
+                       \r
+                       // ... set validation to CREATE\r
+                       logger.warn("Initializing datastore");\r
+                       dbSchemaValidation = DbSchemaValidation.CREATE;\r
+                       \r
+                       // ... and note in prefs that application has been initialized\r
+                       getPreferenceStore().setValue(ITaxEditorConstants.INITIALIZED, true);\r
                }\r
-               return nameService;\r
        }\r
        \r
-       private IDescriptionService descriptionService;\r
-       \r
-       public IDescriptionService getDescriptionService() {\r
-               if (descriptionService == null) {\r
-                       descriptionService = getCdmApp().getDescriptionService();\r
-               }\r
-               return descriptionService;\r
-               \r
-       }\r
-\r
        /***************************************************************************\r
-        * OBSERVABLE LISTS\r
+        * CDM SERVICES\r
         **************************************************************************/\r
 \r
-       private WritableList observableRecentNamesList = null;\r
-       private WritableList observableFavoritesList = null;\r
+       /**\r
+        * All CDM services are called via the application controller\r
+        */\r
+       private CdmApplicationController applicationController;\r
 \r
-       public WritableList getObservableRecentNamesList() {\r
-               if (observableRecentNamesList == null) {\r
-                       observableRecentNamesList = new WritableList();\r
+       private CdmApplicationController initApplicationController() {\r
+               \r
+               // Get the "current" - i.e. most recently used - data source\r
+               ICdmDataSource cdmDatasource = CdmDataSourceRepository.getDefault().\r
+                               getCurrentDataSource();\r
+               \r
+               // Initialize the controller with the data source\r
+               try {\r
+                       applicationController = CdmApplicationController.NewInstance(cdmDatasource, dbSchemaValidation);\r
+               } catch (DataSourceNotFoundException e) {\r
+                       // TODO user-friendly failure here\r
+                       e.printStackTrace();\r
+               } catch (TermNotFoundException e) {\r
+                       // TODO Auto-generated catch block\r
+                       e.printStackTrace();\r
                }\r
-               return observableRecentNamesList;\r
+               \r
+               // Set application controller for objects that use it \r
+               CdmTransactionController.setApplicationController(applicationController);\r
+               CdmDataSourceRepository.getDefault().setCdmApplicationController(applicationController);\r
+               CdmSessionDataRepository.getDefault().setApplicationController(applicationController);\r
+               \r
+//             // Terms have to be initialized explicitly as of now\r
+//             logger.warn("MAC Workaround enabled!!");\r
+//             DefaultTermInitializer vocabularyStore = new DefaultTermInitializer();\r
+//             vocabularyStore.initialize();\r
+               \r
+               return applicationController;\r
        }\r
-\r
-       public WritableList getObservableFavoritesList() {\r
-               if (observableFavoritesList == null) {\r
-                       observableFavoritesList = new WritableList();\r
+       \r
+       public CdmApplicationController getApplicationController() {\r
+               if (applicationController == null) {\r
+                       throw new IllegalStateException("CdmApplicationController not yet set.");\r
                }\r
-               return observableFavoritesList;\r
+               return applicationController;\r
        }\r
 \r
        /***************************************************************************\r
@@ -346,10 +201,41 @@ public class TaxEditorPlugin extends AbstractUIPlugin {
                return getImageRegistry().get(key);\r
        }\r
 \r
-       // Resource bundle.\r
-       private ResourceBundle resourceBundle;\r
-       private FormColors formColors;\r
+       /**\r
+        * Gets an image for the given URL. Adds the image to the registry as needed.\r
+        * \r
+        * @param url\r
+        * @return\r
+        */\r
+       public Image getImage(URL url) {                \r
+               \r
+               String key = url.toString();\r
+               ImageRegistry registry = getImageRegistry();\r
 \r
+               Image image = registry.get(key);\r
+               \r
+               if (image == null) {\r
+                       ImageDescriptor desc = ImageDescriptor.createFromURL(url);\r
+                       \r
+//                     logger.warn(ImageDescriptor.getMissingImageDescriptor().getClass());\r
+//                     logger.warn(desc.getClass());\r
+//                     \r
+//                     if (ImageDescriptor.getMissingImageDescriptor().equals(desc)) {\r
+//                             logger.warn("img not found");\r
+//                     }\r
+                       \r
+                       registry.put(key, desc);\r
+                       try {\r
+                               image = registry.get(key);\r
+                       } catch (Exception e) {\r
+                               // TODO Auto-generated catch block\r
+                               e.printStackTrace();\r
+                       }\r
+               }\r
+               \r
+               return image;\r
+       }\r
+       \r
        protected void initializeImageRegistry(ImageRegistry registry) {\r
                registerImage(registry, ITaxEditorConstants.EDIT_ICON, "edit_16x16.ico");\r
                registerImage(registry, ITaxEditorConstants.WARNING_ICON,\r
@@ -368,6 +254,8 @@ public class TaxEditorPlugin extends AbstractUIPlugin {
                                "heterosyn_original_no_bg.gif");\r
                registerImage(registry, ITaxEditorConstants.MISAPPLIED_NAME_ICON,\r
                                "misapplied_no_bg.gif");\r
+               registerImage(registry, ITaxEditorConstants.CONCEPT_ICON,\r
+                               "concept_no_bg.gif");\r
                registerImage(registry, ITaxEditorConstants.AUTONYM_ICON,\r
                                "autonym_no_bg.gif");\r
                registerImage(registry, ITaxEditorConstants.BASIONYM_ICON,\r
@@ -390,6 +278,10 @@ public class TaxEditorPlugin extends AbstractUIPlugin {
                                "quick_add.gif");\r
                registerImage(registry, ITaxEditorConstants.TAXON_TO_SYNONYM_ICON,\r
                                "tax_to_syn.gif");\r
+               registerImage(registry, ITaxEditorConstants.ERROR_ANNOTATION_ICON,\r
+                               "error_co.gif");\r
+               registerImage(registry, ITaxEditorConstants.EDIT_BITMAP_ICON,\r
+                               "256color_16x16.bmp");\r
        }\r
 \r
        private void registerImage(ImageRegistry registry, String key,\r
@@ -404,6 +296,7 @@ public class TaxEditorPlugin extends AbstractUIPlugin {
                } catch (Exception e) {\r
                }\r
        }\r
+       \r
 \r
        /***************************************************************************\r
         * FONT REGISTRY\r
@@ -424,10 +317,12 @@ public class TaxEditorPlugin extends AbstractUIPlugin {
                                        new FontData[] { new FontData("Georgia", 10, SWT.NONE) });\r
                        fontRegistry.put(ITaxEditorConstants.MISAPPLIEDNAME_FONT,\r
                                        new FontData[] { new FontData("Georgia", 10, SWT.NONE) });\r
+                       fontRegistry.put(ITaxEditorConstants.CONCEPT_FONT,\r
+                                       new FontData[] { new FontData("Georgia", 10, SWT.NONE) });\r
                        fontRegistry.put(ITaxEditorConstants.CHOOSE_NAME_TEXT_FONT,\r
                                        new FontData[] { new FontData("Arial", 12, SWT.BOLD) });\r
                        fontRegistry.put(ITaxEditorConstants.DEFAULT_PROMPT_FONT,\r
-                                       new FontData[] { new FontData("Georgia", 10, SWT.ITALIC) });\r
+                                       new FontData[] { new FontData("Georgia", 10, SWT.ITALIC) });                    \r
                }\r
                return fontRegistry;\r
        }\r
@@ -436,331 +331,77 @@ public class TaxEditorPlugin extends AbstractUIPlugin {
                return getFontRegistry().get(key);\r
        }\r
 \r
+       /**\r
+        * @param font\r
+        */\r
+       public Font italicizeFont(Font font) {\r
+               FontData fontData = font.getFontData()[0];\r
+               fontData.setStyle(fontData.getStyle() | SWT.ITALIC);\r
+               Font italFont = new Font(Display.getDefault(), fontData);\r
+               \r
+               int i = 0;\r
+               String fontName = "italic";\r
+               Set keySet = fontRegistry.getKeySet();\r
+               while (keySet.contains(fontName + i)) {\r
+                       i++;\r
+               }\r
+               fontRegistry.put(fontName + i, italFont.getFontData());\r
+               \r
+               return italFont;\r
+       }\r
+\r
        /***************************************************************************\r
         * COLOR MAP\r
         **************************************************************************/\r
-       private static HashMap<String, Color> colorMap;\r
+       private static HashMap<String, Color> colorRegistry;\r
        \r
        public Color getColor(String key) {\r
-               return getColorMap().get(key);\r
+               return getColorRegistry().get(key);\r
        }\r
        \r
-       private HashMap<String, Color> getColorMap() {\r
-               if (colorMap == null) {\r
-                        colorMap = new HashMap<String, Color>();\r
+       private HashMap<String, Color> getColorRegistry() {\r
+               if (colorRegistry == null) {\r
+                        colorRegistry = new HashMap<String, Color>();\r
                         \r
-                        colorMap.put(ITaxEditorConstants.GROUP_GRAY_BKG_COLOR,\r
-                                        new Color(null, 246, 246, 246));\r
+                        colorRegistry.put(ITaxEditorConstants.GROUP_GRAY_BKG_COLOR,\r
+                                        new Color(null, 240, 240, 240));\r
+                        colorRegistry.put(ITaxEditorConstants.PROP_SHEET_RED,\r
+                                        new Color(null, 255, 0, 0));                    \r
                }\r
-               return colorMap;\r
+               return colorRegistry;\r
        }\r
        \r
        private void disposeColors() {\r
-               if (colorMap == null) {\r
+               if (colorRegistry == null) {\r
                        return;\r
                }\r
-        for (Color color : colorMap.values()) {\r
+        for (Color color : colorRegistry.values()) {\r
                color.dispose();\r
         }\r
-        colorMap.clear();\r
+        colorRegistry.clear();\r
        }\r
 \r
        /***************************************************************************\r
-        * TAXONOMIC TREE\r
+        * PROPERTY SHEET\r
         **************************************************************************/\r
-\r
-       public ReferenceBase getSec() {\r
-               return getCdmApp().getReferenceService().getReferenceByUuid(\r
-                               UUID.fromString("f3593c18-a8d2-4e51-bdad-0befbf8fb2d1"));\r
-       }\r
-\r
-       private Set<Taxon> sessionRootTaxa;\r
-       /**\r
-        * The taxonomic tree content provider observes this set for changes, and\r
-        * makes the appropriate changes to the tree.\r
-        */\r
-       private IObservableSet observableSessionTaxonSet;\r
-       /**\r
-        * This map of taxa to their taxonomic children is used by\r
-        * NameTreeContentProvider's getChildren method.\r
-        * \r
-        * key = taxon, value = key's child taxa Note that a map can have a key ==\r
-        * null, i.e. no parent taxon\r
-        */\r
-       private HashMap<Taxon, Set<Taxon>> sessionTaxonomicChildrenMap;\r
-\r
-       public Set<Taxon> getSessionRootTaxa() {\r
-               if (sessionRootTaxa == null) {\r
-                       sessionRootTaxa = new HashSet<Taxon>();\r
-                       sessionRootTaxa.addAll(getCdmApp().getTaxonService().getRootTaxa(\r
-                                       getSec(), null, false));\r
-//                     sessionRootTaxa.addAll(getCdmApp().getTaxonService().getRootTaxa(\r
-//                                     getSec(), null, true));                 \r
-                       addSessionTaxa(sessionRootTaxa);\r
-               }\r
-               return sessionRootTaxa;\r
-       }\r
-\r
-       private Map<Taxon, Set<Taxon>> getTaxonomicChildrenMap() {\r
-               if (sessionTaxonomicChildrenMap == null) {\r
-                       sessionTaxonomicChildrenMap = new HashMap<Taxon, Set<Taxon>>();\r
-               }\r
-               return sessionTaxonomicChildrenMap;\r
-       }\r
-\r
-       /**\r
-        * Returns a set of any child taxa for this taxon that have already been\r
-        * requested during this session.\r
-        * \r
-        * @param parentTaxon\r
-        * @return\r
-        */\r
-       public Set<Taxon> getSessionTaxonomicChildren(Taxon parentTaxon) {\r
-               if (!getTaxonomicChildrenMap().containsKey(parentTaxon)) {\r
-                       if (parentTaxon == null) {\r
-                               getTaxonomicChildrenMap().put(parentTaxon, getSessionRootTaxa());\r
-                       } else {\r
-                       \r
-                               // BUG deleted taxon were re-appearing as NULL children\r
-                               Set<Taxon> childTaxa = new HashSet<Taxon>();\r
-                               for (Taxon taxon : parentTaxon.getTaxonomicChildren()) {\r
-                                       if (taxon != null) {\r
-                                               childTaxa.add(taxon);\r
-                                       }\r
-                               }\r
-                               getTaxonomicChildrenMap().put(parentTaxon, childTaxa);\r
-                       }\r
-               }\r
-               return getTaxonomicChildrenMap().get(parentTaxon);\r
-       }\r
-\r
-       /**\r
-        * @return\r
-        */\r
-       public IObservableSet getObservableSessionTaxa() {\r
-               if (observableSessionTaxonSet == null) {\r
-                       Realm realm = SWTObservables.getRealm(Display.getDefault());\r
-                       observableSessionTaxonSet = new WritableSet(realm);\r
-               }\r
-               return observableSessionTaxonSet;\r
-       }\r
-\r
-       /**\r
-        * Recursive function to clear the hashmap of a taxon's children used in\r
-        * this session, and the childrens' children, etc.\r
-        * \r
-        * @param taxon\r
-        */\r
-       private void clearTaxonomicChildren(Taxon taxon) {\r
-               Set<Taxon> children = getSessionTaxonomicChildren(taxon);\r
-               if (children != null) {\r
-                       for (Taxon child : children) {\r
-                               clearTaxonomicChildren(child);\r
-                       }\r
-                       getTaxonomicChildrenMap().remove(taxon);\r
-                       getObservableSessionTaxa().removeAll(children);\r
-               }\r
-       }\r
-\r
-       /**\r
-        * Remove taxon from all session collections\r
-        * \r
-        * @param taxon\r
-        */\r
-       public void removeSessionTaxon(Taxon taxon) {\r
-\r
-               // Recursively remove all children, children's children, etc.\r
-               clearTaxonomicChildren(taxon);\r
-\r
-               Taxon parentTaxon = taxon.getTaxonomicParent();\r
-\r
-               // Remove from parent's child map, or from root taxa\r
-               if (parentTaxon == null) {\r
-                       getSessionRootTaxa().remove(taxon);\r
-               } else {\r
-                       getSessionTaxonomicChildren(parentTaxon).remove(taxon);\r
-               }\r
-\r
-               // Remove from session taxa\r
-               getObservableSessionTaxa().remove(taxon);\r
-               \r
-               UiUtil.getTreeViewer().remove(taxon);\r
-       }\r
-\r
-       public void addSessionTaxa(Collection<Taxon> taxa) {\r
-               for (Taxon taxon : taxa) {\r
-                       addSessionTaxon(taxon);\r
-               }\r
-       }\r
-\r
-       /**\r
-        * Whenever a taxon is opened, either for editing or for display in the\r
-        * taxonomic tree, it should be added to the collections of taxa used during\r
-        * this session.\r
-        * \r
-        * @param taxon\r
-        */\r
-       public void addSessionTaxon(Taxon taxon) {\r
-\r
-               // Add taxon to session taxa if not already there\r
-               if (!(getObservableSessionTaxa().contains(taxon))) {\r
-                       getObservableSessionTaxa().add(taxon);\r
-               }\r
-               \r
-               Taxon parentTaxon = taxon.getTaxonomicParent();\r
-\r
-               // If taxon has no parent, add it to root taxa\r
-               if (parentTaxon == null) {\r
-                       if (!(getSessionRootTaxa().contains(taxon))) {\r
-                               getSessionRootTaxa().add(taxon);\r
-                       }\r
-               }\r
-\r
-               // Add taxon to its parent's child map\r
-               getSessionTaxonomicChildren(parentTaxon).add(taxon);\r
-                               \r
-               TaxonomicTreeViewer viewer = UiUtil.getTreeViewer();\r
-               \r
-               if (viewer != null) {\r
-                       \r
-                       if (parentTaxon == null) {\r
-                               viewer.setInput(getSessionRootTaxa());\r
-                       } else {\r
-                               viewer.add(parentTaxon, taxon);                 \r
-                       }\r
-               \r
-               }\r
-       }\r
-\r
        \r
-//     private TaxonomicTreeView taxonomicTreeView;\r
-//     \r
-//     public void setTaxonomicTree(TaxonomicTreeView taxonomicTreeView) {\r
-//             this.taxonomicTreeView = taxonomicTreeView;\r
-//     }\r
+       private Tree propertySheetTree;\r
        \r
-       /***************************************************************************\r
-        * RANKS\r
-        **************************************************************************/\r
-       OrderedTermVocabulary<Rank> rankVocabulary = null;\r
-\r
-       public OrderedTermVocabulary<Rank> getRankVocabulary() {\r
-               if (rankVocabulary == null) {\r
-                       rankVocabulary = getCdmApp().getNameService().getRankVocabulary();\r
-               }\r
-               return rankVocabulary;\r
+       public void setPropertySheetTree(Tree tree) {\r
+               this.propertySheetTree = tree;\r
        }\r
-\r
-       /***************************************************************************\r
-        * NOMENCLATURAL STATUS\r
-        **************************************************************************/\r
-       TermVocabulary<NomenclaturalStatusType> nomStatusVocabulary = null;\r
-\r
-       public TermVocabulary<NomenclaturalStatusType> getNomStatusVocabulary() {\r
-               if (nomStatusVocabulary == null) {\r
-                       nomStatusVocabulary = getCdmApp().getNameService()\r
-                                       .getStatusTypeVocabulary();\r
-               }\r
-               return nomStatusVocabulary;\r
-       }\r
-\r
-       /***************************************************************************\r
-        * NAME RELATIONS\r
-        **************************************************************************/\r
-       TermVocabulary<NameRelationshipType> nameRelationshipTypeVocabulary = null;\r
-\r
-       public TermVocabulary<NameRelationshipType> getNameRelationshipTypeVocabulary() {\r
-               if (nameRelationshipTypeVocabulary == null) {\r
-                       nameRelationshipTypeVocabulary = getCdmApp().getNameService()\r
-                                       .getNameRelationshipTypeVocabulary();\r
-               }\r
-               return nameRelationshipTypeVocabulary;\r
+       \r
+       public Tree getPropertySheetTree() {\r
+               return propertySheetTree;\r
        }\r
 \r
-       public Set<NameRelationshipType> getSortedNameRelationshipTypes() {\r
-               return getNameRelationshipTypeVocabulary().getTermsOrderedByLabels(\r
-                               Language.DEFAULT());\r
+       private PropertySheetPage propertySheetPage;\r
+       \r
+       public void setPropertySheetPage(PropertySheetPage page) {\r
+               this.propertySheetPage = page;\r
        }\r
-\r
-       /***************************************************************************\r
-        * SORAYA DATA\r
-        **************************************************************************/\r
-       private Taxon getSorayasGenusTaxon() {\r
-\r
-               String[] children = new String[] {\r
-                               "Heterospathe annectens H.E.Moore",\r
-                               "Heterospathe arfakiana (Becc.) H.E.Moore",\r
-                               "Heterospathe brevicaulis Fernando",\r
-                               "Heterospathe cagayanensis Becc.",\r
-                               "Heterospathe califrons Fernando, Palms 45: 118 (2001).",\r
-                               "Heterospathe clemensiae (Burret) H.E.Moore",\r
-                               "Heterospathe delicatula H.E.Moore",\r
-                               "Heterospathe dransfieldii Fernando",\r
-                               "Heterospathe elata Scheff.",\r
-                               "Heterospathe elata var. elata.",\r
-                               "Heterospathe elata var. guamensis Becc.",\r
-                               "Heterospathe elata var. palauensis (Becc.) Becc.",\r
-                               "Heterospathe elegans (Becc.) Becc.",\r
-                               "Heterospathe elmeri Becc.",\r
-                               "Heterospathe glabra (Burret) H.E.Moore",\r
-                               "Heterospathe glauca (Scheff.) H.E.Moore",\r
-                               "Heterospathe humilis Becc.",\r
-                               "Heterospathe intermedia (Becc.) Fernando",\r
-                               "Heterospathe kajewskii Burret",\r
-                               "Heterospathe ledermanniana Becc.",\r
-                               "Heterospathe lepidota H.E.Moore",\r
-                               "Heterospathe longipes (H.E.Moore) Norup",\r
-                               "Heterospathe macgregorii (Becc.) H.E.Moore",\r
-                               "Heterospathe micrantha (Becc.) H.E.Moore",\r
-                               "Heterospathe minor Burret",\r
-                               "Heterospathe muelleriana (Becc.) Becc.",\r
-                               "Heterospathe negrosensis Becc.",\r
-                               "Heterospathe obriensis (Becc.) H.E.Moore",\r
-                               "Heterospathe palauensis Becc.",\r
-                               "Heterospathe parviflora Essig",\r
-                               "Heterospathe philippinensis (Becc.) Becc.",\r
-                               // "Heterospathe phillipsii D.Fuller & Dowe", // <--------------\r
-                               "Heterospathe pilosa (Burret) Burret",\r
-                               "Heterospathe pisifera (Gaertn.) Burret",\r
-                               "Heterospathe pulchra H.E.Moore",\r
-                               "Heterospathe ramulosa Burret",\r
-                               "Heterospathe salomonensis Becc.",\r
-                               "Heterospathe scitula Fernando", "Heterospathe sensisi Becc.",\r
-                               "Heterospathe sibuyanensis Becc.",\r
-                               "Heterospathe sphaerocarpa Burret",\r
-                               "Heterospathe trispatha Fernando",\r
-                               "Heterospathe uniformis Dowe",\r
-                               "Heterospathe versteegiana Becc.",\r
-                               "Heterospathe woodfordiana Becc." };\r
-\r
-               BotanicalName genusName = BotanicalName\r
-                               .PARSED_NAME("Heterospathe Scheff.");\r
-\r
-               Taxon genusTaxon = Taxon.NewInstance(genusName, CdmUtil\r
-                               .getSessionDefaultSec());\r
-\r
-               for (String child : children) {\r
-                       BotanicalName speciesName = BotanicalName.PARSED_NAME(child);\r
-\r
-                       Taxon childTaxon = Taxon.NewInstance(speciesName, CdmUtil\r
-                                       .getSessionDefaultSec());\r
-                       childTaxon.setTaxonomicParent(genusTaxon, null, null);\r
-\r
-                       if (child.equals("Heterospathe elegans (Becc.) Becc.")) {\r
-                               BotanicalName basionym = BotanicalName\r
-                                               .PARSED_NAME("Barkerwebbia elegans Becc.");\r
-                               speciesName.addRelationshipFromName(basionym,\r
-                                               NameRelationshipType.BASIONYM(), null);\r
-                               childTaxon.addHomotypicSynonymName(basionym, null, null);\r
-                       }\r
-\r
-                       if (child.equals("Heterospathe humilis Becc.")) {\r
-                               BotanicalName synonymName = BotanicalName\r
-                                               .PARSED_NAME("Barkerwebbia humilis (Becc.) Becc. ex Martelli");\r
-                               childTaxon.addHomotypicSynonymName(synonymName, null, null);\r
-                       }\r
-               }\r
-\r
-               return genusTaxon;\r
+       \r
+       public PropertySheetPage getPropertySheetPage() {\r
+               return propertySheetPage;\r
        }\r
-}
\ No newline at end of file
+}\r