</elements>
<elements xsi:type="basic:PartDescriptor" xmi:id="_rpaDsNK2EeeWSJT7vW9jsw" elementId="eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.CharacterMatrixPart" label="%partdescriptor.label.4" tooltip="%partdescriptor.tooltip.2" allowMultiple="true" closeable="true" dirtyable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.CharacterMatrixPart">
<handlers xmi:id="_d_HUYOPBEeeIH8IplZ0cuA" elementId="eu.etaxonomy.taxeditor.editor.handler.2" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.charactermatrix.handler.ExportCharacterMatrixHandler" command="_YeWagOPBEeeIH8IplZ0cuA"/>
+ <handlers xmi:id="_mUM1cLKVEeikjKoOnLFm2w" elementId="eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.handler.CreateDefaultTaxonDescriptionHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.handler.CreateDefaultTaxonDescriptionHandler" command="_ZHC3oLKVEeikjKoOnLFm2w"/>
+ <handlers xmi:id="_t8dAQLKVEeikjKoOnLFm2w" elementId="eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.handler.CreateLiteratureTaxonDescriptionHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.handler.CreateLiteratureTaxonDescriptionHandler" command="_fkPkkLKVEeikjKoOnLFm2w"/>
<menus xmi:id="_PLw00OPBEeeIH8IplZ0cuA" elementId="eu.etaxonomy.taxeditor.editor.menu.characterMatrix" label="%menu.label.7">
<children xsi:type="menu:HandledMenuItem" xmi:id="_TGK04OPBEeeIH8IplZ0cuA" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.characterMatrix.export" label="%handledmenuitem.label.12" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/export.gif" command="_YeWagOPBEeeIH8IplZ0cuA"/>
</menus>
+ <menus xsi:type="menu:PopupMenu" xmi:id="__10yYLKREeikjKoOnLFm2w" elementId="eu.etaxonomy.taxeditor.editor.popupmenu.charactermatrix">
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_AyHbgLKSEeikjKoOnLFm2w" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.createdefaultdescription" label="Create default description" command="_ZHC3oLKVEeikjKoOnLFm2w"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_DYlHcLKSEeikjKoOnLFm2w" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.createliteraturedescription" label="Create literature description" command="_fkPkkLKVEeikjKoOnLFm2w"/>
+ </menus>
</elements>
<elements xsi:type="basic:PartDescriptor" xmi:id="_XcQMEN8mEee9zP45RW4C3A" elementId="eu.etaxonomy.taxeditor.editor.descriptiveDataSet.DescriptiveDataSetNavigator" label="%partdescriptor.label.5" closeable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.descriptiveDataSet.DescriptiveDataSetNavigator">
<handlers xmi:id="_JvYVgNXoEeeLtdyzt6BEAA" elementId="eu.etaxonomy.taxeditor.editor.descriptiveDataSet.handler.OpenCharacterMatrixHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.descriptiveDataSet.handler.OpenCharacterMatrixHandler" command="_FnWwMNXoEeeLtdyzt6BEAA"/>
<elements xsi:type="commands:Command" xmi:id="_c3wW8FeBEeiJAP3GTkE0aQ" elementId="eu.etaxonomy.taxeditor.editor.command.descriptivedataseteditor.removeTaxon" commandName="%command.commandname.21"/>
<elements xsi:type="commands:Command" xmi:id="_HSKdYFgXEeiQk_eTMvMviQ" elementId="eu.etaxonomy.taxeditor.editor.name.createProParteSynonym" commandName="%command.name.60"/>
<elements xsi:type="commands:Command" xmi:id="_BgX6gFj_EeiQk_eTMvMviQ" elementId="eu.etaxonomy.taxeditor.editor.command.changeToProParteSynonym" commandName="%command.name.61"/>
+ <elements xsi:type="commands:Command" xmi:id="_ZHC3oLKVEeikjKoOnLFm2w" elementId="eu.etaxonomy.taxeditor.editor.charactermatrix.command.createDefaultTaxonDescription" commandName="Create default taxon description"/>
+ <elements xsi:type="commands:Command" xmi:id="_fkPkkLKVEeikjKoOnLFm2w" elementId="eu.etaxonomy.taxeditor.editor.charactermatrix.command.createLiteratureTaxonDescription" commandName="Create literature taxon description"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_pZmusEalEeeXMc6kSYO7Xg" featurename="children" parentElementId="eu.etaxonomy.taxeditor.menu.showView" positionInList="after:eu.etaxonomy.taxeditor.workbench.menuseparator.navigation">
<elements xsi:type="menu:HandledMenuItem" xmi:id="_FPIHQKNwEeebGZ23ERGMGw" elementId="eu.etaxonomy.taxeditor.editor.showViewMenu.conceptGraph" label="%view.name.3" iconURI="" tooltip="%view.name.3" command="_WPjpoDSnEeek0dKsFNy--Q">
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.e4.ui.di.UISynchronize;
+import org.eclipse.e4.ui.services.EMenuService;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.viewers.ComboViewer;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.nebula.widgets.nattable.NatTable;
+import org.eclipse.nebula.widgets.nattable.config.AbstractUiBindingConfiguration;
import org.eclipse.nebula.widgets.nattable.config.ConfigRegistry;
import org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration;
import org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate;
+import org.eclipse.nebula.widgets.nattable.coordinate.Range;
import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
import org.eclipse.nebula.widgets.nattable.data.ListDataProvider;
import org.eclipse.nebula.widgets.nattable.export.command.ExportCommandHandler;
import org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer;
import org.eclipse.nebula.widgets.nattable.tree.ITreeRowModel;
import org.eclipse.nebula.widgets.nattable.tree.TreeLayer;
+import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
+import org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher;
+import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuAction;
+import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder;
import org.eclipse.nebula.widgets.nattable.util.GUIHelper;
import org.eclipse.swt.SWT;
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.Menu;
import ca.odell.glazedlists.BasicEventList;
import ca.odell.glazedlists.EventList;
@Inject
private UISynchronize sync;
+ @Inject
+ private EMenuService menuService;
+
private DescriptiveDataSet descriptiveDataSet;
private NatTable natTable;
//register aggregation configuration
summaryRowLayer.addConfiguration(new AggregationConfiguration(this));
+ //+++CONTEXT MENU+++
+ menuService.registerContextMenu(natTable, "eu.etaxonomy.taxeditor.editor.popupmenu.charactermatrix"); //$NON-NLS-1$
+ // get the menu registered by EMenuService
+ final Menu e4Menu = natTable.getMenu();
+ // remove the menu reference from NatTable instance
+ natTable.setMenu(null);
+ natTable.addConfiguration(
+ new AbstractUiBindingConfiguration() {
+ @Override
+ public void configureUiBindings(
+ UiBindingRegistry uiBindingRegistry) {
+ // add e4 menu to NatTable
+ new PopupMenuBuilder(natTable, e4Menu)
+ .build();
+
+ // register the UI binding for header, corner and body region
+ uiBindingRegistry.registerMouseDownBinding(
+ new MouseEventMatcher(
+ SWT.NONE,
+ null,
+ MouseEventMatcher.RIGHT_BUTTON),
+ new PopupMenuAction(e4Menu));
+ }
+ });
+
natTable.configure();
}
job.schedule();
}
+ public IStructuredSelection getSelection(){
+ Set<Range> selectedRowPositions = bodyLayer.getSelectionLayer().getSelectedRowPositions();
+ List<Object> selectedObjects = new ArrayList<>();
+ for (Range range : selectedRowPositions) {
+ for(int i=range.start;i<range.end;i++){
+ selectedObjects.add(bodyDataProvider.getRowObject(i));
+ }
+ }
+ return new StructuredSelection(selectedObjects);
+ }
+
private void loadingDone() {
this.part.loadingDone();
}
import org.eclipse.e4.ui.model.application.ui.MDirtyable;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StackLayout;
}
}
+ public IStructuredSelection getSelection(){
+ return matrix.getSelection();
+ }
+
public void setDirty() {
this.dirty.setDirty(true);
}
return selService;
}
+ public CharacterMatrix getMatrix() {
+ return matrix;
+ }
+
@Persist
@Override
public void save(IProgressMonitor monitor) {
--- /dev/null
+/**
+* Copyright (C) 2018 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.descriptiveDataSet.matrix.handler;
+
+import eu.etaxonomy.cdm.model.common.MarkerType;
+
+/**
+ * @author pplitzner
+ * @since Sep 7, 2018
+ *
+ */
+public class CreateDefaultTaxonDescriptionHandler extends CreateTaxonDescriptionHandler{
+
+ @Override
+ protected boolean getMarkerFlag() {
+ return true;
+ }
+
+ @Override
+ protected MarkerType getMarkerType() {
+ return MarkerType.USE();
+ }
+}
--- /dev/null
+/**
+* Copyright (C) 2018 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.descriptiveDataSet.matrix.handler;
+
+import eu.etaxonomy.cdm.model.common.MarkerType;
+
+/**
+ * @author pplitzner
+ * @since Sep 7, 2018
+ *
+ */
+public class CreateLiteratureTaxonDescriptionHandler extends CreateTaxonDescriptionHandler{
+
+ @Override
+ protected boolean getMarkerFlag() {
+ return true;
+ }
+
+ @Override
+ protected MarkerType getMarkerType() {
+ return MarkerType.IN_BIBLIOGRAPHY();
+ }
+}
--- /dev/null
+/**
+* Copyright (C) 2018 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.descriptiveDataSet.matrix.handler;
+
+import javax.inject.Named;
+
+import org.eclipse.e4.core.di.annotations.CanExecute;
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.ui.di.UISynchronize;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
+import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+import eu.etaxonomy.cdm.api.service.IDescriptiveDataSetService;
+import eu.etaxonomy.cdm.api.service.dto.TaxonRowWrapperDTO;
+import eu.etaxonomy.cdm.model.common.MarkerType;
+import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.CharacterMatrixPart;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author pplitzner
+ * @since Sep 7, 2018
+ *
+ */
+public abstract class CreateTaxonDescriptionHandler {
+
+ @Execute
+ public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart, UISynchronize sync) {
+ CharacterMatrixPart matrixPart = (CharacterMatrixPart) activePart.getObject();
+ DescriptiveDataSet descriptiveDataSet = matrixPart.getDescriptiveDataSet();
+ TaxonNode node = (TaxonNode) matrixPart.getSelection().getFirstElement();
+ TaxonRowWrapperDTO taxonRowWrapperDTO = CdmStore.getService(IDescriptiveDataSetService.class)
+ .createTaxonDescription(descriptiveDataSet.getUuid(), node.getUuid(), getMarkerType(), getMarkerFlag());
+ matrixPart.getMatrix().getDescriptions().add(taxonRowWrapperDTO);
+ }
+
+ protected abstract boolean getMarkerFlag();
+
+
+ protected abstract MarkerType getMarkerType();
+
+ @CanExecute
+ public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
+ MHandledMenuItem menuItem){
+ boolean canExecute = false;
+ IStructuredSelection selection = ((CharacterMatrixPart)activePart.getObject()).getSelection();
+ canExecute = selection.size()==1
+ && selection.getFirstElement() instanceof TaxonNode;
+ menuItem.setVisible(canExecute);
+ return canExecute;
+ }
+
+}