Project

General

Profile

Revision c050c60b

IDc050c60b3181d6f4aba95e0bc21c76adfa12724b
Parent 2d8daa57
Child 6568e8a5

Added by Patrick Plitzner over 3 years ago

ref #6566 Fix open handler for specimen editor

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java
44 44
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
45 45
import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditor;
46 46
import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditorInput;
47
//import eu.etaxonomy.taxeditor.store.view.dataimport.BioCaseEditorInput;
48
//import eu.etaxonomy.taxeditor.view.dataimport.DataImportEditor;
49
//import eu.etaxonomy.taxeditor.view.dataimport.DataImportEditorInput;
50
//import eu.etaxonomy.taxeditor.view.dataimport.GbifImportEditor;
51
//import eu.etaxonomy.taxeditor.view.dataimport.GbifImportEditorInput;
52
//import eu.etaxonomy.taxeditor.view.dataimport.SpecimenImportEditor;
53
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
54
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
55 47
import eu.etaxonomy.taxeditor.model.AbstractUtility;
56 48
import eu.etaxonomy.taxeditor.model.MessagingUtils;
57 49
import eu.etaxonomy.taxeditor.store.CdmStore;
......
112 104
	}
113 105

  
114 106
	/**
115
	 * Opens a new DerivateView for the given input
116
	 * @param input a {@link DerivateViewEditorInput} representing the selected derivate
117
	 * @throws PartInitException
118
	 */
119
	public static void open(DerivateViewEditorInput input)
120
	        throws PartInitException {
121
	    open(input, DerivateView.ID);
122
	}
123

  
124

  
125
	/**
126 107
	 * Opens a new ChecklistView for the given input
127 108
	 * @param input a {@link ChecklistEditorInput} representing the selected checklist
128 109
	 * @throws PartInitException
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenDerivateViewHandler.java
3 3
import org.eclipse.core.commands.AbstractHandler;
4 4
import org.eclipse.core.commands.ExecutionEvent;
5 5
import org.eclipse.core.commands.ExecutionException;
6
import org.eclipse.ui.PartInitException;
6
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
7
import org.eclipse.e4.ui.workbench.modeling.EPartService;
8
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
7 9

  
8
import eu.etaxonomy.taxeditor.editor.EditorUtil;
9
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
10
import eu.etaxonomy.taxeditor.editor.AppModelId;
11
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
10 12
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
11
import eu.etaxonomy.taxeditor.model.MessagingUtils;
13
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
12 14

  
13 15
public class OpenDerivateViewHandler extends AbstractHandler {
14 16

  
15 17
    @Override
16 18
    public Object execute(ExecutionEvent event) throws ExecutionException {
17
        try {
18
            EditorUtil.open(new DerivateViewEditorInput());
19
        } catch (PartInitException e) {
20
            MessagingUtils.error(OpenDerivateViewHandler.class, Messages.OpenDerivateViewHandler_COULD_NOT_OPEN, e);
21
        }
19
        MPart part = TaxeditorStorePlugin.getDefault().getWorkbench().getService(EPartService.class).showPart(
20
                AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DERIVATE_DERIVATEVIEW, PartState.ACTIVATE);
21
        DerivateView derivateView = (DerivateView) part.getObject();
22
        derivateView.init(new DerivateViewEditorInput());
22 23
        return null;
23 24
    }
24 25

  
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/defaultHandler/DefaultOpenSpecimenEditorForTypeSpecimenHandler.java
2 2
import java.util.UUID;
3 3

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

  
7 9
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
8
import eu.etaxonomy.taxeditor.editor.EditorUtil;
9
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
10
import eu.etaxonomy.taxeditor.editor.AppModelId;
11
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
10 12
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
11 13
import eu.etaxonomy.taxeditor.handler.defaultHandler.DefaultOpenHandlerBase;
12
import eu.etaxonomy.taxeditor.model.MessagingUtils;
13 14
import eu.etaxonomy.taxeditor.store.CdmStore;
15
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
14 16

  
15 17

  
16 18
public class DefaultOpenSpecimenEditorForTypeSpecimenHandler extends
......
23 25

  
24 26
	@Override
25 27
	protected void open(ExecutionEvent event, SpecimenTypeDesignation entity) {
26
        try {
27
            EditorUtil.open(new DerivateViewEditorInput(entity.getUuid()));
28
        } catch (PartInitException e) {
29
            MessagingUtils.error(DefaultOpenSpecimenEditorForTypeSpecimenHandler.class, Messages.DefaultOpenSpecimenEditorForTypeSpecimenHandler_COULD_NOT_OPEN, e);
30
        }		
28
	    DerivateViewEditorInput input = new DerivateViewEditorInput(entity.getUuid());
29
	    MPart part = TaxeditorStorePlugin.getDefault().getWorkbench().getService(EPartService.class).showPart(
30
	            AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DERIVATE_DERIVATEVIEW, PartState.ACTIVATE);
31
	    DerivateView derivateView = (DerivateView) part.getObject();
32
	    derivateView.init(input);
31 33
	}
32 34

  
33 35
}
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
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
8
import org.eclipse.e4.ui.workbench.modeling.EPartService;
9
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
10

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

  
18
public class OpenDerivativeEditorForDescriptionElement extends DefaultOpenHandlerBaseE4<IndividualsAssociation, DerivateView> {
24
public class OpenDerivativeEditorForDescriptionElement extends DefaultOpenHandlerBase<IndividualsAssociation> {
19 25

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

  
29 35
    @Override
30
    protected void initPart(IndividualsAssociation entity, DerivateView part) {
31
        if(entity==null || entity.getAssociatedSpecimenOrObservation()==null){
32
            MessagingUtils.messageDialog(Messages.OpenDerivativeEditorForDescriptionElement_NO_SPECIMENS, this, Messages.OpenDerivativeEditorForDescriptionElement_NO_SPECIMENS_MESSAGE);
33
            return;
34
        }
36
    protected void open(ExecutionEvent event, IndividualsAssociation entity) {
37
    	if(entity==null || entity.getAssociatedSpecimenOrObservation()==null){
38
    		MessagingUtils.messageDialog(Messages.OpenDerivativeEditorForDescriptionElement_NO_SPECIMENS, this, Messages.OpenDerivativeEditorForDescriptionElement_NO_SPECIMENS_MESSAGE);
39
    		return;
40
    	}
35 41
        SpecimenOrObservationBase associatedSpecimenOrObservation = entity.getAssociatedSpecimenOrObservation();
36 42
        if(associatedSpecimenOrObservation!=null){
37 43
            UUID specimenUuid = associatedSpecimenOrObservation.getUuid();
38
            part.init(new DerivateViewEditorInput(Collections.singletonList(specimenUuid)));
44
            DerivateViewEditorInput input = new DerivateViewEditorInput(Collections.singletonList(specimenUuid));
45
            MPart part = TaxeditorStorePlugin.getDefault().getWorkbench().getService(EPartService.class).showPart(
46
                    AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DERIVATE_DERIVATEVIEW, PartState.ACTIVATE);
47
            DerivateView derivateView = (DerivateView) part.getObject();
48
            derivateView.init(input);
39 49
        }
40
    }
41 50

  
42
    @Override
43
    protected String getPartId() {
44
        return AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DERIVATE_DERIVATEVIEW;
45 51
    }
46 52

  
47 53
}
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
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
7
import org.eclipse.e4.ui.workbench.modeling.EPartService;
8
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
9

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

  
14
public class OpenDerivativeEditorForSpecimenOrOBservationBase extends DefaultOpenHandlerBaseE4<SpecimenOrObservationBase<?>, DerivateView>{
20
public class OpenDerivativeEditorForSpecimenOrOBservationBase extends DefaultOpenHandlerBase<SpecimenOrObservationBase<?>>{
15 21

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

  
......
24 30
    }
25 31

  
26 32
    @Override
27
    protected void initPart(SpecimenOrObservationBase<?> entity, DerivateView part) {
28
        part.init(new DerivateViewEditorInput(entity.getUuid()));
29
    }
30

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

  
36

  
37

  
38 41
}
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
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
10
import org.eclipse.e4.ui.workbench.modeling.EPartService;
11
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
12

  
8 13
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
9 14
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
10 15
import eu.etaxonomy.cdm.api.service.config.FindOccurrencesConfigurator;
......
14 19
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
15 20
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
16 21
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
17
import eu.etaxonomy.taxeditor.handler.defaultHandler.DefaultOpenHandlerBaseE4;
22
import eu.etaxonomy.taxeditor.handler.defaultHandler.DefaultOpenHandlerBase;
18 23
import eu.etaxonomy.taxeditor.store.CdmStore;
24
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
19 25

  
20
public class OpenDerivativeEditorForTaxonNode extends DefaultOpenHandlerBaseE4<TaxonNode, DerivateView> {
26
public class OpenDerivativeEditorForTaxonNode extends DefaultOpenHandlerBase<TaxonNode> {
21 27

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

  
......
27 33
    }
28 34

  
29 35
    @Override
30
    protected void initPart(TaxonNode entity, DerivateView part) {
36
    protected void open(ExecutionEvent event, TaxonNode entity) {
31 37
        FindOccurrencesConfigurator config = new FindOccurrencesConfigurator();
32 38
        UUID taxonUuid = entity.getTaxon().getUuid();
33 39
        config.setAssociatedTaxonUuid(taxonUuid);
......
36 42
        for (SpecimenOrObservationBase specimenOrObservationBase : specimens) {
37 43
            specimenUuids.add(specimenOrObservationBase.getUuid());
38 44
        }
39
        part.init(new DerivateViewEditorInput(specimenUuids, taxonUuid));
40
    }
41

  
42
    @Override
43
    protected String getPartId() {
44
        return AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DERIVATE_DERIVATEVIEW;
45
        DerivateViewEditorInput input = new DerivateViewEditorInput(specimenUuids, taxonUuid);
46
        MPart part = TaxeditorStorePlugin.getDefault().getWorkbench().getService(EPartService.class).showPart(
47
                AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DERIVATE_DERIVATEVIEW, PartState.ACTIVATE);
48
        DerivateView derivateView = (DerivateView) part.getObject();
49
        derivateView.init(input);
45 50
    }
46 51

  
47 52
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/CdmViewerUtil.java
66 66
                        String viewerName = configElement.getAttribute("viewerName"); //$NON-NLS-1$
67 67
                        Class<?> selectionClass = Class.forName(configElement.getAttribute("selection")); //$NON-NLS-1$
68 68
                        if(selectionClass.isAssignableFrom(input.getClass())){
69
                            ICommandService commandService = (ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class);
69
                            ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class);
70 70
                            Command command = commandService.getCommand(commandId);
71 71
                            if(command.isEnabled()){
72 72
                                commandViewerNameMap.put(command, viewerName);

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)