<handlers xmi:id="_VSc2UGcqEee0qLTtA2ZpVQ" elementId="eu.etaxonomy.taxeditor.featuretree.e4.handler.FeatureTreeExportHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.featuretree.e4.handler.FeatureTreeExportHandler" command="_I_yx4GcqEee0qLTtA2ZpVQ"/>
<handlers xmi:id="_hPTxMBezEeiXusClKZjycQ" elementId="eu.etaxonomy.taxeditor.featuretree.e4.handler.AddChildFeatureHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.featuretree.e4.handler.AddChildFeatureHandler" command="_aPYxsBezEeiXusClKZjycQ"/>
<handlers xmi:id="_Bb0TwCFeEeiVXriJfxPIuA" elementId="eu.etaxonomy.taxeditor.featuretree.e4.handler.RemoveFeatureTreeHandlers" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.featuretree.e4.handler.RemoveFeatureTreeHandler" command="_3mqzkCFdEeiVXriJfxPIuA"/>
+ <handlers xmi:id="_DYhGACHXEeiP8eNo0PEm1g" elementId="eu.etaxonomy.taxeditor.featuretree.e4.handler.CreateFeatureTreeHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.featuretree.e4.handler.CreateFeatureTreeHandler" command="_AJtnsCHXEeiP8eNo0PEm1g"/>
<menus xsi:type="menu:PopupMenu" xmi:id="__Jwh4GceEee0qLTtA2ZpVQ" elementId="eu.etaxonomy.taxeditor.store.popupmenu.featureTreeEditor">
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_GuuM0CHXEeiP8eNo0PEm1g" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.newfeaturetree" label="New Feature Tree" iconURI="platform:/plugin/org.eclipse.ui/icons/full/etool16/new_wiz.png" command="_AJtnsCHXEeiP8eNo0PEm1g"/>
+ <children xsi:type="menu:MenuSeparator" xmi:id="_eIB1kCHXEeiP8eNo0PEm1g" elementId="eu.etaxonomy.taxeditor.store.menuseparator.5"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_jr4E0Be0EeiXusClKZjycQ" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.addchildfeature" label="Add Child Feature" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/add.gif" command="_aPYxsBezEeiXusClKZjycQ"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_eWBz0GcjEee0qLTtA2ZpVQ" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.addFeature" label="Add Feature" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/add.gif" command="_oftL0GceEee0qLTtA2ZpVQ"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_7vaEcGcqEee0qLTtA2ZpVQ" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.exportFeatureTree" label="Export Feature Tree" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/export.gif" command="_I_yx4GcqEee0qLTtA2ZpVQ">
<elements xsi:type="commands:Command" xmi:id="_jSJrsBWPEeiazYUJirF0Pw" elementId="eu.etaxonomy.taxeditor.store.command.update" commandName="Check for updates"/>
<elements xsi:type="commands:Command" xmi:id="_aPYxsBezEeiXusClKZjycQ" elementId="eu.etaxonomy.taxeditor.store.command.featureTree.addChildFeature" commandName="Add child feature"/>
<elements xsi:type="commands:Command" xmi:id="_3mqzkCFdEeiVXriJfxPIuA" elementId="eu.etaxonomy.taxeditor.store.command.featureTree.deleteFeatureTree" commandName="Delete feature tree"/>
+ <elements xsi:type="commands:Command" xmi:id="_AJtnsCHXEeiP8eNo0PEm1g" elementId="eu.etaxonomy.taxeditor.store.command.featureTree.createFeatureTree" commandName="Create feature tree"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_swGH0GhvEee3K4uKJljEYg" featurename="handlers" parentElementId="xpath:/">
<elements xsi:type="commands:Handler" xmi:id="_rVEdIGcjEee0qLTtA2ZpVQ" elementId="eu.etaxonomy.taxeditor.featuretree.e4.handler.RemoveFeatureHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.featuretree.e4.handler.RemoveFeatureHandler" command="_fNBtQGcjEee0qLTtA2ZpVQ"/>
--- /dev/null
+/**
+* Copyright (C) 2017 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+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.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;
+
+/**
+ * @author pplitzner
+ * @since Jul 12, 2017
+ *
+ */
+public class CreateFeatureTreeHandler {
+
+ @Execute
+ public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart thisPart){
+ FeatureTree tree = FeatureTree.NewInstance();
+ FeatureTreeEditor editor = (FeatureTreeEditor) thisPart.getObject();
+ List<FeatureTree> trees = (List<FeatureTree>) editor.getViewer().getInput();
+ trees.add(tree);
+ editor.getViewer().setInput(trees);
+ editor.setDirty(true);
+ }
+
+ @CanExecute
+ public boolean canExecute(
+ @Named(IServiceConstants.ACTIVE_PART)MPart thisPart,
+ MHandledMenuItem menuItem) {
+ boolean canExecute = false;
+ canExecute = thisPart.getObject() instanceof FeatureTreeEditor;
+ menuItem.setVisible(canExecute);
+ return canExecute;
+ }
+
+}
@Optional@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
@Named(IServiceConstants.ACTIVE_PART)MPart thisPart,
MHandledMenuItem menuItem) {
- boolean canExecute = false;
- if(selection!=null && !selection.isEmpty()){
- for(Object object:selection.toArray()){
- canExecute &= object instanceof FeatureNode;
- }
+ boolean canExecute = selection!=null && !selection.isEmpty();
+ for(Object object:selection.toArray()){
+ canExecute &= object instanceof FeatureNode;
}
canExecute &= thisPart.getObject() instanceof IE4ViewerPart;
menuItem.setVisible(canExecute);
@Execute
public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart thisPart,
@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection){
+ FeatureTreeEditor editor = (FeatureTreeEditor) thisPart.getObject();
+ List<FeatureTree> trees = (List<FeatureTree>) editor.getViewer().getInput();
for (Object selectedObject : selection.toArray()) {
FeatureTree featureTree = (FeatureTree) selectedObject;
CdmStore.getService(IFeatureTreeService.class).delete(featureTree.getUuid());
+ trees.remove(featureTree);
}
- FeatureTreeEditor editor = (FeatureTreeEditor) thisPart.getObject();
- List<FeatureTree> trees = CdmStore.getService(IFeatureTreeService.class).list(FeatureTree.class, null, null, null, null);
editor.getViewer().setInput(trees);
}
@Optional@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
@Named(IServiceConstants.ACTIVE_PART)MPart thisPart,
MHandledMenuItem menuItem) {
- boolean canExecute = false;
- if(selection!=null && !selection.isEmpty()){
+ boolean canExecute = selection!=null && !selection.isEmpty();
+ if(canExecute){
for(Object object:selection.toArray()){
canExecute &= object instanceof FeatureTree;
}