From 71f9f770e9c409ff810b984990105625bcdb6801 Mon Sep 17 00:00:00 2001 From: Patric Plitzner Date: Wed, 26 Nov 2014 12:19:10 +0000 Subject: [PATCH] - moved extension point for taxon navigator context menu - fixed DerivateSearchView layout - added "disabled" extension point for toggling individual assciations in factual data view --- .gitattributes | 1 + eu.etaxonomy.taxeditor.editor/plugin.xml | 38 ++++++++++++++++++ .../DescriptiveContentProvider.java | 29 ++++++++++++-- .../view/descriptive/DescriptiveViewPart.java | 10 ++++- ...ShowOnlyIndividualAssociationsHandler.java | 40 +++++++++++++++++++ eu.etaxonomy.taxeditor.store/plugin.xml | 9 ----- .../DerivateSearchComposite.java | 25 +++++------- 7 files changed, 123 insertions(+), 29 deletions(-) create mode 100644 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/ToggleShowOnlyIndividualAssociationsHandler.java diff --git a/.gitattributes b/.gitattributes index 53b2647bc..5379bc671 100644 --- a/.gitattributes +++ b/.gitattributes @@ -554,6 +554,7 @@ eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/d eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/DynamicFeatureMenu.java -text eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/MoveDescriptionElementsHandler.java -text eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/MoveDescriptionToOtherTaxonHandler.java -text +eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/ToggleShowOnlyIndividualAssociationsHandler.java -text eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/AddDerivedUnitFacadeMediaOperation.java -text eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/CreateDescriptionElementOperation.java -text eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/CreateSpecimenDescriptionOperation.java -text diff --git a/eu.etaxonomy.taxeditor.editor/plugin.xml b/eu.etaxonomy.taxeditor.editor/plugin.xml index 014860335..c0c7fc3dd 100644 --- a/eu.etaxonomy.taxeditor.editor/plugin.xml +++ b/eu.etaxonomy.taxeditor.editor/plugin.xml @@ -823,6 +823,28 @@ + + + + + + + @@ -939,6 +961,18 @@ + + diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveContentProvider.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveContentProvider.java index 6238071e9..b24ee1704 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveContentProvider.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveContentProvider.java @@ -15,9 +15,11 @@ import eu.etaxonomy.cdm.api.service.ITermService; import eu.etaxonomy.cdm.model.common.Marker; import eu.etaxonomy.cdm.model.common.MarkerType; import eu.etaxonomy.cdm.model.description.DescriptionBase; +import eu.etaxonomy.cdm.model.description.DescriptionElementBase; import eu.etaxonomy.cdm.model.description.Feature; import eu.etaxonomy.cdm.model.description.FeatureTree; import eu.etaxonomy.cdm.model.description.IDescribable; +import eu.etaxonomy.cdm.model.description.IndividualsAssociation; import eu.etaxonomy.taxeditor.editor.UsageTermCollection; import eu.etaxonomy.taxeditor.model.FeatureNodeContainer; import eu.etaxonomy.taxeditor.model.FeatureNodeContainerTree; @@ -36,14 +38,19 @@ public class DescriptiveContentProvider implements ITreeContentProvider { protected static final Object[] NO_CHILDREN = new Object[0]; protected Map, FeatureNodeContainerTree> featureNodeContainerCache; + private boolean showOnlyIndividualAssociations; + public DescriptiveContentProvider(Map, FeatureNodeContainerTree> featureNodeContainerCache) { + this(featureNodeContainerCache, false); + } /** *

Constructor for DescriptiveContentProvider.

* * @param featureNodeContainerCache a {@link java.util.Map} object. */ - public DescriptiveContentProvider(Map, FeatureNodeContainerTree> featureNodeContainerCache) { + public DescriptiveContentProvider(Map, FeatureNodeContainerTree> featureNodeContainerCache, boolean showOnlyIndividualAssociations) { this.featureNodeContainerCache = featureNodeContainerCache; + this.showOnlyIndividualAssociations = showOnlyIndividualAssociations; } /* (non-Javadoc) @@ -61,13 +68,25 @@ public class DescriptiveContentProvider implements ITreeContentProvider { FeatureNodeContainerTree containerTree = getContainerTreeForDesription(description); - return containerTree.getRoot().getChildren().toArray(); + if(getChildren(containerTree).length>=0){ + return containerTree.getRoot().getChildren().toArray(); + } } } else if (parentElement instanceof FeatureNodeContainer){ FeatureNodeContainer container = (FeatureNodeContainer) parentElement; if(container.isLeaf()){ - return container.getDescriptionElements().toArray(); + List descriptionElements = container.getDescriptionElements(); + if(showOnlyIndividualAssociations){ + List filteredDescriptionElements = new ArrayList(); + for (DescriptionElementBase descriptionElement : descriptionElements) { + if(descriptionElement instanceof IndividualsAssociation){ + filteredDescriptionElements.add(descriptionElement); + } + } + descriptionElements = filteredDescriptionElements; + } + return descriptionElements.toArray(); }else{ return container.getChildren().toArray(); } @@ -187,4 +206,8 @@ public class DescriptiveContentProvider implements ITreeContentProvider { @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} + public void toggleShowOnlyIndividualAssociations() { + showOnlyIndividualAssociations = !showOnlyIndividualAssociations; + } + } diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveViewPart.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveViewPart.java index db2d4a174..4951bc8f9 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveViewPart.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveViewPart.java @@ -82,12 +82,15 @@ public class DescriptiveViewPart extends AbstractCdmEditorViewPart implements IP protected int dndOperations = DND.DROP_COPY | DND.DROP_MOVE; + private DescriptiveContentProvider provider; + /** {@inheritDoc} */ @Override public void createViewer(Composite parent) { viewer = new TreeViewer(new Tree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION)); - viewer.setContentProvider(new DescriptiveContentProvider(featureNodeContainerCache)); + provider = new DescriptiveContentProvider(featureNodeContainerCache); + viewer.setContentProvider(provider); viewer.setLabelProvider(new DescriptiveLabelProvider()); viewer.setSorter(new DescriptiveViewerSorter()); viewer.setAutoExpandLevel(2); @@ -279,4 +282,9 @@ public class DescriptiveViewPart extends AbstractCdmEditorViewPart implements IP public boolean onComplete() { return false; } + + public void toggleShowOnlyIndividualAssociations(){ + provider.toggleShowOnlyIndividualAssociations(); + viewer.refresh(); + } } diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/ToggleShowOnlyIndividualAssociationsHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/ToggleShowOnlyIndividualAssociationsHandler.java new file mode 100644 index 000000000..5298ffa88 --- /dev/null +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/ToggleShowOnlyIndividualAssociationsHandler.java @@ -0,0 +1,40 @@ +// $Id$ +/** +* Copyright (C) 2014 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.editor.view.descriptive.handler; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.handlers.HandlerUtil; + +import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart; + +/** + * @author pplitzner + * @date Nov 25, 2014 + * + */ +public class ToggleShowOnlyIndividualAssociationsHandler extends AbstractHandler { + + /* (non-Javadoc) + * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) + */ + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + IWorkbenchPart activePart = HandlerUtil.getActivePart(event); + if(activePart instanceof DescriptiveViewPart){ + DescriptiveViewPart descriptiveViewPart = (DescriptiveViewPart)activePart; + descriptiveViewPart.toggleShowOnlyIndividualAssociations(); + } + return null; + } + +} diff --git a/eu.etaxonomy.taxeditor.store/plugin.xml b/eu.etaxonomy.taxeditor.store/plugin.xml index 4a9583881..44d489e5a 100644 --- a/eu.etaxonomy.taxeditor.store/plugin.xml +++ b/eu.etaxonomy.taxeditor.store/plugin.xml @@ -523,15 +523,6 @@ style="push"> - - - -
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/derivateSearch/DerivateSearchComposite.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/derivateSearch/DerivateSearchComposite.java index f005d663a..354f87523 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/derivateSearch/DerivateSearchComposite.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/derivateSearch/DerivateSearchComposite.java @@ -13,6 +13,8 @@ import org.eclipse.jface.viewers.TableViewer; import org.eclipse.swt.SWT; 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.Combo; import org.eclipse.swt.widgets.Composite; @@ -21,8 +23,6 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.TableWrapData; -import org.eclipse.ui.forms.widgets.TableWrapLayout; import org.eclipse.wb.swt.ResourceManager; /** @@ -50,38 +50,32 @@ public class DerivateSearchComposite extends Composite { */ public DerivateSearchComposite(Composite parent, int style) { super(parent, style); - { - TableWrapLayout tableWrapLayout = new TableWrapLayout(); - tableWrapLayout.numColumns = 4; - setLayout(tableWrapLayout); - } + setLayout(new GridLayout(4, false)); lblTaxon = new Label(this, SWT.NONE); - lblTaxon.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1)); lblTaxon.setText("Taxon"); textTaxonName = formToolkit.createText(this, "New Text", SWT.NONE); - textTaxonName.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.MIDDLE, 1, 1)); + textTaxonName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); textTaxonName.setEnabled(false); textTaxonName.setText(""); btnBrowseTaxa = formToolkit.createButton(this, "", SWT.NONE); - btnBrowseTaxa.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1)); btnBrowseTaxa.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/open.gif")); btnClearTaxon = formToolkit.createButton(this, "", SWT.NONE); + btnClearTaxon.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); btnClearTaxon.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/trash.gif")); lblDerivateType = new Label(this, SWT.NULL); - lblDerivateType.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1)); lblDerivateType.setText("Derivate Type"); comboDerivateType = new Combo(this, SWT.READ_ONLY); - comboDerivateType.setLayoutData(new TableWrapData(TableWrapData.FILL, TableWrapData.MIDDLE, 1, 1)); + comboDerivateType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); formToolkit.paintBordersFor(comboDerivateType); btnFilterUndeterminedSpecimen = new Button(this, SWT.CHECK); - btnFilterUndeterminedSpecimen.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 2)); + btnFilterUndeterminedSpecimen.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1)); btnFilterUndeterminedSpecimen.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { @@ -90,17 +84,16 @@ public class DerivateSearchComposite extends Composite { btnFilterUndeterminedSpecimen.setText("Determined"); buttonSearch = new Button(this, SWT.NONE); - buttonSearch.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1)); formToolkit.adapt(buttonSearch, true, true); buttonSearch.setText("Search"); searchField = formToolkit.createText(this, "New Text", SWT.NONE); - searchField.setLayoutData(new TableWrapData(TableWrapData.FILL, TableWrapData.MIDDLE, 1, 3)); + searchField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 3, 1)); searchField.setText(""); resultViewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI); table = resultViewer.getTable(); - table.setLayoutData(new TableWrapData(TableWrapData.FILL, TableWrapData.FILL, 1, 4)); + table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1)); } -- 2.34.1