eu.etaxonomy.taxeditor.editor,
org.eclipse.e4.ui.model.workbench;bundle-version="1.2.0.v20160229-1459",
org.eclipse.e4.ui.di,
- javax.inject
+ javax.inject,
+ org.eclipse.e4.ui.services,
+ org.eclipse.e4.ui.workbench
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: org.eclipse.core.resources,
org.eclipse.core.runtime,
<?xml version="1.0" encoding="ASCII"?>
-<fragment:ModelFragments xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/descriptor/basic" xmlns:fragment="http://www.eclipse.org/ui/2010/UIModel/fragment" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmlns:ui="http://www.eclipse.org/ui/2010/UIModel/application/ui" xmi:id="_OhwnQCTfEeeiN5lBIuqN3g">
+<fragment:ModelFragments xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/descriptor/basic" xmlns:commands="http://www.eclipse.org/ui/2010/UIModel/application/commands" xmlns:fragment="http://www.eclipse.org/ui/2010/UIModel/fragment" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmlns:ui="http://www.eclipse.org/ui/2010/UIModel/application/ui" xmi:id="_OhwnQCTfEeeiN5lBIuqN3g">
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_oDvMsCTfEeeiN5lBIuqN3g" featurename="children" parentElementId="eu.etaxonomy.taxeditor.workbench.trimcontribution.mainToolbar">
<elements xsi:type="menu:ToolControl" xmi:id="_7kZI4CTfEeeiN5lBIuqN3g" elementId="eu.etaxonomy.taxeditor.navigation.toolcontrol.search_bar" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.search.SearchBar"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_Z-4rwJIVEeeJAdt8ZUxyaw" featurename="descriptors" parentElementId="org.eclipse.e4.legacy.ide.application">
- <elements xsi:type="basic:PartDescriptor" xmi:id="_gH5RYJIVEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator" label="%view.name.2" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.navigation/icons/edit_16x16.gif" closeable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4"/>
+ <elements xsi:type="basic:PartDescriptor" xmi:id="_gH5RYJIVEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator" label="%view.name.2" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.navigation/icons/edit_16x16.gif" closeable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4">
+ <handlers xmi:id="_Ic-1EJIyEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.MoveTaxonHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.MoveTaxonHandlerE4" command="_w4RNkJIxEeeJAdt8ZUxyaw"/>
+ <handlers xmi:id="_xeEM0JIyEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.RefreshTreeHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.RefreshTreeHandlerE4" command="_ukhM0JIyEeeJAdt8ZUxyaw"/>
+ <handlers xmi:id="_0d3l0JIyEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.CopyHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.CopyHandlerE4" command="_EJ-u0JIyEeeJAdt8ZUxyaw"/>
+ <handlers xmi:id="_3I_vUJIyEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.ChangeAcceptedTaxonToSynonymHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.ChangeAcceptedTaxonToSynonymHandlerE4" command="_p7Oi8JIxEeeJAdt8ZUxyaw"/>
+ <handlers xmi:id="_6l8-YJIyEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.SetSecReferenceForSubtreeHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.SetSecReferenceForSubtreeHandlerE4" command="_uFj1YJIxEeeJAdt8ZUxyaw"/>
+ <handlers xmi:id="_-QYowJIyEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.NewClassificationHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.NewClassificationHandlerE4" command="_Vco-4JIxEeeJAdt8ZUxyaw"/>
+ <handlers xmi:id="_Bc8EUJIzEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.NewTaxonNodeHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.NewTaxonNodeHandlerE4" command="_Nx06MJIvEeeJAdt8ZUxyaw"/>
+ <handlers xmi:id="_GTyegJIzEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.MoveFactualDataHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.MoveFactualDataHandlerE4" command="_3PRy8JIxEeeJAdt8ZUxyaw"/>
+ <handlers xmi:id="_JPKqgJIzEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.CreateClassificationHierarchyHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.CreateClassificationHierarchyHandlerE4" command="_jXX0YJIxEeeJAdt8ZUxyaw"/>
+ <handlers xmi:id="_M64uUJIzEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.DeleteHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.DeleteHandlerE4" command="__n644JIxEeeJAdt8ZUxyaw"/>
+ <handlers xmi:id="_QQq-YJIzEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.CloneClassificationHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.CloneClassificationHandlerE4" command="_nOOxMJIxEeeJAdt8ZUxyaw"/>
+ <menus xsi:type="menu:PopupMenu" xmi:id="_XNXnkJIvEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigator.popupmenu.taxonnavigator">
+ <children xsi:type="menu:Menu" xmi:id="_yzFmYJIvEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.menu.new" label="%menu.label">
+ <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_7FKxUJIvEeeJAdt8ZUxyaw" coreExpressionId="isCdmStoreConnected"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_wzftMJIvEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.menu.new.taxon" label="%command.label.2" command="_Nx06MJIvEeeJAdt8ZUxyaw"/>
+ <children xsi:type="menu:MenuSeparator" xmi:id="_33c4IJIvEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.menuseparator.0"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_4dTXMJIvEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.menu.new.classification" label="%command.label.3" command="_Vco-4JIxEeeJAdt8ZUxyaw"/>
+ </children>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_9hdNkJIvEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.fixclassificationhierarchy" label="%command.label.fixClassificationHierarchy" command="_jXX0YJIxEeeJAdt8ZUxyaw"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_ivOrwJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.cloneclassification" label="Clone Classification" command="_nOOxMJIxEeeJAdt8ZUxyaw"/>
+ <children xsi:type="menu:MenuSeparator" xmi:id="_ktyqMJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.menuseparator.1"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_lALasJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.accTaxonToSynonym" label="%command.label.6" command="_p7Oi8JIxEeeJAdt8ZUxyaw"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_mLjosJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.setsecforsubtree" label="%command.label.setSecForSubtree" command="_uFj1YJIxEeeJAdt8ZUxyaw"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_nh_3MJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.moveTaxon" label="%command.label.7" command="_w4RNkJIxEeeJAdt8ZUxyaw"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_o1PAsJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.movefactualdata" label="%command.label.moveFactualData" command="_3PRy8JIxEeeJAdt8ZUxyaw"/>
+ <children xsi:type="menu:MenuSeparator" xmi:id="_rBdnsJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.menuseparator.2"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_rWZV4JIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.import" visible="false" label="%command.label.8"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_wNp_wJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.export" visible="false" label="%command.label.9"/>
+ <children xsi:type="menu:MenuSeparator" xmi:id="_x0uEMJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.menuseparator.3" visible="false"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_yH9JQJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.delete" label="%command.label.10" command="__n644JIxEeeJAdt8ZUxyaw"/>
+ <children xsi:type="menu:MenuSeparator" xmi:id="_z0Q6EJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.menuseparator.4"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_0FX4MJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.refresh" label="%command.label.11" command="_ukhM0JIyEeeJAdt8ZUxyaw"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_1JIbQJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.copy" label="%command.label.12" command="_EJ-u0JIyEeeJAdt8ZUxyaw"/>
+ <children xsi:type="menu:MenuSeparator" xmi:id="_24NMMJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.menuseparator.5"/>
+ <children xsi:type="menu:DynamicMenuContribution" xmi:id="_3d1BwJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.dynamicmenucontribution.openInCdmViewer" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.view.CdmViewerContextMenuE4"/>
+ </menus>
+ </elements>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_wITZ8JIVEeeJAdt8ZUxyaw" featurename="children" parentElementId="eu.etaxonomy.taxeditor.menu.showView" positionInList="">
<elements xsi:type="menu:HandledMenuItem" xmi:id="_wITZ8ZIVEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigator.showViewMenu.navigator" label="%command.label" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.navigation/icons/edit_16x16.gif">
<parameters xmi:id="_wITZ85IVEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.store.showView.parameter.detailsView" name="eu.etaxonomy.taxeditor.workbench.commandparameter.partName" value="eu.etaxonomy.taxeditor.navigation.navigator"/>
</elements>
</fragments>
+ <fragments xsi:type="fragment:StringModelFragment" xmi:id="_MOKIAJIvEeeJAdt8ZUxyaw" featurename="commands" parentElementId="org.eclipse.e4.legacy.ide.application">
+ <elements xsi:type="commands:Command" xmi:id="_Nx06MJIvEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.command.create.taxonNode" commandName="%command.name"/>
+ <elements xsi:type="commands:Command" xmi:id="_Vco-4JIxEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.create.classification" commandName="%command.name.0"/>
+ <elements xsi:type="commands:Command" xmi:id="_jXX0YJIxEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.handler.OpenFixClassificationHierarchyHandler" commandName="%command.name.10"/>
+ <elements xsi:type="commands:Command" xmi:id="_nOOxMJIxEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.cloneClassification" commandName="Clone Classification"/>
+ <elements xsi:type="commands:Command" xmi:id="_p7Oi8JIxEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigator.command.update.changeAcceptedToSynonym" commandName="%command.name.5"/>
+ <elements xsi:type="commands:Command" xmi:id="_uFj1YJIxEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigator.command.update.setSecundumForSubtree" commandName="%command.name.setSecForSubtree"/>
+ <elements xsi:type="commands:Command" xmi:id="_w4RNkJIxEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.command.update.moveTaxon" commandName="%command.name.2"/>
+ <elements xsi:type="commands:Command" xmi:id="_3PRy8JIxEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.moveFactualData" commandName="%command.name.moveFactualData"/>
+ <elements xsi:type="commands:Command" xmi:id="__n644JIxEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.command.delete" commandName="%command.name.11"/>
+ <elements xsi:type="commands:Command" xmi:id="_EJ-u0JIyEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.command.copyTaxonName" commandName="%command.name.4"/>
+ <elements xsi:type="commands:Command" xmi:id="_ukhM0JIyEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.command.refreshNavigator" commandName="Refresh Navigator"/>
+ </fragments>
</fragment:ModelFragments>
</extension>
<extension
point="org.eclipse.ui.commands">
- <command
- defaultHandler="eu.etaxonomy.taxeditor.navigation.navigator.handler.MoveTaxonHandler"
- id="eu.etaxonomy.taxeditor.navigation.command.update.moveTaxon"
- name="%command.name.2">
- </command>
- <command
- defaultHandler="eu.etaxonomy.taxeditor.navigation.navigator.handler.RefreshTreeHandler"
- id="org.eclipse.ui.file.refresh"
- name="%command.name.3">
- </command>
- <command
- defaultHandler="eu.etaxonomy.taxeditor.navigation.navigator.handler.CopyHandler"
- id="eu.etaxonomy.taxeditor.navigation.command.copyTaxonName"
- name="%command.name.4">
- </command>
- <command
- defaultHandler="eu.etaxonomy.taxeditor.navigation.navigator.handler.ChangeAcceptedTaxonToSynonymHandler"
- id="eu.etaxonomy.taxeditor.navigator.command.update.changeAcceptedToSynonym"
- name="%command.name.5">
- </command>
- <command
- defaultHandler="eu.etaxonomy.taxeditor.navigation.navigator.handler.SetSecReferenceForSubtreeHandler"
- id="eu.etaxonomy.taxeditor.navigator.command.update.setSecundumForSubtree"
- name="%command.name.setSecForSubtree">
- </command>
- <command
- defaultHandler="eu.etaxonomy.taxeditor.navigation.navigator.handler.NewClassificationHandler"
- id="eu.etaxonomy.taxeditor.navigation.create.classification"
- name="%command.name.0">
- </command>
- <command
- defaultHandler="eu.etaxonomy.taxeditor.navigation.navigator.handler.NewTaxonNodeHandler"
- id="eu.etaxonomy.taxeditor.navigation.command.create.taxonNode"
- name="%command.name">
- </command>
<command
defaultHandler="eu.etaxonomy.taxeditor.navigation.key.polytomous.handler.NewPolytomousKeyHandler"
id="eu.etaxonomy.taxeditor.navigation.key.polytomous.newKey"
id="eu.etaxonomy.taxeditor.navigation.key.polytomous.refreshKeyNodes"
name="%command.name.9">
</command>
- <command
- defaultHandler="eu.etaxonomy.taxeditor.navigation.navigator.handler.MoveFactualDataHandler"
- id="eu.etaxonomy.taxeditor.navigation.moveFactualData"
- name="%command.name.moveFactualData">
- </command>
- <command
- defaultHandler="eu.etaxonomy.taxeditor.navigation.navigator.handler.CreateClassificationHierarchyHandler"
- id="eu.etaxonomy.taxeditor.navigation.navigator.handler.OpenFixClassificationHierarchyHandler"
- name="%command.name.10">
- </command>
- <command
- defaultHandler="eu.etaxonomy.taxeditor.navigation.navigator.handler.DeleteHandler"
- id="eu.etaxonomy.taxeditor.navigation.command.delete"
- name="%command.name.11">
- </command>
<command
defaultHandler="eu.etaxonomy.taxeditor.navigation.key.polytomous.handler.DeleteHandler"
id="eu.etaxonomy.taxeditor.navigation.key.polytomous.command.delete"
name="%command.name.11">
</command>
- <command
- defaultHandler="eu.etaxonomy.taxeditor.navigation.navigator.handler.CloneClassificationHandler"
- id="eu.etaxonomy.taxeditor.navigation.cloneClassification"
- name="Clone Classification">
- </command>
</extension>
<extension
point="org.eclipse.ui.handlers">
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.e4.ui.di.Focus;
+import org.eclipse.e4.ui.services.EMenuService;
+import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWT;
import eu.etaxonomy.cdm.model.taxon.TaxonNodeByNameComparator;
import eu.etaxonomy.cdm.model.taxon.TaxonNodeByRankAndNameComparator;
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.DataChangeBridge;
import eu.etaxonomy.taxeditor.model.IDataChangeBehavior;
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
private TreeViewer viewer;
+ @Inject
+ private ESelectionService selService;
+
+ private ISelectionChangedListener selectionChangedListener;
+
@Inject
public TaxonNavigatorE4() {
}
@PostConstruct
- private void create(Composite parent){
+ private void create(Composite parent, EMenuService menuService){
FillLayout layout = new FillLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
viewer = new TreeViewer(parent);
viewer.getControl().setLayoutData(LayoutConstants.FILL());
+ viewer.setContentProvider(new TaxonNavigatorContentProviderE4());
+ viewer.setLabelProvider(new TaxonNavigatorLabelProviderE4());
+ viewer.setInput(getInitialInput());
+
+ //propagate selection
+ selectionChangedListener = (event -> selService.setSelection(AbstractUtility.getElementsFromSelectionChangedEvent(event)));
+ viewer.addSelectionChangedListener(selectionChangedListener);
+
+ //create context menu
+ menuService.registerContextMenu(viewer.getControl(), "eu.etaxonomy.taxeditor.navigator.popupmenu.taxonnavigator");
+
init();
}
CdmApplicationState.getCurrentDataChangeService().register(this);
}
CdmStore.getLoginManager().addObserver(this);
-
- viewer.setContentProvider(new TaxonNavigatorContentProviderE4());
- viewer.setLabelProvider(new TaxonNavigatorLabelProviderE4());
- viewer.setInput(getInitialInput());
}
/**
--- /dev/null
+/**
+ *
+ */
+package eu.etaxonomy.taxeditor.navigation.navigator.e4.handler;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.UUID;
+
+import javax.inject.Named;
+
+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.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.swt.widgets.Shell;
+
+import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
+import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
+import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4;
+import eu.etaxonomy.taxeditor.navigation.navigator.operation.ChangeAcceptedTaxonToSynonymOperation;
+import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
+import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
+
+/**
+ *
+ * @author pplitzner
+ * @date 05.09.2017
+ *
+ */
+public class ChangeAcceptedTaxonToSynonymHandlerE4 extends DeleteHandlerE4 implements IPostOperationEnabled {
+
+ private UUID newAcceptedTaxonNodeUuid;
+
+ @Override
+ public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection,
+ @Named(IServiceConstants.ACTIVE_SHELL)Shell shell,
+ @Named(IServiceConstants.ACTIVE_PART)MPart activePart,
+ MHandledMenuItem menuItem) {
+
+ TaxonNavigatorE4 taxonNavigator = (TaxonNavigatorE4) activePart.getObject();
+
+ Iterator selectionIterator = selection.iterator();
+ Set<ITaxonTreeNode> treeNodes = new HashSet<ITaxonTreeNode>();
+
+ while (selectionIterator.hasNext()){
+ Object object = selectionIterator.next();
+ if(object instanceof ITaxonTreeNode) {
+ treeNodes.add((ITaxonTreeNode) object);
+ }
+ }
+ boolean allEditorsClosed = true;
+ for (ITaxonTreeNode treeNode : treeNodes){
+ if(treeNode instanceof TaxonNode) {
+ allEditorsClosed &= closeObsoleteEditor((TaxonNode) treeNode);
+ }
+ }
+ AbstractPostOperation operation = null;
+ if (treeNodes.size() == 1 ){
+ ITaxonTreeNode treeNode = treeNodes.iterator().next();
+ ITaxonTreeNode oldAcceptedTaxonNode =treeNode;
+
+ // check if taxon has no children
+ if(((TaxonNode)oldAcceptedTaxonNode).getCountChildren() > 0) {
+ MessagingUtils.warningDialog(Messages.ChangeAcceptedTaxonToSynonymHandler_PREREQUISITE, this,
+ Messages.ChangeAcceptedTaxonToSynonymHandler_PREREQUISITE_MESSAGE);
+ return;
+ }
+ /*if(((TaxonNode)oldAcceptedTaxonNode).getTaxon().hasSynonyms()) {
+ EditorUtil.warningDialog("Prerequisite not met", this,
+ "The accepted taxon must not have any synonyms. You need to move all synonyms to " +
+ "another taxon before attempting to turn the accepted " +
+ "taxon into a synonym.");
+ return null;
+ }*/
+
+ List<UUID> excludeTaxa = new ArrayList<UUID>();
+ excludeTaxa.add(((TaxonNode)oldAcceptedTaxonNode).getTaxon().getUuid());
+ TaxonNode newAcceptedTaxonNode = TaxonNodeSelectionDialog.select(shell,
+ taxonNavigator.getConversationHolder(),
+ Messages.ChangeAcceptedTaxonToSynonymHandler_CHOOSE_TAXON,
+ excludeTaxa,
+ null,
+ ((TaxonNode)oldAcceptedTaxonNode).getClassification());
+
+ if (newAcceptedTaxonNode == null) {
+ return;
+ }
+
+ if (allEditorsClosed){
+
+ operation = new ChangeAcceptedTaxonToSynonymOperation(menuItem.getLocalizedLabel(),
+ NavigationUtil.getUndoContext(),
+ oldAcceptedTaxonNode,
+ newAcceptedTaxonNode,
+ taxonNavigator,
+ taxonNavigator,
+ taxonNavigator);
+
+ AbstractUtility.executeOperation(operation);
+ }
+ } else{
+ if( MessageDialog.openConfirm(shell, Messages.ChangeAcceptedTaxonToSynonymHandler_MOVE_SYNONYMY, Messages.ChangeAcceptedTaxonToSynonymHandler_MOVE_SYNONYMY_MESSAGE)){
+ return;
+ }
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean postOperation(CdmBase objectAffectedByOperation) {
+ //FIXME E4 migrate
+// Display.getDefault().asyncExec(new Runnable(){
+//
+// @Override
+// public void run() {
+// EditorUtil.close(editor.getMultiPageTaxonEditor());
+//
+// try {
+// MultiPageTaxonEditor possibleOpenEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(newAcceptedTaxonNodeUuid);
+// if(possibleOpenEditor != null){
+// EditorUtil.close(possibleOpenEditor);
+// }
+// EditorUtil.openTaxonNodeE4(newAcceptedTaxonNodeUuid);
+// } catch (PartInitException e) {
+// MessagingUtils.error(this.getClass(), e);
+// throw new RuntimeException(e);
+// } catch (Exception e) {
+// MessagingUtils.warningDialog(Messages.ChangeAcceptedTaxonToSynonymHandler_CREATE_FAILED, this, e.getMessage());
+// }
+// }
+//
+// });
+ return true;
+ }
+
+ @Override
+ public boolean onComplete() {
+ return false;
+ }
+}
--- /dev/null
+package eu.etaxonomy.taxeditor.navigation.navigator.e4.handler;
+
+import javax.inject.Named;
+
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+
+import eu.etaxonomy.cdm.model.reference.Reference;
+import eu.etaxonomy.cdm.model.taxon.Classification;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
+import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
+import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4;
+import eu.etaxonomy.taxeditor.navigation.operation.CloneClassificationOperation;
+import eu.etaxonomy.taxeditor.store.StoreUtil;
+import eu.etaxonomy.taxeditor.ui.section.classification.CloneClassificationWizard;
+
+/**
+ *
+ * @author pplitzner
+ * @date 05.09.2017
+ *
+ */
+public class CloneClassificationHandlerE4 {
+
+ public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection,
+ @Named(IServiceConstants.ACTIVE_SHELL)Shell shell,
+ @Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
+
+ TaxonNavigatorE4 taxonNavigator = (TaxonNavigatorE4) activePart.getObject();
+
+ Object selectedElement = selection.getFirstElement();
+ if (selectedElement instanceof TaxonNode && !((TaxonNode)selectedElement).hasTaxon()) {
+ Classification classification = ((TaxonNode)selectedElement).getClassification();
+ CloneClassificationWizard wizard = new CloneClassificationWizard(classification);
+ WizardDialog dialog = new WizardDialog(shell, wizard);
+ dialog.open();
+
+ String classificationName = wizard.getClassificationName();
+ TaxonRelationshipType relationType = wizard.getRelationType();
+ Reference reference = wizard.getReference();
+
+ CloneClassificationOperation operation = new CloneClassificationOperation(Messages.CloneClassificationHandler_CLONE_CLASSIFICATION,
+ StoreUtil.getUndoContext(), classification, classificationName, reference, relationType,
+ NavigationUtil.getNavigator(false), NavigationUtil.getNavigator(false));
+
+ AbstractUtility.executeOperation(operation);
+ taxonNavigator.refresh();
+ }
+ }
+
+}
--- /dev/null
+/**
+* Copyright (C) 2009 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.navigation.navigator.e4.handler;
+
+import javax.inject.Named;
+
+import org.eclipse.core.runtime.IStatus;
+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.TreeSelection;
+
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4;
+import eu.etaxonomy.taxeditor.navigation.navigator.operation.CopyOperation;
+import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
+import eu.etaxonomy.taxeditor.store.StoreUtil;
+
+/**
+ *
+ * @author pplitzner
+ * @date 05.09.2017
+ *
+ */
+public class CopyHandlerE4 {
+
+ public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection,
+ @Named(IServiceConstants.ACTIVE_PART)MPart activePart,
+ MHandledMenuItem menuItem) {
+
+ TaxonNavigatorE4 taxonNavigator = (TaxonNavigatorE4) activePart.getObject();
+
+ if(selection.size() == 1) {
+ Object selectedObject = selection.getFirstElement();
+ if (selectedObject instanceof TaxonNode) {
+ AbstractPostOperation operation = new CopyOperation(menuItem.getLocalizedLabel(), StoreUtil.getUndoContext(),
+ (TaxonNode)selectedObject, taxonNavigator);
+ IStatus status = AbstractUtility.executeOperation(operation);
+ }
+ }
+ }
+
+}
--- /dev/null
+package eu.etaxonomy.taxeditor.navigation.navigator.e4.handler;
+
+import javax.inject.Named;
+
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.jface.viewers.TreeSelection;
+
+import eu.etaxonomy.cdm.model.taxon.Classification;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
+import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4;
+import eu.etaxonomy.taxeditor.navigation.operation.CreateNewTaxonHierarchyOperation;
+import eu.etaxonomy.taxeditor.store.StoreUtil;
+
+/**
+ *
+ * @author pplitzner
+ * @date 05.09.2017
+ *
+ */
+public class CreateClassificationHierarchyHandlerE4 {
+
+ public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection,
+ @Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
+
+ TaxonNavigatorE4 taxonNavigator = (TaxonNavigatorE4) activePart.getObject();
+
+ Object selectedElement = selection.getFirstElement();
+ if (selectedElement instanceof TaxonNode && !((TaxonNode)selectedElement).hasTaxon()) {
+ Classification classification = ((TaxonNode) selectedElement).getClassification();
+ try {
+ CreateNewTaxonHierarchyOperation operation = new CreateNewTaxonHierarchyOperation(Messages.CreateClassificationHierarchyHandler_CREATE_HIERARCHY, StoreUtil.getUndoContext(),classification, taxonNavigator, taxonNavigator);
+ AbstractUtility.executeOperation(operation);
+ taxonNavigator.refresh();
+ } catch (Exception e) {
+ MessagingUtils.messageDialog(Messages.CreateClassificationHierarchyHandler_FAILED, CreateClassificationHierarchyHandlerE4.class,
+ Messages.CreateClassificationHierarchyHandler_FAILED_MESSAGE, e);
+ }
+ }
+ }
+}
--- /dev/null
+/**
+* Copyright (C) 2007 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.navigation.navigator.e4.handler;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.inject.Named;
+
+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.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.swt.widgets.Shell;
+
+import eu.etaxonomy.cdm.api.service.config.NodeDeletionConfigurator.ChildHandling;
+import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
+import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator;
+import eu.etaxonomy.cdm.model.taxon.Classification;
+import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
+import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
+import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4;
+import eu.etaxonomy.taxeditor.navigation.navigator.operation.DeleteOperation;
+import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
+import eu.etaxonomy.taxeditor.ui.dialog.configurator.deleteConfigurator.DeleteConfiguratorDialog;
+
+/**
+ *
+ * @author pplitzner
+ * @date 05.09.2017
+ *
+ */
+public class DeleteHandlerE4 {
+
+ protected static final String SKIP = Messages.DeleteHandler_SKIP;
+ protected static final String MOVE_CHILDREN_TO_PARENT_NODE = Messages.DeleteHandler_MOVE_TO_PARENT;
+ protected static final String DELETE_ALL_CHILDREN = Messages.DeleteHandler_DELETE_ALL;
+ protected static final String THERE_ARE_CHILDNODES_WHICH_WILL_BE_DELETED_TOO = Messages.DeleteHandler_THERE_ARE_CHILDNODES;
+ protected static final String THE_TREE_HAS_CHILDREN_THEY_WILL_BE_DELETED_TOO = Messages.DeleteHandler_THERE_ARE_CHILDREN;
+ protected static final String DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S = Messages.DeleteHandler_DELETE_NODE;
+ protected static final String DO_YOU_REALLY_WANT_TO_DELETE_THE_CLASSIFICATION = Messages.DeleteHandler_DELETE_CLASSIFICATION;
+ protected static final String CONFIRM_DELETION = Messages.DeleteHandler_CONFIRM_DELETE;
+
+ public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection,
+ @Named(IServiceConstants.ACTIVE_SHELL)Shell shell,
+ @Named(IServiceConstants.ACTIVE_PART)MPart activePart,
+ MHandledMenuItem menuItem) {
+
+ TaxonNavigatorE4 taxonNavigator = (TaxonNavigatorE4) activePart.getObject();
+
+ Iterator selectionIterator = selection.iterator();
+ Set<ITaxonTreeNode> treeNodes = new HashSet<ITaxonTreeNode>();
+
+ while (selectionIterator.hasNext()){
+ Object object = selectionIterator.next();
+ if(object instanceof ITaxonTreeNode) {
+ treeNodes.add((ITaxonTreeNode) object);
+ }
+ }
+ boolean allEditorsClosed = true;
+ for (ITaxonTreeNode treeNode : treeNodes){
+ if(treeNode instanceof TaxonNode) {
+ allEditorsClosed &= closeObsoleteEditor((TaxonNode) treeNode);
+ }
+ }
+ AbstractPostOperation operation = null;
+ TaxonDeletionConfigurator config = new TaxonDeletionConfigurator();
+ config.setDeleteInAllClassifications(false);
+
+ if (treeNodes.size() == 1 ){
+ try {
+
+ ITaxonTreeNode treeNode = treeNodes.iterator().next();
+ ITaxonTreeNode taxonNode =treeNode;
+ TaxonNodeDeletionConfigurator configNodes = new TaxonNodeDeletionConfigurator();
+
+ //configNodes.setDeleteTaxon(false);
+ if (taxonNode instanceof Classification && taxonNode.hasChildNodes()){
+ if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(config, shell, CONFIRM_DELETION, DO_YOU_REALLY_WANT_TO_DELETE_THE_CLASSIFICATION+THE_TREE_HAS_CHILDREN_THEY_WILL_BE_DELETED_TOO)){
+ return;
+ }
+ } else if (taxonNode instanceof Classification && !taxonNode.hasChildNodes()){
+ if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(config, shell, CONFIRM_DELETION, DO_YOU_REALLY_WANT_TO_DELETE_THE_CLASSIFICATION)){
+ return;
+ }
+ } else {
+
+ if (taxonNode.hasChildNodes()){
+ DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(
+ config,
+ shell,
+ CONFIRM_DELETION,
+ null,
+ DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S+THERE_ARE_CHILDNODES_WHICH_WILL_BE_DELETED_TOO,
+ MessageDialog.WARNING, new String[] { DELETE_ALL_CHILDREN,
+ MOVE_CHILDREN_TO_PARENT_NODE, SKIP }, 0);
+ int dialog_result = dialog.open();
+
+ if (dialog_result == 0){
+ //delete all children
+ configNodes.setChildHandling(ChildHandling.DELETE);
+ config.setTaxonNodeConfig(configNodes);
+ } else if (dialog_result == 1){
+ //move children
+ configNodes.setChildHandling(ChildHandling.MOVE_TO_PARENT);
+ config.setTaxonNodeConfig(configNodes);
+ } else if (dialog_result == 2){
+ //skip
+ return;
+
+ }
+ }else{
+ if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(configNodes, shell, CONFIRM_DELETION, DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S)){
+ return;
+ }
+ config.setTaxonNodeConfig(configNodes);
+ }
+ }
+
+ if (allEditorsClosed){
+ /*if(! MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the selected nodes?")){
+ return null;
+ }*/
+
+ operation = new DeleteOperation(menuItem.getLocalizedLabel(),
+ NavigationUtil.getUndoContext(),
+ taxonNode,
+ config,
+ taxonNavigator,
+ taxonNavigator,
+ taxonNavigator);
+
+ AbstractUtility.executeOperation(operation);
+
+ //}
+ }
+
+
+
+ } catch (Exception e){
+ MessagingUtils.error(getClass(), e);
+ }
+ } else{
+ try{
+ if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(config, shell, CONFIRM_DELETION, DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S)){
+ return;
+ }
+ if (allEditorsClosed){
+
+ operation = new DeleteOperation(menuItem.getLocalizedLabel(),
+ NavigationUtil.getUndoContext(),
+ treeNodes,
+ new TaxonDeletionConfigurator(),
+ taxonNavigator,
+ taxonNavigator,
+ taxonNavigator);
+
+ AbstractUtility.executeOperation(operation);
+
+ }
+ }catch (Exception e){
+ MessagingUtils.error(getClass(), e);
+ }
+ }
+ return;
+ }
+
+ protected boolean closeObsoleteEditor(TaxonNode taxonNode){
+ //FIXME E4 migrate
+ boolean result = true;
+// for (IEditorReference ref : activePage.getEditorReferences()) {
+// try {
+// String treeIndex = ((ITreeNode)taxonNode).treeIndex();
+//
+//
+// IEditorInput input = ref.getEditorInput();
+// if (input instanceof TaxonEditorInput) {
+// TaxonNode node = ((TaxonEditorInput) input).getTaxonNode();
+// //if node is a child of taxonNode then close the editor
+// if( ((ITreeNode) node).treeIndex().startsWith(treeIndex)){
+// //if (taxonNode.equals(node)) {
+// result &= activePage.closeEditor(ref.getEditor(false), true);
+//
+// }
+// }
+// } catch (PartInitException e) {
+// continue;
+// }
+// }
+ return result;
+ }
+}
--- /dev/null
+package eu.etaxonomy.taxeditor.navigation.navigator.e4.handler;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+import javax.inject.Named;
+
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+import eu.etaxonomy.cdm.api.service.IDescriptionService;
+import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
+import eu.etaxonomy.cdm.api.service.ITaxonService;
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
+import eu.etaxonomy.cdm.model.taxon.Taxon;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
+import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
+import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
+
+public class MoveFactualDataHandlerE4 {
+
+ public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection,
+ @Named(IServiceConstants.ACTIVE_SHELL)Shell shell,
+ @Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
+
+ TaxonNavigatorE4 taxonNavigator = (TaxonNavigatorE4) activePart.getObject();
+
+ if(taxonNavigator!=null){
+ Object object = selection.getFirstElement();
+ if(object instanceof TaxonNode){
+ TaxonNode taxonNode = HibernateProxyHelper.deproxy(object, TaxonNode.class);
+ final TaxonNode sourceTaxonNode = CdmStore.getService(ITaxonNodeService.class).load(taxonNode.getUuid());
+ if(NavigationUtil.isDirty(sourceTaxonNode)){
+ MessageDialog.openWarning(shell, Messages.MoveFactualDataHandler_UNSAVED_SOURCE, Messages.MoveFactualDataHandler_UNSAVED_SOURCE_MESSAGE);
+ return;
+ }
+ //reload to avoid session conflicts
+ Taxon taxon = HibernateProxyHelper.deproxy(CdmStore.getService(ITaxonService.class).load(sourceTaxonNode.getTaxon().getUuid()), Taxon.class);
+ if(taxon!=null){
+ // Choose the target taxon
+ List<UUID> excludeTaxa = new ArrayList<UUID>();
+ excludeTaxa.add(taxon.getUuid());
+ TaxonNode dialogTaxonNode = TaxonNodeSelectionDialog.select(shell,
+ taxonNavigator.getConversationHolder(),
+ Messages.MoveFactualDataHandler_CHOOSE_TAXON,
+ excludeTaxa,
+ sourceTaxonNode,
+ sourceTaxonNode.getClassification());
+ if (dialogTaxonNode == null) {
+ return;
+ }
+ //reload to avoid session conflicts
+ final TaxonNode targetTaxonNode = CdmStore.getService(ITaxonNodeService.class).load(dialogTaxonNode.getUuid());
+ if(NavigationUtil.isDirty(targetTaxonNode)){
+ MessageDialog.openWarning(shell, Messages.MoveFactualDataHandler_UNSAVED_TARGET, Messages.MoveFactualDataHandler_UNSAVED_TARGET_MESSAGE);
+ return;
+ }
+ CdmStore.getService(IDescriptionService.class).moveTaxonDescriptions(taxon.getUuid(),targetTaxonNode.getTaxon().getUuid());
+
+ taxonNavigator.getConversationHolder().bind();
+ taxonNavigator.getConversationHolder().commit();
+
+ Display.getDefault().asyncExec(new Runnable(){
+
+ @Override
+ public void run() {
+ //FIXME E4 refresh factual view via events or similar
+// try {
+// //close and re-open to refresh factual data view
+// MultiPageTaxonEditor sourceEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(sourceTaxonNode.getUuid());
+// MultiPageTaxonEditor targetEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(targetTaxonNode.getUuid());
+// if(targetEditor != null){
+// AbstractUtility.close(sourceEditor);
+// AbstractUtility.close(targetEditor);
+// }
+// EditorUtil.openTaxonNodeE4(sourceTaxonNode.getUuid());
+// EditorUtil.openTaxonNodeE4(targetTaxonNode.getUuid());
+// } catch (PartInitException e) {
+// MessagingUtils.error(this.getClass(), e);
+// throw new RuntimeException(e);
+// } catch (Exception e) {
+// MessagingUtils.warningDialog(Messages.MoveFactualDataHandler_CREATE_FAILED, this, e.getMessage());
+// }
+ }
+
+ });
+ }
+ }
+ }
+ }
+
+}
--- /dev/null
+/**
+* Copyright (C) 2007 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.navigation.navigator.e4.handler;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.UUID;
+
+import javax.inject.Named;
+
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.swt.widgets.Shell;
+
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
+import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.model.taxon.Classification;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
+import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
+import eu.etaxonomy.taxeditor.navigation.navigator.TreeNodeDropAdapter.MovingType;
+import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4;
+import eu.etaxonomy.taxeditor.navigation.navigator.operation.MoveTaxonOperation;
+import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
+import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
+
+/**
+ *
+ * @author pplitzner
+ * @date 05.09.2017
+ *
+ */
+public class MoveTaxonHandlerE4 implements IPostOperationEnabled {
+
+ private TaxonNode parentTaxonNode;
+
+ public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection,
+ @Named(IServiceConstants.ACTIVE_SHELL)Shell shell,
+ @Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
+
+ TaxonNavigatorE4 taxonNavigator = (TaxonNavigatorE4) activePart.getObject();
+
+ Iterator<?> selectionIterator = selection.iterator();
+ Set<TaxonNode> taxonNodes = new HashSet<TaxonNode>();
+ TaxonNode taxonNode= null;
+ Set<UUID> taxonNodeUUIDs = new HashSet<UUID>();
+ // do not show the current selection
+ List<UUID> excludeTaxa = new ArrayList<UUID>();
+
+ while (selectionIterator.hasNext()){
+ Object object = selectionIterator.next();
+ if(object instanceof TaxonNode){
+ taxonNode = HibernateProxyHelper.deproxy(object,TaxonNode.class);
+ taxonNodes.add(taxonNode);
+ taxonNodeUUIDs.add(taxonNode.getUuid());
+ excludeTaxa.add(taxonNode.getTaxon().getUuid());
+ }
+ }
+
+
+ if (taxonNodes.size() >= 1){
+ Classification classification = taxonNodes.iterator().next().getClassification();
+ MovingType moveToNewParent = MovingType.CHILD;
+ if (PreferencesUtil.getSortNodesNaturally()){
+ if(!MessageDialog.openQuestion(null, Messages.MoveTaxonHandler_TARGET_NODE, Messages.MoveTaxonHandler_TARGET_NODE_MESSAGE)){
+ moveToNewParent = MovingType.BEHIND;
+ }
+ parentTaxonNode = TaxonNodeSelectionDialog.select(shell, taxonNavigator.getConversationHolder(), Messages.MoveTaxonHandler_CHOOSE_ABOVE, excludeTaxa, null, classification);
+ }else{
+ parentTaxonNode = TaxonNodeSelectionDialog.select(shell, taxonNavigator.getConversationHolder(), Messages.MoveTaxonHandler_CHOOSE_PARENT, excludeTaxa, null, classification);
+ }
+ if(parentTaxonNode != null){
+ if(NavigationUtil.isDirty(parentTaxonNode)){
+ MessageDialog.openWarning(shell, Messages.MoveTaxonHandler_UNSAVED_PARENT, Messages.MoveTaxonHandler_UNSAVED_PARENT_MESSAGE);
+ return;
+ }
+
+ AbstractPostOperation<?> operation = new MoveTaxonOperation
+ (Messages.MoveTaxonHandler_MOVE_TO_PARENT, NavigationUtil.getUndoContext(), taxonNodeUUIDs, parentTaxonNode, taxonNavigator, taxonNavigator, moveToNewParent); //$NON-NLS-1$
+ AbstractUtility.executeOperation(operation);
+ taxonNavigator.refresh();
+
+ }
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean postOperation(CdmBase objectAffectedByOperation) {
+ return true;
+ }
+
+ @Override
+ public boolean onComplete() {
+ return false;
+ }
+
+}
--- /dev/null
+/**
+* Copyright (C) 2007 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.navigation.navigator.e4.handler;
+
+import javax.inject.Named;
+
+import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+
+import eu.etaxonomy.taxeditor.newWizard.NewClassificationWizard;
+
+/**
+ *
+ * @author pplitzner
+ * @date 05.09.2017
+ *
+ */
+public class NewClassificationHandlerE4 {
+
+ public void execute(@Named(IServiceConstants.ACTIVE_SHELL)Shell shell) {
+ NewClassificationWizard wizard = new NewClassificationWizard();
+ wizard.init(null, null);
+ WizardDialog dialog = new WizardDialog(shell, wizard);
+ dialog.open();
+ }
+}
--- /dev/null
+/**
+ * Copyright (C) 2007 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.navigation.navigator.e4.handler;
+
+import javax.inject.Named;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+
+import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.taxeditor.newWizard.IWizardPageListener;
+import eu.etaxonomy.taxeditor.newWizard.NewTaxonNodeWizard;
+
+/**
+ *
+ * @author pplitzner
+ * @date 05.09.2017
+ *
+ */
+public class NewTaxonNodeHandlerE4 {
+
+ public void execute(@Named(IServiceConstants.ACTIVE_SHELL)Shell shell) throws Exception {
+
+ final NewTaxonNodeWizard wizard = new NewTaxonNodeWizard();
+ wizard.init(null, null);
+ final WizardDialog dialog = new WizardDialog(shell, wizard);
+ wizard.addWizardPageListener(new IWizardPageListener() {
+ @Override
+ public void close() {
+ wizard.performFinish();
+ dialog.close();
+ }
+ });
+ int status = dialog.open();
+
+ if(status == IStatus.OK && wizard.openInEditor()){
+ if(wizard.openEmpty()){
+ EditorUtil.openEmptyE4(wizard.getParentTreeNode().getUuid());
+ }else if(wizard.getTaxonNode() != null){
+ EditorUtil.openTaxonNodeE4(wizard.getTaxonNode().getUuid());
+ }
+ }
+ }
+}
--- /dev/null
+/**
+* Copyright (C) 2007 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.navigation.navigator.e4.handler;
+
+import javax.inject.Named;
+
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.services.IServiceConstants;
+
+import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4;
+
+/**
+ *
+ * @author pplitzner
+ * @date 05.09.2017
+ *
+ */
+public class RefreshTreeHandlerE4 {
+
+ public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
+
+ TaxonNavigatorE4 taxonNavigator = (TaxonNavigatorE4) activePart.getObject();
+
+ taxonNavigator.refresh();
+ }
+}
--- /dev/null
+/**
+* Copyright (C) 2017 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.navigation.navigator.e4.handler;
+
+import org.eclipse.core.commands.operations.AbstractOperation;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+
+import eu.etaxonomy.cdm.io.common.SetSecundumForSubtreeConfigurator;
+import eu.etaxonomy.cdm.model.taxon.Classification;
+import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigatorLabels;
+import eu.etaxonomy.taxeditor.navigation.navigator.operation.SetSecundumForSubtreeOperation;
+import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4;
+import eu.etaxonomy.taxeditor.ui.dialog.configurator.SetSecundumForSubtreeConfigurationWizard;
+
+/**
+ * @author k.luther
+ * @author pplitzner
+ * @date 10.02.2017
+ *
+ */
+public class SetSecReferenceForSubtreeHandlerE4 extends RemotingCdmHandlerE4 {
+
+ private ITaxonTreeNode taxonNode;
+ private SetSecundumForSubtreeConfigurator configurator;
+
+ public SetSecReferenceForSubtreeHandlerE4() {
+ super(TaxonNavigatorLabels.CHANGE_SECUNDUM_FOR_SUBTREE);
+ }
+
+ @Override
+ public IStatus allowOperations(TreeSelection selection,
+ Shell shell,
+ MPart activePart,
+ MHandledMenuItem menuItem) {
+ // check that only a single taxon tree node has been selected
+ if(selection.size() > 1) { }
+
+ // check for no taxon tree node selected
+ if(selection.size() == 0) {
+ return new Status(IStatus.ERROR,
+ "unknown", //$NON-NLS-1$
+ TaxonNavigatorLabels.NO_TAXON_SELECTION_MESSAGE);
+ }
+
+ // check that selected object is a taxon node
+ Object obj = selection.iterator().next();
+ if(obj instanceof ITaxonTreeNode) {
+ if (obj instanceof Classification){
+ taxonNode = ((Classification)obj).getRootNode();
+ }else{
+ taxonNode = (ITaxonTreeNode)obj;
+ }
+ } else{
+ return new Status(IStatus.ERROR,
+ "unknown", //$NON-NLS-1$
+ TaxonNavigatorLabels.SELECTED_OBJECT_NOT_TREE_NODE_MESSAGE);
+ }
+
+
+ // check if corresponding name editor is closed
+ //FIXME E4 migrate
+// boolean editorClosed = NavigatorHandlerUtils.closeObsoleteEditor(event, (TaxonNode) taxonNode);
+// if(editorClosed != true) {
+// return new Status(IStatus.ERROR,
+// "unknown", //$NON-NLS-1$
+// TaxonNavigatorLabels.RELATED_EDITOR_NOT_CLOSED_MESSAGE);
+// }
+
+ configurator = new SetSecundumForSubtreeConfigurator(taxonNode.getUuid());
+ SetSecundumForSubtreeConfigurationWizard wizard = new SetSecundumForSubtreeConfigurationWizard(configurator);
+
+ WizardDialog dialog = new WizardDialog(AbstractUtility.getShell(), wizard);
+
+ if (dialog.open() == Window.OK) {
+ return Status.OK_STATUS;
+ }else{
+ return Status.CANCEL_STATUS;
+ }
+
+ }
+
+ @Override
+ public AbstractOperation prepareOperation(TreeSelection selection,
+ Shell shell,
+ MPart activePart,
+ MHandledMenuItem menuItem) {
+ SetSecundumForSubtreeOperation operation =
+ new SetSecundumForSubtreeOperation(getTrigger(),
+ false,
+ taxonNode.getUuid(),
+ configurator);
+
+ return operation;
+ }
+
+ @Override
+ public void onComplete() {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Object getTrigger() {
+ return this;
+ }
+
+}
eu.etaxonomy.taxeditor.model;uses:="eu.etaxonomy.cdm.model.common,eu.etaxonomy.cdm.model.name,eu.etaxonomy.cdm.model.taxon",
eu.etaxonomy.taxeditor.newWizard,
eu.etaxonomy.taxeditor.operation,
+ eu.etaxonomy.taxeditor.operation.e4,
eu.etaxonomy.taxeditor.parser,
eu.etaxonomy.taxeditor.preference,
eu.etaxonomy.taxeditor.preference.matching,
import eu.etaxonomy.taxeditor.operation.IPostMoniteredOperationEnabled;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
import eu.etaxonomy.taxeditor.operation.RemotingCdmHandler;
+import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4;
import eu.etaxonomy.taxeditor.store.CdmStore;
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
import eu.etaxonomy.taxeditor.ui.dialog.ReportTextDialog;
return Status.OK_STATUS;
}
+ public static IStatus executeOperation(final AbstractOperation operation, final RemotingCdmHandlerE4 handler) {
+ return executeOperation(operation, handler);
+ }
+
public static IStatus executeOperation(final AbstractOperation operation, final RemotingCdmHandler handler) {
+ return executeOperation(operation, handler);
+ }
+
+ public static IStatus executeOperation(final AbstractOperation operation, final Object handler) {
if (getOperationHistory() == null) {
throw new IllegalArgumentException(
"There is no operation history for this context");
operation.addContext(IOperationHistory.GLOBAL_UNDO_CONTEXT);
status = getOperationHistory().execute(operation, monitor,
uiInfoAdapter);
- if(handler != null) {
- handler.postOperation(status);
+ if(handler instanceof RemotingCdmHandler) {
+ ((RemotingCdmHandler) handler).postOperation(status);
+ }
+ else if(handler instanceof RemotingCdmHandlerE4) {
+ ((RemotingCdmHandlerE4) handler).postOperation(status);
}
} catch (ExecutionException e) {
MessagingUtils.operationDialog(this, e, TaxeditorStorePlugin.PLUGIN_ID, operationlabel, null);
--- /dev/null
+/**
+* Copyright (C) 2015 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.operation.e4;
+
+import javax.inject.Named;
+
+import org.eclipse.core.commands.operations.AbstractOperation;
+import org.eclipse.core.runtime.IStatus;
+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.dialogs.ErrorDialog;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.swt.widgets.Shell;
+
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
+
+/**
+ * @author cmathew
+ * @date 16 Jun 2015
+ *
+ */
+public abstract class RemotingCdmHandlerE4 {
+
+ private final String label;
+
+ public RemotingCdmHandlerE4(String label) {
+ this.label = label;
+ }
+
+ public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection,
+ @Named(IServiceConstants.ACTIVE_SHELL)Shell shell,
+ @Named(IServiceConstants.ACTIVE_PART)MPart activePart,
+ MHandledMenuItem menuItem) {
+ IStatus allowStatus = allowOperations(selection, shell, activePart, menuItem);
+ if(allowStatus.isOK()) {
+ AbstractOperation op = prepareOperation(selection, shell, activePart, menuItem);
+ if(op != null) {
+ AbstractUtility.executeOperation(op, this);
+ }
+ } else if(allowStatus.getSeverity() == IStatus.ERROR ||
+ allowStatus.getSeverity() == IStatus.WARNING ||
+ allowStatus.getSeverity() == IStatus.INFO) {
+ MessagingUtils.warningDialog("Can not perform " + label, getTrigger(), allowStatus);
+ }
+ return;
+ }
+
+ public void postOperation(IStatus status) {
+
+ switch(status.getSeverity()) {
+ case IStatus.WARNING:
+ ErrorDialog.openError(null, "Operation successful but with warnings", null, status);
+ break;
+ case IStatus.ERROR:
+ ErrorDialog.openError(null, "Error executing operation", null, status);
+ break;
+ default:
+ }
+
+ onComplete();
+ }
+
+ public abstract IStatus allowOperations(TreeSelection selection,
+ Shell shell,
+ MPart activePart,
+ MHandledMenuItem menuItem);
+
+ public abstract AbstractOperation prepareOperation(TreeSelection selection,
+ Shell shell,
+ MPart activePart,
+ MHandledMenuItem menuItem);
+
+ public abstract void onComplete();
+
+ protected abstract Object getTrigger();
+
+}