Add flag for displaying choose action in name details view #5260
authorPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 10 Nov 2015 17:39:40 +0000 (18:39 +0100)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 10 Nov 2015 17:39:40 +0000 (18:39 +0100)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NonViralNameDetailSection.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewer.java

index d0255238423d81458506fe3a027f3c8144f8e86d..861571c28f77436a4c6093c3495302c4ffe2b19c 100644 (file)
@@ -1553,8 +1553,8 @@ public class CdmFormFactory extends FormToolkit {
         return section;
     }
 
-    public NonViralNameDetailSection createNonViralNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
-        NonViralNameDetailSection section = new NonViralNameDetailSection(this, conversation, parentElement, selectionProvider, style);
+    public NonViralNameDetailSection createNonViralNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, boolean nameChoosable, int style){
+        NonViralNameDetailSection section = new NonViralNameDetailSection(this, conversation, parentElement, selectionProvider, nameChoosable, style);
         addAndAdaptSection(parentElement, section);
         return section;
     }
index 4f4c09e06ef72de7927395d69682a0d90195c6d6..9a02d8f98d514b01315b30a4767b272ca9265ea9 100644 (file)
@@ -44,6 +44,7 @@ public class NonViralNameDetailSection extends AbstractCdmDetailSection<NonViral
                implements ITaxonBaseDetailSection {
 
        private TaxonBase taxonBase;
+       boolean nameChoosable = false;
 
        /**
         * <p>Constructor for NonViralNameDetailSection.</p>
@@ -52,41 +53,45 @@ public class NonViralNameDetailSection extends AbstractCdmDetailSection<NonViral
         * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
         * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
         * @param selectionProvider a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
+        * @param nameChoosable if <code>true</code> adds a button to choose the displayed name
         * @param style a int.
         */
        public NonViralNameDetailSection(CdmFormFactory formFactory, ConversationHolder conversation,
-                       ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
+                       ICdmFormElement parentElement, ISelectionProvider selectionProvider, boolean nameChoosable, int style) {
                super(formFactory, conversation, parentElement, selectionProvider, style);
+               this.nameChoosable = nameChoosable;
        }
 
        @Override
        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);
+               ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
+
+               if(nameChoosable){
+                   //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())){
index 6a0dab25f8ac9b57a3da8a371495f890d70fed8a..9924ad799fe36168848e16e77d37eb339ecadcf0 100644 (file)
@@ -368,8 +368,9 @@ public class DetailsViewer extends AbstractCdmDataViewer {
                        ExpandableComposite.TWISTIE     | ExpandableComposite.EXPANDED);
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        NonViralNameDetailSection nonViralNameSection = formFactory.createNonViralNameDetailSection(getConversationHolder(), parent, this,
-                       ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+        NonViralNameDetailSection nonViralNameSection = formFactory
+                .createNonViralNameDetailSection(getConversationHolder(), parent, this, true,
+                        ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
         NomenclaturalReferenceDetailSection referenceDetailSection = formFactory.createNomenclaturalReferenceDetailSection(getConversationHolder(), parent, this,
@@ -405,8 +406,9 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
     private void createNameSections(RootElement parent) {
         destroySections();
-        NonViralNameDetailSection nonViralNameSection = formFactory.createNonViralNameDetailSection(getConversationHolder(), parent, this,
-                       ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+        NonViralNameDetailSection nonViralNameSection = formFactory.createNonViralNameDetailSection(
+                getConversationHolder(), parent, this, false, ExpandableComposite.TWISTIE
+                        | ExpandableComposite.EXPANDED);
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
         NomenclaturalReferenceDetailSection referenceDetailSection = formFactory.createNomenclaturalReferenceDetailSection(getConversationHolder(), parent, this,