Project

General

Profile

Revision 2c5756ad

ID2c5756ad2ae740ff9a2be5409f8abf46315c0c7b
Parent f57d8d08
Child eeb8c46f

Added by Patrick Plitzner over 2 years ago

ref #6746 Add "Create Feature Tree" menu item

View differences:

eu.etaxonomy.taxeditor.store/fragment.e4xmi
14 14
      <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"/>
15 15
      <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"/>
16 16
      <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"/>
17
      <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"/>
17 18
      <menus xsi:type="menu:PopupMenu" xmi:id="__Jwh4GceEee0qLTtA2ZpVQ" elementId="eu.etaxonomy.taxeditor.store.popupmenu.featureTreeEditor">
19
        <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"/>
20
        <children xsi:type="menu:MenuSeparator" xmi:id="_eIB1kCHXEeiP8eNo0PEm1g" elementId="eu.etaxonomy.taxeditor.store.menuseparator.5"/>
18 21
        <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"/>
19 22
        <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"/>
20 23
        <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">
......
125 128
    <elements xsi:type="commands:Command" xmi:id="_jSJrsBWPEeiazYUJirF0Pw" elementId="eu.etaxonomy.taxeditor.store.command.update" commandName="Check for updates"/>
126 129
    <elements xsi:type="commands:Command" xmi:id="_aPYxsBezEeiXusClKZjycQ" elementId="eu.etaxonomy.taxeditor.store.command.featureTree.addChildFeature" commandName="Add child feature"/>
127 130
    <elements xsi:type="commands:Command" xmi:id="_3mqzkCFdEeiVXriJfxPIuA" elementId="eu.etaxonomy.taxeditor.store.command.featureTree.deleteFeatureTree" commandName="Delete feature tree"/>
131
    <elements xsi:type="commands:Command" xmi:id="_AJtnsCHXEeiP8eNo0PEm1g" elementId="eu.etaxonomy.taxeditor.store.command.featureTree.createFeatureTree" commandName="Create feature tree"/>
128 132
  </fragments>
129 133
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_swGH0GhvEee3K4uKJljEYg" featurename="handlers" parentElementId="xpath:/">
130 134
    <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"/>
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/handler/CreateFeatureTreeHandler.java
1
/**
2
* Copyright (C) 2017 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.featuretree.e4.handler;
10

  
11
import java.util.List;
12

  
13
import javax.inject.Named;
14

  
15
import org.eclipse.e4.core.di.annotations.CanExecute;
16
import org.eclipse.e4.core.di.annotations.Execute;
17
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
18
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
19
import org.eclipse.e4.ui.services.IServiceConstants;
20

  
21
import eu.etaxonomy.cdm.model.description.FeatureTree;
22
import eu.etaxonomy.taxeditor.featuretree.e4.FeatureTreeEditor;
23

  
24
/**
25
 * @author pplitzner
26
 * @since Jul 12, 2017
27
 *
28
 */
29
public class CreateFeatureTreeHandler {
30

  
31
    @Execute
32
    public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart thisPart){
33
        FeatureTree tree = FeatureTree.NewInstance();
34
        FeatureTreeEditor editor = (FeatureTreeEditor) thisPart.getObject();
35
        List<FeatureTree> trees = (List<FeatureTree>) editor.getViewer().getInput();
36
        trees.add(tree);
37
        editor.getViewer().setInput(trees);
38
        editor.setDirty(true);
39
    }
40

  
41
    @CanExecute
42
    public boolean canExecute(
43
            @Named(IServiceConstants.ACTIVE_PART)MPart thisPart,
44
            MHandledMenuItem menuItem) {
45
        boolean canExecute = false;
46
        canExecute = thisPart.getObject() instanceof FeatureTreeEditor;
47
        menuItem.setVisible(canExecute);
48
        return canExecute;
49
    }
50

  
51
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/handler/RemoveFeatureHandler.java
47 47
            @Optional@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
48 48
            @Named(IServiceConstants.ACTIVE_PART)MPart thisPart,
49 49
            MHandledMenuItem menuItem) {
50
        boolean canExecute = false;
51
        if(selection!=null && !selection.isEmpty()){
52
            for(Object object:selection.toArray()){
53
                canExecute &= object instanceof FeatureNode;
54
            }
50
        boolean canExecute = selection!=null && !selection.isEmpty();
51
        for(Object object:selection.toArray()){
52
            canExecute &= object instanceof FeatureNode;
55 53
        }
56 54
        canExecute &= thisPart.getObject() instanceof IE4ViewerPart;
57 55
        menuItem.setVisible(canExecute);
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/handler/RemoveFeatureTreeHandler.java
35 35
    @Execute
36 36
    public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart thisPart,
37 37
            @Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection){
38
        FeatureTreeEditor editor = (FeatureTreeEditor) thisPart.getObject();
39
        List<FeatureTree> trees = (List<FeatureTree>) editor.getViewer().getInput();
38 40
        for (Object selectedObject : selection.toArray()) {
39 41
            FeatureTree featureTree = (FeatureTree) selectedObject;
40 42
            CdmStore.getService(IFeatureTreeService.class).delete(featureTree.getUuid());
43
            trees.remove(featureTree);
41 44
        }
42
        FeatureTreeEditor editor = (FeatureTreeEditor) thisPart.getObject();
43
        List<FeatureTree> trees = CdmStore.getService(IFeatureTreeService.class).list(FeatureTree.class, null, null, null, null);
44 45
        editor.getViewer().setInput(trees);
45 46
    }
46 47

  
......
49 50
            @Optional@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
50 51
            @Named(IServiceConstants.ACTIVE_PART)MPart thisPart,
51 52
            MHandledMenuItem menuItem) {
52
        boolean canExecute = false;
53
        if(selection!=null && !selection.isEmpty()){
53
        boolean canExecute = selection!=null && !selection.isEmpty();
54
        if(canExecute){
54 55
            for(Object object:selection.toArray()){
55 56
                canExecute &= object instanceof FeatureTree;
56 57
            }

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)