*/
package eu.etaxonomy.taxeditor.featuretree.e4.handler;
-import java.util.List;
-
import javax.inject.Named;
-import org.eclipse.core.runtime.NullProgressMonitor;
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 org.eclipse.jface.viewers.IStructuredSelection;
import eu.etaxonomy.cdm.model.description.FeatureTree;
-import eu.etaxonomy.taxeditor.featuretree.e4.FeatureNodeDropAdapter;
import eu.etaxonomy.taxeditor.featuretree.e4.FeatureTreeEditor;
import eu.etaxonomy.taxeditor.featuretree.e4.operation.RemoveFeatureTreeOperation;
-import eu.etaxonomy.taxeditor.model.MessagingUtils;
+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();
- if (editor.isDirty()) {
- if (MessagingUtils.confirmDialog(FeatureNodeDropAdapter.SAVE_CHANGES_TITLE,
- FeatureNodeDropAdapter.SAVE_CHANGES_MESSAGE)){
- editor.save(new NullProgressMonitor());
- }
- else{
- return;
- }
+ if (StoreUtil.checkDirty(editor)) {
+ return;
+ }
+ if(!StoreUtil.confirmDelete()){
+ return;
}
- List<FeatureTree> trees = (List<FeatureTree>) editor.getViewer().getInput();
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