*/
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.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.FeatureNodeDropAdapter;
-import eu.etaxonomy.taxeditor.featuretree.e4.FeatureTreeEditor;
+import eu.etaxonomy.taxeditor.featuretree.e4.IFeatureTreeEditor;
import eu.etaxonomy.taxeditor.featuretree.e4.operation.CreateFeatureTreeOperation;
-import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.store.StoreUtil;
/**
* @author pplitzner
public class CreateFeatureTreeHandler {
@Execute
- public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart thisPart){
- FeatureTreeEditor editor = (FeatureTreeEditor) thisPart.getObject();
+ public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart thisPart, UISynchronize sync){
+ IFeatureTreeEditor editor = (IFeatureTreeEditor) thisPart.getObject();
- if (editor.isDirty()) {
- if (MessagingUtils.confirmDialog(FeatureNodeDropAdapter.SAVE_CHANGES_TITLE,
- FeatureNodeDropAdapter.SAVE_CHANGES_MESSAGE)){
- editor.save(new NullProgressMonitor());
- }
- else{
- return;
- }
+ if (StoreUtil.promptCheckIsDirty(editor)) {
+ return;
}
FeatureTree tree = FeatureTree.NewInstance();
tree.setTitleCache("New feature tree", true);
CreateFeatureTreeOperation operation = new CreateFeatureTreeOperation(tree, editor, editor);
- editor.addOperation(operation);
- List<FeatureTree> trees = (List<FeatureTree>) editor.getViewer().getInput();
- trees.add(tree);
- editor.getViewer().setInput(trees);
- editor.setDirty(true);
+ AbstractUtility.executeOperation(operation, sync);
}
@CanExecute
@Named(IServiceConstants.ACTIVE_PART)MPart thisPart,
MHandledMenuItem menuItem) {
boolean canExecute = false;
- canExecute = thisPart.getObject() instanceof FeatureTreeEditor;
+ canExecute = thisPart.getObject() instanceof IFeatureTreeEditor;
menuItem.setVisible(canExecute);
return canExecute;
}