added a new wizard to create new taxon nodes
authorn.hoffmann <n.hoffmann@localhost>
Wed, 23 Sep 2009 09:15:10 +0000 (09:15 +0000)
committern.hoffmann <n.hoffmann@localhost>
Wed, 23 Sep 2009 09:15:10 +0000 (09:15 +0000)
14 files changed:
.gitattributes
taxeditor-navigation/plugin.xml
taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/MoveTaxonHandler.java
taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/NewTaxonNodeHandler.java [new file with mode: 0644]
taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/NewTaxonomicTreeHandler.java [new file with mode: 0644]
taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/QuickCreateChildTaxonHandler.java
taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/Root.java
taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNavigator.java
taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/search/SearchBar.java
taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/search/SearchResultView.java
taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/newWizards/NewTaxonNodeWizard.java [new file with mode: 0644]
taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/newWizards/NewTaxonNodeWizardPage.java [new file with mode: 0644]
taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/newWizards/NewTaxonomicTreeWizard.java [moved from taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/NewTaxonomicTreeWizard.java with 91% similarity]
taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/newWizards/NewTaxonomicTreeWizardPage.java [new file with mode: 0644]

index 810dbc90e86646b614b009222a1dcbca361938e0..8015bf1c8bc23295150b3bea794dfc88ae5e4e91 100644 (file)
@@ -905,7 +905,8 @@ taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/Cre
 taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/DeleteTaxonNodeHandler.java -text
 taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/EditTaxonHandler.java -text
 taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/MoveTaxonHandler.java -text
-taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/NewTaxonomicTreeWizard.java -text
+taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/NewTaxonNodeHandler.java -text
+taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/NewTaxonomicTreeHandler.java -text
 taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/NewTaxonomicTreeWizardPage.java -text
 taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/QuickCreateChildTaxonHandler.java -text
 taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/RefreshTreeHandler.java -text
@@ -927,6 +928,10 @@ taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/T
 taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/search/SearchBar.java -text
 taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/search/SearchResultLabelProvider.java -text
 taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/search/SearchResultView.java -text
+taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/newWizards/NewTaxonNodeWizard.java -text
+taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/newWizards/NewTaxonNodeWizardPage.java -text
+taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/newWizards/NewTaxonomicTreeWizard.java -text
+taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/newWizards/NewTaxonomicTreeWizardPage.java -text
 taxeditor-navigation/src/main/java/log4j.properties -text
 taxeditor-navigation/src/test/java/eu/etaxonomy/taxeditor/navigation/Application.java -text
 taxeditor-navigation/src/test/java/eu/etaxonomy/taxeditor/navigation/ApplicationActionBarAdvisor.java -text
index 0c643de536f1d6efbda0243c5dce13f1d6757efb..f5d3a6f0dcc9a661fc8d0b7cbf098f4d8f70f301 100644 (file)
    <extension
          point="org.eclipse.ui.menus">
       <menuContribution
-            locationURI="popup:eu.etaxonomy.taxeditor.navigation.search.searchResultView">
-         <command
-               commandId="eu.etaxonomy.taxeditor.navigation.command.editTaxon"
-               label="Edit"
-               style="push">
-         </command>
-      </menuContribution>
-      <menuContribution
-            locationURI="toolbar:org.eclipse.ui.main.toolbar">
-         <toolbar
-               id="eu.etaxonomy.taxeditor.navigation.search.toolbar">
-            <control
-                  class="eu.etaxonomy.taxeditor.navigation.search.SearchBar">
-            </control>
-         </toolbar>
-      </menuContribution>
-      <menuContribution
-            locationURI="menu:org.eclipse.ui.main.menu.file?before=eu.etaxonomy.taxeditor.application.filemenu.separator">
+            locationURI="menu:org.eclipse.ui.main.menu.file">
          <separator
-               name="eu.etaxonomy.taxeditor.navigation.separator"
+               name="eu.etaxonomy.taxeditor.navigation.recentnames.separator"
                visible="true">
          </separator>
          <dynamic
                commandId="eu.etaxonomy.taxeditor.navigation.command.showTaxonomicTreeView"
                label="Taxonomic Tree"
                style="push">
-         </command>         
+         </command>
       </menuContribution>
       <menuContribution
-            locationURI="popup:eu.etaxonomy.taxeditor.navigation.navigatorpopup">
+            locationURI="popup:eu.etaxonomy.taxeditor.navigation.search.searchResultView">
          <command
-               commandId="org.eclipse.ui.newWizard"
-               label="New"
+               commandId="eu.etaxonomy.taxeditor.navigation.command.editTaxon"
+               label="Edit"
                style="push">
          </command>
+      </menuContribution>
+      <menuContribution
+            locationURI="popup:eu.etaxonomy.taxeditor.navigation.navigatorpopup">
+         <menu
+               id="eu.etaxonomy.navigation.menu.new"
+               label="New">
+            <command
+                  commandId="eu.etaxonomy.taxeditor.navigation.newTaxonNode"
+                  label="Taxon Node"
+                  style="push">
+            </command>
+            <separator
+                  name="eu.etaxonomy.navigation.menu.new.separator1"
+                  visible="true">
+            </separator>
+            <command
+                  commandId="eu.etaxonomy.taxeditor.navigation.newTaxonomicTree"
+                  id="eu.etaxonomy.taxeditor.navigation.menu.nu.new.taxonomicTree"
+                  label="Taxonomic Tree"
+                  style="push">
+            </command>
+         </menu>
          <separator
                name="taxeditor-navigation.separator1"
                visible="true">
          <command
                commandId="eu.etaxonomy.taxeditor.navigation.command.editTaxon"
                label="Edit"
-               style="push">
+               style="push">       
+            <separator
+                  name="taxeditor-navigation.separator4">
+            </separator>    
             <visibleWhen>
                <reference
                      definitionId="isTaxonNode">
          </command>
          <command
                commandId="eu.etaxonomy.taxeditor.navigation.command.moveTaxon"
-               label="Move Taxon"
+               label="Move Taxon (with Subtree)"
                style="push">
             <visibleWhen>
                <reference
                style="push">
          </command>
       </menuContribution>
+      <menuContribution
+            locationURI="toolbar:org.eclipse.ui.main.toolbar">
+         <toolbar
+               id="eu.etaxonomy.taxeditor.navigation.search.toolbar">
+            <control
+                  class="eu.etaxonomy.taxeditor.navigation.search.SearchBar">
+            </control>
+         </toolbar>
+      </menuContribution>
+      <menuContribution
+            locationURI="menu:eu.etaxonomy.navigation.menu.new">
+         <command
+               commandId="eu.etaxonomy.taxeditor.navigation.newTaxonNode"
+               label="Taxon Node"
+               style="push">
+         </command>
+         <separator
+               name="eu.etaxonomy.navigation.menu.new.separator1"
+               visible="true">
+         </separator>
+         <command
+               commandId="eu.etaxonomy.taxeditor.navigation.newTaxonomicTree"
+               id="eu.etaxonomy.taxeditor.navigation.menu.nu.new.taxonomicTree"
+               label="Taxonomic Tree"
+               style="push">
+         </command>
+      </menuContribution>
    </extension>
    <extension
          point="org.eclipse.ui.commands">
             name="Show Taxonomic Tree View">
       </command>
    </extension>
+   <extension
+         point="org.eclipse.ui.commands">
+      <command
+            defaultHandler="eu.etaxonomy.taxeditor.navigation.handler.NewTaxonNodeHandler"
+            id="eu.etaxonomy.taxeditor.navigation.newTaxonNode"
+            name="New Taxon Node">
+      </command>
+      <command
+            defaultHandler="eu.etaxonomy.taxeditor.navigation.handler.NewTaxonomicTreeHandler"
+            id="eu.etaxonomy.taxeditor.navigation.newTaxonomicTree"
+            name="New Taxonomic Tree">
+      </command>
+   </extension>
 
       <extension
          point="org.eclipse.ui.themes">
       </primaryWizard-->
       <wizard
             category="eu.etaxonomy.taxeditor.new.category.cdm"
-            class="eu.etaxonomy.taxeditor.navigation.handler.NewTaxonomicTreeWizard"
+            class="eu.etaxonomy.taxeditor.newWizards.NewTaxonomicTreeWizard"
+            hasPages="true"
             icon="icons/tree_icon_small.jpg"
-            id="taxeditor-navigation.wizard1"
+            id="eu.etaxonomy.taxeditor.new.taxonomicTree"
             name="Taxonomic Tree">
       </wizard>
+      <wizard
+            category="eu.etaxonomy.taxeditor.new.category.cdm"
+            class="eu.etaxonomy.taxeditor.newWizards.NewTaxonNodeWizard"
+            hasPages="true"
+            id="eu.etaxonomy.taxeditor.new.taxonNode"
+            name="Taxon Node">
+      </wizard>
    </extension>
    <extension
          point="org.eclipse.core.expressions.definitions">
index 66fffcdfe9d7e12668d0171fe1c7649016b2cfad..cc8b072ede52d592469efafa03a0f210f09fd310 100644 (file)
@@ -48,7 +48,7 @@ public class MoveTaxonHandler extends AbstractHandler implements IPostOperationE
                // do not show the current selection
                List<UUID> excludeTaxa = new ArrayList<UUID>();
                excludeTaxa.add(taxonNode.getTaxon().getUuid());
-               parentTaxonNode = FilteredTaxonNodeSelectionDialog.selectTaxonNode(shell, "Choose new parent", excludeTaxa);
+               parentTaxonNode = FilteredTaxonNodeSelectionDialog.selectTaxonNode(shell, "Choose new parent", excludeTaxa, null);
                                
                if(parentTaxonNode != null){
                        
diff --git a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/NewTaxonNodeHandler.java b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/NewTaxonNodeHandler.java
new file mode 100644 (file)
index 0000000..5d44bc1
--- /dev/null
@@ -0,0 +1,54 @@
+package eu.etaxonomy.taxeditor.navigation.handler;
+// $Id$
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy 
+* http://www.e-taxonomy.eu
+* 
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+
+import org.apache.log4j.Logger;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
+import eu.etaxonomy.taxeditor.newWizards.NewTaxonNodeWizard;
+
+/**
+ * @author n.hoffmann
+ * @created Sep 15, 2009
+ * @version 1.0
+ */
+public class NewTaxonNodeHandler extends AbstractHandler implements IHandler {
+       private static final Logger logger = Logger
+                       .getLogger(NewTaxonNodeHandler.class);
+
+       /* (non-Javadoc)
+        * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+        */
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               
+               StructuredSelection selection = (StructuredSelection) HandlerUtil.getActiveMenuSelection(event);
+               
+               NewTaxonNodeWizard wizard = new NewTaxonNodeWizard(selection);
+               WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), wizard);
+               int status = dialog.open();
+               
+               if(status == Status.OK && wizard.openInEditor()){
+                       NavigationUtil.openEditor(wizard.getTaxonNode());
+                       // if name is empty
+//                     NavigationUtil.openEmpty(parentNodeUuid);
+               }               
+               
+               return null;
+       }
+}
diff --git a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/NewTaxonomicTreeHandler.java b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/NewTaxonomicTreeHandler.java
new file mode 100644 (file)
index 0000000..972af53
--- /dev/null
@@ -0,0 +1,44 @@
+// $Id$
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy 
+* http://www.e-taxonomy.eu
+* 
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.navigation.handler;
+
+import org.apache.log4j.Logger;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+import eu.etaxonomy.taxeditor.newWizards.NewTaxonNodeWizard;
+import eu.etaxonomy.taxeditor.newWizards.NewTaxonomicTreeWizard;
+
+/**
+ * @author n.hoffmann
+ * @created Sep 15, 2009
+ * @version 1.0
+ */
+public class NewTaxonomicTreeHandler extends AbstractHandler implements
+               IHandler {
+       private static final Logger logger = Logger
+                       .getLogger(NewTaxonomicTreeHandler.class);
+
+       /* (non-Javadoc)
+        * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+        */
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               
+               WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), new NewTaxonomicTreeWizard());
+               dialog.open();
+               
+               return null;
+       }
+}
index 6a0ccceaefed3c395f385f21a38d18ac8c026979..7ed2170b8ee9d26066e833c12750a6cd034483f9 100644 (file)
@@ -31,7 +31,7 @@ import eu.etaxonomy.taxeditor.editor.EditorUtil;
 import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
 import eu.etaxonomy.taxeditor.operations.CreateTaxonNodeOperation;
 import eu.etaxonomy.taxeditor.operations.IPostOperationEnabled;
-import eu.etaxonomy.taxeditor.parser.CdmParserUtil;
+import eu.etaxonomy.taxeditor.parser.ParserUtil;
 import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
 
 /**
@@ -70,7 +70,7 @@ public class QuickCreateChildTaxonHandler extends AbstractHandler implements
                        
                        //TaxonUtil.addChildTaxonBaseIsolated(parentTaxon.getUuid(), dialog.getValue());
 
-                       TaxonNameBase name = CdmParserUtil.parseReferencedName(dialog.getValue());
+                       TaxonNameBase name = ParserUtil.parseReferencedName(dialog.getValue());
                        
                        CreateTaxonNodeOperation operation;
                        try {
index ec1d79451fae9d90747f8709462f132bb4f0f2d9..5d4712fbc8e71d068ac098d391a9516f7fcaec7b 100644 (file)
@@ -32,7 +32,7 @@ public class Root extends PlatformObject implements IAdaptable, IPersistableElem
        private static final Logger logger = Logger.getLogger(Root.class);\r
        \r
        public List<TaxonomicTree> getParentBeans() {\r
-               List<TaxonomicTree> trees = CdmStore.getTaxonomicTrees();\r
+               List<TaxonomicTree> trees = CdmStore.getTaxonTreeService().list(null, null).getRecords();\r
                return trees;\r
        }\r
 \r
index 056b43af198bda3e2a80f99d40b7b14c999a8309..e436e55884c8379df7efa6af7b1c0d46c82f3306 100644 (file)
@@ -112,10 +112,10 @@ public class TaxonNavigator extends CommonNavigator implements IConversationEnab
                if(string.length() == 0) return null; \r
                \r
                for (String uuid : string.split(" ")) {\r
-                       CdmBase cdmBaseObject = CdmStore.getTaxonService().getTaxonNodeByUuid(UUID.fromString(uuid));\r
+                       CdmBase cdmBaseObject = CdmStore.getTaxonTreeService().getTaxonNodeByUuid(UUID.fromString(uuid));\r
                        if (cdmBaseObject == null) {\r
                                // is this a tree uuid?\r
-                               cdmBaseObject = CdmStore.getTaxonService().getTaxonomicTreeByUuid(UUID.fromString(uuid));\r
+                               cdmBaseObject = CdmStore.getTaxonTreeService().getTaxonomicTreeByUuid(UUID.fromString(uuid));\r
                                \r
                                if(cdmBaseObject == null) return null;\r
                        }\r
@@ -188,10 +188,11 @@ public class TaxonNavigator extends CommonNavigator implements IConversationEnab
         */\r
        @Override\r
        public void dispose() {\r
-               conversation.commit();\r
-               conversation.unregisterForDataStoreChanges(this);\r
-               \r
                super.dispose();\r
+               dataChangeBehavior = null;\r
+               if(conversation != null){\r
+                       conversation.unregisterForDataStoreChanges(this);\r
+               }\r
        }\r
        \r
        /* (non-Javadoc)\r
index 8a80788682ad5c7127eb5cd15641c6a02c06e9db..d01b8008793433683333e723ba1c5343737468ed 100644 (file)
@@ -176,7 +176,7 @@ public class SearchBar extends WorkbenchWindowControlContribution{
        
        class ConfigurationSelectionListener extends SelectionAdapter{
 
-               ITaxonServiceConfigurator configurator;
+               private ITaxonServiceConfigurator configurator;
                
                /* (non-Javadoc)
                 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
@@ -186,19 +186,19 @@ public class SearchBar extends WorkbenchWindowControlContribution{
                        SearchOption option = (SearchOption) e.widget.getData();
                        
                        if(option == SearchOption.TAXON){
-                               getConfigurator().setDoTaxa(configurator.isDoTaxa() ? false : true);
+                               getConfigurator().setDoTaxa(getConfigurator().isDoTaxa() ? false : true);
                        }
                        
                        if(option == SearchOption.SYNONYM){
-                               getConfigurator().setDoSynonyms(configurator.isDoSynonyms() ? false : true);
+                               getConfigurator().setDoSynonyms(getConfigurator().isDoSynonyms() ? false : true);
                        }
                        
                        if(option == SearchOption.NAME){
-                               getConfigurator().setDoNamesWithoutTaxa(configurator.isDoNamesWithoutTaxa() ? false : true);
+                               getConfigurator().setDoNamesWithoutTaxa(getConfigurator().isDoNamesWithoutTaxa() ? false : true);
                        }
                        
                        if(option == SearchOption.COMMON_NAME){
-                               getConfigurator().setDoTaxaByCommonNames(configurator.isDoTaxaByCommonNames() ? false : true);
+                               getConfigurator().setDoTaxaByCommonNames(getConfigurator().isDoTaxaByCommonNames() ? false : true);
                        }
                        saveConfigurator();
                }
@@ -211,7 +211,7 @@ public class SearchBar extends WorkbenchWindowControlContribution{
                }
                
                private void saveConfigurator(){
-                       PreferencesUtil.setSearchConfigurator(configurator);
+                       PreferencesUtil.setSearchConfigurator(getConfigurator());
                        this.configurator = PreferencesUtil.getSearchConfigurator();
                }
        }
index 27577bed3d8de6aafd4f94833a032dc558ec7009..9ac54c0de528fd3d0ac3b84e03393fa62df0c0b2 100644 (file)
@@ -47,8 +47,6 @@ public class SearchResultView extends ViewPart implements IConversationEnabled{
                        "eu.etaxonomy.taxeditor.navigation.search.searchResultView"; //$NON-NLS-1$\r
 \r
        private TableViewer resultViewer;\r
-       \r
-       private String queryString;\r
 \r
        private ConversationHolder conversation;\r
 \r
diff --git a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/newWizards/NewTaxonNodeWizard.java b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/newWizards/NewTaxonNodeWizard.java
new file mode 100644 (file)
index 0000000..3f6c31a
--- /dev/null
@@ -0,0 +1,106 @@
+/**
+ * 
+ */
+package eu.etaxonomy.taxeditor.newWizards;
+
+import org.apache.log4j.Logger;
+import org.eclipse.core.commands.operations.AbstractOperation;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
+import eu.etaxonomy.taxeditor.operations.CreateTaxonNodeOperation;
+import eu.etaxonomy.taxeditor.operations.IPostOperationEnabled;
+
+/**
+ * 
+ * @author n.hoffmann
+ * @created Sep 15, 2009
+ * @version 1.0
+ */
+public class NewTaxonNodeWizard extends Wizard implements INewWizard, IPostOperationEnabled {
+       private static final Logger logger = Logger.getLogger(NewTaxonNodeWizard.class);
+
+       private NewTaxonNodeWizardPage page;
+
+       private IStructuredSelection selection;
+
+       private IWorkbench workbench;
+
+       private TaxonNode generatedTaxonNode;
+
+       private boolean openEmptyEditor = false;
+       
+       public NewTaxonNodeWizard() {
+               this.setWindowTitle("New Taxon Node");
+       }
+
+       
+       
+       /**
+        * @param selection
+        */
+       public NewTaxonNodeWizard(StructuredSelection selection) {
+               this();
+               this.selection = selection;
+       }
+
+
+
+       @Override
+       public boolean performFinish() {
+               if(page.getTaxonName() == null){
+                       openEmptyEditor = true;
+               }else{
+                       AbstractOperation operation = new CreateTaxonNodeOperation("Create Taxon Node", 
+                                       NavigationUtil.getUndoContext(), page.getParentNode().getUuid(), page.getTaxonName(), this);
+                       NavigationUtil.executeOperation(operation);
+       
+                       NavigationUtil.getNavigator().getCommonViewer().refresh();
+               }
+               return true;
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.Wizard#addPages()
+        */
+       @Override
+       public void addPages() {
+               super.addPages();
+               
+               page = new NewTaxonNodeWizardPage(selection);
+               
+               addPage(page);
+       }
+
+       public void init(IWorkbench workbench, IStructuredSelection selection) {
+               this.workbench = workbench;
+               this.selection = selection;
+       }
+
+       public boolean openInEditor(){
+               return page.openInEditor();
+       }
+       
+       public boolean openEmpty(){
+               return openInEditor() && openEmptyEditor;
+       }
+
+       public TaxonNode getTaxonNode(){
+               return generatedTaxonNode;
+       }
+
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.operations.IPostOperationEnabled#postOperation(eu.etaxonomy.cdm.model.common.CdmBase)
+        */
+       public boolean postOperation(CdmBase objectAffectedByOperation) {
+               generatedTaxonNode = (TaxonNode) objectAffectedByOperation;
+               
+               return true;
+       }
+}
diff --git a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/newWizards/NewTaxonNodeWizardPage.java b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/newWizards/NewTaxonNodeWizardPage.java
new file mode 100644 (file)
index 0000000..4ba54a9
--- /dev/null
@@ -0,0 +1,314 @@
+// $Id$
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy 
+* http://www.e-taxonomy.eu
+* 
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.newWizards;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+import eu.etaxonomy.cdm.model.name.TaxonNameBase;
+import eu.etaxonomy.cdm.model.taxon.ITreeNode;
+import eu.etaxonomy.cdm.model.taxon.TaxonBase;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.cdm.model.taxon.TaxonomicTree;
+import eu.etaxonomy.taxeditor.dialogs.FilteredNameSelectionDialog;
+import eu.etaxonomy.taxeditor.dialogs.FilteredTaxonNodeSelectionDialog;
+import eu.etaxonomy.taxeditor.dialogs.FilteredTaxonSelectionDialog;
+import eu.etaxonomy.taxeditor.dialogs.FilteredTaxonomicTreeSelectionDialog;
+import eu.etaxonomy.taxeditor.editor.name.ParseHandler;
+import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
+
+/**
+ * @author n.hoffmann
+ * @created Sep 15, 2009
+ * @version 1.0
+ */
+public class NewTaxonNodeWizardPage extends WizardPage implements ModifyListener {
+
+       private static final Logger logger = Logger
+                       .getLogger(NewTaxonNodeWizardPage.class);
+       
+       private static final String BUTTON_TEXT_BROWSE = "Browse";
+       
+       private TaxonomicTree taxonomicTree;
+       
+       private ParseHandler parseHandler;
+       
+       private TaxonNode parentTaxonNode;
+       
+       private TaxonBase taxonBase;
+       
+       private boolean reuseExistingTaxon = false;
+       
+       private TaxonNameBase taxonName;
+       
+       private boolean openInEditor = true;
+
+       private Button button_openInEditor;
+
+       private Text text_parentTaxonNode;
+
+       private Text text_reuseTaxon;
+
+       private Text text_taxonName;
+
+       private Text text_taxonomicTree;
+
+       private Button button_taxonName;
+
+       private Button button_reuseTaxon;
+
+       private Button button_toggleReuseTaxon;
+       
+       /**
+        * @param pageName
+        */
+       protected NewTaxonNodeWizardPage(IStructuredSelection selection) {
+               super("New Taxon Node");
+               
+               if(selection != null && selection.size() == 1){
+                       if(selection.getFirstElement() instanceof ITreeNode){
+                               ITreeNode parentNode = (ITreeNode) selection.getFirstElement();                 
+                               
+                               if(parentNode instanceof TaxonNode){
+                                       parentTaxonNode = (TaxonNode) parentNode;
+                                       taxonomicTree = parentTaxonNode.getTaxonomicTree();
+                               }else{
+                                       taxonomicTree = (TaxonomicTree) parentNode;
+                               }
+                       }
+               }
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+        */
+       public void createControl(Composite parent) {
+               Composite composite = new Composite(parent, SWT.NULL);
+               
+               GridLayout layout = new GridLayout(3, false);
+               composite.setLayout(layout);
+               
+               // taxonomic tree
+               Label label_taxonomicTree = new Label(composite, SWT.NULL);
+               label_taxonomicTree.setText("Taxonomic Tree");
+               
+               text_taxonomicTree = new Text(composite, SWT.BORDER | SWT.SINGLE);
+               text_taxonomicTree.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
+               text_taxonomicTree.setEnabled(false);
+               text_taxonomicTree.setText(taxonomicTree != null ? taxonomicTree.getTitleCache() : "");
+               
+               Button button_taxonomicTree = new Button(composite, SWT.PUSH);
+               button_taxonomicTree.setText(BUTTON_TEXT_BROWSE);
+               button_taxonomicTree.addSelectionListener(new TaxonomicTreeSelector());
+               
+               
+               // parental node
+               Label label_parentTaxonNode = new Label(composite, SWT.NULL);
+               label_parentTaxonNode.setText("Parent Taxon Node");
+               
+               text_parentTaxonNode = new Text(composite, SWT.BORDER | SWT.SINGLE);
+               text_parentTaxonNode.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
+               text_parentTaxonNode.setEnabled(false);
+               text_parentTaxonNode.setText(parentTaxonNode != null ? parentTaxonNode.getTaxon().getName().getTitleCache() : "");
+               
+               Button button_parentTaxonNode = new Button(composite, SWT.PUSH);
+               button_parentTaxonNode.setText(BUTTON_TEXT_BROWSE);
+               button_parentTaxonNode.addSelectionListener(new TaxonNodeSelector());
+               
+               // existing taxon
+               Composite container_label_reuseTaxon = new Composite(composite, SWT.NULL);
+               container_label_reuseTaxon.setLayout(new GridLayout(2, false));
+               
+               button_toggleReuseTaxon = new Button(container_label_reuseTaxon, SWT.CHECK);
+               button_toggleReuseTaxon.addSelectionListener(new ToggleReuseTaxonSelector());
+               button_toggleReuseTaxon.setSelection(reuseExistingTaxon);
+               
+               Label label_reuseTaxon = new Label(container_label_reuseTaxon, SWT.NULL);
+               label_reuseTaxon.setText("Reuse Existing Taxon");
+               label_reuseTaxon.setEnabled(false);
+               
+               text_reuseTaxon = new Text(composite, SWT.BORDER | SWT.SINGLE);
+               text_reuseTaxon.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
+               text_reuseTaxon.setEnabled(false);
+       
+               
+               button_reuseTaxon = new Button(composite, SWT.PUSH);
+               button_reuseTaxon.setText(BUTTON_TEXT_BROWSE);
+               button_reuseTaxon.addSelectionListener(new TaxonSelector());
+               button_reuseTaxon.setEnabled(false);
+               
+               // name
+               Label label_taxonName = new Label(composite, SWT.NULL);
+               label_taxonName.setText("Taxon Name");
+               
+               text_taxonName = new Text(composite, SWT.BORDER | SWT.SINGLE);
+               text_taxonName.addModifyListener(this);
+               text_taxonName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
+               
+               button_taxonName = new Button(composite, SWT.PUSH);
+               button_taxonName.setText(BUTTON_TEXT_BROWSE);
+               button_taxonName.addSelectionListener(new TaxonNameSelector());
+               
+               // open in editor
+               Composite container_openInEditor = new Composite(composite, SWT.NULL);
+               container_openInEditor.setLayout(new GridLayout(2, false));
+               button_openInEditor = new Button(container_openInEditor, SWT.CHECK);
+               button_openInEditor.addSelectionListener(new OpenInEditorSelector());
+               button_openInEditor.setSelection(openInEditor);
+               
+               Label label_openInEditor = new Label(container_openInEditor, SWT.NULL);
+               label_openInEditor.setText("Open Taxon in Editor");
+                               
+               // initialize the parse handler
+               parseHandler = ParseHandler.NewInstance(text_taxonName, taxonName);
+               
+               // set focus to name field
+               text_taxonName.setFocus();
+               
+               setControl(composite);
+       }
+
+       /**
+        * @return the taxon
+        */
+       public TaxonBase getTaxon() {
+               return taxonBase;
+       }
+
+       /**
+        * @return the name
+        */
+       public TaxonNameBase getTaxonName() {
+               return taxonName;
+       }
+       
+       /**
+        * @return
+        */
+       public ITreeNode getParentNode() {
+               return parentTaxonNode != null ? parentTaxonNode : taxonomicTree;
+       }
+       
+       public boolean openInEditor(){
+               return openInEditor;
+       }
+       
+       
+       /*
+        * SELECTION ADAPTERS
+        */
+       
+       private class TaxonomicTreeSelector extends SelectionAdapter{
+               /* (non-Javadoc)
+                * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+                */
+               @Override
+               public void widgetSelected(SelectionEvent e) {
+                       super.widgetSelected(e);
+                       taxonomicTree = FilteredTaxonomicTreeSelectionDialog.selectTaxonomicTree(NavigationUtil.getShell());
+                       text_taxonomicTree.setText(taxonomicTree.getTitleCache());
+               }
+       }
+       
+       private class TaxonNodeSelector extends SelectionAdapter{
+               /* (non-Javadoc)
+                * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+                */
+               @Override
+               public void widgetSelected(SelectionEvent e) {
+                       super.widgetSelected(e);
+                       parentTaxonNode = FilteredTaxonNodeSelectionDialog.selectTaxonNode(NavigationUtil.getShell(), "Select parent", null, null);
+                       text_parentTaxonNode.setText(parentTaxonNode.getTaxon().getTitleCache());
+               }
+               
+       }
+       
+       private class TaxonSelector extends SelectionAdapter{
+               /* (non-Javadoc)
+                * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+                */
+               @Override
+               public void widgetSelected(SelectionEvent e) {
+                       super.widgetSelected(e);
+                       taxonBase = FilteredTaxonSelectionDialog.selectTaxon(NavigationUtil.getShell());
+                       text_reuseTaxon.setText(taxonBase.getTitleCache());
+               }
+       }
+       
+       private class TaxonNameSelector extends SelectionAdapter{
+               /* (non-Javadoc)
+                * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+                */
+               @Override
+               public void widgetSelected(SelectionEvent e) {
+                       super.widgetSelected(e);
+                       taxonName = FilteredNameSelectionDialog.selectName(NavigationUtil.getShell(), null);
+                       text_taxonName.setText(taxonName.getTitleCache());
+               }
+       }
+       
+       private class OpenInEditorSelector extends SelectionAdapter{
+               /* (non-Javadoc)
+                * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+                */
+               @Override
+               public void widgetSelected(SelectionEvent e) {
+                       super.widgetSelected(e);
+                       openInEditor = button_openInEditor.getSelection();
+               }
+       }
+       
+       private class ToggleReuseTaxonSelector extends SelectionAdapter{
+               /* (non-Javadoc)
+                * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+                */
+               @Override
+               public void widgetSelected(SelectionEvent e) {
+                       super.widgetSelected(e);
+                       
+                       if(button_toggleReuseTaxon.getSelection()){
+                               // enable reuse Taxon
+                               text_reuseTaxon.setEnabled(true);
+                               button_reuseTaxon.setEnabled(true);
+                               // disable name
+                               text_taxonName.setEnabled(false);
+                               button_taxonName.setEnabled(false);
+                       }else{
+                               // disable reuse Taxon
+                               text_reuseTaxon.setEnabled(false);
+                               button_reuseTaxon.setEnabled(false);
+                               // enable name
+                               text_taxonName.setEnabled(true);
+                               button_taxonName.setEnabled(true);
+                       }
+                       
+               }
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+        */
+       public void modifyText(ModifyEvent e) {
+               taxonName = parseHandler.parse();
+       }       
+}
similarity index 91%
rename from taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/handler/NewTaxonomicTreeWizard.java
rename to taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/newWizards/NewTaxonomicTreeWizard.java
index ec48d9a75e3be663bb997bc8a4a319ff9d27d396..354ff9879a8eacfe9f9f2c3866c38a224eb88f71 100644 (file)
@@ -8,17 +8,15 @@
 * See LICENSE.TXT at the top of this package for the full license terms.
 */
 
-package eu.etaxonomy.taxeditor.navigation.handler;
+package eu.etaxonomy.taxeditor.newWizards;
 
 import org.apache.log4j.Logger;
-import org.eclipse.core.commands.common.NotDefinedException;
 import org.eclipse.core.commands.operations.AbstractOperation;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.ui.INewWizard;
 import org.eclipse.ui.IWorkbench;
 
-import eu.etaxonomy.taxeditor.editor.EditorUtil;
 import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
 import eu.etaxonomy.taxeditor.operations.CreateTaxonomicTreeOperation;
 
@@ -73,7 +71,6 @@ public class NewTaxonomicTreeWizard extends Wizard implements INewWizard {
         * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
         */
        public void init(IWorkbench workbench, IStructuredSelection selection) {
-               // TODO Auto-generated method stub
-
+               
        }
 }
diff --git a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/newWizards/NewTaxonomicTreeWizardPage.java b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/newWizards/NewTaxonomicTreeWizardPage.java
new file mode 100644 (file)
index 0000000..90f5457
--- /dev/null
@@ -0,0 +1,151 @@
+// $Id$
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy 
+* http://www.e-taxonomy.eu
+* 
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.newWizards;
+
+
+import java.util.UUID;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+import eu.etaxonomy.cdm.model.reference.ReferenceBase;
+import eu.etaxonomy.taxeditor.dialogs.FilteredReferenceSelectionDialog;
+import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
+
+/**
+ * @author n.hoffmann
+ * @created 23.06.2009
+ * @version 1.0
+ */
+public class NewTaxonomicTreeWizardPage extends WizardPage implements ModifyListener {
+       private static final Logger logger = Logger
+                       .getLogger(NewTaxonomicTreeWizardPage.class);
+
+       private Text text_treeLabel;
+
+       private Text text_reference;
+
+       private Button button_browseReference;
+
+       private UUID referenceUuid;
+
+       private Text text_microReference;
+
+       /**
+        * @param pageName
+        */
+       protected NewTaxonomicTreeWizardPage(String pageName) {
+               super(pageName);
+               this.setTitle("Taxonomic Tree");
+               
+               this.setDescription("Create a new Taxonomic Tree.");
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+        */
+       public void createControl(Composite parent) {
+               
+               setPageComplete(false);
+               
+               Composite composite = new Composite(parent, SWT.NONE);
+               GridLayout gridLayout = new GridLayout();
+               gridLayout.numColumns = 3;
+               composite.setLayout(gridLayout);
+               
+               CLabel label_treeLabel = new CLabel(composite, SWT.NULL);
+               label_treeLabel.setText("Label:");
+               
+               text_treeLabel = new Text(composite, SWT.BORDER);
+               text_treeLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
+               text_treeLabel.addModifyListener(this);
+
+               // FIXME this is a rudimentary implementation. Add missing fields.
+
+               CLabel label_reference = new CLabel(composite, SWT.NULL);
+               label_reference.setText("Reference:");
+               
+               text_reference = new Text(composite, SWT.BORDER);
+               text_reference.setEnabled(false);
+               text_reference.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+               
+               button_browseReference = new Button(composite, SWT.PUSH);
+               button_browseReference.setText("Browse...");
+               button_browseReference.addMouseListener(new MouseAdapter(){
+
+                       /* (non-Javadoc)
+                        * @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
+                        */
+                       @Override
+                       public void mouseUp(MouseEvent e) {
+                               // TODO Auto-generated method stub
+                               super.mouseUp(e);
+                               logger.warn("Open reference search dialog");
+                               
+                               ReferenceBase reference = FilteredReferenceSelectionDialog.selectReference(NavigationUtil.getShell(), null);
+                               
+                               referenceUuid = reference.getUuid();
+                                
+                               text_reference.setText(reference.getTitleCache());
+                       }
+                       
+               });
+               
+               CLabel label_microReference = new CLabel(composite, SWT.NULL);
+               label_microReference.setText("Reference Detail");
+               
+               text_microReference = new Text(composite, SWT.BORDER);
+               text_microReference.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
+               
+               setControl(composite);
+       }
+
+       /**
+        * @return the text_treeLabel
+        */
+       public String getTreeLabel() {
+               return text_treeLabel.getText();
+       }
+
+       /**
+        * @return
+        */
+       public String getMicroReference() {
+               return text_microReference.getText();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+        */
+       public void modifyText(ModifyEvent e) {
+               if(getTreeLabel().trim().length() > 0){
+                       setPageComplete(true);
+               }
+       }
+
+       /**
+        * @return
+        */
+       public UUID getReferenceUuid() {
+               return referenceUuid;
+       }
+}