Revision ece2b239
Added by Patrick Plitzner over 5 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/e4/DefinedTermEditorE4.java | ||
---|---|---|
20 | 20 |
import org.eclipse.e4.core.contexts.IEclipseContext; |
21 | 21 |
import org.eclipse.e4.ui.di.Focus; |
22 | 22 |
import org.eclipse.e4.ui.di.Persist; |
23 |
import org.eclipse.e4.ui.di.UISynchronize; |
|
24 | 23 |
import org.eclipse.e4.ui.model.application.ui.MDirtyable; |
25 | 24 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
26 | 25 |
import org.eclipse.e4.ui.services.EMenuService; |
... | ... | |
39 | 38 |
|
40 | 39 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
41 | 40 |
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; |
41 |
import eu.etaxonomy.cdm.api.service.ITermService; |
|
42 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
|
43 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
|
44 |
import eu.etaxonomy.cdm.persistence.dto.TermDto; |
|
45 |
import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto; |
|
42 | 46 |
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap; |
43 | 47 |
import eu.etaxonomy.taxeditor.editor.definedterm.DefinedTermSorter; |
44 | 48 |
import eu.etaxonomy.taxeditor.editor.definedterm.TermDtoContentProvider; |
... | ... | |
47 | 51 |
import eu.etaxonomy.taxeditor.editor.definedterm.input.TermEditorInput; |
48 | 52 |
import eu.etaxonomy.taxeditor.event.EventUtility; |
49 | 53 |
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants; |
50 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
|
51 | 54 |
import eu.etaxonomy.taxeditor.model.IContextListener; |
52 | 55 |
import eu.etaxonomy.taxeditor.model.IDirtyMarkable; |
53 | 56 |
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails; |
54 | 57 |
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData; |
55 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
|
56 | 58 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
57 | 59 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
58 | 60 |
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants; |
... | ... | |
73 | 75 |
|
74 | 76 |
protected ConversationHolder conversation; |
75 | 77 |
|
76 |
@Inject |
|
77 |
private UISynchronize sync; |
|
78 |
|
|
79 | 78 |
@Inject |
80 | 79 |
private ESelectionService selService; |
81 | 80 |
|
... | ... | |
90 | 89 |
@Inject |
91 | 90 |
private MPart thisPart; |
92 | 91 |
|
93 |
private List<AbstractPostOperation> operations = new ArrayList<>();
|
|
92 |
private List<DefinedTermBase> changedTerms = new ArrayList<>();
|
|
94 | 93 |
|
95 | 94 |
@Inject |
96 | 95 |
public DefinedTermEditorE4() { |
... | ... | |
135 | 134 |
|
136 | 135 |
} |
137 | 136 |
|
138 |
public void addOperation(AbstractPostOperation operation){ |
|
139 |
operations.add(operation); |
|
140 |
} |
|
141 |
|
|
142 | 137 |
@Override |
143 | 138 |
public boolean postOperation(Object objectAffectedByOperation) { |
144 | 139 |
viewer.refresh(); |
... | ... | |
162 | 157 |
@Persist |
163 | 158 |
public void save(IProgressMonitor monitor) { |
164 | 159 |
getConversationHolder().commit(); |
165 |
operations.forEach(operation->AbstractUtility.executeOperation(operation, sync));
|
|
166 |
operations.clear();
|
|
160 |
changedTerms.forEach(term->CdmStore.getService(ITermService.class).merge(term));
|
|
161 |
changedTerms.clear();
|
|
167 | 162 |
input.merge(); |
168 | 163 |
setDirty(false); |
169 | 164 |
input.initialiseVocabularies(); |
... | ... | |
199 | 194 |
|
200 | 195 |
@Override |
201 | 196 |
public void changed(Object element) { |
197 |
if(element instanceof DefinedTermBase){ |
|
198 |
DefinedTermBase definedTermBase = (DefinedTermBase) element; |
|
199 |
TermDto termDto = new TermDto(definedTermBase.getUuid(), |
|
200 |
definedTermBase.getRepresentations(), |
|
201 |
null, |
|
202 |
null, |
|
203 |
null); |
|
204 |
viewer.update(termDto, null); |
|
205 |
changedTerms.add(definedTermBase); |
|
206 |
} |
|
207 |
else if(element instanceof TermVocabulary){ |
|
208 |
TermVocabulary vocabulary = (TermVocabulary)element; |
|
209 |
TermVocabularyDto vocabularyDto = new TermVocabularyDto(vocabulary.getUuid(), vocabulary.getRepresentations()); |
|
210 |
viewer.update(vocabularyDto, null); |
|
211 |
} |
|
202 | 212 |
setDirty(true); |
203 | 213 |
viewer.update(element, null); |
204 | 214 |
} |
Also available in: Unified diff
ref #7887 Implement editing of DTOs in details view