Revision c2e12c2b
Added by Patrick Plitzner almost 6 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/handler/AddFeatureHandler.java | ||
---|---|---|
23 | 23 |
import org.eclipse.jface.wizard.WizardDialog; |
24 | 24 |
import org.eclipse.swt.widgets.Shell; |
25 | 25 |
|
26 |
import eu.etaxonomy.cdm.api.service.IFeatureNodeService; |
|
27 | 26 |
import eu.etaxonomy.cdm.model.description.Feature; |
27 |
import eu.etaxonomy.cdm.model.description.FeatureNode; |
|
28 | 28 |
import eu.etaxonomy.cdm.model.description.FeatureTree; |
29 | 29 |
import eu.etaxonomy.taxeditor.featuretree.AvailableFeaturesWizard; |
30 | 30 |
import eu.etaxonomy.taxeditor.featuretree.e4.FeatureTreeEditor; |
31 |
import eu.etaxonomy.taxeditor.store.CdmStore;
|
|
31 |
import eu.etaxonomy.taxeditor.featuretree.e4.operation.AddFeatureOperation;
|
|
32 | 32 |
|
33 | 33 |
/** |
34 | 34 |
* @author pplitzner |
... | ... | |
49 | 49 |
FeatureTree tree = (FeatureTree) selection.iterator().next(); |
50 | 50 |
Collection<Feature> additionalFeatures = wizard.getAdditionalFeatures(); |
51 | 51 |
for (Feature feature : additionalFeatures) { |
52 |
CdmStore.getService(IFeatureNodeService.class).addChildFeatureNode(tree.getRoot().getUuid(), feature.getUuid()); |
|
52 |
FeatureNode childNode = FeatureNode.NewInstance(feature); |
|
53 |
tree.getRoot().addChild(childNode); |
|
54 |
AddFeatureOperation operation = new AddFeatureOperation(feature, tree.getRoot(), editor, editor); |
|
55 |
editor.addOperation(operation); |
|
53 | 56 |
} |
57 |
editor.setDirty(true); |
|
54 | 58 |
editor.getViewer().refresh(); |
55 | 59 |
editor.getViewer().expandToLevel(selection, 1); |
56 | 60 |
} |
... | ... | |
62 | 66 |
@Named(IServiceConstants.ACTIVE_PART)MPart thisPart, |
63 | 67 |
MHandledMenuItem menuItem) { |
64 | 68 |
boolean canExecute = false; |
65 |
canExecute = selection!=null |
|
69 |
canExecute = thisPart.getObject() instanceof FeatureTreeEditor |
|
70 |
&& selection!=null |
|
66 | 71 |
&& selection.size()==1 |
67 |
&& selection.iterator().next() instanceof FeatureTree |
|
68 |
&& thisPart.getObject() instanceof FeatureTreeEditor; |
|
72 |
&& selection.iterator().next() instanceof FeatureTree; |
|
69 | 73 |
menuItem.setVisible(canExecute); |
70 | 74 |
return canExecute; |
71 | 75 |
} |
Also available in: Unified diff
ref #6806 Implement operation framework for feature tree editor