Revision ddf52a47
Added by Patrick Plitzner almost 7 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/handler/RemoveFeatureHandler.java | ||
---|---|---|
19 | 19 |
import eu.etaxonomy.cdm.api.service.IFeatureNodeService; |
20 | 20 |
import eu.etaxonomy.cdm.api.service.config.FeatureNodeDeletionConfigurator; |
21 | 21 |
import eu.etaxonomy.cdm.model.description.FeatureNode; |
22 |
import eu.etaxonomy.taxeditor.featuretree.e4.FeatureTreeEditor; |
|
23 | 22 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
23 |
import eu.etaxonomy.taxeditor.workbench.part.IE4ViewerPart; |
|
24 | 24 |
|
25 | 25 |
/** |
26 | 26 |
* @author pplitzner |
... | ... | |
31 | 31 |
|
32 | 32 |
@Execute |
33 | 33 |
public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart thisPart){ |
34 |
FeatureTreeEditor editor = (FeatureTreeEditor) thisPart.getObject(); |
|
35 |
IStructuredSelection selection = (IStructuredSelection) editor.getViewer().getSelection(); |
|
36 |
for (Object selectedObject : selection.toArray()) { |
|
37 |
FeatureNode featureNode = (FeatureNode) selectedObject; |
|
38 |
CdmStore.getService(IFeatureNodeService.class).deleteFeatureNode(featureNode.getUuid(), new FeatureNodeDeletionConfigurator()); |
|
34 |
if(thisPart.getObject() instanceof IE4ViewerPart){ |
|
35 |
IE4ViewerPart editor = (IE4ViewerPart) thisPart.getObject(); |
|
36 |
IStructuredSelection selection = editor.getSelection(); |
|
37 |
for (Object selectedObject : selection.toArray()) { |
|
38 |
FeatureNode featureNode = (FeatureNode) selectedObject; |
|
39 |
CdmStore.getService(IFeatureNodeService.class).deleteFeatureNode(featureNode.getUuid(), new FeatureNodeDeletionConfigurator()); |
|
40 |
} |
|
41 |
thisPart.setDirty(true); |
|
42 |
editor.refresh(); |
|
39 | 43 |
} |
40 |
thisPart.setDirty(true); |
|
41 |
editor.refresh(); |
|
42 | 44 |
} |
43 | 45 |
|
44 | 46 |
@CanExecute |
45 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection, |
|
46 |
@Named(IServiceConstants.ACTIVE_PART)MPart thisPart){ |
|
47 |
return thisPart.getObject() instanceof FeatureTreeEditor && selection!=null && !selection.isEmpty(); |
|
47 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart thisPart){ |
|
48 |
if(thisPart.getObject() instanceof IE4ViewerPart){ |
|
49 |
IE4ViewerPart viewerPart = (IE4ViewerPart)thisPart.getObject(); |
|
50 |
return viewerPart.getSelection()!=null && !viewerPart.getSelection().isEmpty(); |
|
51 |
} |
|
52 |
return false; |
|
48 | 53 |
} |
49 | 54 |
|
50 | 55 |
} |
Also available in: Unified diff
ref #6762 Add context menu to CharacterEditor