From: Patrick Plitzner Date: Tue, 10 Nov 2015 17:39:40 +0000 (+0100) Subject: Add flag for displaying choose action in name details view #5260 X-Git-Tag: 3.12.0^2~65 X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/commitdiff_plain/d0e973da2c977e5dbee1166006f1b4174fa53e76 Add flag for displaying choose action in name details view #5260 --- diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java index d02552384..861571c28 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java @@ -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; } diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NonViralNameDetailSection.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NonViralNameDetailSection.java index 4f4c09e06..9a02d8f98 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NonViralNameDetailSection.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NonViralNameDetailSection.java @@ -44,6 +44,7 @@ public class NonViralNameDetailSection extends AbstractCdmDetailSectionConstructor for NonViralNameDetailSection.

@@ -52,41 +53,45 @@ public class NonViralNameDetailSection extends AbstractCdmDetailSectiontrue 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())){ diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewer.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewer.java index 6a0dab25f..9924ad799 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewer.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewer.java @@ -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,