1
|
/**
|
2
|
* 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
|
|
10
|
package eu.etaxonomy.taxeditor.bulkeditor.e4.handler;
|
11
|
|
12
|
import java.util.Collections;
|
13
|
|
14
|
import javax.inject.Named;
|
15
|
|
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.di.UISynchronize;
|
20
|
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
21
|
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
|
22
|
import org.eclipse.e4.ui.services.IServiceConstants;
|
23
|
|
24
|
import eu.etaxonomy.cdm.model.common.IAnnotatableEntity;
|
25
|
import eu.etaxonomy.cdm.model.common.MarkerType;
|
26
|
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorUtil;
|
27
|
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4;
|
28
|
import eu.etaxonomy.taxeditor.bulkeditor.e4.command.DynamicMarkerTypeEditingMenuE4;
|
29
|
import eu.etaxonomy.taxeditor.bulkeditor.operation.SetMarkerFlagOperation;
|
30
|
import eu.etaxonomy.taxeditor.model.AbstractUtility;
|
31
|
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
|
32
|
|
33
|
/**
|
34
|
*
|
35
|
* @author pplitzner
|
36
|
* @date 26.09.2017
|
37
|
*
|
38
|
*/
|
39
|
public class SetMarkerFlagHandlerE4 {
|
40
|
|
41
|
@Execute
|
42
|
public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)IAnnotatableEntity selection,
|
43
|
@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
|
44
|
MHandledMenuItem menuItem, UISynchronize sync) {
|
45
|
|
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
|
AbstractUtility.executeOperation(operation, sync);
|
53
|
}
|
54
|
|
55
|
|
56
|
@CanExecute
|
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);
|
62
|
return canExecute;
|
63
|
}
|
64
|
}
|