<elements xsi:type="commands:Command" xmi:id="_S8xR4JcNEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.delete" commandName="%command.label.4"/>
<elements xsi:type="commands:Command" xmi:id="_jWkVYJcOEeeM745tzuPNCQ" elementId="taxeditor-bulkeditor.dynamicnewobjectcommand" commandName="%command.name.2"/>
<elements xsi:type="commands:Command" xmi:id="_tLGKgJcOEeeM745tzuPNCQ" elementId="taxeditor-bulkeditor.dynamicdeleteobjectcommand" commandName="%command.name.3"/>
+ <elements xsi:type="commands:Command" xmi:id="_Svo9oKK6EeeZb4PEjoRsuw" elementId="taxeditor-bulkeditor.command.setMarkerFlag" commandName="%command.name.6"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_l_8NMCQUEeelPNxAg-e3TA" featurename="children" parentElementId="eu.etaxonomy.taxeditor.workbench.menu.admin">
<elements xsi:type="menu:MenuSeparator" xmi:id="_zph3kDF2Eee-JvlKXQGppA" elementId="eu.etaxonomy.taxeditor.bulkeditor.menuseparator.0"/>
<handlers xmi:id="_a-U4EJcOEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.e4.handler.SetMergeTargetHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.bulkeditor/eu.etaxonomy.taxeditor.bulkeditor.e4.handler.SetMergeTargetHandlerE4" command="_GAm9cJcNEeeM745tzuPNCQ"/>
<handlers xmi:id="_qPOPQJcOEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.annotatedlineeditor.e4.handler.NewObjectHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.bulkeditor/eu.etaxonomy.taxeditor.annotatedlineeditor.e4.handler.NewObjectHandlerE4" command="_jWkVYJcOEeeM745tzuPNCQ"/>
<handlers xmi:id="_vskBsJcOEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.annotatedlineeditor.e4.handler.DeleteObjectHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.bulkeditor/eu.etaxonomy.taxeditor.annotatedlineeditor.e4.handler.DeleteObjectHandlerE4" command="_tLGKgJcOEeeM745tzuPNCQ"/>
+ <handlers xmi:id="_c9ppwKK6EeeZb4PEjoRsuw" elementId="eu.etaxonomy.taxeditor.bulkeditor.e4.handler.SetMarkerFlagHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.bulkeditor/eu.etaxonomy.taxeditor.bulkeditor.e4.handler.SetMarkerFlagHandlerE4" command="_Svo9oKK6EeeZb4PEjoRsuw"/>
<menus xsi:type="menu:PopupMenu" xmi:id="_B6IFsJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.popupmenu.bulkeditor">
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_H83EMJcMEeeM745tzuPNCQ" coreExpressionId="isCdmStoreConnected"/>
<children xsi:type="menu:DynamicMenuContribution" xmi:id="_Y49vAJfHEeeUB5KN7hGpYQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.e4.command.DynamicNewObjectMenuE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.bulkeditor/eu.etaxonomy.taxeditor.bulkeditor.e4.command.DynamicNewObjectMenuE4"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_l6dgYJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.handledmenuitem.convertTeam2Person" label="%command.label.5" command="_PtZy4JcNEeeM745tzuPNCQ"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_oKqBYJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.handledmenuitem.convertPerson2Team" label="%command.label.6" command="_RFEJYJcNEeeM745tzuPNCQ"/>
<children xsi:type="menu:MenuSeparator" xmi:id="_p-7bYJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.menuseparator.3"/>
- <children xsi:type="menu:Menu" xmi:id="_saDaAJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.menu.chooseMarkerType" label="%menu.label.2"/>
+ <children xsi:type="menu:DynamicMenuContribution" xmi:id="_MughoKK6EeeZb4PEjoRsuw" elementId="eu.etaxonomy.taxeditor.bulkeditor.e4.command.DynamicMarkerTypeEditingMenuE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.bulkeditor/eu.etaxonomy.taxeditor.bulkeditor.e4.command.DynamicMarkerTypeEditingMenuE4"/>
<children xsi:type="menu:MenuSeparator" xmi:id="_x3rgUJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.menuseparator.4"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_yt2TUJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.handledmenuitem.delete" label="%command.label.4" command="_S8xR4JcNEeeM745tzuPNCQ"/>
</menus>
name="%editor.name.1">
</editor>
</extension>
- <extension
- point="org.eclipse.ui.menus">
- <menuContribution
- locationURI="popup:bulkeditor.editor">
- <menu
- label="%menu.label.1">
- <dynamic
- class="eu.etaxonomy.taxeditor.bulkeditor.command.DynamicNewObjectMenu"
- id="eu.etaxonomy.taxeditor.bulkeditor.dynamicNewMenu">
- <visibleWhen
- checkEnabled="false">
- <reference
- definitionId="isCdmStoreConnected">
- </reference>
- </visibleWhen>
- </dynamic>
- <visibleWhen
- checkEnabled="true">
- <reference
- definitionId="isCdmStoreConnected">
- </reference>
- </visibleWhen>
- </menu>
- <separator
- name="taxeditor-bulkeditor.separator4"
- visible="true">
- </separator>
- <command
- commandId="bulkeditor.commands.setmergetarget"
- label="%command.label.0"
- style="push">
- <visibleWhen>
- <reference
- definitionId="isMergeEnabled">
- </reference>
- </visibleWhen>
- </command>
-
- <command
- commandId="bulkeditor.commands.setmergecandidate"
- label="%command.label.1"
- style="push">
- <visibleWhen>
- <reference
- definitionId="isMergeEnabled">
- </reference>
- </visibleWhen>
- </command>
- <command
- commandId="bulkeditor.commands.removemergecandidate"
- label="%command.label.2"
- style="push">
- <visibleWhen>
- <reference
- definitionId="isMergeEnabled">
- </reference>
- </visibleWhen>
- </command>
- <command
- commandId="bulkeditor.commands.mergegroup"
- label="%command.label.3"
- style="push">
- <visibleWhen>
- <reference
- definitionId="isMergeEnabled">
- </reference>
- </visibleWhen>
- </command>
- <separator
- name="eu.etaxonomy.taxeditor.bulkeditor.separator1"
- visible="true">
- </separator>
- <command
- commandId="eu.etaxonomy.taxeditor.bulkeditor.convertTeam2Person"
- label="%command.label.5"
- style="push">
- <visibleWhen
- checkEnabled="true">
- <and>
- <reference
- definitionId="isConvertEnabled">
- </reference>
- <reference
- definitionId="isTeam">
- </reference>
- </and>
- </visibleWhen>
- </command>
- <command
- commandId="eu.etaxonomy.taxeditor.bulkeditor.convertPerson2Team"
- label="%command.label.6"
- style="push">
- <visibleWhen
- checkEnabled="true">>
- <and>
- <reference
- definitionId="isConvertEnabled">
- </reference>
- <reference
- definitionId="isPerson">
- </reference>
- </and>
- </visibleWhen>
- </command>
- <separator
- name="taxeditor-bulkeditor.separator2"
- visible="true">
- </separator>
- <menu
- label="%menu.label.2">
- <dynamic
- class="eu.etaxonomy.taxeditor.bulkeditor.command.DynamicMarkerTypeEditingMenu"
- id="eu.etaxonomy.taxeditor.bulkeditor.dynamicMarkerTypeEditingMenu">
- </dynamic>
- <visibleWhen
- checkEnabled="true">
- <reference
- definitionId="isCdmStoreConnected">
- </reference>
- </visibleWhen>
- </menu>
- <separator
- name="taxeditor-bulkeditor.separator3"
- visible="true">
- </separator>
- <command
- commandId="eu.etaxonomy.taxeditor.bulkeditor.delete"
- label="%command.label.4"
- style="push">
- <visibleWhen
- checkEnabled="true">
- <reference
- definitionId="isCdmStoreConnected">
- </reference>
- </visibleWhen>
- </command>
- <dynamic
- class="eu.etaxonomy.taxeditor.view.CdmViewerContextMenu"
- id="eu.etaxonomy.taxeditor.bulkeditor.cdmViewerContextMenu">
- </dynamic>
- <!--menuContribution
- locationURI="popup:org.eclipse.ui.popup.any"-->
- </menuContribution>
- </extension>
<extension
point="org.eclipse.ui.commands">
- <command
- defaultHandler="eu.etaxonomy.taxeditor.bulkeditor.handler.SetMarkerFlagHandler"
- id="taxeditor-bulkeditor.command.setMarkerFlag"
- name="%command.name.6">
- </command>
<command
id="eu.etaxonomy.taxeditor.openReferencingObjectsView"
name="%command.name.OPEN_REFERENCING_OBJECTS_VIEW">
typeId="eu.etaxonomy.taxeditor.uuidParameterType">
</commandParameter>
</command>
- <command
- defaultHandler="eu.etaxonomy.taxeditor.handler.defaultHandler.OpenReferencingObjectsView"
- id="eu.etaxonomy.taxeditor.openReferencingObjectsViewFromMenu"
- name="%command.name.OPEN_REFERENCING_OBJECTS_VIEW">
- </command>
<!--command
defaultHandler="eu.etaxonomy.taxeditor.bulkeditor.handler.NewEntityHandler"
id="eu.etaxonomy.taxeditor.bulkeditor.command.new"
--- /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.bulkeditor.e4.command;
+
+import java.util.List;
+
+import javax.inject.Named;
+
+import org.eclipse.e4.ui.di.AboutToShow;
+import org.eclipse.e4.ui.model.application.commands.MCommand;
+import org.eclipse.e4.ui.model.application.commands.MCommandsFactory;
+import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
+import org.eclipse.e4.ui.model.application.ui.menu.MMenu;
+import org.eclipse.e4.ui.model.application.ui.menu.MMenuElement;
+import org.eclipse.e4.ui.model.application.ui.menu.MMenuFactory;
+import org.eclipse.e4.ui.services.IServiceConstants;
+
+import eu.etaxonomy.cdm.model.common.MarkerType;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ *
+ * @author pplitzner
+ * @date 26.09.2017
+ *
+ */
+public class DynamicMarkerTypeEditingMenuE4 {
+
+ public static final String COMMAND_ID = "taxeditor-bulkeditor.command.setMarkerFlag";
+ public static final String COMMAND_PARAMETER_MARKER_TYPE = COMMAND_ID+".markerType";
+ public static final String COMMAND_PARAMETER_MARKER_STATE = COMMAND_ID+".markerState";
+
+ /** {@inheritDoc} */
+ @AboutToShow
+ public void aboutToShow(List<MMenuElement> items, @Named(IServiceConstants.ACTIVE_SELECTION)Object selection) {
+ if(selection==null){
+ return;
+ }
+ MMenu menu = MMenuFactory.INSTANCE.createMenu();
+ menu.setLabel("Choose marker type");
+ items.add(menu);
+ for(MarkerType markerType : CdmStore.getTermManager().getPreferredTerms(MarkerType.class)){
+ createMenuItem(menu, markerType);
+ }
+ }
+
+ private void createMenuItem(MMenu menu, final MarkerType markerType) {
+
+ MMenu subMenu = MMenuFactory.INSTANCE.createMenu();
+ subMenu.setLabel(String.format("Set Flag '%s'", markerType.getLabel()));
+ menu.getChildren().add(subMenu);
+
+ MHandledMenuItem subMenuItemYes = MMenuFactory.INSTANCE.createHandledMenuItem();
+ subMenuItemYes.setLabel("Yes");
+ MCommand mCommandYes = MCommandsFactory.INSTANCE.createCommand();
+ mCommandYes.setElementId(COMMAND_ID);
+ //set params
+ subMenuItemYes.getTransientData().put(COMMAND_PARAMETER_MARKER_TYPE, markerType);
+ subMenuItemYes.getTransientData().put(COMMAND_PARAMETER_MARKER_STATE, true);
+ subMenuItemYes.setCommand(mCommandYes);
+ subMenu.getChildren().add(subMenuItemYes);
+
+ MHandledMenuItem subMenuItemNo = MMenuFactory.INSTANCE.createHandledMenuItem();
+ subMenuItemNo.setLabel("No");
+ MCommand mCommandNo = MCommandsFactory.INSTANCE.createCommand();
+ mCommandNo.setElementId(COMMAND_ID);
+ //set params
+ subMenuItemNo.getTransientData().put(COMMAND_PARAMETER_MARKER_TYPE, markerType);
+ subMenuItemNo.getTransientData().put(COMMAND_PARAMETER_MARKER_STATE, false);
+ subMenuItemNo.setCommand(mCommandNo);
+ subMenu.getChildren().add(subMenuItemNo);
+ }
+
+}
/**
-* 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.
-*/
+ * 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.bulkeditor.e4.handler;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
+import java.util.Collections;
+
+import javax.inject.Named;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.text.TextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.e4.core.di.annotations.CanExecute;
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.core.di.annotations.Optional;
+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 eu.etaxonomy.cdm.model.common.IAnnotatableEntity;
import eu.etaxonomy.cdm.model.common.MarkerType;
-import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotation;
-import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotationModel;
-import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorUtil;
+import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4;
+import eu.etaxonomy.taxeditor.bulkeditor.e4.command.DynamicMarkerTypeEditingMenuE4;
+import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
import eu.etaxonomy.taxeditor.bulkeditor.operation.SetMarkerFlagOperation;
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
/**
- * <p>SetMarkerFlagTrueHandler class.</p>
*
- * @author p.ciardelli
- * @created 20.10.2009
- * @version 1.0
+ * @author pplitzner
+ * @date 26.09.2017
+ *
*/
-public class SetMarkerFlagHandlerE4 extends AbstractHandler {
+public class SetMarkerFlagHandlerE4 {
+
+ @Execute
+ public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)IAnnotatableEntity selection,
+ @Named(IServiceConstants.ACTIVE_PART)MPart activePart,
+ MHandledMenuItem menuItem) {
+
+ BulkEditorE4 editor = (BulkEditorE4) activePart.getObject();
+ AbstractBulkEditorInput input = editor.getEditorInput();
+ MarkerType markerType = (MarkerType) menuItem.getTransientData().get(DynamicMarkerTypeEditingMenuE4.COMMAND_PARAMETER_MARKER_TYPE);
+ boolean markerState = (boolean) menuItem.getTransientData().get(DynamicMarkerTypeEditingMenuE4.COMMAND_PARAMETER_MARKER_STATE);
+
+
+ AbstractPostOperation operation = new SetMarkerFlagOperation("Set Marker", BulkEditorUtil.getUndoContext(), Collections.singleton(selection), markerType, markerState, editor);
+ BulkEditorUtil.executeOperation(operation);
+ }
+
- /* (non-Javadoc)
- * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- /** {@inheritDoc} */
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- ISelection selection = HandlerUtil.getCurrentSelection(event);
-
- IEditorPart editor = HandlerUtil.getActiveEditor(event);
-
- Object[] data = (Object[]) ((Event) event.getTrigger()).data;
-
- if (selection instanceof TextSelection
- && editor instanceof BulkEditor) {
- TextSelection textSelection = (TextSelection) selection;
- BulkEditor bulkEditor = (BulkEditor) editor;
-
- LineAnnotationModel model = (LineAnnotationModel) bulkEditor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
- if (model != null) {
- Iterator iter = model.getAnnotationIterator(textSelection.getOffset(), textSelection.getLength(), true, true);
-
- Set<IAnnotatableEntity> annotatableEntities = new HashSet<IAnnotatableEntity>();
- while (iter.hasNext()) {
- Object next = iter.next();
- if (next instanceof LineAnnotation) {
- Object entity = ((LineAnnotation) next).getEntity();
-
- if(entity instanceof IAnnotatableEntity){
- annotatableEntities.add((IAnnotatableEntity) entity);
- }
- }
- }
-
- AbstractPostOperation operation = new SetMarkerFlagOperation("Set Marker", BulkEditorUtil.getUndoContext(), annotatableEntities, (MarkerType) data[0], (Boolean) data[1], bulkEditor);
- BulkEditorUtil.executeOperation(operation);
- }
- }
- return null;
- }
+ @CanExecute
+ public boolean canExecute(@Optional@Named(IServiceConstants.ACTIVE_SELECTION)Object selection,
+ MHandledMenuItem menuItem){
+ boolean canExecute = false;
+ canExecute = selection instanceof IAnnotatableEntity;
+ menuItem.setVisible(canExecute);
+ return canExecute;
+ }
}