2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.bulkeditor
.e4
.handler
;
12 import java
.util
.Collections
;
14 import javax
.inject
.Named
;
16 import org
.eclipse
.e4
.core
.di
.annotations
.CanExecute
;
17 import org
.eclipse
.e4
.core
.di
.annotations
.Execute
;
18 import org
.eclipse
.e4
.core
.di
.annotations
.Optional
;
19 import org
.eclipse
.e4
.ui
.model
.application
.ui
.basic
.MPart
;
20 import org
.eclipse
.e4
.ui
.model
.application
.ui
.menu
.MHandledMenuItem
;
21 import org
.eclipse
.e4
.ui
.services
.IServiceConstants
;
23 import eu
.etaxonomy
.cdm
.model
.common
.IAnnotatableEntity
;
24 import eu
.etaxonomy
.cdm
.model
.common
.MarkerType
;
25 import eu
.etaxonomy
.taxeditor
.bulkeditor
.BulkEditorUtil
;
26 import eu
.etaxonomy
.taxeditor
.bulkeditor
.e4
.BulkEditorE4
;
27 import eu
.etaxonomy
.taxeditor
.bulkeditor
.e4
.command
.DynamicMarkerTypeEditingMenuE4
;
28 import eu
.etaxonomy
.taxeditor
.bulkeditor
.input
.AbstractBulkEditorInput
;
29 import eu
.etaxonomy
.taxeditor
.bulkeditor
.operation
.SetMarkerFlagOperation
;
30 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostOperation
;
38 public class SetMarkerFlagHandlerE4
{
41 public void execute(@Named(IServiceConstants
.ACTIVE_SELECTION
)IAnnotatableEntity selection
,
42 @Named(IServiceConstants
.ACTIVE_PART
)MPart activePart
,
43 MHandledMenuItem menuItem
) {
45 BulkEditorE4 editor
= (BulkEditorE4
) activePart
.getObject();
46 AbstractBulkEditorInput input
= editor
.getEditorInput();
47 MarkerType markerType
= (MarkerType
) menuItem
.getTransientData().get(DynamicMarkerTypeEditingMenuE4
.COMMAND_PARAMETER_MARKER_TYPE
);
48 boolean markerState
= (boolean) menuItem
.getTransientData().get(DynamicMarkerTypeEditingMenuE4
.COMMAND_PARAMETER_MARKER_STATE
);
51 AbstractPostOperation operation
= new SetMarkerFlagOperation("Set Marker", BulkEditorUtil
.getUndoContext(), Collections
.singleton(selection
), markerType
, markerState
, editor
);
52 BulkEditorUtil
.executeOperation(operation
);
57 public boolean canExecute(@Optional@Named(IServiceConstants
.ACTIVE_SELECTION
)Object selection
,
58 MHandledMenuItem menuItem
){
59 boolean canExecute
= false;
60 canExecute
= selection
instanceof IAnnotatableEntity
;
61 menuItem
.setVisible(canExecute
);