- added functionality to choose the taxon name for a taxon in the DetailsView (...
authorPatric Plitzner <p.plitzner@bgbm.org>
Fri, 24 Apr 2015 07:54:06 +0000 (07:54 +0000)
committerPatric Plitzner <p.plitzner@bgbm.org>
Fri, 24 Apr 2015 07:54:06 +0000 (07:54 +0000)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditor.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NonViralNameDetailSection.java

index 164ed003754e187e91dfa9ce91fe3ef3f23c4b00..94107c24aa62579a0771388f9ed03a5724d1d099 100644 (file)
@@ -307,6 +307,9 @@ public class MultiPageTaxonEditor extends FormEditor implements
                 container.refresh();
             }
         }
+        //refresh part title
+        //TODO: refresh taxon node in taxon navigator
+        setPartName();
     }
 
     /* (non-Javadoc)
@@ -421,7 +424,7 @@ public class MultiPageTaxonEditor extends FormEditor implements
     /** {@inheritDoc} */
     @Override
     public boolean postOperation(CdmBase objectAffectedByOperation) {
-        setDirty(true);
+               setDirty(true);
 
         for (IEditorPart editor : this.getPages()) {
             if (editor instanceof IPostOperationEnabled) {
index fbaac5d51eeebc31dc8b8ccd3f26871a93ea1fd5..a44b2e7b7008e984bcb26ff1c00c38d9067b598b 100644 (file)
@@ -18,10 +18,16 @@ import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Control;
 
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
+import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
 import eu.etaxonomy.cdm.model.name.NonViralName;
+import eu.etaxonomy.cdm.model.name.TaxonNameBase;
 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.taxeditor.model.ImageResources;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+import eu.etaxonomy.taxeditor.ui.dialog.selection.NameSelectionDialog;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
@@ -62,11 +68,37 @@ public class NonViralNameDetailSection extends AbstractCdmDetailSection<NonViral
        protected Control createToolbar() {
                ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
 
+               //choose name
+               Action chooseNameAction = new Action("Choose Name", IAction.AS_PUSH_BUTTON){
+                   @Override
+                   public void run() {
+                       TaxonNameBase taxonName = NameSelectionDialog.select(getShell(), getConversationHolder(), null);
+                       if(taxonName!=null){
+                           if(taxonName.isInstanceOf(NonViralName.class)){
+                               CdmStore.getService(ITaxonNodeService.class).list(TaxonNode.class, null, null, null, null);
+                               NonViralName nonViralName = HibernateProxyHelper.deproxy(taxonName, NonViralName.class);
+                               taxonBase.setName(nonViralName);
+                               //                                      taxonBase.getTitleCache();
+                               setEntity(nonViralName);
+                               firePropertyChangeEvent(NonViralNameDetailSection.this);
+                           }
+                           else{
+                               MessagingUtils.warningDialog("Invalid name", this, "The selected name can not be used for this taxon.");
+                           }
+                       }
+                   }
+               };
+               chooseNameAction.setToolTipText("Choose name for this taxon");
+               chooseNameAction.setImageDescriptor(ImageResources.getImageDescriptor(ImageResources.BROWSE_ICON));
+
+               toolBarManager.add(chooseNameAction);
+
+               //clone
                if(getEntity() != null && checkForMultipleNameUsages(getEntity())){
 
                        Action cloneAction = new Action("Clone", IAction.AS_PUSH_BUTTON){
-                               @Override
-                public void run() {
+                           @Override
+                           public void run() {
                                        boolean confirm = MessagingUtils.confirmDialog("Confirm cloning", "Do you really want to clone the name?");
 
                                        if(confirm){
@@ -75,7 +107,6 @@ public class NonViralNameDetailSection extends AbstractCdmDetailSection<NonViral
                                                setEntity(clonedName);
                                                taxonBase.setName(clonedName);
                                                taxonBase.generateTitle();
-//                                             EditorUtil.getActiveMultiPageTaxonEditor().r
                                                firePropertyChangeEvent(new CdmPropertyChangeEvent(NonViralNameDetailSection.this, null));
                                        }