Revision 41e1666a
Added by Patrick Plitzner over 5 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/handler/RemoveFeatureTreeHandler.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.featuretree.e4.handler; |
10 | 10 |
|
11 |
import java.util.List; |
|
12 |
|
|
13 | 11 |
import javax.inject.Named; |
14 | 12 |
|
15 |
import org.eclipse.core.runtime.NullProgressMonitor; |
|
16 | 13 |
import org.eclipse.e4.core.di.annotations.CanExecute; |
17 | 14 |
import org.eclipse.e4.core.di.annotations.Execute; |
18 | 15 |
import org.eclipse.e4.core.di.annotations.Optional; |
16 |
import org.eclipse.e4.ui.di.UISynchronize; |
|
19 | 17 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
20 | 18 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
21 | 19 |
import org.eclipse.e4.ui.services.IServiceConstants; |
22 | 20 |
import org.eclipse.jface.viewers.IStructuredSelection; |
23 | 21 |
|
24 | 22 |
import eu.etaxonomy.cdm.model.description.FeatureTree; |
25 |
import eu.etaxonomy.taxeditor.featuretree.e4.FeatureNodeDropAdapter; |
|
26 | 23 |
import eu.etaxonomy.taxeditor.featuretree.e4.FeatureTreeEditor; |
27 | 24 |
import eu.etaxonomy.taxeditor.featuretree.e4.operation.RemoveFeatureTreeOperation; |
28 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
|
25 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
|
26 |
import eu.etaxonomy.taxeditor.store.StoreUtil; |
|
29 | 27 |
|
30 | 28 |
/** |
31 | 29 |
* @author pplitzner |
... | ... | |
36 | 34 |
|
37 | 35 |
@Execute |
38 | 36 |
public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart thisPart, |
39 |
@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection){ |
|
37 |
@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection, UISynchronize sync){
|
|
40 | 38 |
FeatureTreeEditor editor = (FeatureTreeEditor) thisPart.getObject(); |
41 | 39 |
|
42 |
if (editor.isDirty()) { |
|
43 |
if (MessagingUtils.confirmDialog(FeatureNodeDropAdapter.SAVE_CHANGES_TITLE, |
|
44 |
FeatureNodeDropAdapter.SAVE_CHANGES_MESSAGE)){ |
|
45 |
editor.save(new NullProgressMonitor()); |
|
46 |
} |
|
47 |
else{ |
|
48 |
return; |
|
49 |
} |
|
40 |
if (StoreUtil.checkDirty(editor)) { |
|
41 |
return; |
|
42 |
} |
|
43 |
if(!StoreUtil.confirmDelete()){ |
|
44 |
return; |
|
50 | 45 |
} |
51 | 46 |
|
52 |
List<FeatureTree> trees = (List<FeatureTree>) editor.getViewer().getInput(); |
|
53 | 47 |
for (Object selectedObject : selection.toArray()) { |
54 | 48 |
FeatureTree featureTree = (FeatureTree) selectedObject; |
55 | 49 |
RemoveFeatureTreeOperation operation = new RemoveFeatureTreeOperation(featureTree, editor, editor); |
56 |
editor.addOperation(operation); |
|
57 |
trees.remove(featureTree); |
|
50 |
AbstractUtility.executeOperation(operation, sync); |
|
51 |
// editor.getViewer().remove(featureTree); |
|
52 |
// editor.getRootEntities().remove(featureTree); |
|
58 | 53 |
} |
59 |
editor.getViewer().setInput(trees); |
|
60 |
editor.setDirty(true); |
|
61 | 54 |
} |
62 | 55 |
|
63 | 56 |
@CanExecute |
Also available in: Unified diff
ref #6806 Fix dirty state handling and saving in feature tree editor