1 |
a4b31985
|
Patrick Plitzner
|
/**
|
2 |
9e92b44f
|
Patrick Plitzner
|
* Copyright (C) 2007 EDIT
|
3 |
|
|
* European Distributed Institute of Taxonomy
|
4 |
|
|
* http://www.e-taxonomy.eu
|
5 |
|
|
*
|
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.
|
8 |
|
|
*/
|
9 |
a4b31985
|
Patrick Plitzner
|
|
10 |
|
|
package eu.etaxonomy.taxeditor.bulkeditor.e4.handler;
|
11 |
|
|
|
12 |
9e92b44f
|
Patrick Plitzner
|
import java.util.Collections;
|
13 |
|
|
|
14 |
|
|
import javax.inject.Named;
|
15 |
a4b31985
|
Patrick Plitzner
|
|
16 |
9e92b44f
|
Patrick Plitzner
|
import org.eclipse.e4.core.di.annotations.CanExecute;
|
17 |
|
|
import org.eclipse.e4.core.di.annotations.Execute;
|
18 |
b5b429af
|
Patrick Plitzner
|
import org.eclipse.e4.ui.di.UISynchronize;
|
19 |
9e92b44f
|
Patrick Plitzner
|
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;
|
22 |
3699c749
|
Katja Luther
|
import org.eclipse.jface.viewers.StructuredSelection;
|
23 |
a4b31985
|
Patrick Plitzner
|
|
24 |
|
|
import eu.etaxonomy.cdm.model.common.IAnnotatableEntity;
|
25 |
|
|
import eu.etaxonomy.cdm.model.common.MarkerType;
|
26 |
|
|
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorUtil;
|
27 |
9e92b44f
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4;
|
28 |
|
|
import eu.etaxonomy.taxeditor.bulkeditor.e4.command.DynamicMarkerTypeEditingMenuE4;
|
29 |
a4b31985
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.bulkeditor.operation.SetMarkerFlagOperation;
|
30 |
485afab8
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.model.AbstractUtility;
|
31 |
a4b31985
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
|
32 |
|
|
|
33 |
|
|
/**
|
34 |
|
|
*
|
35 |
9e92b44f
|
Patrick Plitzner
|
* @author pplitzner
|
36 |
|
|
* @date 26.09.2017
|
37 |
|
|
*
|
38 |
a4b31985
|
Patrick Plitzner
|
*/
|
39 |
9e92b44f
|
Patrick Plitzner
|
public class SetMarkerFlagHandlerE4 {
|
40 |
|
|
|
41 |
|
|
@Execute
|
42 |
|
|
public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)IAnnotatableEntity selection,
|
43 |
|
|
@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
|
44 |
b5b429af
|
Patrick Plitzner
|
MHandledMenuItem menuItem, UISynchronize sync) {
|
45 |
9e92b44f
|
Patrick Plitzner
|
|
46 |
|
|
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject();
|
47 |
|
|
MarkerType markerType = (MarkerType) menuItem.getTransientData().get(DynamicMarkerTypeEditingMenuE4.COMMAND_PARAMETER_MARKER_TYPE);
|
48 |
|
|
boolean markerState = (boolean) menuItem.getTransientData().get(DynamicMarkerTypeEditingMenuE4.COMMAND_PARAMETER_MARKER_STATE);
|
49 |
|
|
|
50 |
|
|
|
51 |
|
|
AbstractPostOperation operation = new SetMarkerFlagOperation("Set Marker", BulkEditorUtil.getUndoContext(), Collections.singleton(selection), markerType, markerState, editor);
|
52 |
b5b429af
|
Patrick Plitzner
|
AbstractUtility.executeOperation(operation, sync);
|
53 |
9e92b44f
|
Patrick Plitzner
|
}
|
54 |
|
|
|
55 |
a4b31985
|
Patrick Plitzner
|
|
56 |
9e92b44f
|
Patrick Plitzner
|
@CanExecute
|
57 |
3699c749
|
Katja Luther
|
public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
|
58 |
9e92b44f
|
Patrick Plitzner
|
MHandledMenuItem menuItem){
|
59 |
|
|
boolean canExecute = false;
|
60 |
8309769f
|
Patrick Plitzner
|
StructuredSelection selection = (StructuredSelection)((BulkEditorE4)activePart.getObject()).getSelection();
|
61 |
3699c749
|
Katja Luther
|
canExecute = !selection.isEmpty() && selection.getFirstElement() instanceof IAnnotatableEntity;
|
62 |
9e92b44f
|
Patrick Plitzner
|
menuItem.setVisible(canExecute);
|
63 |
|
|
return canExecute;
|
64 |
|
|
}
|
65 |
a4b31985
|
Patrick Plitzner
|
}
|