package eu.etaxonomy.taxeditor.editor;
+import java.util.Collection;
import java.util.UUID;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.handlers.HandlerUtil;
import eu.etaxonomy.cdm.api.service.ITaxonService;
-import eu.etaxonomy.cdm.model.common.ITreeNode;
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
return null;
}
- public static boolean closeObsoleteEditor(TaxonNode taxonNode, IWorkbenchPage activePage){
- 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);
-
- }
+ public static void closeObsoleteEditor(TaxonNode taxonNode, EPartService partService){
+ String treeIndex = taxonNode.treeIndex();
+ Collection<MPart> parts = partService.getParts();
+ for (MPart part : parts) {
+ Object object = part.getObject();
+ if(object instanceof TaxonNameEditorE4){
+ TaxonNameEditorE4 taxonEditor = (TaxonNameEditorE4)object;
+ TaxonNode node = taxonEditor.getEditorInput().getTaxonNode();
+ if(node.treeIndex().startsWith(treeIndex)){
+ partService.hidePart(part, true);
}
- } catch (PartInitException e) {
- continue;
}
}
- return result;
}
}
</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">
- <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="_Ic-1EJIyEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.RemotingMoveTaxonNodeHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.RemotingMoveTaxonNodeHandlerE4" 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="_3I_vUJIyEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.RemotingChangeAcceptedTaxonToSynonymHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.RemotingChangeAcceptedTaxonToSynonymHandlerE4" 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="_GTyegJIzEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.RemotingMoveFactualDataHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.RemotingMoveFactualDataHandlerE4" 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="_M64uUJIzEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.RemotingDeleteTaxonNodeHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.RemotingDeleteTaxonNodeHandlerE4" 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">
/**
*
*/
-package eu.etaxonomy.taxeditor.navigation.navigator.handler;
+package eu.etaxonomy.taxeditor.navigation.navigator.e4.handler;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
-import org.apache.log4j.Logger;
-import org.eclipse.core.commands.ExecutionEvent;
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.ui.handlers.HandlerUtil;
+import org.eclipse.swt.widgets.Shell;
import eu.etaxonomy.cdm.api.conversation.ConversationHolderMock;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.taxeditor.editor.EditorUtil;
import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigatorLabels;
import eu.etaxonomy.taxeditor.navigation.navigator.operation.RemotingChangeAcceptedTaxonToSynonymOperation;
-import eu.etaxonomy.taxeditor.operation.RemotingCdmHandler;
+import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4;
import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
/**
- * <p>ChangeAcceptedTaxonToSynonymHandler class.</p>
*
- * @author n.hoffmann
- * @created Jan 4, 2010
- * @version 1.0
+ * @author pplitzner
+ * @since Sep 6, 2017
+ *
*/
-public class RemotingChangeAcceptedTaxonToSynonymHandler extends RemotingCdmHandler {
-
- private static final Logger logger = Logger
- .getLogger(RemotingChangeAcceptedTaxonToSynonymHandler.class);
+public class RemotingChangeAcceptedTaxonToSynonymHandlerE4 extends RemotingCdmHandlerE4 {
private TaxonNode oldTaxonNode;
- /**
- * @param label
- */
- public RemotingChangeAcceptedTaxonToSynonymHandler() {
+ public RemotingChangeAcceptedTaxonToSynonymHandlerE4() {
super(TaxonNavigatorLabels.CHANGE_ACCEPTED_TAXON_TO_SYNONYM_LABEL);
}
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#allowOperations(org.eclipse.core.commands.ExecutionEvent)
- */
+
@Override
- public IStatus allowOperations(ExecutionEvent event) {
- TreeSelection selection = (TreeSelection) HandlerUtil.getCurrentSelection(event);
+ 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) {
return new Status(IStatus.ERROR,
}
// check if corresponding name editor is closed
- boolean editorClosed = NavigatorHandlerUtils.closeObsoleteEditor(event, oldTaxonNode);
- if(editorClosed != true) {
- return new Status(IStatus.ERROR,
- "unknown", //$NON-NLS-1$
- TaxonNavigatorLabels.RELATED_EDITOR_NOT_CLOSED_MESSAGE);
- }
+ EditorUtil.closeObsoleteEditor(oldTaxonNode, partService);
return Status.OK_STATUS;
}
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#doOperations(org.eclipse.core.commands.ExecutionEvent)
- */
+
@Override
- public AbstractOperation prepareOperation(ExecutionEvent event) {
+ public AbstractOperation prepareOperation(TreeSelection selection,
+ Shell shell,
+ MPart activePart,
+ MHandledMenuItem menuItem) {
List<UUID> excludeTaxa = new ArrayList<UUID>();
excludeTaxa.add(oldTaxonNode.getTaxon().getUuid());
- TaxonNode newAcceptedTaxonNode = TaxonNodeSelectionDialog.select(HandlerUtil.getActiveShell(event),
+ TaxonNode newAcceptedTaxonNode = TaxonNodeSelectionDialog.select(shell,
new ConversationHolderMock(),
Messages.RemotingChangeAcceptedTaxonToSynonymHandler_CHOOSE_TAXON,
excludeTaxa,
}
RemotingChangeAcceptedTaxonToSynonymOperation rcattso =
- new RemotingChangeAcceptedTaxonToSynonymOperation(event.getTrigger(),
+ new RemotingChangeAcceptedTaxonToSynonymOperation(getTrigger(),
false,
oldTaxonNode.getUuid(),
newAcceptedTaxonNode.getUuid());
return rcattso;
}
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#onComplete(org.eclipse.core.commands.ExecutionEvent)
- */
@Override
public void onComplete() {
- // TODO Auto-generated method stub
-
}
-
-
-
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Object getTrigger() {
+ return this;
+ }
}
* 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.handler;
+package eu.etaxonomy.taxeditor.navigation.navigator.e4.handler;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
-import org.eclipse.core.commands.ExecutionEvent;
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.dialogs.MessageDialog;
import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.swt.widgets.Shell;
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
import eu.etaxonomy.cdm.api.service.config.NodeDeletionConfigurator.ChildHandling;
import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigatorLabels;
import eu.etaxonomy.taxeditor.navigation.navigator.operation.RemotingDeleteTaxonNodeOperation;
-import eu.etaxonomy.taxeditor.operation.RemotingCdmHandler;
+import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4;
import eu.etaxonomy.taxeditor.ui.dialog.configurator.deleteConfigurator.DeleteConfiguratorDialog;
/**
* @date 22 Jun 2015
*
*/
-public class RemotingDeleteTaxonNodeHandler extends RemotingCdmHandler {
+public class RemotingDeleteTaxonNodeHandlerE4 extends RemotingCdmHandlerE4 {
private TaxonDeletionConfigurator config;
private Set<ITaxonTreeNode> treeNodes;
- public RemotingDeleteTaxonNodeHandler() {
+ public RemotingDeleteTaxonNodeHandlerE4() {
super(TaxonNavigatorLabels.DELETE_TAXON_NODE_LABEL);
}
@Override
- public IStatus allowOperations(ExecutionEvent event) {
- TreeSelection selection = (TreeSelection) HandlerUtil.getCurrentSelection(event);
+ public IStatus allowOperations(TreeSelection selection,
+ Shell shell,
+ MPart activePart,
+ MHandledMenuItem menuItem) {
Iterator<?> selectionIterator = selection.iterator();
treeNodes = new HashSet<ITaxonTreeNode>();
treeNodes.add((ITaxonTreeNode) object);
}
}
- boolean allEditorsClosed = true;
- IWorkbenchPage activePage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
for (ITaxonTreeNode treeNode : treeNodes) {
if(treeNode instanceof TaxonNode) {
- allEditorsClosed &= EditorUtil.closeObsoleteEditor((TaxonNode) treeNode, activePage);
+ EditorUtil.closeObsoleteEditor((TaxonNode) treeNode, partService);
}
}
- if(!allEditorsClosed) {
- return new Status(IStatus.WARNING,
- "unknown", //$NON-NLS-1$
- TaxonNavigatorLabels.RELATED_EDITOR_NOT_CLOSED_MESSAGE);
- }
config = new TaxonDeletionConfigurator();
if (taxonNode instanceof Classification) {
String message;
if (taxonNode.hasChildNodes()) {
- message = DeleteHandler.DO_YOU_REALLY_WANT_TO_DELETE_THE_CLASSIFICATION+DeleteHandler.THE_TREE_HAS_CHILDREN_THEY_WILL_BE_DELETED_TOO;
+ message = DeleteHandlerE4.DO_YOU_REALLY_WANT_TO_DELETE_THE_CLASSIFICATION+DeleteHandlerE4.THE_TREE_HAS_CHILDREN_THEY_WILL_BE_DELETED_TOO;
} else {
- message = DeleteHandler.DO_YOU_REALLY_WANT_TO_DELETE_THE_CLASSIFICATION;
+ message = DeleteHandlerE4.DO_YOU_REALLY_WANT_TO_DELETE_THE_CLASSIFICATION;
}
- if (!DeleteConfiguratorDialog.openConfirm(
- HandlerUtil.getActiveShell(event), DeleteHandler.CONFIRM_DELETION,
+ if (!MessageDialog.openConfirm(
+ shell, DeleteHandlerE4.CONFIRM_DELETION,
message)) {
return Status.CANCEL_STATUS;
}
if (taxonNode.hasChildNodes()){
DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(
config,
- HandlerUtil.getActiveShell(event),
- DeleteHandler.CONFIRM_DELETION,
+ shell,
+ DeleteHandlerE4.CONFIRM_DELETION,
null,
- DeleteHandler.DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S+DeleteHandler.THERE_ARE_CHILDNODES_WHICH_WILL_BE_DELETED_TOO,
- MessageDialog.WARNING, new String[] { DeleteHandler.DELETE_ALL_CHILDREN,
- DeleteHandler.MOVE_CHILDREN_TO_PARENT_NODE, DeleteHandler.SKIP }, 0);
+ DeleteHandlerE4.DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S+DeleteHandlerE4.THERE_ARE_CHILDNODES_WHICH_WILL_BE_DELETED_TOO,
+ MessageDialog.WARNING, new String[] { DeleteHandlerE4.DELETE_ALL_CHILDREN,
+ DeleteHandlerE4.MOVE_CHILDREN_TO_PARENT_NODE, DeleteHandlerE4.SKIP }, 0);
int result = dialog.open();
if (result == 0){
return Status.CANCEL_STATUS;
}
} else{
- if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(configNodes, HandlerUtil.getActiveShell(event), DeleteHandler.CONFIRM_DELETION, DeleteHandler.DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S)){
+ if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(configNodes, shell, DeleteHandlerE4.CONFIRM_DELETION, DeleteHandlerE4.DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S)){
return Status.CANCEL_STATUS;
}
config.setTaxonNodeConfig(configNodes);
}
@Override
- public AbstractOperation prepareOperation(ExecutionEvent event) {
- return new RemotingDeleteTaxonNodeOperation(event.getTrigger(),
+ public AbstractOperation prepareOperation(TreeSelection selection,
+ Shell shell,
+ MPart activePart,
+ MHandledMenuItem menuItem) {
+ return new RemotingDeleteTaxonNodeOperation(getTrigger(),
false,
treeNodes,
config);
public void onComplete() {
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Object getTrigger() {
+ return this;
+ }
+
}
* 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.handler;
+package eu.etaxonomy.taxeditor.navigation.navigator.e4.handler;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
-import org.eclipse.core.commands.ExecutionEvent;
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.swt.widgets.Display;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.swt.widgets.Shell;
import eu.etaxonomy.cdm.api.conversation.ConversationHolderMock;
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
-import eu.etaxonomy.taxeditor.editor.EditorUtil;
-import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
-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.TaxonNavigatorLabels;
import eu.etaxonomy.taxeditor.navigation.navigator.operation.RemotingMoveFactualDataOperation;
-import eu.etaxonomy.taxeditor.operation.RemotingCdmHandler;
+import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4;
import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
/**
* @date 19 Jun 2015
*
*/
-public class RemotingMoveFactualDataHandler extends RemotingCdmHandler {
-
+public class RemotingMoveFactualDataHandlerE4 extends RemotingCdmHandlerE4 {
private TaxonNode sourceTaxonNode;
private TaxonNode targetTaxonNode;
- /**
- * @param label
- */
- public RemotingMoveFactualDataHandler() {
+
+ public RemotingMoveFactualDataHandlerE4() {
super(TaxonNavigatorLabels.MOVE_FACTUAL_DATA_LABEL);
}
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#allowOperations(org.eclipse.core.commands.ExecutionEvent)
- */
@Override
- public IStatus allowOperations(ExecutionEvent event) {
- TreeSelection selection = (TreeSelection) HandlerUtil.getCurrentSelection(event);
+ 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) {
return new Status(IStatus.ERROR,
List<UUID> excludeTaxa = new ArrayList<UUID>();
excludeTaxa.add(sourceTaxonNode.getTaxon().getUuid());
- targetTaxonNode = TaxonNodeSelectionDialog.select(HandlerUtil.getActiveShell(event),
+ targetTaxonNode = TaxonNodeSelectionDialog.select(shell,
new ConversationHolderMock(),
Messages.RemotingMoveFactualDataHandler_CHOOSE_TAXA,
excludeTaxa,
return Status.OK_STATUS;
}
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#prepareOperation(org.eclipse.core.commands.ExecutionEvent)
- */
@Override
- public AbstractOperation prepareOperation(ExecutionEvent event) {
- return new RemotingMoveFactualDataOperation(event.getTrigger(),
+ public AbstractOperation prepareOperation(TreeSelection selection,
+ Shell shell,
+ MPart activePart,
+ MHandledMenuItem menuItem) {
+ return new RemotingMoveFactualDataOperation(getTrigger(),
false,
sourceTaxonNode.getTaxon().getUuid(),
targetTaxonNode.getTaxon().getUuid());
}
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#onComplete()
- */
@Override
public void onComplete() {
Display.getDefault().asyncExec(new Runnable(){
@Override
public void run() {
- 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.RemotingMoveFactualDataHandler_CREATE_FAILED, this, e.getMessage());
- }
+ //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.RemotingMoveFactualDataHandler_CREATE_FAILED, this, e.getMessage());
+// }
}
});
-
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Object getTrigger() {
+ return this;
+ }
}
* 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.handler;
+package eu.etaxonomy.taxeditor.navigation.navigator.e4.handler;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
-import org.eclipse.core.commands.ExecutionEvent;
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.dialogs.MessageDialog;
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.handlers.HandlerUtil;
import eu.etaxonomy.cdm.api.conversation.ConversationHolderMock;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigatorLabels;
import eu.etaxonomy.taxeditor.navigation.navigator.TreeNodeDropAdapter.MovingType;
import eu.etaxonomy.taxeditor.navigation.navigator.operation.RemotingMoveTaxonOperation;
-import eu.etaxonomy.taxeditor.operation.RemotingCdmHandler;
+import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
* @date 19 Jun 2015
*
*/
-public class RemotingMoveTaxonNodeHandler extends RemotingCdmHandler {
+public class RemotingMoveTaxonNodeHandlerE4 extends RemotingCdmHandlerE4 {
private TaxonNode oldTaxonNode;
- public RemotingMoveTaxonNodeHandler() {
+ public RemotingMoveTaxonNodeHandlerE4() {
super(TaxonNavigatorLabels.MOVE_TAXON_LABEL);
}
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#allowOperations(org.eclipse.core.commands.ExecutionEvent)
- */
@Override
- public IStatus allowOperations(ExecutionEvent event) {
- TreeSelection selection = (TreeSelection) HandlerUtil.getCurrentSelection(event);
+ 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) {
return new Status(IStatus.ERROR,
return Status.OK_STATUS;
}
-
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#prepareOperation(org.eclipse.core.commands.ExecutionEvent)
- */
@Override
- public AbstractOperation prepareOperation(ExecutionEvent event) {
- Shell activeShell = HandlerUtil.getActiveShell(event);
+ public AbstractOperation prepareOperation(TreeSelection selection,
+ Shell shell,
+ MPart activePart,
+ MHandledMenuItem menuItem) {
TaxonNode parentTaxonNode;
List<UUID> excludeTaxa = new ArrayList<UUID>();
if (PreferencesUtil.getSortNodesNaturally()){
- parentTaxonNode = TaxonNodeSelectionDialog.select(activeShell,
+ parentTaxonNode = TaxonNodeSelectionDialog.select(shell,
new ConversationHolderMock(),
Messages.RemotingMoveTaxonNodeHandler_CHOOSE_TAXON,
excludeTaxa,
moveToNewParent = MovingType.BEHIND;
}
} else {
- parentTaxonNode = TaxonNodeSelectionDialog.select(activeShell,
+ parentTaxonNode = TaxonNodeSelectionDialog.select(shell,
new ConversationHolderMock(),
Messages.RemotingMoveTaxonNodeHandler_CHOOSE_PARENT,
excludeTaxa,
if(parentTaxonNode != null){
if(NavigationUtil.isDirty(parentTaxonNode)){
- MessageDialog.openWarning(activeShell,
+ MessageDialog.openWarning(shell,
Messages.RemotingMoveTaxonNodeHandler_UNSAVED_PARENT,
Messages.RemotingMoveTaxonNodeHandler_UNSAVED_PARENT_MESSAGE);
return null;
}
- return new RemotingMoveTaxonOperation(event.getTrigger(),
+ return new RemotingMoveTaxonOperation(getTrigger(),
false,
oldTaxonNode.getUuid(),
parentTaxonNode.getUuid(),
return null;
}
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#onComplete()
- */
@Override
public void onComplete() {
- // TODO Auto-generated method stub
-
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Object getTrigger() {
+ return this;
+ }
}
/**
-* 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.
-*/
+ * 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 javax.inject.Named;
*/
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;
- }
- }
-
- @CanExecute
- private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){
- boolean canExecute = false;
- menuItem.setVisible(canExecute);
- canExecute = selection.getFirstElement() instanceof ITaxonTreeNode;
- return canExecute;
- }
-
- @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() {
- }
-
- /**
+ 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;
+ }
+ }
+
+ @CanExecute
+ private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){
+ boolean canExecute = false;
+ menuItem.setVisible(canExecute);
+ canExecute = selection.getFirstElement() instanceof ITaxonTreeNode;
+ return canExecute;
+ }
+
+ @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
+++ /dev/null
-/**
- *
- */
-package eu.etaxonomy.taxeditor.navigation.navigator.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 org.apache.log4j.Logger;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.commands.common.NotDefinedException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-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.editor.EditorUtil;
-import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
-import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
-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.operation.ChangeAcceptedTaxonToSynonymOperation;
-import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
-import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
-import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
-
-/**
- * <p>ChangeAcceptedTaxonToSynonymHandler class.</p>
- *
- * @author n.hoffmann
- * @created Jan 4, 2010
- * @version 1.0
- */
-public class ChangeAcceptedTaxonToSynonymHandler extends DeleteHandler
- implements IHandler, IPostOperationEnabled {
- private static final Logger logger = Logger
- .getLogger(ChangeAcceptedTaxonToSynonymHandler.class);
- private ChangeAcceptedTaxonToSynonymOperation operation;
-
- private UUID newAcceptedTaxonNodeUuid;
- private TaxonNameEditor editor;
-
- /* (non-Javadoc)
- * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- /** {@inheritDoc} */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
-
- activePage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
-
- taxonNavigator = NavigationUtil.showNavigator();
-
- TreeSelection selection = (TreeSelection) HandlerUtil.getCurrentSelection(event);
-
- // Prompt user for confirmation
-
-
-
- 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 ){
- try {
-
- 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 null;
- }
- /*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(HandlerUtil.getActiveShell(event),
- taxonNavigator.getConversationHolder(),
- Messages.ChangeAcceptedTaxonToSynonymHandler_CHOOSE_TAXON,
- excludeTaxa,
- null,
- ((TaxonNode)oldAcceptedTaxonNode).getClassification());
-
- if (newAcceptedTaxonNode == null) {
- return null;
- }
-
- if (allEditorsClosed){
-
- operation = new ChangeAcceptedTaxonToSynonymOperation(event.getCommand().getName(),
- NavigationUtil.getUndoContext(),
- oldAcceptedTaxonNode,
- newAcceptedTaxonNode,
- taxonNavigator,
- taxonNavigator,
- taxonNavigator);
-
- NavigationUtil.executeOperation(operation);
- //}
- }
-
-
-
- } catch (NotDefinedException e) {
- MessagingUtils.warn(getClass(), "Command name not set"); //$NON-NLS-1$
- }
- } else{
- if( MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), Messages.ChangeAcceptedTaxonToSynonymHandler_MOVE_SYNONYMY, Messages.ChangeAcceptedTaxonToSynonymHandler_MOVE_SYNONYMY_MESSAGE)){
- return null;
- }
- }
-
-
- return null;
-
- }
-
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.operations.IPostOperationEnabled#postOperation(eu.etaxonomy.cdm.model.common.CdmBase)
- */
- /** {@inheritDoc} */
- @Override
- public boolean postOperation(CdmBase objectAffectedByOperation) {
- 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;
- }
-
- /**
- * <p>onComplete</p>
- *
- * @return a boolean.
- */
- @Override
- public boolean onComplete() {
- // TODO Auto-generated method stub
- return false;
- }
-}
+++ /dev/null
-package eu.etaxonomy.taxeditor.navigation.navigator.handler;
-
-import org.apache.log4j.Logger;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-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.TaxonNavigator;
-import eu.etaxonomy.taxeditor.navigation.operation.CloneClassificationOperation;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
-import eu.etaxonomy.taxeditor.ui.section.classification.CloneClassificationWizard;
-
-public class CloneClassificationHandler extends AbstractHandler {
-
- @SuppressWarnings("unused")
- private static final Logger logger = Logger.getLogger(CloneClassificationHandler.class);
-
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
- if (currentSelection instanceof IStructuredSelection) {
- Object selectedElement = ((IStructuredSelection) currentSelection).getFirstElement();
- if (selectedElement instanceof TaxonNode && !((TaxonNode)selectedElement).hasTaxon()) {
- Classification classification = ((TaxonNode)selectedElement).getClassification();
- TaxonNavigator taxonNavigator = (TaxonNavigator)AbstractUtility.showView(TaxonNavigator.ID);
- CloneClassificationWizard wizard = new CloneClassificationWizard(classification);
- WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), 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();
- }
- }
- return null;
- }
-
-}
+++ /dev/null
-/**\r
-* Copyright (C) 2009 EDIT\r
-* European Distributed Institute of Taxonomy \r
-* http://www.e-taxonomy.eu\r
-* \r
-* The contents of this file are subject to the Mozilla Public License Version 1.1\r
-* See LICENSE.TXT at the top of this package for the full license terms.\r
-*/\r
-package eu.etaxonomy.taxeditor.navigation.navigator.handler;\r
-\r
-import org.eclipse.core.commands.AbstractHandler;\r
-import org.eclipse.core.commands.ExecutionEvent;\r
-import org.eclipse.core.commands.ExecutionException;\r
-import org.eclipse.core.commands.IHandler;\r
-import org.eclipse.core.commands.common.NotDefinedException;\r
-import org.eclipse.core.runtime.IStatus;\r
-import org.eclipse.jface.viewers.IStructuredSelection;\r
-import org.eclipse.ui.handlers.HandlerUtil;\r
-\r
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;\r
-import eu.etaxonomy.taxeditor.model.MessagingUtils;\r
-import eu.etaxonomy.taxeditor.navigation.NavigationUtil;\r
-import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigator;\r
-import eu.etaxonomy.taxeditor.navigation.navigator.operation.CopyOperation;\r
-import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;\r
-import eu.etaxonomy.taxeditor.store.StoreUtil;\r
-\r
-/**\r
- * @author l.morris\r
- * @date 23 Jan 2012\r
- *\r
- */\r
-public class CopyHandler extends AbstractHandler implements IHandler {\r
- \r
- private TaxonNavigator taxonNavigator;\r
-\r
- /* (non-Javadoc)\r
- * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)\r
- */\r
- @Override\r
- public Object execute(ExecutionEvent event) throws ExecutionException {\r
- \r
- taxonNavigator = NavigationUtil.showNavigator();\r
- \r
- IStructuredSelection selection = (IStructuredSelection) HandlerUtil\r
- .getCurrentSelection(event);\r
-\r
- if(selection.size() == 1) {\r
- \r
- Object selectedObject = selection.getFirstElement();\r
- \r
- if (selectedObject instanceof TaxonNode) {\r
- \r
- try {\r
- \r
- AbstractPostOperation operation = new CopyOperation(event.getCommand().getName(), StoreUtil.getUndoContext(),\r
- (TaxonNode)selectedObject, taxonNavigator);\r
- \r
- IStatus status = NavigationUtil.executeOperation(operation);\r
- \r
- } catch (NotDefinedException e) {\r
- MessagingUtils.warn(getClass(), "Command name not set"); //$NON-NLS-1$\r
- }\r
- }\r
- }\r
- \r
- \r
- return null;\r
- }\r
-\r
-}\r
+++ /dev/null
-package eu.etaxonomy.taxeditor.navigation.navigator.handler;
-
-import org.apache.log4j.Logger;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-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.NavigationUtil;
-import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
-import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigator;
-import eu.etaxonomy.taxeditor.navigation.operation.CreateNewTaxonHierarchyOperation;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
-
-public class CreateClassificationHierarchyHandler extends AbstractHandler {
-
- private static final Logger logger = Logger.getLogger(CreateClassificationHierarchyHandler.class);
-
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.
- * ExecutionEvent)
- */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
- if (currentSelection instanceof IStructuredSelection) {
- Object selectedElement = ((IStructuredSelection) currentSelection).getFirstElement();
- if (selectedElement instanceof TaxonNode && !((TaxonNode)selectedElement).hasTaxon()) {
-
- Classification classification = ((TaxonNode) selectedElement).getClassification();
- try {
- TaxonNavigator taxonNavigator = (TaxonNavigator)AbstractUtility.showView(TaxonNavigator.ID);
-// IClassificationService service = CdmStore.getService(IClassificationService.class);
-
- // Map<String, List<TaxonNode>> sortedGenusList =
- // service.getSortedGenusList(classification.getAllNodes());
-
-
- CreateNewTaxonHierarchyOperation operation = new CreateNewTaxonHierarchyOperation(Messages.CreateClassificationHierarchyHandler_CREATE_HIERARCHY, StoreUtil.getUndoContext(),classification,NavigationUtil.getNavigator(false), NavigationUtil.getNavigator(false) );
-
- AbstractUtility.executeOperation(operation);
-// UpdateResult result = service.createHierarchyInClassification(classification, null);
-//
-// Classification classification2 = CdmBase.deproxy(result.getCdmEntity(), Classification.class);
-//
-// Set<CdmBase> updatedObjects = result.getUpdatedObjects();
-//
-// Shell activeShell = HandlerUtil.getActiveShell(event);
-
-// MessagingUtils.messageDialog("Add Hierarchy successful",
-// FixClassificationHierarchyHandler.class, "Operation 'Fix Hierarchy' was successful. New classification is "
-// + classification2.getTitleCache() + "\nUpdated Objects: " + updatedObjects.size());
- //Success
- taxonNavigator.refresh();
- } catch (Exception e) {
- MessagingUtils.messageDialog(Messages.CreateClassificationHierarchyHandler_FAILED, CreateClassificationHierarchyHandler.class,
- Messages.CreateClassificationHierarchyHandler_FAILED_MESSAGE, e);
- }
- }
- }
- return null;
- }
-
-}
+++ /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.handler;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.common.NotDefinedException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-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.common.ITreeNode;
-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.editor.TaxonEditorInput;
-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.TaxonNavigator;
-import eu.etaxonomy.taxeditor.navigation.navigator.operation.DeleteOperation;
-import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
-import eu.etaxonomy.taxeditor.ui.dialog.configurator.deleteConfigurator.DeleteConfiguratorDialog;
-
-/**
- * <p>DeleteTreeNodeHandler class.</p>
- *
- * @author n.hoffmann
- * @created 06.04.2009
- * @version 1.0
- */
-public class DeleteHandler extends AbstractHandler{
-
- 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;
-
- protected IWorkbenchPage activePage;
- protected TaxonNavigator taxonNavigator;
-
- /** {@inheritDoc} */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- activePage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
-
- taxonNavigator = NavigationUtil.showNavigator();
-
- TreeSelection selection = (TreeSelection) HandlerUtil.getCurrentSelection(event);
-
-
- // Prompt user for confirmation
-
-
-
- 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, HandlerUtil.getActiveShell(event), CONFIRM_DELETION, DO_YOU_REALLY_WANT_TO_DELETE_THE_CLASSIFICATION+THE_TREE_HAS_CHILDREN_THEY_WILL_BE_DELETED_TOO)){
- return null;
- }
- } else if (taxonNode instanceof Classification && !taxonNode.hasChildNodes()){
- if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), CONFIRM_DELETION, DO_YOU_REALLY_WANT_TO_DELETE_THE_CLASSIFICATION)){
- return null;
- }
- } else {
-
- if (taxonNode.hasChildNodes()){
- DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(
- config,
- HandlerUtil.getActiveShell(event),
- 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 null;
-
- }
- }else{
- if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(configNodes, HandlerUtil.getActiveShell(event), CONFIRM_DELETION, DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S)){
- return null;
- }
- 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(event.getCommand().getName(),
- NavigationUtil.getUndoContext(),
- taxonNode,
- config,
- taxonNavigator,
- taxonNavigator,
- taxonNavigator);
-
- NavigationUtil.executeOperation(operation);
-
- //}
- }
-
-
-
- } catch (NotDefinedException e) {
- MessagingUtils.warn(getClass(), "Command name not set"); //$NON-NLS-1$
- } catch (Exception e){
- MessagingUtils.error(getClass(), e);
- }
- } else{
- try{
- if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), CONFIRM_DELETION, DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S)){
- return null;
- }
- if (allEditorsClosed){
-
- operation = new DeleteOperation(event.getCommand().getName(),
- NavigationUtil.getUndoContext(),
- treeNodes,
- new TaxonDeletionConfigurator(),
- taxonNavigator,
- taxonNavigator,
- taxonNavigator);
-
- NavigationUtil.executeOperation(operation);
-
- }
- }catch (NotDefinedException e) {
- MessagingUtils.warn(getClass(), Messages.DeleteHandler_9);
- } catch (Exception e){
- MessagingUtils.error(getClass(), e);
- }
- }
- return null;
- }
-
- protected boolean closeObsoleteEditor(TaxonNode taxonNode){
- 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.handler;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-
-import org.apache.log4j.Logger;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-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.editor.EditorUtil;
-import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
-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.TaxonNavigator;
-import eu.etaxonomy.taxeditor.store.CdmStore;
-import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
-
-public class MoveFactualDataHandler extends AbstractHandler {
-
- @SuppressWarnings("unused")
- private static final Logger logger = Logger.getLogger(MoveFactualDataHandler.class);
-
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
- Object activePart = AbstractUtility.getActiveE4Part();
- TaxonNavigator navigator = null;
- if(activePart instanceof TaxonNavigator){
- navigator = (TaxonNavigator)activePart;
- }
- if(navigator!=null && currentSelection instanceof TreeSelection){
- Object object = ((TreeSelection) currentSelection).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(HandlerUtil.getActiveShell(event), Messages.MoveFactualDataHandler_UNSAVED_SOURCE, Messages.MoveFactualDataHandler_UNSAVED_SOURCE_MESSAGE);
- return null;
- }
- //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(HandlerUtil.getActiveShell(event),
- navigator.getConversationHolder(),
- Messages.MoveFactualDataHandler_CHOOSE_TAXON,
- excludeTaxa,
- sourceTaxonNode,
- sourceTaxonNode.getClassification());
- if (dialogTaxonNode == null) {
- return null;
- }
- //reload to avoid session conflicts
- final TaxonNode targetTaxonNode = CdmStore.getService(ITaxonNodeService.class).load(dialogTaxonNode.getUuid());
- if(NavigationUtil.isDirty(targetTaxonNode)){
- MessageDialog.openWarning(HandlerUtil.getActiveShell(event), Messages.MoveFactualDataHandler_UNSAVED_TARGET, Messages.MoveFactualDataHandler_UNSAVED_TARGET_MESSAGE);
- return null;
- }
- CdmStore.getService(IDescriptionService.class).moveTaxonDescriptions(taxon.getUuid(),targetTaxonNode.getTaxon().getUuid());
-
- navigator.getConversationHolder().bind();
- navigator.getConversationHolder().commit();
-
- Display.getDefault().asyncExec(new Runnable(){
-
- @Override
- public void run() {
- 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());
- }
- }
-
- });
- }
- }
- }
- return null;
- }
-
-}
+++ /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.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 org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-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.navigation.NavigationUtil;
-import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
-import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigator;
-import eu.etaxonomy.taxeditor.navigation.navigator.TreeNodeDropAdapter.MovingType;
-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;
-
-/**
- * <p>MoveTaxonHandler class.</p>
- *
- * @author n.hoffmann
- * @created 01.04.2009
- * @version 1.0
- */
-public class MoveTaxonHandler extends AbstractHandler implements IPostOperationEnabled {
-
- private TaxonNode parentTaxonNode;
- protected IWorkbenchPage activePage;
-
- /** {@inheritDoc} */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- activePage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
- TaxonNavigator taxonNavigator = (TaxonNavigator)NavigationUtil.showView(TaxonNavigator.ID);
-
- TreeSelection selection = (TreeSelection) HandlerUtil.getCurrentSelection(event);
-
- 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>();
-
- //if (selection.size() == 1){
-
- 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());
- }
- }
- /*} else{
- if( MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Moving taxon", "The operation move accepted taxon to other parent is available only for a single taxon.")){
- return null;
- }
- }*/
-
-
-// TaxonNode taxonNode = (TaxonNode) selection.getFirstElement();
- 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(HandlerUtil.getActiveShell(event), taxonNavigator.getConversationHolder(), Messages.MoveTaxonHandler_CHOOSE_ABOVE, excludeTaxa, null, classification);
- }else{
- parentTaxonNode = TaxonNodeSelectionDialog.select(HandlerUtil.getActiveShell(event), taxonNavigator.getConversationHolder(), Messages.MoveTaxonHandler_CHOOSE_PARENT, excludeTaxa, null, classification);
- }
- if(parentTaxonNode != null){
- if(NavigationUtil.isDirty(parentTaxonNode)){
- MessageDialog.openWarning(HandlerUtil.getActiveShell(event), Messages.MoveTaxonHandler_UNSAVED_PARENT, Messages.MoveTaxonHandler_UNSAVED_PARENT_MESSAGE);
- return null;
- }
-
-
- AbstractPostOperation<?> operation = new MoveTaxonOperation
- (Messages.MoveTaxonHandler_MOVE_TO_PARENT, NavigationUtil.getUndoContext(),
- taxonNodeUUIDs, parentTaxonNode, taxonNavigator, taxonNavigator, moveToNewParent); //$NON-NLS-1$
- NavigationUtil.executeOperation(operation);
- taxonNavigator.refresh();
-
- }
- }
- return null;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean postOperation(CdmBase objectAffectedByOperation) {
- return true;
- }
-
- /**
- * <p>onComplete</p>
- *
- * @return a boolean.
- */
- @Override
- public boolean onComplete() {
- return false;
- }
-
-}
+++ /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.navigation.navigator.handler;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-import eu.etaxonomy.cdm.model.common.ITreeNode;
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;
-import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
-
-/**
- * @author cmathew
- * @date 16 Jun 2015
- *
- */
-public class NavigatorHandlerUtils {
-
- protected static boolean closeObsoleteEditor(ExecutionEvent event, TaxonNode taxonNode){
- IWorkbenchPage activePage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
- 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
-/**
-* 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.handler;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-import eu.etaxonomy.taxeditor.newWizard.NewClassificationWizard;
-
-/**
- * <p>NewClassificationHandler class.</p>
- *
- * @author n.hoffmann
- * @created Sep 15, 2009
- * @version 1.0
- */
-public class NewClassificationHandler extends AbstractHandler implements
- IHandler {
-
- /* (non-Javadoc)
- * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- /** {@inheritDoc} */
- public Object execute(ExecutionEvent event) throws ExecutionException {
- NewClassificationWizard wizard = new NewClassificationWizard();
- wizard.init(null, null);
- WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), wizard);
- dialog.open();
-
- return null;
- }
-}
+++ /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.handler;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
-import eu.etaxonomy.taxeditor.newWizard.IWizardPageListener;
-import eu.etaxonomy.taxeditor.newWizard.NewTaxonNodeWizard;
-
-/**
- * <p>NewTaxonNodeHandler class.</p>
- *
- * @author n.hoffmann
- * @created Sep 15, 2009
- * @version 1.0
- */
-public class NewTaxonNodeHandler extends AbstractHandler {
-
- /** {@inheritDoc} */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- final NewTaxonNodeWizard wizard = new NewTaxonNodeWizard();
- wizard.init(null, null);
- final WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), 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()){
- NavigationUtil.openEmpty(wizard.getParentTreeNode().getUuid());
- }else if(wizard.getTaxonNode() != null){
- NavigationUtil.openEditor(wizard.getTaxonNode());
- }
- }
- return null;
- }
-}
+++ /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.handler;
-
-import org.apache.log4j.Logger;
-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.navigation.navigator.TaxonNavigator;
-
-/**
- * <p>RefreshTreeHandler class.</p>
- *
- * @author p.ciardelli
- * @created 04.09.2009
- * @version 1.0
- */
-public class RefreshTreeHandler extends AbstractHandler {
- private static final Logger logger = Logger
- .getLogger(RefreshTreeHandler.class);
-
- /* (non-Javadoc)
- * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- /** {@inheritDoc} */
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- IWorkbenchPart part = HandlerUtil.getActivePart(event);
- if (part instanceof TaxonNavigator) {
- ((TaxonNavigator) part).refresh();
- }
- return null;
- }
-}
+++ /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.handler;
-
-import org.apache.log4j.Logger;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.operations.AbstractOperation;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-import eu.etaxonomy.cdm.io.common.SetSecundumForSubtreeConfigurator;
-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.navigation.navigator.TaxonNavigatorLabels;
-import eu.etaxonomy.taxeditor.navigation.navigator.operation.SetSecundumForSubtreeOperation;
-import eu.etaxonomy.taxeditor.operation.RemotingCdmHandler;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
-import eu.etaxonomy.taxeditor.ui.dialog.configurator.SetSecundumForSubtreeConfigurationWizard;
-
-/**
- * @author k.luther
- * @date 10.02.2017
- *
- */
-public class SetSecReferenceForSubtreeHandler extends RemotingCdmHandler {
-
- private static final Logger logger = Logger
- .getLogger(SetSecReferenceForSubtreeHandler.class);
-
-
- private ITaxonTreeNode taxonNode;
- private SetSecundumForSubtreeConfigurator configurator;
-
- /**
- * @param label
- */
- public SetSecReferenceForSubtreeHandler() {
- super(TaxonNavigatorLabels.CHANGE_SECUNDUM_FOR_SUBTREE);
- }
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#allowOperations(org.eclipse.core.commands.ExecutionEvent)
- */
- @Override
- public IStatus allowOperations(ExecutionEvent event) {
- TreeSelection selection = (TreeSelection) HandlerUtil.getCurrentSelection(event);
- // 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
- 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(StoreUtil.getShell(), wizard);
-
- if (dialog.open() == Window.OK) {
- return Status.OK_STATUS;
- }else{
- return Status.CANCEL_STATUS;
- }
-
-// if(!SetSecundumForSubtreeConfigurationWizard.openConfirmWithConfigurator(configurator)){
-//
-// return Status.CANCEL_STATUS;
-// }
-//
-//
-// return Status.OK_STATUS;
- }
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#doOperations(org.eclipse.core.commands.ExecutionEvent)
- */
- @Override
- public AbstractOperation prepareOperation(ExecutionEvent event) {
- SetSecundumForSubtreeOperation operation =
- new SetSecundumForSubtreeOperation(event.getTrigger(),
- false,
- taxonNode.getUuid(),
- configurator);
-
- return operation;
- }
-
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#onComplete(org.eclipse.core.commands.ExecutionEvent)
- */
- @Override
- public void onComplete() {
- // TODO Auto-generated method stub
-
- }
-
-
-
-
-
-
-}
*/
package eu.etaxonomy.taxeditor.operation.e4;
+import javax.inject.Inject;
import javax.inject.Named;
import org.eclipse.core.commands.operations.AbstractOperation;
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.e4.ui.workbench.modeling.EPartService;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.swt.widgets.Shell;
public abstract class RemotingCdmHandlerE4 {
private final String label;
+ @Inject
+ protected EPartService partService;
public RemotingCdmHandlerE4(String label) {
this.label = label;