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
|
package eu.etaxonomy.taxeditor.bulkeditor.handler.defaultHandler;
|
10
|
|
11
|
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
12
|
import org.eclipse.swt.widgets.Shell;
|
13
|
|
14
|
import eu.etaxonomy.cdm.model.agent.AgentBase;
|
15
|
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
|
16
|
import eu.etaxonomy.cdm.model.media.Media;
|
17
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
18
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
|
19
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
20
|
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
21
|
import eu.etaxonomy.cdm.persistence.dto.ReferencingObjectDto;
|
22
|
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
|
23
|
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorUtil;
|
24
|
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
|
25
|
import eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenHandlerBaseE4;
|
26
|
|
27
|
public class OpenBulkEditorForIdentifiableEntityE4 extends DefaultOpenHandlerBaseE4<Object>{
|
28
|
|
29
|
@Override
|
30
|
protected void open(Object entity, Shell shell, EPartService partService) {
|
31
|
@SuppressWarnings("rawtypes")
|
32
|
AbstractBulkEditorInput input = null;
|
33
|
if (entity instanceof UuidAndTitleCache){
|
34
|
input = AbstractBulkEditorInput.NewInstance(((UuidAndTitleCache<?>)entity).getType(), ((UuidAndTitleCache<?>)entity).getUuid());
|
35
|
}else if (entity instanceof IdentifiableEntity){
|
36
|
input = AbstractBulkEditorInput.NewInstance((IdentifiableEntity)entity);
|
37
|
}
|
38
|
BulkEditorUtil.openBulkEditor(input, modelService, partService, application);
|
39
|
}
|
40
|
|
41
|
@Override
|
42
|
protected boolean canExecute(Object entity) {
|
43
|
if (entity instanceof UuidAndTitleCache){
|
44
|
if (entity instanceof ReferencingObjectDto && ((ReferencingObjectDto) entity).getOpenInTarget() != null){
|
45
|
entity = ((ReferencingObjectDto) entity).getOpenInTarget();
|
46
|
}
|
47
|
Class<?> type = ((UuidAndTitleCache<?>)entity).getType();
|
48
|
return (TaxonName.class.isAssignableFrom(type)
|
49
|
|| AgentBase.class.isAssignableFrom(type)
|
50
|
|| SpecimenOrObservationBase.class.isAssignableFrom(type)
|
51
|
|| TaxonBase.class.isAssignableFrom(type)
|
52
|
|| Reference.class.isAssignableFrom(type)
|
53
|
|| Media.class.isAssignableFrom(type));
|
54
|
}
|
55
|
|
56
|
return entity instanceof Reference
|
57
|
|| entity instanceof TaxonName
|
58
|
|| entity instanceof AgentBase
|
59
|
|| entity instanceof SpecimenOrObservationBase
|
60
|
|| entity instanceof TaxonBase
|
61
|
|| entity instanceof Media
|
62
|
;
|
63
|
}
|
64
|
|
65
|
@Override
|
66
|
protected String getPartId() {
|
67
|
return eu.etaxonomy.taxeditor.bulkeditor.AppModelId.PARTDESCRIPTOR_BULKEDITOR_EDITOR;
|
68
|
}
|
69
|
}
|