Revision c9f13bde
Added by Cherian Mathew over 8 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateView.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.util.Collection; |
4 | 4 |
import java.util.HashSet; |
5 |
import java.util.List; |
|
6 |
import java.util.Map; |
|
7 | 5 |
import java.util.Map.Entry; |
8 | 6 |
import java.util.Set; |
9 |
import java.util.UUID; |
|
10 | 7 |
|
11 | 8 |
import org.eclipse.core.runtime.IProgressMonitor; |
12 | 9 |
import org.eclipse.jface.action.MenuManager; |
... | ... | |
34 | 31 |
|
35 | 32 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
36 | 33 |
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; |
37 |
import eu.etaxonomy.cdm.api.service.IOccurrenceService; |
|
38 | 34 |
import eu.etaxonomy.cdm.api.service.molecular.ISequenceService; |
39 | 35 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
40 | 36 |
import eu.etaxonomy.cdm.model.molecular.Sequence; |
... | ... | |
48 | 44 |
import eu.etaxonomy.taxeditor.model.IPartContentHasMedia; |
49 | 45 |
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData; |
50 | 46 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
51 |
import eu.etaxonomy.taxeditor.session.ICdmEntitySession; |
|
52 |
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled; |
|
53 | 47 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
54 | 48 |
import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateContentProvider; |
55 | 49 |
import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateLabelProvider; |
... | ... | |
60 | 54 |
*/ |
61 | 55 |
public class DerivateView extends EditorPart implements IPartContentHasFactualData, IDirtyMarkable, |
62 | 56 |
IConversationEnabled, IPartContentHasDetails, IPartContentHasSupplementalData, IPartContentHasMedia, |
63 |
ISelectionChangedListener, IPostOperationEnabled , ICdmEntitySessionEnabled {
|
|
57 |
ISelectionChangedListener, IPostOperationEnabled{ |
|
64 | 58 |
|
65 | 59 |
public static final String ID = "eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView"; //$NON-NLS-1$ |
66 | 60 |
|
... | ... | |
81 | 75 |
|
82 | 76 |
private ISelection selection = null; |
83 | 77 |
|
84 |
private final ICdmEntitySession cdmEntitySession; |
|
85 | 78 |
|
86 | 79 |
private DerivateContentProvider contentProvider; |
87 | 80 |
|
... | ... | |
89 | 82 |
* Default constructor |
90 | 83 |
*/ |
91 | 84 |
public DerivateView() { |
92 |
cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true); |
|
93 | 85 |
} |
94 | 86 |
|
95 | 87 |
@Override |
... | ... | |
116 | 108 |
generateMultiLinkSingleReads(); |
117 | 109 |
labelProvider.setMultiLinkSingleReads(multiLinkSingleReads); |
118 | 110 |
IEditorInput editorInput = getEditorInput(); |
119 |
viewer.setInput(((DerivateViewEditorInput) editorInput).getRootUUIDs());
|
|
111 |
viewer.setInput(((DerivateViewEditorInput) editorInput).getRootEntities());
|
|
120 | 112 |
//set selection to selected derivate if only one was selected |
121 | 113 |
if(editorInput instanceof DerivateViewEditorInput){ |
122 |
Set<UUID> derivateUUIDs = ((DerivateViewEditorInput) editorInput).getDerivateUUIDs();
|
|
123 |
if(derivateUUIDs.size()==1){
|
|
124 |
SpecimenOrObservationBase<?> specimen = CdmStore.getService(IOccurrenceService.class).load(derivateUUIDs.iterator().next());
|
|
125 |
if(specimen!=null){
|
|
114 |
Set<SpecimenOrObservationBase<?>> derivateEntities = ((DerivateViewEditorInput) editorInput).getDerivateEntities();
|
|
115 |
if(derivateEntities.size()==1){
|
|
116 |
SpecimenOrObservationBase<?> specimen = derivateEntities.iterator().next();
|
|
117 |
if(specimen != null){
|
|
126 | 118 |
viewer.setSelection(new StructuredSelection(new TreeNode(specimen))); |
127 | 119 |
} |
128 | 120 |
} |
... | ... | |
149 | 141 |
|
150 | 142 |
// commit the conversation and start a new transaction immediately |
151 | 143 |
conversation.commit(true); |
152 |
CdmStore.getService(IOccurrenceService.class).merge(getRootEntities());
|
|
144 |
((DerivateViewEditorInput) getEditorInput()).merge();
|
|
153 | 145 |
monitor.worked(1); |
154 | 146 |
|
155 | 147 |
this.setDirty(false); |
... | ... | |
207 | 199 |
if(!conversation.isBound()){ |
208 | 200 |
conversation.bind(); |
209 | 201 |
} |
210 |
cdmEntitySession.bind();
|
|
202 |
((DerivateViewEditorInput) getEditorInput()).bind();
|
|
211 | 203 |
} |
212 | 204 |
|
213 | 205 |
@Override |
... | ... | |
306 | 298 |
|
307 | 299 |
@Override |
308 | 300 |
public void dispose() { |
309 |
cdmEntitySession.dispose();
|
|
301 |
((DerivateViewEditorInput) getEditorInput()).dispose();
|
|
310 | 302 |
super.dispose(); |
311 | 303 |
} |
312 | 304 |
|
313 |
/* (non-Javadoc) |
|
314 |
* @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getCdmEntitySession() |
|
315 |
*/ |
|
316 |
@Override |
|
317 |
public ICdmEntitySession getCdmEntitySession() { |
|
318 |
return cdmEntitySession; |
|
319 |
} |
|
320 |
|
|
321 |
/* (non-Javadoc) |
|
322 |
* @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities() |
|
323 |
*/ |
|
324 |
@Override |
|
325 |
public List<SpecimenOrObservationBase> getRootEntities() { |
|
326 |
return contentProvider.getRootElements(); |
|
327 |
} |
|
328 |
|
|
329 |
/* (non-Javadoc) |
|
330 |
* @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getPropertyPathsMap() |
|
331 |
*/ |
|
332 |
@Override |
|
333 |
public Map<Object, List<String>> getPropertyPathsMap() { |
|
334 |
// TODO Auto-generated method stub |
|
335 |
return null; |
|
336 |
} |
|
337 | 305 |
|
338 | 306 |
@Override |
339 | 307 |
public boolean canAttachMedia() { |
Also available in: Unified diff
#5242, #5223 Improve performance of derivate loading and editing