Revision 884aefac
Added by Katja Luther about 4 years ago
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/defaultHandler/OpenBulkEditorForIdentifiableEntityE4.java | ||
---|---|---|
1 | 1 |
package eu.etaxonomy.taxeditor.bulkeditor.handler.defaultHandler; |
2 | 2 |
|
3 |
import java.util.UUID; |
|
4 |
|
|
5 | 3 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
4 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
6 | 5 |
import org.eclipse.swt.widgets.Shell; |
7 | 6 |
|
8 | 7 |
import eu.etaxonomy.cdm.model.agent.AgentBase; |
... | ... | |
15 | 14 |
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorUtil; |
16 | 15 |
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput; |
17 | 16 |
import eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenHandlerBaseE4; |
18 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
19 | 17 |
|
20 | 18 |
public class OpenBulkEditorForIdentifiableEntityE4 extends DefaultOpenHandlerBaseE4<IdentifiableEntity>{ |
21 | 19 |
|
22 | 20 |
/** |
23 | 21 |
* {@inheritDoc} |
24 | 22 |
*/ |
25 |
@Override |
|
26 |
protected IdentifiableEntity getEntity(UUID uuid) { |
|
27 |
return CdmStore.getCommonService().find(IdentifiableEntity.class, uuid); |
|
28 |
} |
|
23 |
// @Override
|
|
24 |
// protected IdentifiableEntity getEntity(UUID uuid) {
|
|
25 |
// return CdmStore.getCommonService().find(IdentifiableEntity.class, uuid);
|
|
26 |
// }
|
|
29 | 27 |
|
30 | 28 |
/** |
31 | 29 |
* {@inheritDoc} |
... | ... | |
40 | 38 |
* {@inheritDoc} |
41 | 39 |
*/ |
42 | 40 |
@Override |
43 |
protected boolean canExecute(IdentifiableEntity entity) {
|
|
41 |
protected boolean canExecute(IStructuredSelection entity) {
|
|
44 | 42 |
return entity instanceof Reference |
45 | 43 |
|| entity instanceof TaxonName |
46 | 44 |
|| entity instanceof AgentBase |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/defaultHandler/OpenBulkEditorForTaxonNodeHandler.java | ||
---|---|---|
1 | 1 |
package eu.etaxonomy.taxeditor.bulkeditor.handler.defaultHandler; |
2 | 2 |
|
3 |
import java.util.UUID; |
|
4 |
|
|
5 | 3 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
4 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
6 | 5 |
import org.eclipse.swt.widgets.Shell; |
7 | 6 |
|
8 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService; |
|
9 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
|
7 |
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto; |
|
10 | 8 |
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorUtil; |
11 | 9 |
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput; |
10 |
import eu.etaxonomy.taxeditor.bulkeditor.input.TaxonEditorInput; |
|
12 | 11 |
import eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenHandlerBaseE4; |
13 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
14 | 12 |
|
15 |
public class OpenBulkEditorForTaxonNodeHandler extends DefaultOpenHandlerBaseE4<TaxonNode> { |
|
13 |
public class OpenBulkEditorForTaxonNodeHandler extends DefaultOpenHandlerBaseE4<TaxonNodeDto> {
|
|
16 | 14 |
|
17 |
@Override |
|
18 |
protected TaxonNode getEntity(UUID uuid) { |
|
19 |
return CdmStore.getService(ITaxonNodeService.class).load(uuid); |
|
20 |
} |
|
15 |
// @Override
|
|
16 |
// protected TaxonNode getEntity(UUID uuid) {
|
|
17 |
// return CdmStore.getService(ITaxonNodeService.class).load(uuid);
|
|
18 |
// }
|
|
21 | 19 |
|
22 | 20 |
@Override |
23 |
protected void open(TaxonNode entity, Shell shell, EPartService partService) { |
|
24 |
AbstractBulkEditorInput input = AbstractBulkEditorInput.NewInstance(entity.getTaxon()); |
|
21 |
protected void open(TaxonNodeDto entity, Shell shell, EPartService partService) { |
|
22 |
AbstractBulkEditorInput input = TaxonEditorInput.getInstance(); |
|
23 |
input.setEntityUuid(entity.getTaxonUuid()); |
|
25 | 24 |
BulkEditorUtil.openBulkEditor(input, modelService, partService, application); |
26 | 25 |
} |
27 | 26 |
|
... | ... | |
29 | 28 |
* {@inheritDoc} |
30 | 29 |
*/ |
31 | 30 |
@Override |
32 |
protected boolean canExecute(TaxonNode entity) { |
|
33 |
return entity.getTaxon()!=null; |
|
31 |
protected boolean canExecute(IStructuredSelection selection) { |
|
32 |
if (selection.getFirstElement() instanceof TaxonNodeDto){ |
|
33 |
return ((TaxonNodeDto)selection.getFirstElement()).getTaxonUuid()!=null; |
|
34 |
} |
|
35 |
return false; |
|
34 | 36 |
} |
35 | 37 |
|
36 | 38 |
@Override |
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 |
import java.util.UUID; |
|
3 |
|
|
4 | 2 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
5 | 3 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
6 | 4 |
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState; |
5 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
7 | 6 |
import org.eclipse.swt.widgets.Shell; |
8 | 7 |
|
9 | 8 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
... | ... | |
11 | 10 |
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView; |
12 | 11 |
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput; |
13 | 12 |
import eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenHandlerBaseE4; |
14 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
15 | 13 |
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin; |
16 | 14 |
|
17 | 15 |
|
18 | 16 |
public class DefaultOpenSpecimenEditorForTypeSpecimenHandler extends |
19 | 17 |
DefaultOpenHandlerBaseE4<SpecimenTypeDesignation> { |
20 | 18 |
|
21 |
@Override |
|
22 |
protected SpecimenTypeDesignation getEntity(UUID uuid) { |
|
23 |
return CdmStore.getCommonService().find(SpecimenTypeDesignation.class, uuid); |
|
24 |
} |
|
19 |
// @Override
|
|
20 |
// protected SpecimenTypeDesignation getEntity(UUID uuid) {
|
|
21 |
// return CdmStore.getCommonService().find(SpecimenTypeDesignation.class, uuid);
|
|
22 |
// }
|
|
25 | 23 |
|
26 | 24 |
@Override |
27 | 25 |
protected void open(SpecimenTypeDesignation entity, Shell shell, EPartService partService) { |
... | ... | |
33 | 31 |
} |
34 | 32 |
|
35 | 33 |
@Override |
36 |
protected boolean canExecute(SpecimenTypeDesignation entity) {
|
|
34 |
protected boolean canExecute(IStructuredSelection entity) {
|
|
37 | 35 |
return true; |
38 | 36 |
} |
39 | 37 |
|
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 |
import java.util.UUID; |
|
3 |
|
|
4 | 2 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
3 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
5 | 4 |
import org.eclipse.swt.widgets.Shell; |
6 | 5 |
|
7 |
import eu.etaxonomy.cdm.api.service.ITaxonService; |
|
8 | 6 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
9 | 7 |
import eu.etaxonomy.taxeditor.editor.AppModelId; |
10 | 8 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
11 | 9 |
import eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenHandlerBaseE4; |
12 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
13 | 10 |
|
14 | 11 |
|
15 | 12 |
public class DefaultOpenTaxonEditorForTaxonBaseHandler extends DefaultOpenHandlerBaseE4<TaxonBase> { |
16 | 13 |
|
17 |
@Override |
|
18 |
protected TaxonBase getEntity(UUID uuid) { |
|
19 |
return CdmStore.getService(ITaxonService.class).load(uuid); |
|
20 |
} |
|
14 |
// @Override
|
|
15 |
// protected TaxonBase getEntity(UUID uuid) {
|
|
16 |
// return CdmStore.getService(ITaxonService.class).load(uuid);
|
|
17 |
// }
|
|
21 | 18 |
|
22 | 19 |
@Override |
23 | 20 |
protected void open(TaxonBase entity, Shell shell, EPartService partService) { |
... | ... | |
28 | 25 |
* {@inheritDoc} |
29 | 26 |
*/ |
30 | 27 |
@Override |
31 |
protected boolean canExecute(TaxonBase entity) {
|
|
28 |
protected boolean canExecute(IStructuredSelection entity) {
|
|
32 | 29 |
return true; |
33 | 30 |
} |
34 | 31 |
|
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 |
import java.util.UUID; |
|
3 |
|
|
4 | 2 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
3 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
5 | 4 |
import org.eclipse.swt.widgets.Shell; |
6 | 5 |
|
7 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService; |
|
8 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
|
6 |
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto; |
|
9 | 7 |
import eu.etaxonomy.taxeditor.editor.AppModelId; |
10 | 8 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
11 | 9 |
import eu.etaxonomy.taxeditor.editor.l10n.Messages; |
12 | 10 |
import eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenHandlerBaseE4; |
13 | 11 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
14 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
15 | 12 |
|
16 | 13 |
|
17 |
public class DefaultOpenTaxonEditorForTaxonNodeHandler extends DefaultOpenHandlerBaseE4<TaxonNode> { |
|
14 |
public class DefaultOpenTaxonEditorForTaxonNodeHandler extends DefaultOpenHandlerBaseE4<TaxonNodeDto> {
|
|
18 | 15 |
|
19 |
@Override |
|
20 |
protected TaxonNode getEntity(UUID uuid) { |
|
21 |
return CdmStore.getService(ITaxonNodeService.class).load(uuid); |
|
22 |
} |
|
16 |
// @Override
|
|
17 |
// protected TaxonNode getEntity(UUID uuid) {
|
|
18 |
// return CdmStore.getService(ITaxonNodeService.class).load(uuid);
|
|
19 |
// }
|
|
23 | 20 |
|
24 | 21 |
@Override |
25 |
protected void open(TaxonNode entity, Shell shell, EPartService partService) { |
|
22 |
protected void open(TaxonNodeDto entity, Shell shell, EPartService partService) {
|
|
26 | 23 |
try { |
27 | 24 |
EditorUtil.openTaxonNodeE4(entity.getUuid(), modelService, partService, application); |
28 | 25 |
} catch (Exception e) { |
29 |
MessagingUtils.error(DefaultOpenTaxonEditorForTaxonNodeHandler.class, Messages.DefaultOpenTaxonEditorForTaxonNodeHandler_COULD_NOT_OPEN+entity.getTaxon(), e); |
|
26 |
MessagingUtils.error(DefaultOpenTaxonEditorForTaxonNodeHandler.class, Messages.DefaultOpenTaxonEditorForTaxonNodeHandler_COULD_NOT_OPEN+entity.getTaxonTitleCache(), e);
|
|
30 | 27 |
} |
31 | 28 |
} |
32 | 29 |
|
... | ... | |
34 | 31 |
* {@inheritDoc} |
35 | 32 |
*/ |
36 | 33 |
@Override |
37 |
protected boolean canExecute(TaxonNode entity) { |
|
38 |
return entity.getTaxon()!=null ; |
|
34 |
protected boolean canExecute(IStructuredSelection selection) { |
|
35 |
if (selection.getFirstElement() instanceof TaxonNodeDto){ |
|
36 |
return ((TaxonNodeDto)selection.getFirstElement()).getTaxonUuid() != null; |
|
37 |
} |
|
38 |
return false ; |
|
39 | 39 |
// boolean hasPermission = CdmStore.currentAuthentiationHasPermission(entity, Operation.UPDATE); |
40 | 40 |
// return hasPermission && entity.getTaxon()!=null ; |
41 | 41 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/OpenDerivativeEditorForDescriptionElement.java | ||
---|---|---|
4 | 4 |
import java.util.UUID; |
5 | 5 |
|
6 | 6 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
7 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
7 | 8 |
import org.eclipse.swt.widgets.Shell; |
8 | 9 |
|
9 |
import eu.etaxonomy.cdm.api.service.IDescriptionService; |
|
10 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
|
11 | 10 |
import eu.etaxonomy.cdm.model.description.IndividualsAssociation; |
12 | 11 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
13 | 12 |
import eu.etaxonomy.taxeditor.editor.AppModelId; |
... | ... | |
16 | 15 |
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput; |
17 | 16 |
import eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenHandlerBaseE4; |
18 | 17 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
19 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
20 | 18 |
|
21 | 19 |
public class OpenDerivativeEditorForDescriptionElement extends DefaultOpenHandlerBaseE4<IndividualsAssociation> { |
22 | 20 |
|
23 |
@Override |
|
24 |
protected IndividualsAssociation getEntity(UUID uuid) { |
|
25 |
DescriptionElementBase descriptionElement = CdmStore.getService(IDescriptionService.class).loadDescriptionElement(uuid, null); |
|
26 |
if(descriptionElement!=null && descriptionElement.isInstanceOf(IndividualsAssociation.class)){ |
|
27 |
return (IndividualsAssociation) descriptionElement; |
|
28 |
} |
|
29 |
return null; |
|
30 |
} |
|
21 |
// @Override
|
|
22 |
// protected IndividualsAssociation getEntity(UUID uuid) {
|
|
23 |
// DescriptionElementBase descriptionElement = CdmStore.getService(IDescriptionService.class).loadDescriptionElement(uuid, null);
|
|
24 |
// if(descriptionElement!=null && descriptionElement.isInstanceOf(IndividualsAssociation.class)){
|
|
25 |
// return (IndividualsAssociation) descriptionElement;
|
|
26 |
// }
|
|
27 |
// return null;
|
|
28 |
// }
|
|
31 | 29 |
|
32 | 30 |
@Override |
33 | 31 |
protected void open(IndividualsAssociation entity, Shell shell, EPartService partService) { |
... | ... | |
46 | 44 |
* {@inheritDoc} |
47 | 45 |
*/ |
48 | 46 |
@Override |
49 |
protected boolean canExecute(IndividualsAssociation entity) {
|
|
47 |
protected boolean canExecute(IStructuredSelection entity) {
|
|
50 | 48 |
return true; |
51 | 49 |
} |
52 | 50 |
|
... | ... | |
54 | 52 |
protected String getPartId() { |
55 | 53 |
return AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DERIVATE_DERIVATEVIEW; |
56 | 54 |
} |
55 |
|
|
56 |
|
|
57 | 57 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/OpenDerivativeEditorForGatheringEvent.java | ||
---|---|---|
6 | 6 |
import java.util.UUID; |
7 | 7 |
|
8 | 8 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
9 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
9 | 10 |
import org.eclipse.swt.widgets.Shell; |
10 | 11 |
|
11 |
import eu.etaxonomy.cdm.api.service.IEventBaseService; |
|
12 | 12 |
import eu.etaxonomy.cdm.api.service.IOccurrenceService; |
13 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
|
14 |
import eu.etaxonomy.cdm.model.common.ICdmBase; |
|
15 | 13 |
import eu.etaxonomy.cdm.model.occurrence.FieldUnit; |
16 | 14 |
import eu.etaxonomy.cdm.model.occurrence.GatheringEvent; |
17 | 15 |
import eu.etaxonomy.taxeditor.editor.AppModelId; |
... | ... | |
25 | 23 |
|
26 | 24 |
protected static final String OPEN_DERIVATIVE_EDITOR_FOR_TAXON_NODE_COULD_NOT_OPEN = Messages.OpenDerivativeEditorForTaxonNode_COULD_NOT_OPEN; |
27 | 25 |
|
28 |
@Override |
|
29 |
protected GatheringEvent getEntity(UUID uuid) { |
|
30 |
ICdmBase load = CdmStore.getService(IEventBaseService.class).load(uuid); |
|
31 |
return HibernateProxyHelper.deproxy(load, GatheringEvent.class ); |
|
32 |
} |
|
26 |
// @Override
|
|
27 |
// protected GatheringEvent getEntity(UUID uuid) {
|
|
28 |
// ICdmBase load = CdmStore.getService(IEventBaseService.class).load(uuid);
|
|
29 |
// return HibernateProxyHelper.deproxy(load, GatheringEvent.class );
|
|
30 |
// }
|
|
33 | 31 |
|
34 | 32 |
@Override |
35 | 33 |
protected void open(GatheringEvent entity, Shell shell, EPartService partService) { |
... | ... | |
44 | 42 |
* {@inheritDoc} |
45 | 43 |
*/ |
46 | 44 |
@Override |
47 |
protected boolean canExecute(GatheringEvent entity) {
|
|
45 |
protected boolean canExecute(IStructuredSelection entity) {
|
|
48 | 46 |
return true; |
49 | 47 |
} |
50 | 48 |
|
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/OpenDerivativeEditorForSpecimenOrOBservationBase.java | ||
---|---|---|
1 | 1 |
package eu.etaxonomy.taxeditor.editor.view.derivate.handler; |
2 | 2 |
|
3 |
import java.util.UUID; |
|
4 |
|
|
5 | 3 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
4 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
6 | 5 |
import org.eclipse.swt.widgets.Shell; |
7 | 6 |
|
8 |
import eu.etaxonomy.cdm.api.service.IOccurrenceService; |
|
9 | 7 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
10 | 8 |
import eu.etaxonomy.taxeditor.editor.AppModelId; |
11 | 9 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
12 | 10 |
import eu.etaxonomy.taxeditor.editor.l10n.Messages; |
13 | 11 |
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput; |
14 | 12 |
import eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenHandlerBaseE4; |
15 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
16 | 13 |
|
17 | 14 |
public class OpenDerivativeEditorForSpecimenOrOBservationBase extends DefaultOpenHandlerBaseE4<SpecimenOrObservationBase<?>>{ |
18 | 15 |
|
... | ... | |
21 | 18 |
/** |
22 | 19 |
* {@inheritDoc} |
23 | 20 |
*/ |
24 |
@Override |
|
25 |
protected SpecimenOrObservationBase<?> getEntity(UUID uuid) { |
|
26 |
return CdmStore.getService(IOccurrenceService.class).load(uuid); |
|
27 |
} |
|
21 |
// @Override
|
|
22 |
// protected SpecimenOrObservationBase<?> getEntity(UUID uuid) {
|
|
23 |
// return CdmStore.getService(IOccurrenceService.class).load(uuid);
|
|
24 |
// }
|
|
28 | 25 |
|
29 | 26 |
@Override |
30 | 27 |
protected void open(SpecimenOrObservationBase<?> entity, Shell shell, EPartService partService) { |
... | ... | |
36 | 33 |
* {@inheritDoc} |
37 | 34 |
*/ |
38 | 35 |
@Override |
39 |
protected boolean canExecute(SpecimenOrObservationBase<?> entity) {
|
|
36 |
protected boolean canExecute(IStructuredSelection entity) {
|
|
40 | 37 |
//FIXME E4 when bulk editor is migrated then move the handler scope to the bulk editor part descriptor |
41 | 38 |
//in the model fragment |
42 | 39 |
return true; |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/OpenDerivativeEditorForTaxonNode.java | ||
---|---|---|
6 | 6 |
import java.util.UUID; |
7 | 7 |
|
8 | 8 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
9 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
9 | 10 |
import org.eclipse.swt.widgets.Shell; |
10 | 11 |
|
11 | 12 |
import eu.etaxonomy.cdm.api.service.IOccurrenceService; |
12 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService; |
|
13 | 13 |
import eu.etaxonomy.cdm.api.service.config.FindOccurrencesConfigurator; |
14 | 14 |
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate; |
15 | 15 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
16 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
|
16 |
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
|
|
17 | 17 |
import eu.etaxonomy.taxeditor.editor.AppModelId; |
18 | 18 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
19 | 19 |
import eu.etaxonomy.taxeditor.editor.l10n.Messages; |
... | ... | |
22 | 22 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
23 | 23 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
24 | 24 |
|
25 |
public class OpenDerivativeEditorForTaxonNode extends DefaultOpenHandlerBaseE4<TaxonNode> { |
|
25 |
public class OpenDerivativeEditorForTaxonNode extends DefaultOpenHandlerBaseE4<TaxonNodeDto> {
|
|
26 | 26 |
|
27 | 27 |
protected static final String OPEN_DERIVATIVE_EDITOR_FOR_TAXON_NODE_COULD_NOT_OPEN = Messages.OpenDerivativeEditorForTaxonNode_COULD_NOT_OPEN; |
28 | 28 |
|
29 |
@Override |
|
30 |
protected TaxonNode getEntity(UUID uuid) { |
|
31 |
return CdmStore.getService(ITaxonNodeService.class).load(uuid); |
|
32 |
} |
|
29 |
// @Override
|
|
30 |
// protected TaxonNode getEntity(UUID uuid) {
|
|
31 |
// return CdmStore.getService(ITaxonNodeService.class).load(uuid);
|
|
32 |
// }
|
|
33 | 33 |
|
34 | 34 |
@Override |
35 |
protected void open(TaxonNode entity, Shell shell, EPartService partService) { |
|
35 |
protected void open(TaxonNodeDto entity, Shell shell, EPartService partService) {
|
|
36 | 36 |
FindOccurrencesConfigurator config = new FindOccurrencesConfigurator(); |
37 |
UUID taxonUuid = entity.getTaxon().getUuid();
|
|
37 |
UUID taxonUuid = entity.getTaxonUuid(); |
|
38 | 38 |
config.setAssociatedTaxonUuid(taxonUuid); |
39 | 39 |
List<SpecimenOrObservationBase> specimens = CdmStore.getService(IOccurrenceService.class).findByTitle(config).getRecords(); |
40 | 40 |
Collection<UUID> specimenUuids = new ArrayList<UUID>(); |
... | ... | |
49 | 49 |
* {@inheritDoc} |
50 | 50 |
*/ |
51 | 51 |
@Override |
52 |
protected boolean canExecute(TaxonNode entity) { |
|
53 |
return (entity.getTaxon()!=null && PreferencesUtil.getBooleanValue(PreferencePredicate.ShowSpecimen.getKey())); |
|
52 |
protected boolean canExecute(IStructuredSelection selection) { |
|
53 |
|
|
54 |
if (selection != null && selection.getFirstElement() instanceof TaxonNodeDto && selection.size() == 1){ |
|
55 |
return (((TaxonNodeDto)selection.getFirstElement()).getTaxonUuid()!=null && PreferencesUtil.getBooleanValue(PreferencePredicate.ShowSpecimen.getKey())); |
|
56 |
} |
|
57 |
return false; |
|
54 | 58 |
} |
55 | 59 |
|
56 | 60 |
@Override |
... | ... | |
58 | 62 |
return AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DERIVATE_DERIVATEVIEW; |
59 | 63 |
} |
60 | 64 |
|
65 |
|
|
61 | 66 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/defaultHandler/e4/DefaultOpenClassificationWizardHandlerE4.java | ||
---|---|---|
1 | 1 |
package eu.etaxonomy.taxeditor.handler.defaultHandler.e4; |
2 | 2 |
|
3 |
import java.util.UUID; |
|
4 |
|
|
5 | 3 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
4 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
6 | 5 |
import org.eclipse.jface.wizard.WizardDialog; |
7 | 6 |
import org.eclipse.swt.widgets.Shell; |
8 | 7 |
|
9 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
|
|
10 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
|
8 |
import eu.etaxonomy.cdm.api.service.IClassificationService;
|
|
9 |
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
|
|
11 | 10 |
import eu.etaxonomy.taxeditor.newWizard.NewClassificationWizard; |
12 | 11 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
13 | 12 |
|
14 |
public class DefaultOpenClassificationWizardHandlerE4 extends DefaultOpenHandlerBaseE4<TaxonNode> { |
|
13 |
public class DefaultOpenClassificationWizardHandlerE4 extends DefaultOpenHandlerBaseE4<TaxonNodeDto> {
|
|
15 | 14 |
|
16 |
@Override |
|
17 |
protected TaxonNode getEntity(UUID uuid) { |
|
18 |
return CdmStore.getService(ITaxonNodeService.class).load(uuid); |
|
19 |
} |
|
15 |
// @Override
|
|
16 |
// protected TaxonNode getEntity(UUID uuid) {
|
|
17 |
// return CdmStore.getService(ITaxonNodeService.class).load(uuid);
|
|
18 |
// }
|
|
20 | 19 |
|
21 | 20 |
@Override |
22 |
protected void open(TaxonNode entity, Shell shell, EPartService partService) { |
|
21 |
protected void open(TaxonNodeDto entity, Shell shell, EPartService partService) {
|
|
23 | 22 |
NewClassificationWizard classificationWizard = new NewClassificationWizard(); |
24 | 23 |
classificationWizard.init(null, null); |
25 |
classificationWizard.setEntity(entity.getClassification());
|
|
24 |
classificationWizard.setEntity(CdmStore.getService(IClassificationService.class).load(entity.getClassificationUUID()));
|
|
26 | 25 |
WizardDialog dialog = new WizardDialog(shell, classificationWizard); |
27 | 26 |
dialog.open(); |
28 | 27 |
} |
... | ... | |
31 | 30 |
* {@inheritDoc} |
32 | 31 |
*/ |
33 | 32 |
@Override |
34 |
protected boolean canExecute(TaxonNode entity) { |
|
35 |
return entity.getClassification().getRootNode().equals(entity); |
|
33 |
protected boolean canExecute(IStructuredSelection entity) { |
|
34 |
return true; |
|
35 |
// return entity.getClassification().getRootNode().equals(entity); |
|
36 | 36 |
} |
37 | 37 |
|
38 | 38 |
|
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/defaultHandler/e4/DefaultOpenHandlerBaseE4.java | ||
---|---|---|
1 | 1 |
package eu.etaxonomy.taxeditor.handler.defaultHandler.e4; |
2 | 2 |
|
3 |
import java.util.UUID; |
|
4 |
|
|
5 | 3 |
import javax.inject.Named; |
6 | 4 |
|
7 | 5 |
import org.eclipse.e4.core.contexts.IEclipseContext; |
... | ... | |
13 | 11 |
import org.eclipse.e4.ui.services.IServiceConstants; |
14 | 12 |
import org.eclipse.e4.ui.workbench.modeling.EModelService; |
15 | 13 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
14 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
16 | 15 |
import org.eclipse.swt.widgets.Shell; |
17 | 16 |
|
18 | 17 |
public abstract class DefaultOpenHandlerBaseE4 <T> { |
... | ... | |
34 | 33 |
|
35 | 34 |
String commandId = menuItem.getCommand().getElementId(); |
36 | 35 |
Object transientData = menuItem.getTransientData().get(commandId+".uuid"); |
37 |
if(transientData instanceof UUID){ |
|
38 |
T entity = getEntity((UUID) transientData); |
|
39 |
open(entity, shell, partService);
|
|
40 |
} |
|
36 |
// if(transientData instanceof UUID){
|
|
37 |
// T entity = getEntity((UUID) transientData);
|
|
38 |
open((T)((IStructuredSelection)transientData).getFirstElement(), shell, partService);
|
|
39 |
// }
|
|
41 | 40 |
} |
42 | 41 |
|
43 | 42 |
@CanExecute |
... | ... | |
50 | 49 |
//check for correct entity |
51 | 50 |
String commandId = menuItem.getCommand().getElementId(); |
52 | 51 |
Object transientData = menuItem.getTransientData().get(commandId+".uuid"); |
53 |
if(transientData instanceof UUID){ |
|
54 |
T entity = getEntity((UUID) transientData); |
|
55 |
canExecute = canExecute(entity) |
|
52 |
if(transientData instanceof IStructuredSelection){ |
|
53 |
//TODO: is it necessary to get the entity? This handler is only available for the navigator and there are all objects are transient, this also needs several db calls, not necessary |
|
54 |
// T entity = getEntity((UUID) transientData); |
|
55 |
|
|
56 |
canExecute = canExecute((IStructuredSelection)transientData) |
|
56 | 57 |
&& (partId!=null?!partId.equals(activePart.getElementId()):true); |
57 | 58 |
} |
58 | 59 |
menuItem.setVisible(canExecute); |
59 | 60 |
return canExecute; |
60 | 61 |
} |
61 | 62 |
|
62 |
protected abstract T getEntity(UUID uuid); |
|
63 |
//protected abstract T getEntity(UUID uuid);
|
|
63 | 64 |
|
64 | 65 |
protected abstract void open(T entity, Shell shell, EPartService partService); |
65 | 66 |
|
66 |
protected abstract boolean canExecute(T entity);
|
|
67 |
protected abstract boolean canExecute(IStructuredSelection entity);
|
|
67 | 68 |
|
68 | 69 |
/** |
69 | 70 |
* Returns the part id for the part this handler opens.<br> |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/defaultHandler/e4/DefaultOpenSetBaseHandler.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2020 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.ArrayList; |
|
12 |
import java.util.List; |
|
13 |
|
|
14 |
import javax.inject.Named; |
|
15 |
|
|
16 |
import org.eclipse.e4.core.contexts.IEclipseContext; |
|
17 |
import org.eclipse.e4.core.di.annotations.Execute; |
|
18 |
import org.eclipse.e4.ui.model.application.MApplication; |
|
19 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
|
20 |
import org.eclipse.e4.ui.services.IServiceConstants; |
|
21 |
import org.eclipse.e4.ui.workbench.modeling.EModelService; |
|
22 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
|
23 |
import org.eclipse.jface.viewers.TreeSelection; |
|
24 |
import org.eclipse.swt.widgets.Shell; |
|
25 |
|
|
26 |
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache; |
|
27 |
|
|
28 |
/** |
|
29 |
* @author k.luther |
|
30 |
* @param <S> |
|
31 |
* @param <S> |
|
32 |
* @param <S> |
|
33 |
* @since Feb 20, 2020 |
|
34 |
*/ |
|
35 |
public abstract class DefaultOpenSetBaseHandler<S> extends DefaultOpenHandlerBaseE4<S> { |
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
@Override |
|
41 |
@Execute |
|
42 |
public void execute(@Named(IServiceConstants.ACTIVE_SHELL)Shell shell, MHandledMenuItem menuItem, |
|
43 |
EModelService modelService, EPartService partService, MApplication application, |
|
44 |
IEclipseContext context) { |
|
45 |
this.context = context; |
|
46 |
this.modelService = modelService; |
|
47 |
this.application = application; |
|
48 |
|
|
49 |
|
|
50 |
String commandId = menuItem.getCommand().getElementId(); |
|
51 |
Object transientData = menuItem.getTransientData().get(commandId+".uuid"); |
|
52 |
S list = null; |
|
53 |
if(transientData instanceof TreeSelection){ |
|
54 |
list = (S) ((TreeSelection)transientData).toList(); |
|
55 |
|
|
56 |
}else if (transientData instanceof UuidAndTitleCache){ |
|
57 |
List<UuidAndTitleCache> uuidList = new ArrayList<>(); |
|
58 |
uuidList.add((UuidAndTitleCache)transientData); |
|
59 |
list = (S)uuidList; |
|
60 |
} |
|
61 |
if (list != null){ |
|
62 |
open(list, shell, partService); |
|
63 |
} |
|
64 |
|
|
65 |
} |
|
66 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/defaultHandler/e4/DefaultOpenTaxonNodeWizardHandlerE4.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.handler.defaultHandler.e4; |
10 | 10 |
|
11 |
import java.util.UUID; |
|
12 |
|
|
13 | 11 |
import org.eclipse.e4.core.contexts.ContextInjectionFactory; |
14 | 12 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
13 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
15 | 14 |
import org.eclipse.jface.wizard.WizardDialog; |
16 | 15 |
import org.eclipse.swt.widgets.Shell; |
17 | 16 |
|
18 | 17 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService; |
19 | 18 |
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate; |
20 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
|
21 | 19 |
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto; |
22 | 20 |
import eu.etaxonomy.taxeditor.event.EventUtility; |
23 | 21 |
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants; |
... | ... | |
30 | 28 |
* @date 22.03.2016 |
31 | 29 |
* |
32 | 30 |
*/ |
33 |
public class DefaultOpenTaxonNodeWizardHandlerE4 extends DefaultOpenHandlerBaseE4<TaxonNode> { |
|
31 |
public class DefaultOpenTaxonNodeWizardHandlerE4 extends DefaultOpenHandlerBaseE4<TaxonNodeDto> {
|
|
34 | 32 |
|
35 |
@Override |
|
36 |
protected TaxonNode getEntity(UUID uuid) { |
|
37 |
return CdmStore.getService(ITaxonNodeService.class).load(uuid); |
|
38 |
} |
|
33 |
// @Override
|
|
34 |
// protected TaxonNode getEntity(UUID uuid) {
|
|
35 |
// return CdmStore.getService(ITaxonNodeService.class).load(uuid);
|
|
36 |
// }
|
|
39 | 37 |
|
40 | 38 |
@Override |
41 |
protected void open(TaxonNode entity, Shell shell, EPartService partService) { |
|
39 |
protected void open(TaxonNodeDto entity, Shell shell, EPartService partService) {
|
|
42 | 40 |
EditTaxonNodeWizard taxonNodeWizard = ContextInjectionFactory.make(EditTaxonNodeWizard.class, context); |
43 | 41 |
taxonNodeWizard.init(null, null); |
44 |
taxonNodeWizard.setEntity(entity);
|
|
42 |
taxonNodeWizard.setEntity(CdmStore.getService(ITaxonNodeService.class).load(entity.getUuid()));
|
|
45 | 43 |
WizardDialog dialog = new WizardDialog(shell, taxonNodeWizard); |
46 | 44 |
dialog.open(); |
47 |
EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAVIGATOR, new TaxonNodeDto(entity));
|
|
45 |
EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAVIGATOR, entity);
|
|
48 | 46 |
|
49 | 47 |
} |
50 | 48 |
|
51 | 49 |
@Override |
52 |
public boolean canExecute(TaxonNode entity) { |
|
53 |
return entity.getTaxon()!=null && PreferencesUtil.getBooleanValue(PreferencePredicate.ShowTaxonNodeWizard.getKey()); |
|
50 |
public boolean canExecute(IStructuredSelection selection) { |
|
51 |
if (selection.getFirstElement() instanceof TaxonNodeDto){ |
|
52 |
return ((TaxonNodeDto)selection.getFirstElement()).getTaxonUuid()!=null && PreferencesUtil.getBooleanValue(PreferencePredicate.ShowTaxonNodeWizard.getKey()); |
|
53 |
} |
|
54 |
return false; |
|
54 | 55 |
} |
55 | 56 |
|
56 | 57 |
} |
Also available in: Unified diff
ref #8047: allow multiselect for open distribution editor