Revision b0a5a69c
Added by Patrick Plitzner almost 6 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/DynamicFeatureMenuE4.java | ||
---|---|---|
21 | 21 |
import org.eclipse.e4.ui.model.application.ui.menu.MMenuElement; |
22 | 22 |
import org.eclipse.e4.ui.model.application.ui.menu.MMenuFactory; |
23 | 23 |
import org.eclipse.e4.ui.services.IServiceConstants; |
24 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
24 | 25 |
|
25 | 26 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
26 | 27 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
... | ... | |
44 | 45 |
|
45 | 46 |
/** {@inheritDoc} */ |
46 | 47 |
@AboutToShow |
47 |
public void aboutToShow(List<MMenuElement> items, @Named(IServiceConstants.ACTIVE_SELECTION) Object selection) {
|
|
48 |
public void aboutToShow(List<MMenuElement> items, @Named(IServiceConstants.ACTIVE_SELECTION) IStructuredSelection selection) {
|
|
48 | 49 |
|
49 | 50 |
MMenu menu = MMenuFactory.INSTANCE.createMenu(); |
50 | 51 |
menu.setLabel(Messages.DynamicFeatureMenuE4_new); |
51 | 52 |
items.add(menu); |
52 | 53 |
|
53 |
if (selection instanceof DescriptionBase<?>) { |
|
54 |
FeatureTree featureTree = getFeatureTree((DescriptionBase<?>) selection); |
|
54 |
Object selectedElement = selection.getFirstElement(); |
|
55 |
|
|
56 |
if (selectedElement instanceof DescriptionBase<?>) { |
|
57 |
FeatureTree featureTree = getFeatureTree((DescriptionBase<?>) selectedElement); |
|
55 | 58 |
|
56 | 59 |
for (FeatureNode childNode : featureTree.getRootChildren()) { |
57 | 60 |
createMenuItem(menu, childNode.getFeature()); |
58 | 61 |
|
59 | 62 |
} |
60 |
} else if (selection instanceof FeatureNodeContainer) {
|
|
61 |
FeatureNode featureNode = ((FeatureNodeContainer) selection)
|
|
63 |
} else if (selectedElement instanceof FeatureNodeContainer) {
|
|
64 |
FeatureNode featureNode = ((FeatureNodeContainer) selectedElement)
|
|
62 | 65 |
.getFeatureNode(); |
63 | 66 |
|
64 | 67 |
// add the feature to the menu |
... | ... | |
68 | 71 |
for (FeatureNode childNode : featureNode.getChildNodes()) { |
69 | 72 |
createMenuItem(menu, childNode.getFeature()); |
70 | 73 |
} |
71 |
} else if (selection instanceof DescriptionElementBase) {
|
|
72 |
Feature feature = ((DescriptionElementBase) selection)
|
|
74 |
} else if (selectedElement instanceof DescriptionElementBase) {
|
|
75 |
Feature feature = ((DescriptionElementBase) selectedElement)
|
|
73 | 76 |
.getFeature(); |
74 | 77 |
createMenuItem(menu, feature); |
75 | 78 |
} |
Also available in: Unified diff
ref #7010 Adapt descriptive view handlers for multiple selection