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.e4.core.contexts.ContextInjectionFactory;
|
14
|
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
15
|
import org.eclipse.jface.wizard.WizardDialog;
|
16
|
import org.eclipse.swt.widgets.Shell;
|
17
|
|
18
|
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
|
19
|
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
|
20
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
21
|
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
|
22
|
import eu.etaxonomy.taxeditor.event.EventUtility;
|
23
|
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
|
24
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
25
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
26
|
import eu.etaxonomy.taxeditor.ui.section.classification.EditTaxonNodeWizard;
|
27
|
|
28
|
/**
|
29
|
* @author k.luther
|
30
|
* @date 22.03.2016
|
31
|
*
|
32
|
*/
|
33
|
public class DefaultOpenTaxonNodeWizardHandlerE4 extends DefaultOpenHandlerBaseE4<TaxonNode> {
|
34
|
|
35
|
@Override
|
36
|
protected TaxonNode getEntity(UUID uuid) {
|
37
|
return CdmStore.getService(ITaxonNodeService.class).load(uuid);
|
38
|
}
|
39
|
|
40
|
@Override
|
41
|
protected void open(TaxonNode entity, Shell shell, EPartService partService) {
|
42
|
EditTaxonNodeWizard taxonNodeWizard = ContextInjectionFactory.make(EditTaxonNodeWizard.class, context);
|
43
|
taxonNodeWizard.init(null, null);
|
44
|
taxonNodeWizard.setEntity(entity);
|
45
|
WizardDialog dialog = new WizardDialog(shell, taxonNodeWizard);
|
46
|
dialog.open();
|
47
|
EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAVIGATOR, new TaxonNodeDto(entity));
|
48
|
|
49
|
}
|
50
|
|
51
|
@Override
|
52
|
public boolean canExecute(TaxonNode entity) {
|
53
|
return entity.getTaxon()!=null && PreferencesUtil.getBooleanValue(PreferencePredicate.ShowTaxonNodeWizard.getKey());
|
54
|
}
|
55
|
|
56
|
}
|