Project

General

Profile

Revision 91333bc6

ID91333bc6afe77b1db8fc745cc72696b8c41fafd4
Parent 3f09ac44
Child e38f6e78

Added by Patrick Plitzner over 3 years ago

ref #6908 Migrate remaining polytomous context menus and handlers

View differences:

eu.etaxonomy.taxeditor.editor/fragment.e4xmi
199 199
    <elements xsi:type="basic:PartDescriptor" xmi:id="_ghDAsKO6EeeWePK798pdTw" elementId="eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyGraphEditorE4" label="%editor.name.2" closeable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyGraphEditorE4">
200 200
      <handlers xmi:id="_dpB_kKRbEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.key.e4.handler.ApplyLayoutHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.key.e4.handler.ApplyLayoutHandlerE4" command="_zN-H8KO8EeeWePK798pdTw"/>
201 201
      <menus xsi:type="menu:PopupMenu" xmi:id="_J8Q6AKRbEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.popupmenu.polytomouskeygrapheditor" toBeRendered="false" visible="false">
202
        <children xsi:type="menu:HandledMenuItem" xmi:id="_bnPG8KRbEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.keygraph.newnode" label="%command.label.20" command="_jJ_4kKO9EeeWePK798pdTw"/>
203
        <children xsi:type="menu:HandledMenuItem" xmi:id="_wKd6cKRbEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.keygraph.delete" label="%command.label.21" command="_uM4zsKO8EeeWePK798pdTw"/>
204
        <children xsi:type="menu:MenuSeparator" xmi:id="_whq5gKRbEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.18"/>
205
        <children xsi:type="menu:HandledMenuItem" xmi:id="_w9X-EKRbEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.keygraph.applylayout" label="%command.label.22" command="_zN-H8KO8EeeWePK798pdTw"/>
202
        <children xsi:type="menu:HandledMenuItem" xmi:id="_bnPG8KRbEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.keygraph.newnode" toBeRendered="false" visible="false" label="%command.label.20" command="_jJ_4kKO9EeeWePK798pdTw"/>
203
        <children xsi:type="menu:HandledMenuItem" xmi:id="_wKd6cKRbEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.keygraph.delete" toBeRendered="false" visible="false" label="%command.label.21" command="_uM4zsKO8EeeWePK798pdTw"/>
204
        <children xsi:type="menu:MenuSeparator" xmi:id="_whq5gKRbEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.18" toBeRendered="false" visible="false"/>
205
        <children xsi:type="menu:HandledMenuItem" xmi:id="_w9X-EKRbEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.keygraph.applylayout" toBeRendered="false" visible="false" label="%command.label.22" command="_zN-H8KO8EeeWePK798pdTw"/>
206 206
      </menus>
207 207
    </elements>
208 208
    <elements xsi:type="basic:PartDescriptor" xmi:id="_tJeg0KO6EeeWePK798pdTw" elementId="eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyListEditorE4" label="%editor.name.3" closeable="true" dirtyable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyListEditorE4">
......
211 211
      <handlers xmi:id="_8DficKRREeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler.CreateChildNodeHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler.CreateChildNodeHandlerE4" command="_tyHGwKO9EeeWePK798pdTw"/>
212 212
      <handlers xmi:id="_QHL6QKRSEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler.CreateSiblingNodeHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler.CreateSiblingNodeHandlerE4" command="_rkKogKO9EeeWePK798pdTw"/>
213 213
      <handlers xmi:id="_pDoJsKRSEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler.RefreshNodeNumberingHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler.RefreshNodeNumberingHandlerE4" command="_mH1G8KRSEeePufXF8uhoCw"/>
214
      <handlers xmi:id="_gCYp4KTaEeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.editor.handler.1" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler.OpenPolytomousGraphEditorHandler" command="_ZolPMKTaEeejf7ggYkp-TA"/>
214 215
      <menus xsi:type="menu:PopupMenu" xmi:id="_2JO_8KRQEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.popupmenu.polytomouskeylisteditor">
215 216
        <children xsi:type="menu:Menu" xmi:id="_2yjpwKRQEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.menu.polytomouskeylist.newkeynumber" label="%menu.label.4">
216 217
          <children xsi:type="menu:HandledMenuItem" xmi:id="_DWtt4KRREeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.polytomouskeylist.new.insertNode" label="%command.label.58" command="_jJ_4kKO9EeeWePK798pdTw"/>
......
218 219
        </children>
219 220
        <children xsi:type="menu:HandledMenuItem" xmi:id="_Iqi_AKRREeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.polytomouskeylist.newAlternative" label="%command.label.24" command="_rkKogKO9EeeWePK798pdTw"/>
220 221
        <children xsi:type="menu:HandledMenuItem" xmi:id="_LJ-14KRREeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.polytomouskeylist.refreshNodes" label="%command.label.25" command="_mH1G8KRSEeePufXF8uhoCw"/>
222
        <children xsi:type="menu:MenuSeparator" xmi:id="_Ww_XAKTaEeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.19"/>
223
        <children xsi:type="menu:HandledMenuItem" xmi:id="_TvBa0KTaEeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.opengraph" label="Open Graph" command="_ZolPMKTaEeejf7ggYkp-TA"/>
224
        <children xsi:type="menu:MenuSeparator" xmi:id="_XMhccKTaEeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.20"/>
221 225
        <children xsi:type="menu:HandledMenuItem" xmi:id="_Rf4A8KRREeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.polytomouskeylist.delete" label="%command.label.26" command="_uM4zsKO8EeeWePK798pdTw"/>
222 226
      </menus>
223 227
    </elements>
......
282 286
    <elements xsi:type="commands:Command" xmi:id="_rkKogKO9EeeWePK798pdTw" elementId="eu.etaxonomy.taxeditor.key.polytomous.command.new.sibling" commandName="%command.name.29"/>
283 287
    <elements xsi:type="commands:Command" xmi:id="_tyHGwKO9EeeWePK798pdTw" elementId="eu.etaxonomy.taxeditor.key.polytomous.command.new.child" commandName="%command.name.28"/>
284 288
    <elements xsi:type="commands:Command" xmi:id="_mH1G8KRSEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.key.polytomous.command.refresh" commandName="%command.name.30"/>
289
    <elements xsi:type="commands:Command" xmi:id="_ZolPMKTaEeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.editor.command.polytomouskeylist.openGraph" commandName="Open Graph Editor"/>
285 290
  </fragments>
286 291
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_pZmusEalEeeXMc6kSYO7Xg" featurename="children" parentElementId="eu.etaxonomy.taxeditor.menu.showView" positionInList="after:eu.etaxonomy.taxeditor.store.menuseparator.afterSupplemental">
287 292
    <elements xsi:type="menu:MenuSeparator" xmi:id="_eAVmMJ7SEee0IagNh8pHpQ" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.14"/>
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/e4/AbstractGraphKeyEditorE4.java
77 77

  
78 78
	public void init(PolytomousKeyEditorInput input) {
79 79
		this.input = input;
80

  
81

  
82
        viewer.setInput(getKey());
80 83
	}
81 84

  
82 85
	public boolean isDirty() {
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/e4/KeyEditorDataChangeBehaviourE4.java
1
/**
2
* Copyright (C) 2007 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

  
10
package eu.etaxonomy.taxeditor.editor.key.e4;
11

  
12
import java.util.Vector;
13

  
14
import eu.etaxonomy.cdm.model.description.PolytomousKey;
15
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeEvent;
16
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeEvent.EventType;
17
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
18
import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyEditorInput;
19
import eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyListEditorE4;
20
import eu.etaxonomy.taxeditor.model.AbstractDataChangeBehaviour;
21

  
22
/**
23
 * @author n.hoffmann
24
 * @created May 5, 2011
25
 * @version 1.0
26
 */
27
public class KeyEditorDataChangeBehaviourE4 extends AbstractDataChangeBehaviour {
28

  
29
	private final PolytomousKeyListEditorE4 source;
30
	private PolytomousKeyEditorInput input;
31

  
32
	public KeyEditorDataChangeBehaviourE4(PolytomousKeyListEditorE4 keyEditor) {
33
		source = keyEditor;
34
	}
35

  
36
	@Override
37
	public void reactOnDataChange(CdmDataChangeMap changeEvents) {
38
		input = source.getEditorInput();
39

  
40
		if(changeEvents.sizeByEventType(EventType.UPDATE) > 0){
41
			reactOnUpdate(changeEvents.getEvents(EventType.UPDATE));
42
		}
43
	}
44

  
45
	/** {@inheritDoc} */
46
	@Override
47
	public void reactOnUpdate(Vector<CdmDataChangeEvent> events){
48

  
49
		for(CdmDataChangeEvent event : events){
50

  
51
			// update editor title
52
			if(event.getEntity() instanceof PolytomousKey){
53
				if(input.getKey().equals(event.getEntity())){
54
					// set the name of the editor window
55
					source.setPartName();
56
				}
57
			}
58
		}
59
	}
60
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/e4/PolytomousKeyGraphEditorE4.java
26 26
import eu.etaxonomy.taxeditor.editor.key.polytomous.IPolytomousKeyEditorPage;
27 27
import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyGraphContentProvider;
28 28
import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyLabelProvider;
29
import eu.etaxonomy.taxeditor.store.CdmStore;
29 30
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
30 31

  
31 32
/**
......
45 46
	@PostConstruct
46 47
    public void createPartControl(Composite parent, EMenuService menuService,
47 48
            @Named(IServiceConstants.ACTIVE_SHELL)Shell shell) {
49
	    if(!CdmStore.isActive()){
50
	        return;
51
	    }
52

  
53
        formFactory = new CdmFormFactory(shell.getDisplay());
48 54
        container = formFactory.createComposite(parent);
49 55

  
50 56
        container.setLayout(new FillLayout());
......
67 73
        //FIXME E4 migrate
68 74
//      createToolbar();
69 75

  
70
        viewer.setInput(getKey());
71

  
72 76
        container.addControlListener(new ControlListener() {
73 77

  
74 78
            @Override
......
81 85

  
82 86
            }
83 87
        });
84

  
85
        formFactory = new CdmFormFactory(shell.getDisplay());
86 88
    }
87 89

  
88 90
	@Override
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/e4/PolytomousKeyListEditorE4.java
45 45
import eu.etaxonomy.cdm.model.taxon.Taxon;
46 46
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
47 47
import eu.etaxonomy.taxeditor.editor.EditorUtil;
48
import eu.etaxonomy.taxeditor.editor.key.KeyEditorDataChangeBehaviour;
48
import eu.etaxonomy.taxeditor.editor.key.e4.KeyEditorDataChangeBehaviourE4;
49 49
import eu.etaxonomy.taxeditor.editor.key.polytomous.IPolytomousKeyEditorPage;
50 50
import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyEditorInput;
51 51
import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyListContentProvider;
52 52
import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyListLabelProvider;
53 53
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
54
import eu.etaxonomy.taxeditor.model.DataChangeBridge;
54 55
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
55 56
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
56 57
import eu.etaxonomy.taxeditor.model.MessagingUtils;
58
import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
57 59

  
58 60
/**
59 61
 *
......
63 65
 */
64 66
public class PolytomousKeyListEditorE4 implements
65 67
		IConversationEnabled, IDirtyMarkable, IPartContentHasDetails,
66
		IPolytomousKeyEditorPage {
68
		IPolytomousKeyEditorPage, IE4SavablePart{
67 69

  
68 70
	private class LinkListener extends MouseAdapter {
69 71

  
......
140 142

  
141 143
	private TableViewer viewer;
142 144

  
143
	private ConversationHolder conversation;
144

  
145
    private KeyEditorDataChangeBehaviour dataChangeBehavior;
145
    private KeyEditorDataChangeBehaviourE4 dataChangeBehavior;
146 146

  
147 147
    private PolytomousKeyEditorInput input;
148 148

  
......
162 162
	}
163 163

  
164 164
	@Override
165
	public void update(CdmDataChangeMap arg0) {
166

  
165
	public void update(CdmDataChangeMap map) {
166
	    if(dataChangeBehavior == null){
167
            dataChangeBehavior = new KeyEditorDataChangeBehaviourE4(this);
168
        }
169
        DataChangeBridge.handleDataChange(map, dataChangeBehavior);
167 170
	}
168 171

  
169 172
	@Override
......
171 174
		return input.getConversationHolder();
172 175
	}
173 176

  
174
	@Persist
175
	public void doSave(IProgressMonitor monitor) {
177
	@Override
178
    @Persist
179
	public void save(IProgressMonitor monitor) {
176 180
        try {
177 181
            monitor.beginTask(Messages.KeyEditor_SAVING, 1);
178 182
            getConversationHolder().bind();
......
196 200
        viewer.setInput(input);
197 201
	}
198 202

  
203
    public PolytomousKeyEditorInput getEditorInput() {
204
        return input;
205
    }
206

  
199 207
	public boolean isDirty() {
200 208
		return dirty.isDirty();
201 209
	}
......
291 299
	@Override
292 300
	public boolean postOperation(CdmBase objectAffectedByOperation) {
293 301
		viewer.refresh();
294
		getConversationHolder().bind();
295
		getConversationHolder().commit(true);
296
		//FIXME E4 migrate/delete
297
//		editor.changed(objectAffectedByOperation);
302
//		getConversationHolder().bind();
303
//		getConversationHolder().commit(true);
304
		changed(objectAffectedByOperation);
298 305

  
299 306
		if (objectAffectedByOperation != null) {
300 307
			viewer.setSelection(new StructuredSelection(
......
308 315
		return true;
309 316
	}
310 317

  
318
    public void setPartName() {
319
        PolytomousKey key = input.getKey();
320
        thisPart.setLabel(key.getTitleCache());
321
    }
322

  
311 323
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/e4/handler/AbstractPolytomousKeyNodeHandlerE4.java
1
/**
2
* Copyright (C) 2016 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.editor.key.polytomous.e4.handler;
10

  
11
import eu.etaxonomy.taxeditor.editor.key.polytomous.IPolytomousKeyEditorPage;
12
import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4;
13

  
14
/**
15
 * @author k.luther
16
 * @date 24.11.2016
17
 *
18
 */
19
public abstract class AbstractPolytomousKeyNodeHandlerE4 extends RemotingCdmHandlerE4 {
20

  
21

  
22
    IPolytomousKeyEditorPage editorPage;
23

  
24
    public AbstractPolytomousKeyNodeHandlerE4(String label) {
25
        super(label);
26
    }
27

  
28
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/e4/handler/CreateChildNodeHandlerE4.java
6 6
import javax.inject.Named;
7 7

  
8 8
import org.eclipse.core.commands.operations.IUndoContext;
9
import org.eclipse.e4.core.di.annotations.CanExecute;
9 10
import org.eclipse.e4.core.di.annotations.Execute;
10 11
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
11 12
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
......
59 60
        }
60 61
    }
61 62

  
63
    @CanExecute
64
    public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
65
            MHandledMenuItem menuItem){
66
        boolean canExecute = false;
67
        canExecute = selection!=null && !selection.isEmpty();
68
        menuItem.setVisible(canExecute);
69
        return canExecute;
70
    }
71

  
62 72
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/e4/handler/DeleteNodeHandlerE4.java
30 30
import eu.etaxonomy.taxeditor.editor.key.polytomous.operation.DeleteNodeOperation;
31 31
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
32 32
import eu.etaxonomy.taxeditor.model.AbstractUtility;
33
import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4;
33 34

  
34 35
/**
35 36
 * @author n.hoffmann
36 37
 * @created Dec 6, 2010
37 38
 * @version 1.0
38 39
 */
39
public class DeleteNodeHandlerE4 extends AbstractPolytomousKeyNodeHandlerE4 {
40
public class DeleteNodeHandlerE4 extends RemotingCdmHandlerE4 {
40 41

  
41 42

  
42 43
    private static final String DO_YOU_REALLY_WANT_TO_DELETE_THE_NODE_THIS_OPERATION_IS_NOT_REVERSABLE = Messages.DeleteNodeHandler_REALLY_DELETE;
......
117 118
            if (!proceed) {
118 119
                return null;
119 120
            }else{
120
                editor.doSave(AbstractUtility.getMonitor());
121
                editor.save(AbstractUtility.getMonitor());
121 122
            }
122 123
        }
123 124

  
124 125
        label = menuItem.getLocalizedLabel();
125 126
        DeleteNodeOperation operation ;
126 127
        if (deleteChildren){
127
            operation = new DeleteNodeOperation(label, undoContext, nodeToBeDeleted, editorPage, true);
128
            operation = new DeleteNodeOperation(label, undoContext, nodeToBeDeleted, editor, true);
128 129
        }else{
129
            operation =  new DeleteNodeOperation(label, undoContext, nodeToBeDeleted, editorPage, false);
130
            operation =  new DeleteNodeOperation(label, undoContext, nodeToBeDeleted, editor, false);
130 131
        }
131 132

  
132 133
        return operation;
......
145 146
    }
146 147

  
147 148
    @CanExecute
148
    public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)Object selection,
149
    public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
149 150
            MHandledMenuItem menuItem){
150 151
        boolean canExecute = false;
151
        canExecute = selection instanceof PolytomousKeyNode;
152
        canExecute = selection!=null && !selection.isEmpty();
152 153
        menuItem.setVisible(canExecute);
153 154
        return canExecute;
154 155
    }
155 156

  
156
}
157
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/e4/handler/InsertNewNodeHandlerE4.java
25 25
import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyEditorLabels;
26 26
import eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyListEditorE4;
27 27
import eu.etaxonomy.taxeditor.editor.key.polytomous.operation.InsertPolytomousKeyNodeOperation;
28
import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4;
28 29

  
29 30
/**
30 31
 * @author k.luther
31 32
 * @date 17.11.2016
32 33
 *
33 34
 */
34
public class InsertNewNodeHandlerE4 extends AbstractPolytomousKeyNodeHandlerE4{
35
public class InsertNewNodeHandlerE4 extends RemotingCdmHandlerE4{
35 36

  
36 37
    private PolytomousKeyNode parentNode ;
37 38

  
......
69 70
            @Named(IServiceConstants.ACTIVE_SHELL)Shell shell,
70 71
            @Named(IServiceConstants.ACTIVE_PART)MPart activePart,
71 72
            MHandledMenuItem menuItem) {
72
        return new InsertPolytomousKeyNodeOperation(getTrigger(), false, parentNode, editorPage);
73
        PolytomousKeyListEditorE4 editor = (PolytomousKeyListEditorE4) activePart.getObject();
74
        return new InsertPolytomousKeyNodeOperation(getTrigger(), false, parentNode, editor);
73 75
    }
74 76

  
75 77
    @Override
......
77 79
    }
78 80

  
79 81
    @CanExecute
80
    public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)Object selection,
82
    public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
81 83
            MHandledMenuItem menuItem){
82 84
        boolean canExecute = false;
83
        canExecute = selection instanceof PolytomousKeyNode;
85
        canExecute = selection!=null && !selection.isEmpty();
84 86
        menuItem.setVisible(canExecute);
85 87
        return canExecute;
86 88
    }
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/e4/handler/OpenPolytomousGraphEditorHandler.java
1

  
2
package eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler;
3

  
4
import javax.inject.Named;
5

  
6
import org.eclipse.e4.core.di.annotations.Execute;
7
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
8
import org.eclipse.e4.ui.services.IServiceConstants;
9
import org.eclipse.e4.ui.workbench.modeling.EPartService;
10
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
11

  
12
import eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyGraphEditorE4;
13
import eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyListEditorE4;
14

  
15
public class OpenPolytomousGraphEditorHandler {
16

  
17
	@Execute
18
	public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart, EPartService partService) {
19
		MPart part = partService.createPart("eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyGraphEditorE4");
20
		part = partService.showPart(part, PartState.ACTIVATE);
21
		PolytomousKeyGraphEditorE4 graphEditor = (PolytomousKeyGraphEditorE4) part.getObject();
22
		PolytomousKeyListEditorE4 listEditor = (PolytomousKeyListEditorE4) activePart.getObject();
23
		graphEditor.init(listEditor.getEditorInput());
24
	}
25

  
26
}
eu.etaxonomy.taxeditor.navigation/fragment.e4xmi
58 58
      <handlers xmi:id="_tvg9wKQVEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.key.polytomous.e4.handler.RemotingEditPolytomousKeyNodesHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.key.polytomous.e4.handler.RemotingEditPolytomousKeyNodesHandlerE4" command="_BrgnkKQVEeeTrq_CRrR-jg"/>
59 59
      <handlers xmi:id="_xhc-UKQVEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.key.polytomous.e4.handler.RemotingUpdatePolytomousKeyAllNodesHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.key.polytomous.e4.handler.RemotingUpdatePolytomousKeyAllNodesHandlerE4" command="_6S6M4KQVEeeTrq_CRrR-jg"/>
60 60
      <handlers xmi:id="_CoKnoKQWEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.key.polytomous.e4.handler.RefreshPolytomousKeyListHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.key.polytomous.e4.handler.RefreshPolytomousKeyListHandlerE4" command="_4BQ6YKQVEeeTrq_CRrR-jg"/>
61
      <handlers xmi:id="_GjyIoKQWEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.key.polytomous.handler.RemotingDeletePolytomousKeyHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.key.polytomous.handler.RemotingDeletePolytomousKeyHandler" command="_8C8AEKQVEeeTrq_CRrR-jg"/>
61
      <handlers xmi:id="_GjyIoKQWEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.key.polytomous.e4.handler.RemotingDeletePolytomousKeyHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.key.polytomous.e4.handler.RemotingDeletePolytomousKeyHandlerE4" command="_8C8AEKQVEeeTrq_CRrR-jg"/>
62 62
      <menus xsi:type="menu:PopupMenu" xmi:id="_FajhpKQUEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.popupmenu.polytomouskeyview">
63 63
        <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_FajhpaQUEeeTrq_CRrR-jg" coreExpressionId="isCdmStoreConnected"/>
64 64
        <children xsi:type="menu:HandledMenuItem" xmi:id="_FajhpqQUEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.polytomouskey.new" label="%command.label.15" command="_lAZG8KQUEeeTrq_CRrR-jg"/>
65 65
        <children xsi:type="menu:DynamicMenuContribution" xmi:id="_ot9k4KQUEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.polytomouskey.dynamicmenucontribution.cdmViewer" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.view.CdmViewerContextMenuE4"/>
66
        <children xsi:type="menu:HandledMenuItem" xmi:id="_Fajhp6QUEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.polytomouskey.edit" label="%command.label.16">
67
          <command href="../eu.etaxonomy.taxeditor.editor/fragment.e4xmi#_uM4zsKO8EeeWePK798pdTw"/>
68
        </children>
66
        <children xsi:type="menu:HandledMenuItem" xmi:id="_Fajhp6QUEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.polytomouskey.edit" label="%command.label.16" command="_BrgnkKQVEeeTrq_CRrR-jg"/>
69 67
        <children xsi:type="menu:Menu" xmi:id="_IKePEKQVEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.menu.polytomouskey.refresh" label="%menu.label.0">
70 68
          <children xsi:type="menu:HandledMenuItem" xmi:id="_JS0-QKQVEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.polytomouskey.refreshlist" label="%command.label.17" command="_4BQ6YKQVEeeTrq_CRrR-jg"/>
71 69
          <children xsi:type="menu:HandledMenuItem" xmi:id="_JsJdMKQVEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.polytomouskey.refreshnodes" label="%command.label.18" command="_6S6M4KQVEeeTrq_CRrR-jg"/>
72 70
        </children>
73 71
        <children xsi:type="menu:MenuSeparator" xmi:id="_FajhqKQUEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.18"/>
74
        <children xsi:type="menu:HandledMenuItem" xmi:id="_FajhqaQUEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.polytomouskey.refresh" label="%command.label.19">
75
          <command href="../eu.etaxonomy.taxeditor.editor/fragment.e4xmi#_zN-H8KO8EeeWePK798pdTw"/>
76
        </children>
72
        <children xsi:type="menu:HandledMenuItem" xmi:id="_FajhqaQUEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.polytomouskey.refresh" label="%command.label.19" command="_8C8AEKQVEeeTrq_CRrR-jg"/>
77 73
      </menus>
78 74
    </elements>
79 75
  </fragments>
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/e4/handler/RemotingEditPolytomousKeyNodesHandlerE4.java
14 14
import org.eclipse.core.runtime.IStatus;
15 15
import org.eclipse.core.runtime.Status;
16 16
import org.eclipse.core.runtime.jobs.Job;
17
import org.eclipse.e4.core.di.annotations.CanExecute;
17 18
import org.eclipse.e4.core.di.annotations.Execute;
18 19
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
20
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
19 21
import org.eclipse.e4.ui.services.IServiceConstants;
20 22
import org.eclipse.e4.ui.workbench.modeling.EPartService;
21 23
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
24
import org.eclipse.jface.viewers.IStructuredSelection;
22 25
import org.eclipse.jface.viewers.StructuredSelection;
23 26
import org.eclipse.swt.widgets.Display;
24 27

  
......
90 93
        }
91 94
    }
92 95

  
96
    @CanExecute
97
    public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)Object selection,
98
            MHandledMenuItem menuItem){
99
        boolean canExecute = false;
100
        canExecute = ((IStructuredSelection)selection).getFirstElement() instanceof PolytomousKey;
101
        menuItem.setVisible(canExecute);
102
        return canExecute;
103
    }
104

  
93 105
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)