Project

General

Profile

« Previous | Next » 

Revision 0db2412a

Added by Patrick Plitzner over 6 years ago

ref #6909, #6598 migrate default open handlers

View differences:

eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/defaultHandler/OpenBulkEditorForIdentifiableEntity.java
1
package eu.etaxonomy.taxeditor.bulkeditor.handler.defaultHandler;
2

  
3
import java.util.UUID;
4

  
5
import org.eclipse.core.commands.ExecutionEvent;
6
import org.eclipse.ui.PartInitException;
7

  
8
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
9
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorUtil;
10
import eu.etaxonomy.taxeditor.handler.defaultHandler.DefaultOpenHandlerBase;
11
import eu.etaxonomy.taxeditor.model.MessagingUtils;
12
import eu.etaxonomy.taxeditor.store.CdmStore;
13

  
14
public class OpenBulkEditorForIdentifiableEntity extends DefaultOpenHandlerBase<IdentifiableEntity> {
15

  
16
	@Override
17
	protected IdentifiableEntity getEntity(UUID uuid) {
18
		return CdmStore.getCommonService().find(IdentifiableEntity.class, uuid);
19
	}
20

  
21
	@Override
22
	protected void open(ExecutionEvent event, IdentifiableEntity entity) {
23
		try {
24
			BulkEditorUtil.openEditor(entity);
25
		} catch (PartInitException e) {
26
            MessagingUtils.error(this.getClass(), "Bulk Editor could not be opened for "+entity, e);
27
		}
28
	}
29

  
30

  
31
}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/defaultHandler/OpenBulkEditorForIdentifiableEntityE4.java
2 2

  
3 3
import java.util.UUID;
4 4

  
5
import org.eclipse.e4.core.di.annotations.Execute;
6
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
5
import org.eclipse.swt.widgets.Shell;
7 6
import org.eclipse.ui.PartInitException;
8 7

  
9 8
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
10 9
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorUtil;
10
import eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenHandlerBaseE4;
11 11
import eu.etaxonomy.taxeditor.model.MessagingUtils;
12 12
import eu.etaxonomy.taxeditor.store.CdmStore;
13 13

  
14
public class OpenBulkEditorForIdentifiableEntityE4 {
14
public class OpenBulkEditorForIdentifiableEntityE4 extends DefaultOpenHandlerBaseE4<IdentifiableEntity>{
15 15

  
16
	@Execute
17
	public void execute(MHandledMenuItem menuItem) {
18
	    String commandId = menuItem.getCommand().getElementId();
19
        UUID uuid = (UUID) menuItem.getTransientData().get(commandId+".uuid");
20
	    IdentifiableEntity entity = CdmStore.getCommonService().find(IdentifiableEntity.class, uuid);
21
		try {
22
			BulkEditorUtil.openEditor(entity);
23
		} catch (PartInitException e) {
16
    /**
17
     * {@inheritDoc}
18
     */
19
    @Override
20
    protected IdentifiableEntity getEntity(UUID uuid) {
21
        return CdmStore.getCommonService().find(IdentifiableEntity.class, uuid);
22
    }
23

  
24
    /**
25
     * {@inheritDoc}
26
     */
27
    @Override
28
    protected void open(IdentifiableEntity entity, Shell shell) {
29
        try {
30
            BulkEditorUtil.openEditor(entity);
31
        } catch (PartInitException e) {
24 32
            MessagingUtils.error(this.getClass(), "Bulk Editor could not be opened for "+entity, e);
25
		}
26
	}
33
        }
34
    }
35

  
36
    /**
37
     * {@inheritDoc}
38
     */
39
    @Override
40
    protected boolean canExecute(IdentifiableEntity entity) {
41
        return true;
42
    }
27 43

  
28 44
}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/defaultHandler/OpenBulkEditorForTaxonNodeHandler.java
2 2

  
3 3
import java.util.UUID;
4 4

  
5
import org.eclipse.core.commands.ExecutionEvent;
5
import org.eclipse.swt.widgets.Shell;
6 6
import org.eclipse.ui.PartInitException;
7 7

  
8 8
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
9 9
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
10 10
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorUtil;
11
import eu.etaxonomy.taxeditor.handler.defaultHandler.DefaultOpenHandlerBase;
11
import eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenHandlerBaseE4;
12 12
import eu.etaxonomy.taxeditor.model.MessagingUtils;
13 13
import eu.etaxonomy.taxeditor.store.CdmStore;
14 14

  
15
public class OpenBulkEditorForTaxonNodeHandler extends DefaultOpenHandlerBase<TaxonNode> {
15
public class OpenBulkEditorForTaxonNodeHandler extends DefaultOpenHandlerBaseE4<TaxonNode> {
16 16

  
17 17
    @Override
18 18
    protected TaxonNode getEntity(UUID uuid) {
......
20 20
    }
21 21

  
22 22
    @Override
23
    protected void open(ExecutionEvent event, TaxonNode entity) {
23
    protected void open(TaxonNode entity, Shell shell) {
24 24
        try {
25 25
            BulkEditorUtil.openEditor(entity.getTaxon());
26 26
        } catch (PartInitException e) {
......
28 28
        }
29 29
    }
30 30

  
31
    /**
32
     * {@inheritDoc}
33
     */
34
    @Override
35
    protected boolean canExecute(TaxonNode entity) {
36
        return entity.getTaxon()!=null;
37
    }
38

  
31 39
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/defaultHandler/DefaultOpenSpecimenEditorForTypeSpecimenHandler.java
1 1
package eu.etaxonomy.taxeditor.editor.handler.defaultHandler;
2 2
import java.util.UUID;
3 3

  
4
import org.eclipse.core.commands.ExecutionEvent;
5 4
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
6 5
import org.eclipse.e4.ui.workbench.modeling.EPartService;
7 6
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
7
import org.eclipse.swt.widgets.Shell;
8 8

  
9 9
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
10 10
import eu.etaxonomy.taxeditor.editor.AppModelId;
11 11
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
12 12
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
13
import eu.etaxonomy.taxeditor.handler.defaultHandler.DefaultOpenHandlerBase;
13
import eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenHandlerBaseE4;
14 14
import eu.etaxonomy.taxeditor.store.CdmStore;
15 15
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
16 16

  
17 17

  
18 18
public class DefaultOpenSpecimenEditorForTypeSpecimenHandler extends
19
		DefaultOpenHandlerBase<SpecimenTypeDesignation> {
19
		DefaultOpenHandlerBaseE4<SpecimenTypeDesignation> {
20 20

  
21 21
	@Override
22 22
	protected SpecimenTypeDesignation getEntity(UUID uuid) {
......
24 24
	}
25 25

  
26 26
	@Override
27
	protected void open(ExecutionEvent event, SpecimenTypeDesignation entity) {
27
	protected void open(SpecimenTypeDesignation entity, Shell shell) {
28 28
	    DerivateViewEditorInput input = new DerivateViewEditorInput(entity.getUuid());
29 29
	    MPart part = TaxeditorStorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getService(EPartService.class).showPart(
30 30
	            AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DERIVATE_DERIVATEVIEW, PartState.ACTIVATE);
......
32 32
	    derivateView.init(input);
33 33
	}
34 34

  
35
    /**
36
     * {@inheritDoc}
37
     */
38
    @Override
39
    protected boolean canExecute(SpecimenTypeDesignation entity) {
40
        return true;
41
    }
42

  
35 43
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/defaultHandler/DefaultOpenTaxonEditorForTaxonBaseHandler.java
1 1
package eu.etaxonomy.taxeditor.editor.handler.defaultHandler;
2 2
import java.util.UUID;
3 3

  
4
import org.eclipse.core.commands.ExecutionEvent;
4
import org.eclipse.swt.widgets.Shell;
5 5
import org.eclipse.ui.PartInitException;
6 6

  
7 7
import eu.etaxonomy.cdm.api.service.ITaxonService;
8 8
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
9 9
import eu.etaxonomy.taxeditor.editor.EditorUtil;
10 10
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
11
import eu.etaxonomy.taxeditor.handler.defaultHandler.DefaultOpenHandlerBase;
11
import eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenHandlerBaseE4;
12 12
import eu.etaxonomy.taxeditor.model.MessagingUtils;
13 13
import eu.etaxonomy.taxeditor.store.CdmStore;
14 14

  
15 15

  
16
public class DefaultOpenTaxonEditorForTaxonBaseHandler extends DefaultOpenHandlerBase<TaxonBase> {
16
public class DefaultOpenTaxonEditorForTaxonBaseHandler extends DefaultOpenHandlerBaseE4<TaxonBase> {
17 17

  
18 18
    @Override
19 19
    protected TaxonBase getEntity(UUID uuid) {
......
21 21
    }
22 22

  
23 23
    @Override
24
    protected void open(ExecutionEvent event, TaxonBase entity) {
24
    protected void open(TaxonBase entity, Shell shell) {
25 25
        try {
26 26
            EditorUtil.openTaxonBaseE4(entity.getUuid());
27 27
        } catch (PartInitException e) {
......
29 29
        }
30 30
    }
31 31

  
32
    /**
33
     * {@inheritDoc}
34
     */
35
    @Override
36
    protected boolean canExecute(TaxonBase entity) {
37
        return true;
38
    }
39

  
32 40
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/defaultHandler/DefaultOpenTaxonEditorForTaxonNodeHandler.java
1 1
package eu.etaxonomy.taxeditor.editor.handler.defaultHandler;
2 2
import java.util.UUID;
3 3

  
4
import org.eclipse.core.commands.ExecutionEvent;
4
import org.eclipse.swt.widgets.Shell;
5 5

  
6 6
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
7 7
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
8 8
import eu.etaxonomy.taxeditor.editor.EditorUtil;
9 9
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
10
import eu.etaxonomy.taxeditor.handler.defaultHandler.DefaultOpenHandlerBase;
10
import eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenHandlerBaseE4;
11 11
import eu.etaxonomy.taxeditor.model.MessagingUtils;
12 12
import eu.etaxonomy.taxeditor.store.CdmStore;
13 13

  
14 14

  
15
public class DefaultOpenTaxonEditorForTaxonNodeHandler extends DefaultOpenHandlerBase<TaxonNode> {
15
public class DefaultOpenTaxonEditorForTaxonNodeHandler extends DefaultOpenHandlerBaseE4<TaxonNode> {
16 16

  
17 17
    @Override
18 18
    protected TaxonNode getEntity(UUID uuid) {
......
20 20
    }
21 21

  
22 22
    @Override
23
    protected void open(ExecutionEvent event, TaxonNode entity) {
23
    protected void open(TaxonNode entity, Shell shell) {
24 24
        try {
25 25
            EditorUtil.openTaxonNodeE4(entity.getUuid());
26 26
        } catch (Exception e) {
......
28 28
        }
29 29
    }
30 30

  
31
    /**
32
     * {@inheritDoc}
33
     */
34
    @Override
35
    protected boolean canExecute(TaxonNode entity) {
36
        return true;
37
    }
38

  
31 39
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/OpenDerivativeEditorForDescriptionElement.java
3 3
import java.util.Collections;
4 4
import java.util.UUID;
5 5

  
6
import org.eclipse.core.commands.ExecutionEvent;
7 6
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
8 7
import org.eclipse.e4.ui.workbench.modeling.EPartService;
9 8
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
9
import org.eclipse.swt.widgets.Shell;
10 10

  
11 11
import eu.etaxonomy.cdm.api.service.IDescriptionService;
12 12
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
......
16 16
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
17 17
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
18 18
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
19
import eu.etaxonomy.taxeditor.handler.defaultHandler.DefaultOpenHandlerBase;
19
import eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenHandlerBaseE4;
20 20
import eu.etaxonomy.taxeditor.model.MessagingUtils;
21 21
import eu.etaxonomy.taxeditor.store.CdmStore;
22 22
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
23 23

  
24
public class OpenDerivativeEditorForDescriptionElement extends DefaultOpenHandlerBase<IndividualsAssociation> {
24
public class OpenDerivativeEditorForDescriptionElement extends DefaultOpenHandlerBaseE4<IndividualsAssociation> {
25 25

  
26 26
    @Override
27 27
    protected IndividualsAssociation getEntity(UUID uuid) {
......
33 33
    }
34 34

  
35 35
    @Override
36
    protected void open(ExecutionEvent event, IndividualsAssociation entity) {
36
    protected void open(IndividualsAssociation entity, Shell shell) {
37 37
    	if(entity==null || entity.getAssociatedSpecimenOrObservation()==null){
38 38
    		MessagingUtils.messageDialog(Messages.OpenDerivativeEditorForDescriptionElement_NO_SPECIMENS, this, Messages.OpenDerivativeEditorForDescriptionElement_NO_SPECIMENS_MESSAGE);
39 39
    		return;
......
50 50

  
51 51
    }
52 52

  
53

  
54
    /**
55
     * {@inheritDoc}
56
     */
57
    @Override
58
    protected boolean canExecute(IndividualsAssociation entity) {
59
        return true;
60
    }
53 61
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/OpenDerivativeEditorForSpecimenOrOBservationBase.java
2 2

  
3 3
import java.util.UUID;
4 4

  
5
import org.eclipse.core.commands.ExecutionEvent;
6 5
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
7 6
import org.eclipse.e4.ui.workbench.modeling.EPartService;
8 7
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
8
import org.eclipse.swt.widgets.Shell;
9 9

  
10 10
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
11 11
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
......
13 13
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
14 14
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
15 15
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
16
import eu.etaxonomy.taxeditor.handler.defaultHandler.DefaultOpenHandlerBase;
16
import eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenHandlerBaseE4;
17 17
import eu.etaxonomy.taxeditor.store.CdmStore;
18 18
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
19 19

  
20
public class OpenDerivativeEditorForSpecimenOrOBservationBase extends DefaultOpenHandlerBase<SpecimenOrObservationBase<?>>{
20
public class OpenDerivativeEditorForSpecimenOrOBservationBase extends DefaultOpenHandlerBaseE4<SpecimenOrObservationBase<?>>{
21 21

  
22 22
    protected static final String OPEN_DERIVATIVE_EDITOR_FOR_TAXON_NODE_COULD_NOT_OPEN = Messages.OpenDerivativeEditorForTaxonNode_COULD_NOT_OPEN;
23 23

  
......
30 30
    }
31 31

  
32 32
    @Override
33
    protected void open(ExecutionEvent event, SpecimenOrObservationBase<?> entity) {
33
    protected void open(SpecimenOrObservationBase<?> entity, Shell shell) {
34 34
        DerivateViewEditorInput input = new DerivateViewEditorInput(entity.getUuid());
35 35
        MPart part = TaxeditorStorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getService(EPartService.class).showPart(
36 36
                AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DERIVATE_DERIVATEVIEW, PartState.ACTIVATE);
......
38 38
        derivateView.init(input);
39 39
    }
40 40

  
41
    /**
42
     * {@inheritDoc}
43
     */
44
    @Override
45
    protected boolean canExecute(SpecimenOrObservationBase<?> entity) {
46
        return true;
47
    }
48

  
41 49
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/OpenDerivativeEditorForTaxonNode.java
5 5
import java.util.List;
6 6
import java.util.UUID;
7 7

  
8
import org.eclipse.core.commands.ExecutionEvent;
9 8
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
10 9
import org.eclipse.e4.ui.workbench.modeling.EPartService;
11 10
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
11
import org.eclipse.swt.widgets.Shell;
12 12

  
13 13
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
14 14
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
......
19 19
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
20 20
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
21 21
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
22
import eu.etaxonomy.taxeditor.handler.defaultHandler.DefaultOpenHandlerBase;
22
import eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenHandlerBaseE4;
23 23
import eu.etaxonomy.taxeditor.store.CdmStore;
24 24
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
25 25

  
26
public class OpenDerivativeEditorForTaxonNode extends DefaultOpenHandlerBase<TaxonNode> {
26
public class OpenDerivativeEditorForTaxonNode extends DefaultOpenHandlerBaseE4<TaxonNode> {
27 27

  
28 28
    protected static final String OPEN_DERIVATIVE_EDITOR_FOR_TAXON_NODE_COULD_NOT_OPEN = Messages.OpenDerivativeEditorForTaxonNode_COULD_NOT_OPEN;
29 29

  
......
33 33
    }
34 34

  
35 35
    @Override
36
    protected void open(ExecutionEvent event, TaxonNode entity) {
36
    protected void open(TaxonNode entity, Shell shell) {
37 37
        FindOccurrencesConfigurator config = new FindOccurrencesConfigurator();
38 38
        UUID taxonUuid = entity.getTaxon().getUuid();
39 39
        config.setAssociatedTaxonUuid(taxonUuid);
......
49 49
        derivateView.init(input);
50 50
    }
51 51

  
52
    /**
53
     * {@inheritDoc}
54
     */
55
    @Override
56
    protected boolean canExecute(TaxonNode entity) {
57
        return true;
58
    }
59

  
52 60
}
eu.etaxonomy.taxeditor.store/META-INF/MANIFEST.MF
19 19
 eu.etaxonomy.taxeditor.featuretree.e4,
20 20
 eu.etaxonomy.taxeditor.handler,
21 21
 eu.etaxonomy.taxeditor.handler.defaultHandler,
22
 eu.etaxonomy.taxeditor.handler.defaultHandler.e4,
22 23
 eu.etaxonomy.taxeditor.io,
23 24
 eu.etaxonomy.taxeditor.io.wizard,
24 25
 eu.etaxonomy.taxeditor.labels,
eu.etaxonomy.taxeditor.store/fragment.e4xmi
93 93
    <elements xsi:type="commands:Command" xmi:id="_Z_XgsIdQEeecZ4F2Y9Z0Og" elementId="eu.etaxonomy.taxeditor.editor.definedTerms.delete" commandName="%command.name.14"/>
94 94
    <elements xsi:type="commands:Command" xmi:id="_GTbAcIfSEeecZ4F2Y9Z0Og" elementId="eu.etaxonomy.taxeditor.editor.definedTerms.newDefinedTerm" commandName="%command.name.6"/>
95 95
    <elements xsi:type="commands:Command" xmi:id="_LMwG4IfSEeecZ4F2Y9Z0Og" elementId="eu.etaxonomy.taxeditor.editor.definedTerms.newKindOfTerm" commandName="New kind-of term"/>
96
    <elements xsi:type="commands:Command" xmi:id="_cE510JMBEeeR4YRjNqCKeA" elementId="eu.etaxonomy.taxeditor.command.openTaxonNodeWizard" commandName="%command.name.OPEN_TAXONNODE_WIZARD"/>
97
    <elements xsi:type="commands:Command" xmi:id="_zJ4-8JMCEeeR4YRjNqCKeA" elementId="eu.etaxonomy.taxeditor.command.openClassificationWizard" commandName="%command.name.OPEN_CLASSIFICATION_WIZARD"/>
96 98
  </fragments>
97 99
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_swGH0GhvEee3K4uKJljEYg" featurename="handlers" parentElementId="org.eclipse.e4.legacy.ide.application">
98 100
    <elements xsi:type="commands:Handler" xmi:id="_rVEdIGcjEee0qLTtA2ZpVQ" elementId="eu.etaxonomy.taxeditor.featuretree.e4.handler.RemoveFeatureHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.featuretree.e4.handler.RemoveFeatureHandler" command="_fNBtQGcjEee0qLTtA2ZpVQ"/>
99
    <elements xsi:type="commands:Handler" xmi:id="_tyCPYIdPEeecZ4F2Y9Z0Og" elementId="eu.etaxonomy.taxeditor.store.handler.0" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.editor.definedterm.e4.handler.OpenDefinedTermEditorHandlerE4" command="_qEMrsIdPEeecZ4F2Y9Z0Og"/>
101
    <elements xsi:type="commands:Handler" xmi:id="_tyCPYIdPEeecZ4F2Y9Z0Og" elementId="eu.etaxonomy.taxeditor.editor.definedterm.e4.handler.OpenDefinedTermEditorHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.editor.definedterm.e4.handler.OpenDefinedTermEditorHandlerE4" command="_qEMrsIdPEeecZ4F2Y9Z0Og"/>
102
    <elements xsi:type="commands:Handler" xmi:id="_XF8ogJMBEeeR4YRjNqCKeA" elementId="eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenTaxonNodeWizardHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenTaxonNodeWizardHandlerE4" command="_cE510JMBEeeR4YRjNqCKeA"/>
103
    <elements xsi:type="commands:Handler" xmi:id="_8HUM8JMCEeeR4YRjNqCKeA" elementId="eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenClassificationWizardHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenClassificationWizardHandlerE4" command="_zJ4-8JMCEeeR4YRjNqCKeA"/>
100 104
  </fragments>
101 105
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_qT4hgIfTEeecZ4F2Y9Z0Og" featurename="children" parentElementId="eu.etaxonomy.taxeditor.workbench.menu.window">
102 106
    <elements xsi:type="menu:Menu" xmi:id="_LT3P8IfcEeecZ4F2Y9Z0Og" elementId="eu.etaxonomy.taxeditor.store.menu.termeditor" label="Term Editor">
eu.etaxonomy.taxeditor.store/plugin.xml
497 497
            id="eu.etaxonomy.taxeditor.store.open"
498 498
            name="%command.name.15">
499 499
      </command>
500
      <command
501
            defaultHandler="eu.etaxonomy.taxeditor.handler.defaultHandler.DefaultOpenClassificationWizardHandler"
502
            id="eu.etaxonomy.taxeditor.command.openClassificationWizard"
503
            name="%command.name.OPEN_CLASSIFICATION_WIZARD">
504
         <commandParameter
505
               id="eu.etaxonomy.taxeditor.command.openClassificationWizard.uuid"
506
               name="Classification Uuid"
507
               optional="true"
508
               typeId="eu.etaxonomy.taxeditor.uuidParameterType">
509
         </commandParameter>
510
      </command>
511
      <command
512
            defaultHandler="eu.etaxonomy.taxeditor.handler.defaultHandler.DefaultOpenTaxonNodeWizardHandler"
513
            id="eu.etaxonomy.taxeditor.command.openTaxonNodeWizard"
514
            name="%command.name.OPEN_TAXONNODE_WIZARD">
515
         <commandParameter
516
               id="eu.etaxonomy.taxeditor.command.openTaxonNodeWizard.uuid"
517
               name="TaxonNode Uuid"
518
               optional="true"
519
               typeId="eu.etaxonomy.taxeditor.uuidParameterType">
520
         </commandParameter>
521
      </command>
522 500
   </extension>
523 501
   <extension
524 502
         point="org.eclipse.ui.commands">
......
1198 1176
      point="eu.etaxonomy.taxeditor.store.cdmViewer">
1199 1177
   <viewCommandMapping
1200 1178
         commandId="eu.etaxonomy.taxeditor.command.openClassificationWizard"
1201
         selection="eu.etaxonomy.cdm.model.taxon.Classification"
1179
         selection="eu.etaxonomy.cdm.model.taxon.TaxonNode"
1202 1180
         viewerName="%viewCommandMapping.viewerName.CLASSIFICATION_WIZARD">
1203 1181
   </viewCommandMapping>
1204 1182
   <viewCommandMapping
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/defaultHandler/DefaultOpenClassificationWizardHandler.java
1
package eu.etaxonomy.taxeditor.handler.defaultHandler;
2

  
3
import java.util.UUID;
4

  
5
import org.eclipse.core.commands.ExecutionEvent;
6
import org.eclipse.jface.wizard.WizardDialog;
7
import org.eclipse.ui.PlatformUI;
8

  
9
import eu.etaxonomy.cdm.api.service.IClassificationService;
10
import eu.etaxonomy.cdm.model.taxon.Classification;
11
import eu.etaxonomy.taxeditor.newWizard.NewClassificationWizard;
12
import eu.etaxonomy.taxeditor.store.CdmStore;
13

  
14
public class DefaultOpenClassificationWizardHandler extends DefaultOpenHandlerBase<Classification> {
15

  
16
    @Override
17
    protected Classification getEntity(UUID uuid) {
18
        return CdmStore.getService(IClassificationService.class).load(uuid);
19
    }
20

  
21
    @Override
22
    protected void open(ExecutionEvent event, Classification entity) {
23
        NewClassificationWizard classificationWizard = new NewClassificationWizard();
24
        classificationWizard.init(null, null);
25
        classificationWizard.setEntity(entity);
26
        WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), classificationWizard);
27
        dialog.open();
28
    }
29

  
30

  
31
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/defaultHandler/DefaultOpenHandlerBase.java
7 7
import org.eclipse.core.commands.ExecutionException;
8 8
import org.eclipse.core.commands.ParameterType;
9 9
import org.eclipse.core.commands.common.NotDefinedException;
10
import org.eclipse.jface.viewers.ISelection;
11
import org.eclipse.jface.viewers.IStructuredSelection;
12
import org.eclipse.ui.handlers.HandlerUtil;
13 10

  
14 11
import eu.etaxonomy.taxeditor.model.MessagingUtils;
12
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
15 13

  
16 14
public abstract class DefaultOpenHandlerBase <T> extends AbstractHandler {
17 15

  
......
35 33
        }
36 34
        //if not try current selection
37 35
        else{
38
            ISelection selection = HandlerUtil.getCurrentSelection(event);
39
            if(selection instanceof IStructuredSelection){
40
                open(event, (T) ((IStructuredSelection) selection).getFirstElement());
41
            }
36
            MessagingUtils.errorDialog("Default Handler", this, "Migrate handler!!!", TaxeditorStorePlugin.PLUGIN_ID, null, false);
37
//            ISelection selection = HandlerUtil.getCurrentSelection(event);
38
//            if(selection instanceof IStructuredSelection){
39
//                open(event, (T) ((IStructuredSelection) selection).getFirstElement());
40
//            }
42 41
        }
43 42
        return null;
44 43
    }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/defaultHandler/DefaultOpenTaxonNodeWizardHandler.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.handler.defaultHandler;
10

  
11
import java.util.UUID;
12

  
13
import org.eclipse.core.commands.ExecutionEvent;
14
import org.eclipse.jface.wizard.WizardDialog;
15
import org.eclipse.ui.PlatformUI;
16

  
17
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
18
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
19
import eu.etaxonomy.taxeditor.store.CdmStore;
20
import eu.etaxonomy.taxeditor.ui.section.classification.EditTaxonNodeWizard;
21

  
22
/**
23
 * @author k.luther
24
 * @date 22.03.2016
25
 *
26
 */
27
public class DefaultOpenTaxonNodeWizardHandler extends DefaultOpenHandlerBase<TaxonNode> {
28
    @Override
29
    protected TaxonNode getEntity(UUID uuid) {
30
        return CdmStore.getService(ITaxonNodeService.class).load(uuid);
31
    }
32

  
33
    @Override
34
    protected void open(ExecutionEvent event, TaxonNode entity) {
35
        EditTaxonNodeWizard taxonNodeWizard = new EditTaxonNodeWizard();
36
        taxonNodeWizard.init(null, null);
37
        taxonNodeWizard.setEntity(entity);
38
        WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), taxonNodeWizard);
39
        dialog.open();
40
    }
41
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/defaultHandler/e4/DefaultOpenClassificationWizardHandlerE4.java
1
package eu.etaxonomy.taxeditor.handler.defaultHandler.e4;
2

  
3
import java.util.UUID;
4

  
5
import org.eclipse.jface.wizard.WizardDialog;
6
import org.eclipse.swt.widgets.Shell;
7

  
8
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
9
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
10
import eu.etaxonomy.taxeditor.newWizard.NewClassificationWizard;
11
import eu.etaxonomy.taxeditor.store.CdmStore;
12

  
13
public class DefaultOpenClassificationWizardHandlerE4 extends DefaultOpenHandlerBaseE4<TaxonNode> {
14

  
15
    @Override
16
    protected TaxonNode getEntity(UUID uuid) {
17
        return CdmStore.getService(ITaxonNodeService.class).load(uuid);
18
    }
19

  
20
    @Override
21
    protected void open(TaxonNode entity, Shell shell) {
22
        NewClassificationWizard classificationWizard = new NewClassificationWizard();
23
        classificationWizard.init(null, null);
24
        classificationWizard.setEntity(entity.getClassification());
25
        WizardDialog dialog = new WizardDialog(shell, classificationWizard);
26
        dialog.open();
27
    }
28

  
29
    /**
30
     * {@inheritDoc}
31
     */
32
    @Override
33
    protected boolean canExecute(TaxonNode entity) {
34
        return entity.getClassification().getRootNode().equals(entity);
35
    }
36

  
37

  
38
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/defaultHandler/e4/DefaultOpenHandlerBaseE4.java
1
package eu.etaxonomy.taxeditor.handler.defaultHandler.e4;
2

  
3
import java.util.UUID;
4

  
5
import javax.inject.Named;
6

  
7
import org.eclipse.e4.core.di.annotations.CanExecute;
8
import org.eclipse.e4.core.di.annotations.Execute;
9
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
10
import org.eclipse.e4.ui.services.IServiceConstants;
11
import org.eclipse.swt.widgets.Shell;
12

  
13
public abstract class DefaultOpenHandlerBaseE4 <T> {
14

  
15
    @Execute
16
    public void execute(@Named(IServiceConstants.ACTIVE_SHELL)Shell shell, MHandledMenuItem menuItem) {
17
        String commandId = menuItem.getCommand().getElementId();
18
        Object transientData = menuItem.getTransientData().get(commandId+".uuid");
19
        if(transientData instanceof UUID){
20
            T entity = getEntity((UUID) transientData);
21
            open(entity, shell);
22
        }
23
    }
24

  
25
    @CanExecute
26
    public boolean canExecute(MHandledMenuItem menuItem) {
27
        boolean canExecute = false;
28
        String commandId = menuItem.getCommand().getElementId();
29
        Object transientData = menuItem.getTransientData().get(commandId+".uuid");
30
        if(transientData instanceof UUID){
31
            T entity = getEntity((UUID) transientData);
32
            canExecute = canExecute(entity);
33
        }
34
        menuItem.setVisible(canExecute);
35
        return canExecute;
36
    }
37

  
38
    protected abstract T getEntity(UUID uuid);
39

  
40
    protected abstract void open(T entity, Shell shell);
41

  
42
    protected abstract boolean canExecute(T entity);
43

  
44
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/defaultHandler/e4/DefaultOpenTaxonNodeWizardHandlerE4.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.handler.defaultHandler.e4;
10

  
11
import java.util.UUID;
12

  
13
import org.eclipse.jface.wizard.WizardDialog;
14
import org.eclipse.swt.widgets.Shell;
15

  
16
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
17
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
18
import eu.etaxonomy.taxeditor.store.CdmStore;
19
import eu.etaxonomy.taxeditor.ui.section.classification.EditTaxonNodeWizard;
20

  
21
/**
22
 * @author k.luther
23
 * @date 22.03.2016
24
 *
25
 */
26
public class DefaultOpenTaxonNodeWizardHandlerE4 extends DefaultOpenHandlerBaseE4<TaxonNode> {
27

  
28
    @Override
29
    protected TaxonNode getEntity(UUID uuid) {
30
        return CdmStore.getService(ITaxonNodeService.class).load(uuid);
31
    }
32

  
33
    @Override
34
    protected void open(TaxonNode entity, Shell shell) {
35
        EditTaxonNodeWizard taxonNodeWizard = new EditTaxonNodeWizard();
36
        taxonNodeWizard.init(null, null);
37
        taxonNodeWizard.setEntity(entity);
38
        WizardDialog dialog = new WizardDialog(shell, taxonNodeWizard);
39
        dialog.open();
40
    }
41

  
42
    @Override
43
    public boolean canExecute(TaxonNode entity) {
44
        return entity.getTaxon()!=null;
45
    }
46

  
47
}

Also available in: Unified diff