Revision 41e1666a
Added by Patrick Plitzner over 5 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/handler/AddChildFeatureHandler.java | ||
---|---|---|
13 | 13 |
import javax.inject.Named; |
14 | 14 |
|
15 | 15 |
import org.eclipse.core.runtime.IStatus; |
16 |
import org.eclipse.core.runtime.NullProgressMonitor; |
|
17 | 16 |
import org.eclipse.e4.core.di.annotations.CanExecute; |
18 | 17 |
import org.eclipse.e4.core.di.annotations.Execute; |
19 | 18 |
import org.eclipse.e4.core.di.annotations.Optional; |
19 |
import org.eclipse.e4.ui.di.UISynchronize; |
|
20 | 20 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
21 | 21 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
22 | 22 |
import org.eclipse.e4.ui.services.IServiceConstants; |
... | ... | |
27 | 27 |
import eu.etaxonomy.cdm.model.description.Feature; |
28 | 28 |
import eu.etaxonomy.cdm.model.description.FeatureNode; |
29 | 29 |
import eu.etaxonomy.taxeditor.featuretree.AvailableFeaturesWizard; |
30 |
import eu.etaxonomy.taxeditor.featuretree.e4.FeatureNodeDropAdapter; |
|
31 | 30 |
import eu.etaxonomy.taxeditor.featuretree.e4.FeatureTreeEditor; |
32 | 31 |
import eu.etaxonomy.taxeditor.featuretree.e4.operation.AddFeatureOperation; |
33 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
|
32 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
|
33 |
import eu.etaxonomy.taxeditor.store.StoreUtil; |
|
34 | 34 |
|
35 | 35 |
/** |
36 | 36 |
* @author pplitzner |
... | ... | |
42 | 42 |
@Execute |
43 | 43 |
public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell, |
44 | 44 |
@Named(IServiceConstants.ACTIVE_PART)MPart thisPart, |
45 |
@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection) { |
|
45 |
@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection, |
|
46 |
UISynchronize sync) { |
|
46 | 47 |
FeatureTreeEditor editor = ((FeatureTreeEditor) thisPart.getObject()); |
47 |
if (editor.isDirty()) { |
|
48 |
if (MessagingUtils.confirmDialog(FeatureNodeDropAdapter.SAVE_CHANGES_TITLE, |
|
49 |
FeatureNodeDropAdapter.SAVE_CHANGES_MESSAGE)){ |
|
50 |
editor.save(new NullProgressMonitor()); |
|
51 |
} |
|
52 |
else{ |
|
53 |
return; |
|
54 |
} |
|
48 |
if (StoreUtil.checkDirty(editor)) { |
|
49 |
return; |
|
55 | 50 |
} |
56 | 51 |
|
57 | 52 |
AvailableFeaturesWizard wizard = new AvailableFeaturesWizard(); |
... | ... | |
62 | 57 |
FeatureNode parent = (FeatureNode)next; |
63 | 58 |
Collection<Feature> additionalFeatures = wizard.getAdditionalFeatures(); |
64 | 59 |
for (Feature feature : additionalFeatures) { |
65 |
FeatureNode childNode = FeatureNode.NewInstance(feature); |
|
66 |
parent.addChild(childNode); |
|
67 | 60 |
AddFeatureOperation operation = new AddFeatureOperation(feature, parent, editor, editor); |
68 |
editor.addOperation(operation);
|
|
61 |
AbstractUtility.executeOperation(operation, sync);
|
|
69 | 62 |
} |
70 |
editor.setDirty(true); |
|
71 |
editor.getViewer().refresh(); |
|
72 |
editor.getViewer().expandToLevel(parent, 1); |
|
73 | 63 |
} |
74 | 64 |
} |
75 | 65 |
|
Also available in: Unified diff
ref #6806 Fix dirty state handling and saving in feature tree editor