Project

General

Profile

Revision 95d1ab8c

ID95d1ab8c1ba437a8825547f23b41d65edcae272f
Parent 27a1e008
Child 259ce092

Added by Patrick Plitzner over 3 years ago

ref #6909 migrate taxon navigator context menu

View differences:

eu.etaxonomy.taxeditor.navigation/META-INF/MANIFEST.MF
22 22
 eu.etaxonomy.taxeditor.editor,
23 23
 org.eclipse.e4.ui.model.workbench;bundle-version="1.2.0.v20160229-1459",
24 24
 org.eclipse.e4.ui.di,
25
 javax.inject
25
 javax.inject,
26
 org.eclipse.e4.ui.services,
27
 org.eclipse.e4.ui.workbench
26 28
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
27 29
Import-Package: org.eclipse.core.resources,
28 30
 org.eclipse.core.runtime,
eu.etaxonomy.taxeditor.navigation/fragment.e4xmi
1 1
<?xml version="1.0" encoding="ASCII"?>
2
<fragment:ModelFragments xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/descriptor/basic" xmlns:fragment="http://www.eclipse.org/ui/2010/UIModel/fragment" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmlns:ui="http://www.eclipse.org/ui/2010/UIModel/application/ui" xmi:id="_OhwnQCTfEeeiN5lBIuqN3g">
2
<fragment:ModelFragments xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/descriptor/basic" xmlns:commands="http://www.eclipse.org/ui/2010/UIModel/application/commands" xmlns:fragment="http://www.eclipse.org/ui/2010/UIModel/fragment" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmlns:ui="http://www.eclipse.org/ui/2010/UIModel/application/ui" xmi:id="_OhwnQCTfEeeiN5lBIuqN3g">
3 3
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_oDvMsCTfEeeiN5lBIuqN3g" featurename="children" parentElementId="eu.etaxonomy.taxeditor.workbench.trimcontribution.mainToolbar">
4 4
    <elements xsi:type="menu:ToolControl" xmi:id="_7kZI4CTfEeeiN5lBIuqN3g" elementId="eu.etaxonomy.taxeditor.navigation.toolcontrol.search_bar" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.search.SearchBar"/>
5 5
  </fragments>
6 6
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_Z-4rwJIVEeeJAdt8ZUxyaw" featurename="descriptors" parentElementId="org.eclipse.e4.legacy.ide.application">
7
    <elements xsi:type="basic:PartDescriptor" xmi:id="_gH5RYJIVEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator" label="%view.name.2" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.navigation/icons/edit_16x16.gif" closeable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4"/>
7
    <elements xsi:type="basic:PartDescriptor" xmi:id="_gH5RYJIVEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator" label="%view.name.2" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.navigation/icons/edit_16x16.gif" closeable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4">
8
      <handlers xmi:id="_Ic-1EJIyEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.MoveTaxonHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.MoveTaxonHandlerE4" command="_w4RNkJIxEeeJAdt8ZUxyaw"/>
9
      <handlers xmi:id="_xeEM0JIyEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.RefreshTreeHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.RefreshTreeHandlerE4" command="_ukhM0JIyEeeJAdt8ZUxyaw"/>
10
      <handlers xmi:id="_0d3l0JIyEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.CopyHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.CopyHandlerE4" command="_EJ-u0JIyEeeJAdt8ZUxyaw"/>
11
      <handlers xmi:id="_3I_vUJIyEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.ChangeAcceptedTaxonToSynonymHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.ChangeAcceptedTaxonToSynonymHandlerE4" command="_p7Oi8JIxEeeJAdt8ZUxyaw"/>
12
      <handlers xmi:id="_6l8-YJIyEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.SetSecReferenceForSubtreeHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.SetSecReferenceForSubtreeHandlerE4" command="_uFj1YJIxEeeJAdt8ZUxyaw"/>
13
      <handlers xmi:id="_-QYowJIyEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.NewClassificationHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.NewClassificationHandlerE4" command="_Vco-4JIxEeeJAdt8ZUxyaw"/>
14
      <handlers xmi:id="_Bc8EUJIzEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.NewTaxonNodeHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.NewTaxonNodeHandlerE4" command="_Nx06MJIvEeeJAdt8ZUxyaw"/>
15
      <handlers xmi:id="_GTyegJIzEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.MoveFactualDataHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.MoveFactualDataHandlerE4" command="_3PRy8JIxEeeJAdt8ZUxyaw"/>
16
      <handlers xmi:id="_JPKqgJIzEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.CreateClassificationHierarchyHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.CreateClassificationHierarchyHandlerE4" command="_jXX0YJIxEeeJAdt8ZUxyaw"/>
17
      <handlers xmi:id="_M64uUJIzEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.DeleteHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.DeleteHandlerE4" command="__n644JIxEeeJAdt8ZUxyaw"/>
18
      <handlers xmi:id="_QQq-YJIzEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.CloneClassificationHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.CloneClassificationHandlerE4" command="_nOOxMJIxEeeJAdt8ZUxyaw"/>
19
      <menus xsi:type="menu:PopupMenu" xmi:id="_XNXnkJIvEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigator.popupmenu.taxonnavigator">
20
        <children xsi:type="menu:Menu" xmi:id="_yzFmYJIvEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.menu.new" label="%menu.label">
21
          <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_7FKxUJIvEeeJAdt8ZUxyaw" coreExpressionId="isCdmStoreConnected"/>
22
          <children xsi:type="menu:HandledMenuItem" xmi:id="_wzftMJIvEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.menu.new.taxon" label="%command.label.2" command="_Nx06MJIvEeeJAdt8ZUxyaw"/>
23
          <children xsi:type="menu:MenuSeparator" xmi:id="_33c4IJIvEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.menuseparator.0"/>
24
          <children xsi:type="menu:HandledMenuItem" xmi:id="_4dTXMJIvEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.menu.new.classification" label="%command.label.3" command="_Vco-4JIxEeeJAdt8ZUxyaw"/>
25
        </children>
26
        <children xsi:type="menu:HandledMenuItem" xmi:id="_9hdNkJIvEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.fixclassificationhierarchy" label="%command.label.fixClassificationHierarchy" command="_jXX0YJIxEeeJAdt8ZUxyaw"/>
27
        <children xsi:type="menu:HandledMenuItem" xmi:id="_ivOrwJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.cloneclassification" label="Clone Classification" command="_nOOxMJIxEeeJAdt8ZUxyaw"/>
28
        <children xsi:type="menu:MenuSeparator" xmi:id="_ktyqMJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.menuseparator.1"/>
29
        <children xsi:type="menu:HandledMenuItem" xmi:id="_lALasJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.accTaxonToSynonym" label="%command.label.6" command="_p7Oi8JIxEeeJAdt8ZUxyaw"/>
30
        <children xsi:type="menu:HandledMenuItem" xmi:id="_mLjosJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.setsecforsubtree" label="%command.label.setSecForSubtree" command="_uFj1YJIxEeeJAdt8ZUxyaw"/>
31
        <children xsi:type="menu:HandledMenuItem" xmi:id="_nh_3MJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.moveTaxon" label="%command.label.7" command="_w4RNkJIxEeeJAdt8ZUxyaw"/>
32
        <children xsi:type="menu:HandledMenuItem" xmi:id="_o1PAsJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.movefactualdata" label="%command.label.moveFactualData" command="_3PRy8JIxEeeJAdt8ZUxyaw"/>
33
        <children xsi:type="menu:MenuSeparator" xmi:id="_rBdnsJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.menuseparator.2"/>
34
        <children xsi:type="menu:HandledMenuItem" xmi:id="_rWZV4JIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.import" visible="false" label="%command.label.8"/>
35
        <children xsi:type="menu:HandledMenuItem" xmi:id="_wNp_wJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.export" visible="false" label="%command.label.9"/>
36
        <children xsi:type="menu:MenuSeparator" xmi:id="_x0uEMJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.menuseparator.3" visible="false"/>
37
        <children xsi:type="menu:HandledMenuItem" xmi:id="_yH9JQJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.delete" label="%command.label.10" command="__n644JIxEeeJAdt8ZUxyaw"/>
38
        <children xsi:type="menu:MenuSeparator" xmi:id="_z0Q6EJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.menuseparator.4"/>
39
        <children xsi:type="menu:HandledMenuItem" xmi:id="_0FX4MJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.refresh" label="%command.label.11" command="_ukhM0JIyEeeJAdt8ZUxyaw"/>
40
        <children xsi:type="menu:HandledMenuItem" xmi:id="_1JIbQJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.copy" label="%command.label.12" command="_EJ-u0JIyEeeJAdt8ZUxyaw"/>
41
        <children xsi:type="menu:MenuSeparator" xmi:id="_24NMMJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.menuseparator.5"/>
42
        <children xsi:type="menu:DynamicMenuContribution" xmi:id="_3d1BwJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.dynamicmenucontribution.openInCdmViewer" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.view.CdmViewerContextMenuE4"/>
43
      </menus>
44
    </elements>
8 45
  </fragments>
9 46
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_wITZ8JIVEeeJAdt8ZUxyaw" featurename="children" parentElementId="eu.etaxonomy.taxeditor.menu.showView" positionInList="">
10 47
    <elements xsi:type="menu:HandledMenuItem" xmi:id="_wITZ8ZIVEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigator.showViewMenu.navigator" label="%command.label" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.navigation/icons/edit_16x16.gif">
......
13 50
      <parameters xmi:id="_wITZ85IVEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.store.showView.parameter.detailsView" name="eu.etaxonomy.taxeditor.workbench.commandparameter.partName" value="eu.etaxonomy.taxeditor.navigation.navigator"/>
14 51
    </elements>
15 52
  </fragments>
53
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_MOKIAJIvEeeJAdt8ZUxyaw" featurename="commands" parentElementId="org.eclipse.e4.legacy.ide.application">
54
    <elements xsi:type="commands:Command" xmi:id="_Nx06MJIvEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.command.create.taxonNode" commandName="%command.name"/>
55
    <elements xsi:type="commands:Command" xmi:id="_Vco-4JIxEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.create.classification" commandName="%command.name.0"/>
56
    <elements xsi:type="commands:Command" xmi:id="_jXX0YJIxEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.handler.OpenFixClassificationHierarchyHandler" commandName="%command.name.10"/>
57
    <elements xsi:type="commands:Command" xmi:id="_nOOxMJIxEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.cloneClassification" commandName="Clone Classification"/>
58
    <elements xsi:type="commands:Command" xmi:id="_p7Oi8JIxEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigator.command.update.changeAcceptedToSynonym" commandName="%command.name.5"/>
59
    <elements xsi:type="commands:Command" xmi:id="_uFj1YJIxEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigator.command.update.setSecundumForSubtree" commandName="%command.name.setSecForSubtree"/>
60
    <elements xsi:type="commands:Command" xmi:id="_w4RNkJIxEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.command.update.moveTaxon" commandName="%command.name.2"/>
61
    <elements xsi:type="commands:Command" xmi:id="_3PRy8JIxEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.moveFactualData" commandName="%command.name.moveFactualData"/>
62
    <elements xsi:type="commands:Command" xmi:id="__n644JIxEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.command.delete" commandName="%command.name.11"/>
63
    <elements xsi:type="commands:Command" xmi:id="_EJ-u0JIyEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.command.copyTaxonName" commandName="%command.name.4"/>
64
    <elements xsi:type="commands:Command" xmi:id="_ukhM0JIyEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.command.refreshNavigator" commandName="Refresh Navigator"/>
65
  </fragments>
16 66
</fragment:ModelFragments>
eu.etaxonomy.taxeditor.navigation/plugin.xml
398 398
   <extension
399 399
         point="org.eclipse.ui.commands">
400 400
      <command
401
            defaultHandler="eu.etaxonomy.taxeditor.navigation.navigator.handler.MoveTaxonHandler"
402
            id="eu.etaxonomy.taxeditor.navigation.command.update.moveTaxon"
403
            name="%command.name.2">
404
      </command>
405
      <command
406
            defaultHandler="eu.etaxonomy.taxeditor.navigation.navigator.handler.RefreshTreeHandler"
407
            id="org.eclipse.ui.file.refresh"
408
            name="%command.name.3">
409
      </command>
410
      <command
411
            defaultHandler="eu.etaxonomy.taxeditor.navigation.navigator.handler.CopyHandler"
412
            id="eu.etaxonomy.taxeditor.navigation.command.copyTaxonName"
413
            name="%command.name.4">
414
      </command>
415
      <command
416
            defaultHandler="eu.etaxonomy.taxeditor.navigation.navigator.handler.ChangeAcceptedTaxonToSynonymHandler"
417
            id="eu.etaxonomy.taxeditor.navigator.command.update.changeAcceptedToSynonym"
418
            name="%command.name.5">
419
      </command>
420
       <command
421
            defaultHandler="eu.etaxonomy.taxeditor.navigation.navigator.handler.SetSecReferenceForSubtreeHandler"
422
            id="eu.etaxonomy.taxeditor.navigator.command.update.setSecundumForSubtree"
423
            name="%command.name.setSecForSubtree">
424
      </command>
425
      <command
426
            defaultHandler="eu.etaxonomy.taxeditor.navigation.navigator.handler.NewClassificationHandler"
427
            id="eu.etaxonomy.taxeditor.navigation.create.classification"
428
            name="%command.name.0">
429
      </command>
430
      <command
431
            defaultHandler="eu.etaxonomy.taxeditor.navigation.navigator.handler.NewTaxonNodeHandler"
432
            id="eu.etaxonomy.taxeditor.navigation.command.create.taxonNode"
433
            name="%command.name">
434
      </command>
435
      <command
436 401
            defaultHandler="eu.etaxonomy.taxeditor.navigation.key.polytomous.handler.NewPolytomousKeyHandler"
437 402
            id="eu.etaxonomy.taxeditor.navigation.key.polytomous.newKey"
438 403
            name="%command.name.6">
......
453 418
            name="%command.name.9">
454 419
      </command>
455 420
      <command
456
            defaultHandler="eu.etaxonomy.taxeditor.navigation.navigator.handler.MoveFactualDataHandler"
457
            id="eu.etaxonomy.taxeditor.navigation.moveFactualData"
458
            name="%command.name.moveFactualData">
459
      </command>
460
      <command
461
            defaultHandler="eu.etaxonomy.taxeditor.navigation.navigator.handler.CreateClassificationHierarchyHandler"
462
            id="eu.etaxonomy.taxeditor.navigation.navigator.handler.OpenFixClassificationHierarchyHandler"
463
            name="%command.name.10">
464
      </command>
465
      <command
466
            defaultHandler="eu.etaxonomy.taxeditor.navigation.navigator.handler.DeleteHandler"
467
            id="eu.etaxonomy.taxeditor.navigation.command.delete"
468
            name="%command.name.11">
469
      </command>
470
      <command
471 421
            defaultHandler="eu.etaxonomy.taxeditor.navigation.key.polytomous.handler.DeleteHandler"
472 422
            id="eu.etaxonomy.taxeditor.navigation.key.polytomous.command.delete"
473 423
            name="%command.name.11">
474 424
      </command>
475
      <command
476
            defaultHandler="eu.etaxonomy.taxeditor.navigation.navigator.handler.CloneClassificationHandler"
477
            id="eu.etaxonomy.taxeditor.navigation.cloneClassification"
478
            name="Clone Classification">
479
      </command>
480 425
   </extension>
481 426
   <extension
482 427
         point="org.eclipse.ui.handlers">
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/TaxonNavigatorE4.java
28 28
import org.eclipse.core.runtime.IAdaptable;
29 29
import org.eclipse.core.runtime.IProgressMonitor;
30 30
import org.eclipse.e4.ui.di.Focus;
31
import org.eclipse.e4.ui.services.EMenuService;
32
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
33
import org.eclipse.jface.viewers.ISelectionChangedListener;
31 34
import org.eclipse.jface.viewers.TreePath;
32 35
import org.eclipse.jface.viewers.TreeViewer;
33 36
import org.eclipse.swt.SWT;
......
49 52
import eu.etaxonomy.cdm.model.taxon.TaxonNodeByNameComparator;
50 53
import eu.etaxonomy.cdm.model.taxon.TaxonNodeByRankAndNameComparator;
51 54
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
55
import eu.etaxonomy.taxeditor.model.AbstractUtility;
52 56
import eu.etaxonomy.taxeditor.model.DataChangeBridge;
53 57
import eu.etaxonomy.taxeditor.model.IDataChangeBehavior;
54 58
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
......
94 98

  
95 99
	private TreeViewer viewer;
96 100

  
101
    @Inject
102
    private ESelectionService selService;
103

  
104
    private ISelectionChangedListener selectionChangedListener;
105

  
97 106
	@Inject
98 107
    public TaxonNavigatorE4() {
99 108
    }
100 109

  
101 110
	@PostConstruct
102
	private void create(Composite parent){
111
	private void create(Composite parent, EMenuService menuService){
103 112
	    FillLayout layout = new FillLayout();
104 113
	    layout.marginHeight = 0;
105 114
	    layout.marginWidth = 0;
......
109 118
	    viewer = new TreeViewer(parent);
110 119
	    viewer.getControl().setLayoutData(LayoutConstants.FILL());
111 120

  
121
	    viewer.setContentProvider(new TaxonNavigatorContentProviderE4());
122
        viewer.setLabelProvider(new TaxonNavigatorLabelProviderE4());
123
        viewer.setInput(getInitialInput());
124

  
125
        //propagate selection
126
        selectionChangedListener = (event -> selService.setSelection(AbstractUtility.getElementsFromSelectionChangedEvent(event)));
127
        viewer.addSelectionChangedListener(selectionChangedListener);
128

  
129
        //create context menu
130
        menuService.registerContextMenu(viewer.getControl(), "eu.etaxonomy.taxeditor.navigator.popupmenu.taxonnavigator");
131

  
112 132
	    init();
113 133
	}
114 134

  
......
150 170
		    CdmApplicationState.getCurrentDataChangeService().register(this);
151 171
		}
152 172
		CdmStore.getLoginManager().addObserver(this);
153

  
154
		viewer.setContentProvider(new TaxonNavigatorContentProviderE4());
155
		viewer.setLabelProvider(new TaxonNavigatorLabelProviderE4());
156
		viewer.setInput(getInitialInput());
157 173
	}
158 174

  
159 175
	/**
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/ChangeAcceptedTaxonToSynonymHandlerE4.java
1
/**
2
 *
3
 */
4
package eu.etaxonomy.taxeditor.navigation.navigator.e4.handler;
5

  
6
import java.util.ArrayList;
7
import java.util.HashSet;
8
import java.util.Iterator;
9
import java.util.List;
10
import java.util.Set;
11
import java.util.UUID;
12

  
13
import javax.inject.Named;
14

  
15
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
16
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
17
import org.eclipse.e4.ui.services.IServiceConstants;
18
import org.eclipse.jface.dialogs.MessageDialog;
19
import org.eclipse.jface.viewers.TreeSelection;
20
import org.eclipse.swt.widgets.Shell;
21

  
22
import eu.etaxonomy.cdm.model.common.CdmBase;
23
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
24
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
25
import eu.etaxonomy.taxeditor.model.AbstractUtility;
26
import eu.etaxonomy.taxeditor.model.MessagingUtils;
27
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
28
import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
29
import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4;
30
import eu.etaxonomy.taxeditor.navigation.navigator.operation.ChangeAcceptedTaxonToSynonymOperation;
31
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
32
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
33
import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
34

  
35
/**
36
 *
37
 * @author pplitzner
38
 * @date 05.09.2017
39
 *
40
 */
41
public class ChangeAcceptedTaxonToSynonymHandlerE4 extends DeleteHandlerE4 implements IPostOperationEnabled {
42

  
43
	private UUID newAcceptedTaxonNodeUuid;
44

  
45
    @Override
46
    public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection,
47
            @Named(IServiceConstants.ACTIVE_SHELL)Shell shell,
48
            @Named(IServiceConstants.ACTIVE_PART)MPart activePart,
49
            MHandledMenuItem menuItem) {
50

  
51
        TaxonNavigatorE4 taxonNavigator = (TaxonNavigatorE4) activePart.getObject();
52

  
53
		Iterator selectionIterator = selection.iterator();
54
		Set<ITaxonTreeNode> treeNodes = new HashSet<ITaxonTreeNode>();
55

  
56
		while (selectionIterator.hasNext()){
57
			Object object = selectionIterator.next();
58
			if(object instanceof ITaxonTreeNode) {
59
                treeNodes.add((ITaxonTreeNode) object);
60
            }
61
		}
62
		boolean allEditorsClosed = true;
63
		for (ITaxonTreeNode treeNode : treeNodes){
64
			if(treeNode instanceof TaxonNode) {
65
				allEditorsClosed &= closeObsoleteEditor((TaxonNode) treeNode);
66
			}
67
		}
68
		AbstractPostOperation operation = null;
69
		if (treeNodes.size() == 1 ){
70
			ITaxonTreeNode treeNode = treeNodes.iterator().next();
71
            ITaxonTreeNode oldAcceptedTaxonNode =treeNode;
72

  
73
            // check if taxon has no children
74
            if(((TaxonNode)oldAcceptedTaxonNode).getCountChildren() > 0) {
75
            	MessagingUtils.warningDialog(Messages.ChangeAcceptedTaxonToSynonymHandler_PREREQUISITE, this,
76
            			Messages.ChangeAcceptedTaxonToSynonymHandler_PREREQUISITE_MESSAGE);
77
            	return;
78
            }
79
            /*if(((TaxonNode)oldAcceptedTaxonNode).getTaxon().hasSynonyms()) {
80
            	EditorUtil.warningDialog("Prerequisite not met", this,
81
            			"The accepted taxon must not have any synonyms. You need to move all synonyms to " +
82
            			"another taxon before attempting to turn the accepted " +
83
            			"taxon into a synonym.");
84
            	return null;
85
            }*/
86

  
87
            List<UUID> excludeTaxa = new ArrayList<UUID>();
88
            excludeTaxa.add(((TaxonNode)oldAcceptedTaxonNode).getTaxon().getUuid());
89
            TaxonNode newAcceptedTaxonNode = TaxonNodeSelectionDialog.select(shell,
90
            		taxonNavigator.getConversationHolder(),
91
            		Messages.ChangeAcceptedTaxonToSynonymHandler_CHOOSE_TAXON,
92
            		excludeTaxa,
93
            		null,
94
            		((TaxonNode)oldAcceptedTaxonNode).getClassification());
95

  
96
            if (newAcceptedTaxonNode == null) {
97
            	return;
98
            }
99

  
100
            if (allEditorsClosed){
101

  
102
            		operation = new ChangeAcceptedTaxonToSynonymOperation(menuItem.getLocalizedLabel(),
103
            		        NavigationUtil.getUndoContext(),
104
            		        oldAcceptedTaxonNode,
105
            		        newAcceptedTaxonNode,
106
            				taxonNavigator,
107
            				taxonNavigator,
108
            				taxonNavigator);
109

  
110
            		AbstractUtility.executeOperation(operation);
111
            }
112
		} else{
113
			if( MessageDialog.openConfirm(shell, Messages.ChangeAcceptedTaxonToSynonymHandler_MOVE_SYNONYMY, Messages.ChangeAcceptedTaxonToSynonymHandler_MOVE_SYNONYMY_MESSAGE)){
114
				return;
115
			}
116
		}
117
	}
118

  
119
	/** {@inheritDoc} */
120
	@Override
121
    public boolean postOperation(CdmBase objectAffectedByOperation) {
122
	    //FIXME E4 migrate
123
//		Display.getDefault().asyncExec(new Runnable(){
124
//
125
//			@Override
126
//            public void run() {
127
//				EditorUtil.close(editor.getMultiPageTaxonEditor());
128
//
129
//				try {
130
//					MultiPageTaxonEditor possibleOpenEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(newAcceptedTaxonNodeUuid);
131
//					if(possibleOpenEditor != null){
132
//						EditorUtil.close(possibleOpenEditor);
133
//					}
134
//					EditorUtil.openTaxonNodeE4(newAcceptedTaxonNodeUuid);
135
//				} catch (PartInitException e) {
136
//					MessagingUtils.error(this.getClass(), e);
137
//					throw new RuntimeException(e);
138
//				} catch (Exception e) {
139
//					MessagingUtils.warningDialog(Messages.ChangeAcceptedTaxonToSynonymHandler_CREATE_FAILED, this, e.getMessage());
140
//				}
141
//			}
142
//
143
//		});
144
		return true;
145
	}
146

  
147
	@Override
148
    public boolean onComplete() {
149
		return false;
150
	}
151
}
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/CloneClassificationHandlerE4.java
1
package eu.etaxonomy.taxeditor.navigation.navigator.e4.handler;
2

  
3
import javax.inject.Named;
4

  
5
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
6
import org.eclipse.e4.ui.services.IServiceConstants;
7
import org.eclipse.jface.viewers.TreeSelection;
8
import org.eclipse.jface.wizard.WizardDialog;
9
import org.eclipse.swt.widgets.Shell;
10

  
11
import eu.etaxonomy.cdm.model.reference.Reference;
12
import eu.etaxonomy.cdm.model.taxon.Classification;
13
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
14
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
15
import eu.etaxonomy.taxeditor.model.AbstractUtility;
16
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
17
import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
18
import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4;
19
import eu.etaxonomy.taxeditor.navigation.operation.CloneClassificationOperation;
20
import eu.etaxonomy.taxeditor.store.StoreUtil;
21
import eu.etaxonomy.taxeditor.ui.section.classification.CloneClassificationWizard;
22

  
23
/**
24
 *
25
 * @author pplitzner
26
 * @date 05.09.2017
27
 *
28
 */
29
public class CloneClassificationHandlerE4 {
30

  
31
    public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection,
32
            @Named(IServiceConstants.ACTIVE_SHELL)Shell shell,
33
            @Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
34

  
35
        TaxonNavigatorE4 taxonNavigator = (TaxonNavigatorE4) activePart.getObject();
36

  
37
        Object selectedElement = selection.getFirstElement();
38
        if (selectedElement instanceof TaxonNode && !((TaxonNode)selectedElement).hasTaxon()) {
39
            Classification classification = ((TaxonNode)selectedElement).getClassification();
40
            CloneClassificationWizard wizard = new CloneClassificationWizard(classification);
41
            WizardDialog dialog = new WizardDialog(shell, wizard);
42
            dialog.open();
43

  
44
            String classificationName = wizard.getClassificationName();
45
            TaxonRelationshipType relationType = wizard.getRelationType();
46
            Reference reference = wizard.getReference();
47

  
48
            CloneClassificationOperation operation = new CloneClassificationOperation(Messages.CloneClassificationHandler_CLONE_CLASSIFICATION,
49
                    StoreUtil.getUndoContext(), classification, classificationName, reference, relationType,
50
                    NavigationUtil.getNavigator(false), NavigationUtil.getNavigator(false));
51

  
52
            AbstractUtility.executeOperation(operation);
53
            taxonNavigator.refresh();
54
        }
55
    }
56

  
57
}
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/CopyHandlerE4.java
1
/**
2
* Copyright (C) 2009 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.navigation.navigator.e4.handler;
10

  
11
import javax.inject.Named;
12

  
13
import org.eclipse.core.runtime.IStatus;
14
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
15
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
16
import org.eclipse.e4.ui.services.IServiceConstants;
17
import org.eclipse.jface.viewers.TreeSelection;
18

  
19
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
20
import eu.etaxonomy.taxeditor.model.AbstractUtility;
21
import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4;
22
import eu.etaxonomy.taxeditor.navigation.navigator.operation.CopyOperation;
23
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
24
import eu.etaxonomy.taxeditor.store.StoreUtil;
25

  
26
/**
27
 *
28
 * @author pplitzner
29
 * @date 05.09.2017
30
 *
31
 */
32
public class CopyHandlerE4 {
33

  
34
    public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection,
35
            @Named(IServiceConstants.ACTIVE_PART)MPart activePart,
36
            MHandledMenuItem menuItem) {
37

  
38
        TaxonNavigatorE4 taxonNavigator = (TaxonNavigatorE4) activePart.getObject();
39

  
40
		if(selection.size() == 1) {
41
			Object selectedObject = selection.getFirstElement();
42
			if (selectedObject instanceof TaxonNode) {
43
				AbstractPostOperation operation = new CopyOperation(menuItem.getLocalizedLabel(), StoreUtil.getUndoContext(),
44
                (TaxonNode)selectedObject, taxonNavigator);
45
                IStatus status = AbstractUtility.executeOperation(operation);
46
			}
47
		}
48
	}
49

  
50
}
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/CreateClassificationHierarchyHandlerE4.java
1
package eu.etaxonomy.taxeditor.navigation.navigator.e4.handler;
2

  
3
import javax.inject.Named;
4

  
5
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
6
import org.eclipse.e4.ui.services.IServiceConstants;
7
import org.eclipse.jface.viewers.TreeSelection;
8

  
9
import eu.etaxonomy.cdm.model.taxon.Classification;
10
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
11
import eu.etaxonomy.taxeditor.model.AbstractUtility;
12
import eu.etaxonomy.taxeditor.model.MessagingUtils;
13
import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
14
import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4;
15
import eu.etaxonomy.taxeditor.navigation.operation.CreateNewTaxonHierarchyOperation;
16
import eu.etaxonomy.taxeditor.store.StoreUtil;
17

  
18
/**
19
 *
20
 * @author pplitzner
21
 * @date 05.09.2017
22
 *
23
 */
24
public class CreateClassificationHierarchyHandlerE4 {
25

  
26
    public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection,
27
            @Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
28

  
29
        TaxonNavigatorE4 taxonNavigator = (TaxonNavigatorE4) activePart.getObject();
30

  
31
            Object selectedElement = selection.getFirstElement();
32
            if (selectedElement instanceof TaxonNode && !((TaxonNode)selectedElement).hasTaxon()) {
33
                Classification classification = ((TaxonNode) selectedElement).getClassification();
34
                try {
35
                    CreateNewTaxonHierarchyOperation operation = new CreateNewTaxonHierarchyOperation(Messages.CreateClassificationHierarchyHandler_CREATE_HIERARCHY, StoreUtil.getUndoContext(),classification, taxonNavigator, taxonNavigator);
36
                    AbstractUtility.executeOperation(operation);
37
                    taxonNavigator.refresh();
38
                } catch (Exception e) {
39
                    MessagingUtils.messageDialog(Messages.CreateClassificationHierarchyHandler_FAILED, CreateClassificationHierarchyHandlerE4.class,
40
                            Messages.CreateClassificationHierarchyHandler_FAILED_MESSAGE, e);
41
                }
42
            }
43
    }
44
}
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/DeleteHandlerE4.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.navigation.navigator.e4.handler;
11

  
12
import java.util.HashSet;
13
import java.util.Iterator;
14
import java.util.Set;
15

  
16
import javax.inject.Named;
17

  
18
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
19
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
20
import org.eclipse.e4.ui.services.IServiceConstants;
21
import org.eclipse.jface.dialogs.MessageDialog;
22
import org.eclipse.jface.viewers.TreeSelection;
23
import org.eclipse.swt.widgets.Shell;
24

  
25
import eu.etaxonomy.cdm.api.service.config.NodeDeletionConfigurator.ChildHandling;
26
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
27
import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator;
28
import eu.etaxonomy.cdm.model.taxon.Classification;
29
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
30
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
31
import eu.etaxonomy.taxeditor.model.AbstractUtility;
32
import eu.etaxonomy.taxeditor.model.MessagingUtils;
33
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
34
import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
35
import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4;
36
import eu.etaxonomy.taxeditor.navigation.navigator.operation.DeleteOperation;
37
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
38
import eu.etaxonomy.taxeditor.ui.dialog.configurator.deleteConfigurator.DeleteConfiguratorDialog;
39

  
40
/**
41
 *
42
 * @author pplitzner
43
 * @date 05.09.2017
44
 *
45
 */
46
public class DeleteHandlerE4 {
47

  
48
    protected static final String SKIP = Messages.DeleteHandler_SKIP;
49
    protected static final String MOVE_CHILDREN_TO_PARENT_NODE = Messages.DeleteHandler_MOVE_TO_PARENT;
50
    protected static final String DELETE_ALL_CHILDREN = Messages.DeleteHandler_DELETE_ALL;
51
    protected static final String THERE_ARE_CHILDNODES_WHICH_WILL_BE_DELETED_TOO = Messages.DeleteHandler_THERE_ARE_CHILDNODES;
52
    protected static final String THE_TREE_HAS_CHILDREN_THEY_WILL_BE_DELETED_TOO = Messages.DeleteHandler_THERE_ARE_CHILDREN;
53
    protected static final String DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S = Messages.DeleteHandler_DELETE_NODE;
54
    protected static final String DO_YOU_REALLY_WANT_TO_DELETE_THE_CLASSIFICATION = Messages.DeleteHandler_DELETE_CLASSIFICATION;
55
    protected static final String CONFIRM_DELETION = Messages.DeleteHandler_CONFIRM_DELETE;
56

  
57
    public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection,
58
            @Named(IServiceConstants.ACTIVE_SHELL)Shell shell,
59
            @Named(IServiceConstants.ACTIVE_PART)MPart activePart,
60
            MHandledMenuItem menuItem) {
61

  
62
        TaxonNavigatorE4 taxonNavigator = (TaxonNavigatorE4) activePart.getObject();
63

  
64
		Iterator selectionIterator = selection.iterator();
65
		Set<ITaxonTreeNode> treeNodes = new HashSet<ITaxonTreeNode>();
66

  
67
		while (selectionIterator.hasNext()){
68
			Object object = selectionIterator.next();
69
			if(object instanceof ITaxonTreeNode) {
70
                treeNodes.add((ITaxonTreeNode) object);
71
            }
72
		}
73
		boolean allEditorsClosed = true;
74
		for (ITaxonTreeNode treeNode : treeNodes){
75
			if(treeNode instanceof TaxonNode) {
76
				allEditorsClosed &= closeObsoleteEditor((TaxonNode) treeNode);
77
			}
78
		}
79
		AbstractPostOperation operation = null;
80
		TaxonDeletionConfigurator config = new TaxonDeletionConfigurator();
81
		config.setDeleteInAllClassifications(false);
82

  
83
		if (treeNodes.size() == 1 ){
84
			try {
85

  
86
				ITaxonTreeNode treeNode = treeNodes.iterator().next();
87
				ITaxonTreeNode taxonNode =treeNode;
88
				TaxonNodeDeletionConfigurator configNodes = new TaxonNodeDeletionConfigurator();
89

  
90
				//configNodes.setDeleteTaxon(false);
91
				if (taxonNode instanceof Classification && taxonNode.hasChildNodes()){
92
					if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(config, shell, CONFIRM_DELETION, DO_YOU_REALLY_WANT_TO_DELETE_THE_CLASSIFICATION+THE_TREE_HAS_CHILDREN_THEY_WILL_BE_DELETED_TOO)){
93
						return;
94
					}
95
				} else if (taxonNode instanceof Classification && !taxonNode.hasChildNodes()){
96
					if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(config, shell, CONFIRM_DELETION, DO_YOU_REALLY_WANT_TO_DELETE_THE_CLASSIFICATION)){
97
						return;
98
					}
99
				} else {
100

  
101
					if (taxonNode.hasChildNodes()){
102
                        DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(
103
                                config,
104
                                shell,
105
                                CONFIRM_DELETION,
106
                                null,
107
                                DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S+THERE_ARE_CHILDNODES_WHICH_WILL_BE_DELETED_TOO,
108
                                MessageDialog.WARNING, new String[] { DELETE_ALL_CHILDREN,
109
                                        MOVE_CHILDREN_TO_PARENT_NODE, SKIP }, 0);
110
						int dialog_result = dialog.open();
111

  
112
						if (dialog_result == 0){
113
							//delete all children
114
							configNodes.setChildHandling(ChildHandling.DELETE);
115
							config.setTaxonNodeConfig(configNodes);
116
						} else if (dialog_result == 1){
117
							//move children
118
							configNodes.setChildHandling(ChildHandling.MOVE_TO_PARENT);
119
							config.setTaxonNodeConfig(configNodes);
120
						} else if (dialog_result == 2){
121
							//skip
122
							return;
123

  
124
						}
125
					}else{
126
						if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(configNodes, shell, CONFIRM_DELETION, DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S)){
127
							return;
128
						}
129
						config.setTaxonNodeConfig(configNodes);
130
					}
131
				}
132

  
133
				if (allEditorsClosed){
134
					/*if(! MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the selected nodes?")){
135
						return null;
136
					}*/
137

  
138
						operation = new DeleteOperation(menuItem.getLocalizedLabel(),
139
						        NavigationUtil.getUndoContext(),
140
								taxonNode,
141
								config,
142
								taxonNavigator,
143
								taxonNavigator,
144
								taxonNavigator);
145

  
146
						AbstractUtility.executeOperation(operation);
147

  
148
						//}
149
				}
150

  
151

  
152

  
153
			} catch (Exception e){
154
			    MessagingUtils.error(getClass(), e);
155
			}
156
		} else{
157
			try{
158
				if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(config, shell, CONFIRM_DELETION, DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S)){
159
					return;
160
				}
161
				if (allEditorsClosed){
162

  
163
					operation = new DeleteOperation(menuItem.getLocalizedLabel(),
164
					        NavigationUtil.getUndoContext(),
165
							treeNodes,
166
							new TaxonDeletionConfigurator(),
167
							taxonNavigator,
168
							taxonNavigator,
169
							taxonNavigator);
170

  
171
					AbstractUtility.executeOperation(operation);
172

  
173
				}
174
			}catch (Exception e){
175
                MessagingUtils.error(getClass(), e);
176
            }
177
		}
178
		return;
179
	}
180

  
181
	protected boolean closeObsoleteEditor(TaxonNode taxonNode){
182
	    //FIXME E4 migrate
183
		boolean result = true;
184
//		for (IEditorReference ref : activePage.getEditorReferences()) {
185
//			try {
186
//				String treeIndex = ((ITreeNode)taxonNode).treeIndex();
187
//
188
//
189
//				IEditorInput input = ref.getEditorInput();
190
//				if (input instanceof TaxonEditorInput) {
191
//					TaxonNode node = ((TaxonEditorInput) input).getTaxonNode();
192
//					//if node is a child of taxonNode then close the editor
193
//					if( ((ITreeNode) node).treeIndex().startsWith(treeIndex)){
194
//					//if (taxonNode.equals(node)) {
195
//						result &= activePage.closeEditor(ref.getEditor(false), true);
196
//
197
//					}
198
//				}
199
//			} catch (PartInitException e) {
200
//				continue;
201
//			}
202
//		}
203
		return result;
204
	}
205
}
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/MoveFactualDataHandlerE4.java
1
package eu.etaxonomy.taxeditor.navigation.navigator.e4.handler;
2

  
3
import java.util.ArrayList;
4
import java.util.List;
5
import java.util.UUID;
6

  
7
import javax.inject.Named;
8

  
9
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
10
import org.eclipse.e4.ui.services.IServiceConstants;
11
import org.eclipse.jface.dialogs.MessageDialog;
12
import org.eclipse.jface.viewers.TreeSelection;
13
import org.eclipse.swt.widgets.Display;
14
import org.eclipse.swt.widgets.Shell;
15

  
16
import eu.etaxonomy.cdm.api.service.IDescriptionService;
17
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
18
import eu.etaxonomy.cdm.api.service.ITaxonService;
19
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
20
import eu.etaxonomy.cdm.model.taxon.Taxon;
21
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
22
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
23
import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
24
import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4;
25
import eu.etaxonomy.taxeditor.store.CdmStore;
26
import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
27

  
28
public class MoveFactualDataHandlerE4 {
29

  
30
    public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection,
31
            @Named(IServiceConstants.ACTIVE_SHELL)Shell shell,
32
            @Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
33

  
34
        TaxonNavigatorE4 taxonNavigator = (TaxonNavigatorE4) activePart.getObject();
35

  
36
        if(taxonNavigator!=null){
37
            Object object = selection.getFirstElement();
38
            if(object instanceof TaxonNode){
39
                TaxonNode taxonNode = HibernateProxyHelper.deproxy(object, TaxonNode.class);
40
                final TaxonNode sourceTaxonNode = CdmStore.getService(ITaxonNodeService.class).load(taxonNode.getUuid());
41
                if(NavigationUtil.isDirty(sourceTaxonNode)){
42
                    MessageDialog.openWarning(shell, Messages.MoveFactualDataHandler_UNSAVED_SOURCE, Messages.MoveFactualDataHandler_UNSAVED_SOURCE_MESSAGE);
43
                    return;
44
                }
45
                //reload to avoid session conflicts
46
                Taxon taxon = HibernateProxyHelper.deproxy(CdmStore.getService(ITaxonService.class).load(sourceTaxonNode.getTaxon().getUuid()), Taxon.class);
47
                if(taxon!=null){
48
                 // Choose the target taxon
49
                    List<UUID> excludeTaxa = new ArrayList<UUID>();
50
                    excludeTaxa.add(taxon.getUuid());
51
                    TaxonNode dialogTaxonNode = TaxonNodeSelectionDialog.select(shell,
52
                            taxonNavigator.getConversationHolder(),
53
                            Messages.MoveFactualDataHandler_CHOOSE_TAXON,
54
                            excludeTaxa,
55
                            sourceTaxonNode,
56
                            sourceTaxonNode.getClassification());
57
                    if (dialogTaxonNode == null) {
58
                        return;
59
                    }
60
                    //reload to avoid session conflicts
61
                    final TaxonNode targetTaxonNode = CdmStore.getService(ITaxonNodeService.class).load(dialogTaxonNode.getUuid());
62
                    if(NavigationUtil.isDirty(targetTaxonNode)){
63
                        MessageDialog.openWarning(shell, Messages.MoveFactualDataHandler_UNSAVED_TARGET, Messages.MoveFactualDataHandler_UNSAVED_TARGET_MESSAGE);
64
                        return;
65
                    }
66
                    CdmStore.getService(IDescriptionService.class).moveTaxonDescriptions(taxon.getUuid(),targetTaxonNode.getTaxon().getUuid());
67

  
68
                    taxonNavigator.getConversationHolder().bind();
69
                    taxonNavigator.getConversationHolder().commit();
70

  
71
                    Display.getDefault().asyncExec(new Runnable(){
72

  
73
                        @Override
74
                        public void run() {
75
                            //FIXME E4 refresh factual view via events or similar
76
//                            try {
77
//                                //close and re-open to refresh factual data view
78
//                                MultiPageTaxonEditor sourceEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(sourceTaxonNode.getUuid());
79
//                                MultiPageTaxonEditor targetEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(targetTaxonNode.getUuid());
80
//                                if(targetEditor != null){
81
//                                    AbstractUtility.close(sourceEditor);
82
//                                    AbstractUtility.close(targetEditor);
83
//                                }
84
//                                EditorUtil.openTaxonNodeE4(sourceTaxonNode.getUuid());
85
//                                EditorUtil.openTaxonNodeE4(targetTaxonNode.getUuid());
86
//                            } catch (PartInitException e) {
87
//                                MessagingUtils.error(this.getClass(), e);
88
//                                throw new RuntimeException(e);
89
//                            } catch (Exception e) {
90
//                                MessagingUtils.warningDialog(Messages.MoveFactualDataHandler_CREATE_FAILED, this, e.getMessage());
91
//                            }
92
                        }
93

  
94
                    });
95
                }
96
            }
97
        }
98
    }
99

  
100
}
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/MoveTaxonHandlerE4.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.navigation.navigator.e4.handler;
11

  
12
import java.util.ArrayList;
13
import java.util.HashSet;
14
import java.util.Iterator;
15
import java.util.List;
16
import java.util.Set;
17
import java.util.UUID;
18

  
19
import javax.inject.Named;
20

  
21
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
22
import org.eclipse.e4.ui.services.IServiceConstants;
23
import org.eclipse.jface.dialogs.MessageDialog;
24
import org.eclipse.jface.viewers.TreeSelection;
25
import org.eclipse.swt.widgets.Shell;
26

  
27
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
28
import eu.etaxonomy.cdm.model.common.CdmBase;
29
import eu.etaxonomy.cdm.model.taxon.Classification;
30
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
31
import eu.etaxonomy.taxeditor.model.AbstractUtility;
32
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
33
import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
34
import eu.etaxonomy.taxeditor.navigation.navigator.TreeNodeDropAdapter.MovingType;
35
import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4;
36
import eu.etaxonomy.taxeditor.navigation.navigator.operation.MoveTaxonOperation;
37
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
38
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
39
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
40
import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
41

  
42
/**
43
 *
44
 * @author pplitzner
45
 * @date 05.09.2017
46
 *
47
 */
48
public class MoveTaxonHandlerE4 implements IPostOperationEnabled {
49

  
50
	private TaxonNode parentTaxonNode;
51

  
52
    public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection,
53
            @Named(IServiceConstants.ACTIVE_SHELL)Shell shell,
54
            @Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
55

  
56
        TaxonNavigatorE4 taxonNavigator = (TaxonNavigatorE4) activePart.getObject();
57

  
58
		Iterator<?> selectionIterator = selection.iterator();
59
		Set<TaxonNode> taxonNodes = new HashSet<TaxonNode>();
60
		TaxonNode taxonNode= null;
61
		Set<UUID> taxonNodeUUIDs = new HashSet<UUID>();
62
		// do not show the current selection
63
		List<UUID> excludeTaxa = new ArrayList<UUID>();
64

  
65
		while (selectionIterator.hasNext()){
66
			Object object = selectionIterator.next();
67
			if(object instanceof TaxonNode){
68
			    taxonNode = HibernateProxyHelper.deproxy(object,TaxonNode.class);
69
				taxonNodes.add(taxonNode);
70
				taxonNodeUUIDs.add(taxonNode.getUuid());
71
				excludeTaxa.add(taxonNode.getTaxon().getUuid());
72
			}
73
		}
74

  
75

  
76
		if (taxonNodes.size() >= 1){
77
		    Classification classification = taxonNodes.iterator().next().getClassification();
78
			MovingType moveToNewParent = MovingType.CHILD;
79
			if (PreferencesUtil.getSortNodesNaturally()){
80
				if(!MessageDialog.openQuestion(null, Messages.MoveTaxonHandler_TARGET_NODE, Messages.MoveTaxonHandler_TARGET_NODE_MESSAGE)){
81
					moveToNewParent = MovingType.BEHIND;
82
				}
83
				parentTaxonNode = TaxonNodeSelectionDialog.select(shell, taxonNavigator.getConversationHolder(), Messages.MoveTaxonHandler_CHOOSE_ABOVE, excludeTaxa, null, classification);
84
			}else{
85
				parentTaxonNode = TaxonNodeSelectionDialog.select(shell, taxonNavigator.getConversationHolder(), Messages.MoveTaxonHandler_CHOOSE_PARENT, excludeTaxa, null, classification);
86
			}
87
			if(parentTaxonNode != null){
88
				if(NavigationUtil.isDirty(parentTaxonNode)){
89
					MessageDialog.openWarning(shell, Messages.MoveTaxonHandler_UNSAVED_PARENT, Messages.MoveTaxonHandler_UNSAVED_PARENT_MESSAGE);
90
					return;
91
				}
92

  
93
				AbstractPostOperation<?> operation = new MoveTaxonOperation
94
						(Messages.MoveTaxonHandler_MOVE_TO_PARENT, NavigationUtil.getUndoContext(), taxonNodeUUIDs, parentTaxonNode, taxonNavigator, taxonNavigator, moveToNewParent); //$NON-NLS-1$
95
				AbstractUtility.executeOperation(operation);
96
				taxonNavigator.refresh();
97

  
98
			}
99
		}
100
	}
101

  
102
	/** {@inheritDoc} */
103
	@Override
104
    public boolean postOperation(CdmBase objectAffectedByOperation) {
105
		return true;
106
	}
107

  
108
	@Override
109
    public boolean onComplete() {
110
		return false;
111
	}
112

  
113
}
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/NewClassificationHandlerE4.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.navigation.navigator.e4.handler;
11

  
12
import javax.inject.Named;
13

  
14
import org.eclipse.e4.ui.services.IServiceConstants;
15
import org.eclipse.jface.wizard.WizardDialog;
16
import org.eclipse.swt.widgets.Shell;
17

  
18
import eu.etaxonomy.taxeditor.newWizard.NewClassificationWizard;
19

  
20
/**
21
 *
22
 * @author pplitzner
23
 * @date 05.09.2017
24
 *
25
 */
26
public class NewClassificationHandlerE4 {
27

  
28
    public void execute(@Named(IServiceConstants.ACTIVE_SHELL)Shell shell) {
29
		NewClassificationWizard wizard = new NewClassificationWizard();
30
		wizard.init(null, null);
31
		WizardDialog dialog = new WizardDialog(shell, wizard);
32
		dialog.open();
33
	}
34
}
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/NewTaxonNodeHandlerE4.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.navigation.navigator.e4.handler;
11

  
12
import javax.inject.Named;
13

  
14
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.e4.ui.services.IServiceConstants;
16
import org.eclipse.jface.wizard.WizardDialog;
17
import org.eclipse.swt.widgets.Shell;
18

  
19
import eu.etaxonomy.taxeditor.editor.EditorUtil;
20
import eu.etaxonomy.taxeditor.newWizard.IWizardPageListener;
21
import eu.etaxonomy.taxeditor.newWizard.NewTaxonNodeWizard;
22

  
23
/**
24
 *
25
 * @author pplitzner
26
 * @date 05.09.2017
27
 *
28
 */
29
public class NewTaxonNodeHandlerE4 {
30

  
31
    public void execute(@Named(IServiceConstants.ACTIVE_SHELL)Shell shell) throws Exception {
32

  
33
		final NewTaxonNodeWizard wizard = new NewTaxonNodeWizard();
34
		wizard.init(null, null);
35
		final WizardDialog dialog = new WizardDialog(shell, wizard);
36
		wizard.addWizardPageListener(new IWizardPageListener() {
37
		    @Override
38
		    public void close() {
39
		        wizard.performFinish();
40
		        dialog.close();
41
		    }
42
		});
43
		int status = dialog.open();
44

  
45
		if(status == IStatus.OK && wizard.openInEditor()){
46
			if(wizard.openEmpty()){
47
                EditorUtil.openEmptyE4(wizard.getParentTreeNode().getUuid());
48
			}else if(wizard.getTaxonNode() != null){
49
                EditorUtil.openTaxonNodeE4(wizard.getTaxonNode().getUuid());
50
			}
51
		}
52
	}
53
}
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/RefreshTreeHandlerE4.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.navigation.navigator.e4.handler;
11

  
12
import javax.inject.Named;
13

  
14
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
15
import org.eclipse.e4.ui.services.IServiceConstants;
16

  
17
import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4;
18

  
19
/**
20
 *
21
 * @author pplitzner
22
 * @date 05.09.2017
23
 *
24
 */
25
public class RefreshTreeHandlerE4 {
26

  
27
    public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
28

  
29
        TaxonNavigatorE4 taxonNavigator = (TaxonNavigatorE4) activePart.getObject();
30

  
31
        taxonNavigator.refresh();
32
	}
33
}
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/SetSecReferenceForSubtreeHandlerE4.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.navigation.navigator.e4.handler;
10

  
11
import org.eclipse.core.commands.operations.AbstractOperation;
12
import org.eclipse.core.runtime.IStatus;
13
import org.eclipse.core.runtime.Status;
14
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
15
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
16
import org.eclipse.jface.viewers.TreeSelection;
17
import org.eclipse.jface.window.Window;
18
import org.eclipse.jface.wizard.WizardDialog;
19
import org.eclipse.swt.widgets.Shell;
20

  
21
import eu.etaxonomy.cdm.io.common.SetSecundumForSubtreeConfigurator;
22
import eu.etaxonomy.cdm.model.taxon.Classification;
23
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
24
import eu.etaxonomy.taxeditor.model.AbstractUtility;
25
import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigatorLabels;
26
import eu.etaxonomy.taxeditor.navigation.navigator.operation.SetSecundumForSubtreeOperation;
27
import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4;
28
import eu.etaxonomy.taxeditor.ui.dialog.configurator.SetSecundumForSubtreeConfigurationWizard;
29

  
30
/**
31
 * @author k.luther
32
 * @author pplitzner
33
 * @date 10.02.2017
34
 *
35
 */
36
public class SetSecReferenceForSubtreeHandlerE4 extends RemotingCdmHandlerE4 {
37

  
38
       private ITaxonTreeNode taxonNode;
39
       private SetSecundumForSubtreeConfigurator configurator;
40

  
41
       public SetSecReferenceForSubtreeHandlerE4() {
42
           super(TaxonNavigatorLabels.CHANGE_SECUNDUM_FOR_SUBTREE);
43
       }
44

  
45
       @Override
46
       public IStatus allowOperations(TreeSelection selection,
47
               Shell shell,
48
               MPart activePart,
49
               MHandledMenuItem menuItem) {
50
           // check that only a single taxon tree node has been selected
51
           if(selection.size() > 1) {  }
52

  
53
           // check for no taxon tree node selected
54
           if(selection.size() == 0) {
55
               return new Status(IStatus.ERROR,
56
                       "unknown", //$NON-NLS-1$
57
                       TaxonNavigatorLabels.NO_TAXON_SELECTION_MESSAGE);
58
           }
59

  
60
           // check that selected object is a taxon node
61
           Object obj = selection.iterator().next();
62
           if(obj instanceof ITaxonTreeNode) {
63
               if (obj instanceof Classification){
64
                   taxonNode = ((Classification)obj).getRootNode();
65
               }else{
66
                   taxonNode = (ITaxonTreeNode)obj;
67
               }
68
          } else{
69
               return new Status(IStatus.ERROR,
70
                       "unknown", //$NON-NLS-1$
71
                       TaxonNavigatorLabels.SELECTED_OBJECT_NOT_TREE_NODE_MESSAGE);
72
           }
73

  
74

  
75
           // check if corresponding name editor is closed
76
           //FIXME E4 migrate
77
//           boolean editorClosed = NavigatorHandlerUtils.closeObsoleteEditor(event, (TaxonNode) taxonNode);
78
//           if(editorClosed != true) {
79
//               return new Status(IStatus.ERROR,
80
//                       "unknown", //$NON-NLS-1$
81
//                       TaxonNavigatorLabels.RELATED_EDITOR_NOT_CLOSED_MESSAGE);
82
//           }
83

  
84
           configurator = new SetSecundumForSubtreeConfigurator(taxonNode.getUuid());
85
           SetSecundumForSubtreeConfigurationWizard wizard = new SetSecundumForSubtreeConfigurationWizard(configurator);
86

  
87
           WizardDialog dialog = new WizardDialog(AbstractUtility.getShell(), wizard);
88

  
89
           if (dialog.open() == Window.OK) {
90
              return Status.OK_STATUS;
91
           }else{
92
               return Status.CANCEL_STATUS;
93
           }
94

  
95
       }
96

  
97
       @Override
98
       public AbstractOperation prepareOperation(TreeSelection selection,
99
               Shell shell,
100
               MPart activePart,
101
               MHandledMenuItem menuItem) {
102
          SetSecundumForSubtreeOperation operation =
103
                   new SetSecundumForSubtreeOperation(getTrigger(),
104
                           false,
105
                           taxonNode.getUuid(),
106
                           configurator);
107

  
108
           return operation;
109
       }
110

  
111
       @Override
112
       public void onComplete() {
113
       }
114

  
115
       /**
116
     * {@inheritDoc}
117
     */
118
    @Override
119
    protected Object getTrigger() {
120
        return this;
121
    }
122

  
123
}
eu.etaxonomy.taxeditor.store/META-INF/MANIFEST.MF
25 25
 eu.etaxonomy.taxeditor.model;uses:="eu.etaxonomy.cdm.model.common,eu.etaxonomy.cdm.model.name,eu.etaxonomy.cdm.model.taxon",
26 26
 eu.etaxonomy.taxeditor.newWizard,
27 27
 eu.etaxonomy.taxeditor.operation,
28
 eu.etaxonomy.taxeditor.operation.e4,
28 29
 eu.etaxonomy.taxeditor.parser,
29 30
 eu.etaxonomy.taxeditor.preference,
30 31
 eu.etaxonomy.taxeditor.preference.matching,
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/AbstractUtility.java
72 72
import eu.etaxonomy.taxeditor.operation.IPostMoniteredOperationEnabled;
73 73
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
74 74
import eu.etaxonomy.taxeditor.operation.RemotingCdmHandler;
75
import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4;
75 76
import eu.etaxonomy.taxeditor.store.CdmStore;
76 77
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
77 78
import eu.etaxonomy.taxeditor.ui.dialog.ReportTextDialog;
......
285 286
        return Status.OK_STATUS;
286 287
    }
287 288

  
289
    public static IStatus executeOperation(final AbstractOperation operation, final RemotingCdmHandlerE4 handler) {
290
        return executeOperation(operation, handler);
291
    }
292

  
288 293
    public static IStatus executeOperation(final AbstractOperation operation, final RemotingCdmHandler handler) {
294
        return executeOperation(operation, handler);
295
    }
296

  
297
    public static IStatus executeOperation(final AbstractOperation operation, final Object handler) {
289 298
        if (getOperationHistory() == null) {
290 299
            throw new IllegalArgumentException(
291 300
                    "There is no operation history for this context");
......
306 315
                    operation.addContext(IOperationHistory.GLOBAL_UNDO_CONTEXT);
307 316
                    status = getOperationHistory().execute(operation, monitor,
308 317
                            uiInfoAdapter);
309
                    if(handler != null) {
310
                        handler.postOperation(status);
318
                    if(handler instanceof RemotingCdmHandler) {
319
                        ((RemotingCdmHandler) handler).postOperation(status);
320
                    }
321
                    else if(handler instanceof RemotingCdmHandlerE4) {
322
                        ((RemotingCdmHandlerE4) handler).postOperation(status);
311 323
                    }
312 324
                } catch (ExecutionException e) {
313 325
                    MessagingUtils.operationDialog(this, e, TaxeditorStorePlugin.PLUGIN_ID, operationlabel, null);
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/e4/RemotingCdmHandlerE4.java
1
/**
2
* Copyright (C) 2015 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.operation.e4;
10

  
11
import javax.inject.Named;
12

  
13
import org.eclipse.core.commands.operations.AbstractOperation;
14
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
16
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
17
import org.eclipse.e4.ui.services.IServiceConstants;
18
import org.eclipse.jface.dialogs.ErrorDialog;
19
import org.eclipse.jface.viewers.TreeSelection;
20
import org.eclipse.swt.widgets.Shell;
21

  
22
import eu.etaxonomy.taxeditor.model.AbstractUtility;
23
import eu.etaxonomy.taxeditor.model.MessagingUtils;
24

  
25
/**
26
 * @author cmathew
27
 * @date 16 Jun 2015
28
 *
29
 */
30
public abstract class RemotingCdmHandlerE4 {
31

  
32
    private final String label;
33

  
34
    public RemotingCdmHandlerE4(String label) {
35
        this.label = label;
36
    }
37

  
38
    public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection,
39
            @Named(IServiceConstants.ACTIVE_SHELL)Shell shell,
40
            @Named(IServiceConstants.ACTIVE_PART)MPart activePart,
41
            MHandledMenuItem menuItem) {
42
        IStatus allowStatus = allowOperations(selection, shell, activePart, menuItem);
43
        if(allowStatus.isOK()) {
44
            AbstractOperation op = prepareOperation(selection, shell, activePart, menuItem);
45
            if(op != null) {
46
                AbstractUtility.executeOperation(op, this);
47
            }
48
        } else if(allowStatus.getSeverity() == IStatus.ERROR ||
49
                allowStatus.getSeverity() == IStatus.WARNING ||
50
                allowStatus.getSeverity() == IStatus.INFO) {
51
            MessagingUtils.warningDialog("Can not perform " + label, getTrigger(), allowStatus);
52
        }
53
        return;
54
    }
55

  
56
    public void postOperation(IStatus status) {
57

  
58
        switch(status.getSeverity()) {
59
        case IStatus.WARNING:
60
            ErrorDialog.openError(null, "Operation successful but with warnings", null, status);
61
            break;
62
        case IStatus.ERROR:
63
            ErrorDialog.openError(null, "Error executing operation", null, status);
64
            break;
65
        default:
66
        }
67

  
68
        onComplete();
69
    }
70

  
71
    public abstract IStatus allowOperations(TreeSelection selection,
72
            Shell shell,
73
            MPart activePart,
74
            MHandledMenuItem menuItem);
75

  
76
    public abstract AbstractOperation prepareOperation(TreeSelection selection,
77
            Shell shell,
78
            MPart activePart,
79
            MHandledMenuItem menuItem);
80

  
81
    public abstract void onComplete();
82

  
83
    protected abstract Object getTrigger();
84

  
85
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)