*/
package eu.etaxonomy.taxeditor.featuretree.e4.handler;
-import java.util.List;
-
import javax.inject.Named;
import org.eclipse.e4.core.di.annotations.CanExecute;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.core.di.annotations.Optional;
+import org.eclipse.e4.ui.di.UISynchronize;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
import org.eclipse.e4.ui.services.IServiceConstants;
import eu.etaxonomy.cdm.model.description.FeatureTree;
import eu.etaxonomy.taxeditor.featuretree.e4.FeatureTreeEditor;
import eu.etaxonomy.taxeditor.featuretree.e4.operation.RemoveFeatureTreeOperation;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.store.StoreUtil;
/**
* @author pplitzner
@Execute
public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart thisPart,
- @Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection){
+ @Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection, UISynchronize sync){
FeatureTreeEditor editor = (FeatureTreeEditor) thisPart.getObject();
- List<FeatureTree> trees = (List<FeatureTree>) editor.getViewer().getInput();
+
+ if (StoreUtil.checkDirty(editor)) {
+ return;
+ }
+ if(!StoreUtil.confirmDelete()){
+ return;
+ }
+
for (Object selectedObject : selection.toArray()) {
FeatureTree featureTree = (FeatureTree) selectedObject;
RemoveFeatureTreeOperation operation = new RemoveFeatureTreeOperation(featureTree, editor, editor);
- editor.addOperation(operation);
- trees.remove(featureTree);
+ AbstractUtility.executeOperation(operation, sync);
+// editor.getViewer().remove(featureTree);
+// editor.getRootEntities().remove(featureTree);
}
- editor.getViewer().setInput(trees);
- editor.setDirty(true);
}
@CanExecute