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.ui.section.classification;
|
10
|
|
11
|
import java.util.Collection;
|
12
|
import java.util.Collections;
|
13
|
import java.util.List;
|
14
|
import java.util.Map;
|
15
|
|
16
|
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
|
17
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
18
|
import eu.etaxonomy.cdm.persistence.dto.MergeResult;
|
19
|
import eu.etaxonomy.taxeditor.event.EventUtility;
|
20
|
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
|
21
|
import eu.etaxonomy.taxeditor.newWizard.IWizardPageListener;
|
22
|
import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
|
23
|
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
|
24
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
25
|
|
26
|
/**
|
27
|
* @author k.luther
|
28
|
* @date 23.03.2016
|
29
|
*
|
30
|
*/
|
31
|
public class EditTaxonNodeWizard extends AbstractEditWizard<TaxonNode> implements ICdmEntitySessionEnabled{
|
32
|
|
33
|
private TaxonNodeWizardPage taxonNodePage;
|
34
|
private IWizardPageListener wizardPageListener;
|
35
|
private ICdmEntitySession cdmEntitySession;
|
36
|
|
37
|
|
38
|
// @Override
|
39
|
// public void init(IWorkbench workbench, IStructuredSelection selection) {
|
40
|
// formFactory = new CdmFormFactory(getContext().get(Shell.class).getDisplay());
|
41
|
// conversation = CdmStore.createConversation();
|
42
|
// }
|
43
|
|
44
|
/* (non-Javadoc)
|
45
|
* @see eu.etaxonomy.taxeditor.ui.section.classification.AbstractEditWizard#getEntityName()
|
46
|
*/
|
47
|
@Override
|
48
|
protected String getEntityName() {
|
49
|
return "taxon node";
|
50
|
}
|
51
|
|
52
|
/* (non-Javadoc)
|
53
|
* @see eu.etaxonomy.taxeditor.ui.section.classification.AbstractEditWizard#saveEntity()
|
54
|
*/
|
55
|
@Override
|
56
|
protected void saveEntity() {
|
57
|
getConversationHolder().bind();
|
58
|
TaxonNode node = getEntity();
|
59
|
|
60
|
MergeResult result = CdmStore.getService(ITaxonNodeService.class).merge(node, true);
|
61
|
EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAME_EDITOR, node.getTaxon().getUuid());
|
62
|
|
63
|
}
|
64
|
@Override
|
65
|
public void addPages() {
|
66
|
taxonNodePage = new TaxonNodeWizardPage(formFactory, getConversationHolder(), getEntity(), wizardPageListener, false);
|
67
|
|
68
|
addPage(taxonNodePage);
|
69
|
}
|
70
|
|
71
|
public void addWizardPageListener(IWizardPageListener wizardPageListener){
|
72
|
this.wizardPageListener = wizardPageListener;
|
73
|
}
|
74
|
|
75
|
/* (non-Javadoc)
|
76
|
* @see eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard#setEntity(java.lang.Object)
|
77
|
*/
|
78
|
@Override
|
79
|
public void setEntity(TaxonNode entity) {
|
80
|
setWindowTitle(String.format("Edit %s", getEntityName()));
|
81
|
if (CdmStore.isActive() && cdmEntitySession == null) {
|
82
|
|
83
|
cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
|
84
|
cdmEntitySession.bind();
|
85
|
}
|
86
|
entity = CdmStore.getService(ITaxonNodeService.class).load(entity.getUuid());
|
87
|
super.setEntity(entity);
|
88
|
}
|
89
|
|
90
|
/**
|
91
|
* {@inheritDoc}
|
92
|
*/
|
93
|
@Override
|
94
|
public ICdmEntitySession getCdmEntitySession() {
|
95
|
|
96
|
return cdmEntitySession;
|
97
|
}
|
98
|
|
99
|
/**
|
100
|
* {@inheritDoc}
|
101
|
*/
|
102
|
@Override
|
103
|
public Collection<TaxonNode> getRootEntities() {
|
104
|
return Collections.singleton(this.getEntity());
|
105
|
}
|
106
|
|
107
|
/**
|
108
|
* {@inheritDoc}
|
109
|
*/
|
110
|
@Override
|
111
|
public Map<Object, List<String>> getPropertyPathsMap() {
|
112
|
// TODO Auto-generated method stub
|
113
|
return null;
|
114
|
}
|
115
|
|
116
|
@Override
|
117
|
public void dispose() {
|
118
|
cdmEntitySession.dispose();
|
119
|
super.dispose();
|
120
|
}
|
121
|
|
122
|
|
123
|
|
124
|
|
125
|
}
|