Revision dd35c5fd
Added by Patrick Plitzner over 7 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateView.java | ||
---|---|---|
1 | 1 |
package eu.etaxonomy.taxeditor.editor.view.derivate; |
2 | 2 |
|
3 |
import java.util.Arrays; |
|
3 | 4 |
import java.util.Collection; |
5 |
import java.util.HashMap; |
|
4 | 6 |
import java.util.HashSet; |
7 |
import java.util.List; |
|
8 |
import java.util.Map; |
|
5 | 9 |
import java.util.Map.Entry; |
6 | 10 |
import java.util.Set; |
7 | 11 |
import java.util.UUID; |
... | ... | |
34 | 38 |
|
35 | 39 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
36 | 40 |
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; |
41 |
import eu.etaxonomy.cdm.api.service.IOccurrenceService; |
|
37 | 42 |
import eu.etaxonomy.cdm.api.service.molecular.ISequenceService; |
38 | 43 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
39 | 44 |
import eu.etaxonomy.cdm.model.molecular.Sequence; |
40 | 45 |
import eu.etaxonomy.cdm.model.molecular.SingleRead; |
46 |
import eu.etaxonomy.cdm.model.occurrence.FieldUnit; |
|
41 | 47 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
42 | 48 |
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap; |
49 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
|
43 | 50 |
import eu.etaxonomy.taxeditor.editor.Messages; |
44 | 51 |
import eu.etaxonomy.taxeditor.editor.view.derivate.searchFilter.DerivateSearchCompositeController; |
45 | 52 |
import eu.etaxonomy.taxeditor.model.IDirtyMarkable; |
... | ... | |
58 | 65 |
*/ |
59 | 66 |
public class DerivateView extends EditorPart implements IPartContentHasFactualData, IDirtyMarkable, |
60 | 67 |
IConversationEnabled, IPartContentHasDetails, IPartContentHasSupplementalData, IPartContentHasMedia, |
61 |
ISelectionChangedListener, IPostOperationEnabled{ |
|
62 | 68 |
|
69 |
ISelectionChangedListener, IPostOperationEnabled/*, ICdmEntitySessionEnabled*/{ |
|
63 | 70 |
public static final String ID = "eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView"; //$NON-NLS-1$ |
64 | 71 |
|
65 | 72 |
public static final String YOU_NEED_TO_SAVE_BEFORE_PERFORMING_THIS_ACTION = Messages.DerivateView_YOU_NEED_TO_SAVE; |
66 | 73 |
public static final String VIEW_HAS_UNSAVED_CHANGES = Messages.DerivateView_UNSAVED_CHANGES; |
67 | 74 |
|
75 |
private static final List<String> SPECIMEN_INIT_STRATEGY = Arrays.asList(new String[] { |
|
76 |
"descriptions", |
|
77 |
"annotations", |
|
78 |
"markers", |
|
79 |
"credits", |
|
80 |
"extensions", |
|
81 |
"rights", |
|
82 |
"sources", |
|
83 |
"derivationEvents.derivatives.annotations", |
|
84 |
"derivationEvents.derivatives.markers", |
|
85 |
"derivationEvents.derivatives.credits", |
|
86 |
"derivationEvents.derivatives.extensions", |
|
87 |
"derivationEvents.derivatives.rights", |
|
88 |
"derivationEvents.derivatives.sources" |
|
89 |
}); |
|
90 |
|
|
68 | 91 |
private ConversationHolder conversation; |
69 | 92 |
|
70 | 93 |
private TreeViewer viewer; |
... | ... | |
84 | 107 |
|
85 | 108 |
private DerivateSearchCompositeController derivateSearchCompositeController; |
86 | 109 |
|
110 |
/** |
|
111 |
* A map with keys being the derivative entities belonging to the {@link UUID}s passed to the constructor |
|
112 |
* and values being the root elements of the hierarchy (may be the same objects as the derivative entities) |
|
113 |
*/ |
|
114 |
private Map<SpecimenOrObservationBase<?>, SpecimenOrObservationBase<?>> derivateToRootEntityMap; |
|
115 |
|
|
116 |
/** |
|
117 |
* The set of root elements |
|
118 |
*/ |
|
119 |
private Set<SpecimenOrObservationBase<?>> rootElements; |
|
120 |
|
|
87 | 121 |
/** |
88 | 122 |
* Default constructor |
89 | 123 |
*/ |
90 | 124 |
public DerivateView() { |
125 |
conversation = CdmStore.createConversation(); |
|
91 | 126 |
} |
92 | 127 |
|
93 | 128 |
@Override |
... | ... | |
129 | 164 |
Menu menu = menuManager.createContextMenu(control); |
130 | 165 |
control.setMenu(menu); |
131 | 166 |
|
167 |
//single read multi links |
|
132 | 168 |
generateMultiLinkSingleReads(); |
133 | 169 |
labelProvider.setMultiLinkSingleReads(multiLinkSingleReads); |
134 |
IEditorInput editorInput = getEditorInput(); |
|
135 |
viewer.setInput(((DerivateViewEditorInput) editorInput).getRootEntities()); |
|
136 |
//set selection to selected derivate if only one was selected |
|
137 |
if(editorInput instanceof DerivateViewEditorInput){ |
|
138 |
Set<SpecimenOrObservationBase<?>> derivateEntities = ((DerivateViewEditorInput) editorInput).getDerivateEntities(); |
|
139 |
if(derivateEntities.size()==1){ |
|
140 |
SpecimenOrObservationBase<?> specimen = derivateEntities.iterator().next(); |
|
141 |
if(specimen != null){ |
|
142 |
viewer.setSelection(new StructuredSelection(new TreeNode(specimen))); |
|
143 |
} |
|
144 |
} |
|
170 |
|
|
171 |
//init tree |
|
172 |
DerivateViewEditorInput editorInput = (DerivateViewEditorInput) getEditorInput(); |
|
173 |
if(editorInput.getDerivativeUUIDs()!=null){ |
|
174 |
updateRootEntities(editorInput.getDerivativeUUIDs()); |
|
175 |
} |
|
176 |
else{ |
|
177 |
updateRootEntities(); |
|
145 | 178 |
} |
146 | 179 |
|
147 | 180 |
//add drag'n'drop support |
... | ... | |
150 | 183 |
viewer.addDropSupport(dndOperations, transfers, new DerivateDropListener(this)); |
151 | 184 |
} |
152 | 185 |
|
186 |
public void updateRootEntities() { |
|
187 |
updateRootEntities(null); |
|
188 |
} |
|
189 |
|
|
190 |
public void updateRootEntities(Collection<UUID> derivativeUuids) { |
|
191 |
if(derivativeUuids!=null){ |
|
192 |
this.derivateToRootEntityMap = new HashMap<SpecimenOrObservationBase<?>, SpecimenOrObservationBase<?>>(); |
|
193 |
this.rootElements = new HashSet<SpecimenOrObservationBase<?>>(); |
|
194 |
for (UUID uuid : derivativeUuids) { |
|
195 |
SpecimenOrObservationBase<?> derivate = CdmStore.getService(IOccurrenceService.class).load(uuid, SPECIMEN_INIT_STRATEGY); |
|
196 |
if(derivate instanceof FieldUnit){ |
|
197 |
derivateToRootEntityMap.put(derivate, derivate); |
|
198 |
} |
|
199 |
else { |
|
200 |
SpecimenOrObservationBase<?> topMostDerivate = EditorUtil.getTopMostDerivate(derivate); |
|
201 |
if(topMostDerivate!=null){ |
|
202 |
derivateToRootEntityMap.put(derivate, topMostDerivate); |
|
203 |
} |
|
204 |
else{ |
|
205 |
derivateToRootEntityMap.put(derivate, derivate); |
|
206 |
} |
|
207 |
} |
|
208 |
} |
|
209 |
for (SpecimenOrObservationBase<?> specimen : derivateToRootEntityMap.values()) { |
|
210 |
rootElements.add(specimen); |
|
211 |
} |
|
212 |
} |
|
213 |
viewer.setInput(rootElements); |
|
214 |
refreshTree(); |
|
215 |
} |
|
216 |
|
|
153 | 217 |
@Override |
154 | 218 |
public void doSave(IProgressMonitor monitor) { |
155 | 219 |
String taskName = Messages.DerivateView_SAVING_HIERARCHY; |
... | ... | |
165 | 229 |
|
166 | 230 |
// commit the conversation and start a new transaction immediately |
167 | 231 |
conversation.commit(true); |
168 |
((DerivateViewEditorInput) getEditorInput()).merge();
|
|
232 |
// TODO: what does this do? merge();
|
|
169 | 233 |
monitor.worked(1); |
170 | 234 |
|
171 | 235 |
this.setDirty(false); |
... | ... | |
179 | 243 |
public void doSaveAs() { |
180 | 244 |
} |
181 | 245 |
|
246 |
public Set<SpecimenOrObservationBase<?>> getRootElements() { |
|
247 |
return rootElements; |
|
248 |
} |
|
249 |
|
|
182 | 250 |
@Override |
183 | 251 |
public String getTitleToolTip() { |
184 | 252 |
if(getEditorInput() instanceof DerivateViewEditorInput){ |
... | ... | |
192 | 260 |
public void init(IEditorSite site, IEditorInput input) throws PartInitException { |
193 | 261 |
setSite(site); |
194 | 262 |
setInput(input); |
195 |
if(input instanceof DerivateViewEditorInput){ |
|
196 |
DerivateViewEditorInput derivateViewEditorInput = (DerivateViewEditorInput) input; |
|
197 |
conversation = derivateViewEditorInput.getConversationHolder(); |
|
198 |
setPartName(derivateViewEditorInput.getName()); |
|
199 |
} |
|
263 |
this.derivateToRootEntityMap = new HashMap<SpecimenOrObservationBase<?>, SpecimenOrObservationBase<?>>(); |
|
264 |
this.rootElements = new HashSet<SpecimenOrObservationBase<?>>(); |
|
200 | 265 |
} |
201 | 266 |
|
202 | 267 |
@Override |
... | ... | |
223 | 288 |
if(!conversation.isBound()){ |
224 | 289 |
conversation.bind(); |
225 | 290 |
} |
226 |
((DerivateViewEditorInput) getEditorInput()).bind(); |
|
227 | 291 |
} |
228 | 292 |
|
229 | 293 |
@Override |
... | ... | |
254 | 318 |
changed(null); |
255 | 319 |
} |
256 | 320 |
|
257 |
protected void setRootEntities(Collection<UUID> rootEntityUuids){ |
|
258 |
((DerivateViewEditorInput)getEditorInput()).updateRootEntities(rootEntityUuids); |
|
259 |
} |
|
321 |
// @Override |
|
322 |
// public Set<SpecimenOrObservationBase<?>> getRootEntities() { |
|
323 |
// return rootElements; |
|
324 |
// } |
|
325 |
// |
|
326 |
// @Override |
|
327 |
// public void merge() { |
|
328 |
// if(CdmStore.getCurrentSessionManager().isRemoting()) { |
|
329 |
// CdmApplicationState.getCurrentAppConfig().getOccurrenceService().merge(new ArrayList(getRootEntities()), true); |
|
330 |
// } |
|
331 |
// } |
|
332 |
// |
|
333 |
// @Override |
|
334 |
// public Map<Object, List<String>> getPropertyPathsMap() { |
|
335 |
// List<String> specimenPropertyPaths = Arrays.asList(new String[] { |
|
336 |
// "descriptions", |
|
337 |
// "derivationEvents.derivates", |
|
338 |
// "annotations", |
|
339 |
// "markers", |
|
340 |
// "credits", |
|
341 |
// "extensions", |
|
342 |
// "rights", |
|
343 |
// "sources" |
|
344 |
// }); |
|
345 |
// Map<Object, List<String>> specimenPropertyPathMap = |
|
346 |
// new HashMap<Object, List<String>>(); |
|
347 |
// specimenPropertyPathMap.put(SpecimenOrObservationBase.class,specimenPropertyPaths); |
|
348 |
// return specimenPropertyPathMap; |
|
349 |
// } |
|
260 | 350 |
|
261 | 351 |
/** |
262 | 352 |
* Refreshes the derivate hierarchy tree and expands the tree |
... | ... | |
283 | 373 |
//FIXME:Remoting hack to make this work for remoting |
284 | 374 |
//This should actually be resolved using remoting post operations |
285 | 375 |
public void remove(Object obj) { |
286 |
Set<SpecimenOrObservationBase<?>> rootEntities = ((DerivateViewEditorInput) getEditorInput()).getRootEntities(); |
|
287 |
rootEntities.remove(obj); |
|
288 |
viewer.setInput(rootEntities); |
|
376 |
rootElements.remove(obj); |
|
377 |
viewer.setInput(rootElements); |
|
289 | 378 |
} |
290 | 379 |
|
291 | 380 |
private void generateMultiLinkSingleReads() { |
... | ... | |
332 | 421 |
return true; |
333 | 422 |
} |
334 | 423 |
|
335 |
@Override |
|
336 |
public void dispose() { |
|
337 |
((DerivateViewEditorInput) getEditorInput()).dispose(); |
|
338 |
super.dispose(); |
|
339 |
} |
|
340 |
|
|
341 | 424 |
|
342 | 425 |
@Override |
343 | 426 |
public boolean canAttachMedia() { |
344 | 427 |
return true; |
345 | 428 |
} |
429 |
|
|
430 |
public void removeHierarchy(SpecimenOrObservationBase<?> specimenOrObservationBase) { |
|
431 |
SpecimenOrObservationBase<?> rootElement = derivateToRootEntityMap.remove(specimenOrObservationBase); |
|
432 |
rootElements.remove(rootElement); |
|
433 |
} |
|
434 |
|
|
435 |
public void addHierarchy(FieldUnit fieldUnit) { |
|
436 |
rootElements.add(fieldUnit); |
|
437 |
derivateToRootEntityMap.put(fieldUnit, fieldUnit); |
|
438 |
} |
|
439 |
|
|
440 |
// @Override |
|
441 |
// public ICdmEntitySession getCdmEntitySession() { |
|
442 |
// return conversation; |
|
443 |
// } |
|
346 | 444 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateViewEditorInput.java | ||
---|---|---|
9 | 9 |
*/ |
10 | 10 |
package eu.etaxonomy.taxeditor.editor.view.derivate; |
11 | 11 |
|
12 |
import java.util.ArrayList; |
|
13 |
import java.util.Arrays; |
|
14 |
import java.util.Collection; |
|
15 |
import java.util.HashMap; |
|
16 |
import java.util.HashSet; |
|
17 |
import java.util.List; |
|
18 |
import java.util.Map; |
|
19 | 12 |
import java.util.Set; |
20 | 13 |
import java.util.UUID; |
21 | 14 |
|
... | ... | |
23 | 16 |
import org.eclipse.ui.IEditorInput; |
24 | 17 |
import org.eclipse.ui.IPersistableElement; |
25 | 18 |
|
26 |
import eu.etaxonomy.cdm.api.application.CdmApplicationState; |
|
27 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
|
28 |
import eu.etaxonomy.cdm.api.service.IOccurrenceService; |
|
29 |
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit; |
|
30 | 19 |
import eu.etaxonomy.cdm.model.occurrence.FieldUnit; |
31 | 20 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
32 |
import eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput; |
|
33 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
|
34 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
35 |
import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateLabelProvider; |
|
36 | 21 |
|
37 | 22 |
/** |
38 | 23 |
* Editor input for the {@link DerivateView} which holds the currently selected derivate for which |
... | ... | |
42 | 27 |
* @date 25.11.2013 |
43 | 28 |
* |
44 | 29 |
*/ |
45 |
public class DerivateViewEditorInput extends CdmEntitySessionInput implements IEditorInput {
|
|
30 |
public class DerivateViewEditorInput implements IEditorInput { |
|
46 | 31 |
|
47 | 32 |
/** |
48 |
* The selected derivate {@link UUID}s
|
|
33 |
* The {@link UUID}s of the derivative entities
|
|
49 | 34 |
*/ |
50 |
private Set<SpecimenOrObservationBase<?>> derivateEntities; |
|
51 |
/** |
|
52 |
* List of the {@link UUID}s of the root elements of the hierarchy (may be the same objects as the derivates) |
|
53 |
*/ |
|
54 |
private Set<SpecimenOrObservationBase<?>> rootEntities; |
|
55 |
private Set<UUID> rootUUIDs; |
|
56 |
|
|
57 |
private final ConversationHolder conversationHolder; |
|
58 |
|
|
59 |
private static final List<String> SPECIMEN_INIT_STRATEGY = Arrays.asList(new String[] { |
|
60 |
"descriptions", |
|
61 |
"annotations", |
|
62 |
"markers", |
|
63 |
"credits", |
|
64 |
"extensions", |
|
65 |
"rights", |
|
66 |
"sources", |
|
67 |
"derivationEvents.derivatives.annotations", |
|
68 |
"derivationEvents.derivatives.markers", |
|
69 |
"derivationEvents.derivatives.credits", |
|
70 |
"derivationEvents.derivatives.extensions", |
|
71 |
"derivationEvents.derivatives.rights", |
|
72 |
"derivationEvents.derivatives.sources" |
|
73 |
}); |
|
35 |
private Set<UUID> derivativeUUIDs; |
|
74 | 36 |
|
75 | 37 |
/** |
76 | 38 |
* Creates an editor input for the {@link DerivateView} with the currently selected derivates and the |
77 | 39 |
* corresponding {@link FieldUnit}s (both may be the same object). |
78 | 40 |
* @param derivateUuids the {@link UUID}s of the derivates for which the derivate hierarchy should be shown |
79 |
* @param rootUUIDs the root of the hierarchy
|
|
41 |
* @param derivativeUUIDs the root of the hierarchy
|
|
80 | 42 |
*/ |
81 | 43 |
public DerivateViewEditorInput(Set<UUID> derivateUuids) { |
82 |
super(false); |
|
83 |
rootUUIDs = derivateUuids; |
|
84 |
//FIXME:Remoting temporary hack for making the sessions work |
|
85 |
//This should ideally be changed to initializing the |
|
86 |
//super class with a collection of (id) objects which can |
|
87 |
//then be used for the hashCode, equals methods |
|
88 |
initSession(); |
|
89 |
this.conversationHolder = CdmStore.createConversation(); |
|
90 |
updateRootEntities(derivateUuids); |
|
91 |
|
|
44 |
this.derivativeUUIDs = derivateUuids; |
|
92 | 45 |
} |
93 | 46 |
|
94 | 47 |
/* (non-Javadoc) |
... | ... | |
142 | 95 |
} |
143 | 96 |
|
144 | 97 |
private String getEditorName() { |
145 |
String name = null; |
|
146 |
for( SpecimenOrObservationBase<?> specimen : rootEntities){ |
|
147 |
if(specimen!=null){ |
|
148 |
if(name==null){ |
|
149 |
name = DerivateLabelProvider.getDerivateText(specimen, conversationHolder); |
|
150 |
} |
|
151 |
else{ |
|
152 |
name += " + "+DerivateLabelProvider.getDerivateText(specimen, conversationHolder); //$NON-NLS-1$ |
|
153 |
} |
|
154 |
} |
|
155 |
} |
|
156 |
if(name==null){ |
|
157 |
name = "Derivative Editor"; |
|
158 |
} |
|
159 |
return name; |
|
98 |
return "Derivative Editor"; |
|
160 | 99 |
} |
161 | 100 |
|
162 |
@Override |
|
163 |
public Set<SpecimenOrObservationBase<?>> getRootEntities() { |
|
164 |
return rootEntities; |
|
165 |
} |
|
166 |
|
|
167 |
public Set<SpecimenOrObservationBase<?>> getDerivateEntities() { |
|
168 |
return derivateEntities; |
|
169 |
} |
|
170 |
|
|
171 |
public void addRootEntity(SpecimenOrObservationBase<?> root){ |
|
172 |
rootEntities.add(root); |
|
173 |
} |
|
174 |
|
|
175 |
|
|
176 |
public ConversationHolder getConversationHolder() { |
|
177 |
return conversationHolder; |
|
101 |
/** |
|
102 |
* @return the derivativeUUIDs |
|
103 |
*/ |
|
104 |
public Set<UUID> getDerivativeUUIDs() { |
|
105 |
return derivativeUUIDs; |
|
178 | 106 |
} |
179 | 107 |
|
180 | 108 |
@Override |
181 | 109 |
public int hashCode() { |
182 | 110 |
final int prime = 31; |
183 | 111 |
int result = 1; |
184 |
result = prime * result + ((rootUUIDs == null) ? 0 : rootUUIDs.hashCode());
|
|
112 |
result = prime * result + ((derivativeUUIDs == null) ? 0 : derivativeUUIDs.hashCode());
|
|
185 | 113 |
return result; |
186 | 114 |
} |
187 | 115 |
|
... | ... | |
197 | 125 |
return false; |
198 | 126 |
} |
199 | 127 |
DerivateViewEditorInput other = (DerivateViewEditorInput) obj; |
200 |
if (rootUUIDs == null) {
|
|
201 |
if (other.rootUUIDs != null) {
|
|
128 |
if (derivativeUUIDs == null) {
|
|
129 |
if (other.derivativeUUIDs != null) {
|
|
202 | 130 |
return false; |
203 | 131 |
} |
204 |
} else if (!rootUUIDs.equals(other.rootUUIDs)) {
|
|
132 |
} else if (!derivativeUUIDs.equals(other.derivativeUUIDs)) {
|
|
205 | 133 |
return false; |
206 | 134 |
} |
207 | 135 |
return true; |
208 | 136 |
} |
209 | 137 |
|
210 |
@Override |
|
211 |
public void merge() { |
|
212 |
if(CdmStore.getCurrentSessionManager().isRemoting()) { |
|
213 |
CdmApplicationState.getCurrentAppConfig().getOccurrenceService().merge(new ArrayList(getRootEntities()), true); |
|
214 |
} |
|
215 |
|
|
216 |
} |
|
217 |
|
|
218 |
@Override |
|
219 |
public Map<Object, List<String>> getPropertyPathsMap() { |
|
220 |
List<String> specimenPropertyPaths = Arrays.asList(new String[] { |
|
221 |
"descriptions", |
|
222 |
"derivationEvents.derivates", |
|
223 |
"annotations", |
|
224 |
"markers", |
|
225 |
"credits", |
|
226 |
"extensions", |
|
227 |
"rights", |
|
228 |
"sources" |
|
229 |
}); |
|
230 |
Map<Object, List<String>> specimenPropertyPathMap = |
|
231 |
new HashMap<Object, List<String>>(); |
|
232 |
specimenPropertyPathMap.put(SpecimenOrObservationBase.class,specimenPropertyPaths); |
|
233 |
return specimenPropertyPathMap; |
|
234 |
} |
|
235 |
|
|
236 |
public void updateRootEntities(Collection<UUID> derivateUuids) { |
|
237 |
this.derivateEntities = new HashSet<SpecimenOrObservationBase<?>>(); |
|
238 |
this.rootEntities = new HashSet<SpecimenOrObservationBase<?>>(); |
|
239 |
for (UUID uuid : derivateUuids) { |
|
240 |
SpecimenOrObservationBase<?> derivate = CdmStore.getService(IOccurrenceService.class).load(uuid, SPECIMEN_INIT_STRATEGY); |
|
241 |
derivateEntities.add(derivate); |
|
242 |
if(derivate instanceof FieldUnit){ |
|
243 |
rootEntities.add(derivate); |
|
244 |
} |
|
245 |
else if(derivate instanceof DerivedUnit){ |
|
246 |
SpecimenOrObservationBase<?> topMostDerivate = EditorUtil.getTopMostDerivate(derivate); |
|
247 |
if(topMostDerivate!=null){ |
|
248 |
rootEntities.add(topMostDerivate); |
|
249 |
} |
|
250 |
} |
|
251 |
} |
|
252 |
if(rootEntities.isEmpty()){ |
|
253 |
rootEntities = derivateEntities; |
|
254 |
} |
|
255 |
} |
|
256 |
|
|
257 | 138 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/CreateFieldUnitHandler.java | ||
---|---|---|
8 | 8 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
9 | 9 |
import eu.etaxonomy.cdm.model.occurrence.FieldUnit; |
10 | 10 |
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView; |
11 |
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput; |
|
12 | 11 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
13 | 12 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
14 | 13 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
... | ... | |
26 | 25 |
FieldUnit fieldUnit = FieldUnit.NewInstance(); |
27 | 26 |
fieldUnit = CdmBase.deproxy(CdmStore.getService(IOccurrenceService.class).save(fieldUnit), FieldUnit.class); |
28 | 27 |
derivateView.getConversationHolder().commit(); |
29 |
DerivateViewEditorInput input = (DerivateViewEditorInput) derivateView.getEditorInput(); |
|
30 |
input.addRootEntity(fieldUnit); |
|
28 |
derivateView.addHierarchy(fieldUnit); |
|
31 | 29 |
derivateView.refreshTree(); |
32 | 30 |
} |
33 | 31 |
return null; |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/searchFilter/DerivateSearchComposite.java | ||
---|---|---|
76 | 76 |
lblNewLabel.setText("Taxon assignment"); |
77 | 77 |
|
78 | 78 |
comboTaxonAssignment = new Combo(this, SWT.NONE); |
79 |
comboTaxonAssignment.setItems(new String[] { "Yes", "No", "All" });
|
|
79 |
comboTaxonAssignment.setItems(new String[] { "All", "Yes", "No" });
|
|
80 | 80 |
comboTaxonAssignment.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); |
81 | 81 |
formToolkit.adapt(comboTaxonAssignment); |
82 | 82 |
formToolkit.paintBordersFor(comboTaxonAssignment); |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/searchFilter/DerivateSearchCompositeController.java | ||
---|---|---|
101 | 101 |
} |
102 | 102 |
|
103 | 103 |
//filter out (un-)assigned specimens |
104 |
DerivateViewEditorInput editorInput = (DerivateViewEditorInput)derivativeEditor.getEditorInput(); |
|
104 | 105 |
int selectionIndex = derivateSearchComposite.getComboTaxonAssignment().getSelectionIndex(); |
105 |
List<SpecimenOrObservationBase> specimensWithAssociations = new ArrayList<SpecimenOrObservationBase>();
|
|
106 |
List<SpecimenOrObservationBase<?>> specimenWithAssociations = new ArrayList<SpecimenOrObservationBase<?>>();
|
|
106 | 107 |
if(selectionIndex!=DerivateSearchComposite.ALL_SPECIMENS){ |
107 | 108 |
for (SpecimenOrObservationBase specimenOrObservationBase : occurrences) { |
108 | 109 |
Collection<TaxonBase<?>> associatedTaxa = CdmStore.getService(IOccurrenceService.class).listAssociatedTaxa(specimenOrObservationBase, null, null, null, null); |
109 | 110 |
if(!associatedTaxa.isEmpty()){ |
110 |
specimensWithAssociations.add(specimenOrObservationBase);
|
|
111 |
specimenWithAssociations.add(specimenOrObservationBase); |
|
111 | 112 |
} |
112 | 113 |
} |
113 | 114 |
} |
114 |
if(selectionIndex==DerivateSearchComposite.ASSIGNED_SPECIMENS){ |
|
115 |
occurrences = specimensWithAssociations;
|
|
116 |
}
|
|
117 |
else if(selectionIndex==DerivateSearchComposite.UNASSIGNED_SPECIMENS){
|
|
118 |
occurrences.retainAll(specimensWithAssociations);
|
|
115 |
if(selectionIndex==DerivateSearchComposite.UNASSIGNED_SPECIMENS){
|
|
116 |
for (SpecimenOrObservationBase<?> specimenOrObservationBase : specimenWithAssociations) {
|
|
117 |
derivativeEditor.removeHierarchy(specimenOrObservationBase);
|
|
118 |
}
|
|
119 |
derivativeEditor.updateRootEntities();
|
|
119 | 120 |
} |
120 |
|
|
121 |
List<UUID> derivateUuids = new ArrayList<UUID>(); |
|
122 |
for (SpecimenOrObservationBase specimenOrObservationBase : occurrences) { |
|
123 |
derivateUuids.add(specimenOrObservationBase.getUuid()); |
|
121 |
else{ |
|
122 |
if(selectionIndex==DerivateSearchComposite.ASSIGNED_SPECIMENS){ |
|
123 |
occurrences = new ArrayList<SpecimenOrObservationBase>(specimenWithAssociations); |
|
124 |
} |
|
125 |
List<UUID> derivateUuids = new ArrayList<UUID>(); |
|
126 |
for (SpecimenOrObservationBase specimenOrObservationBase : occurrences) { |
|
127 |
derivateUuids.add(specimenOrObservationBase.getUuid()); |
|
128 |
} |
|
129 |
derivativeEditor.updateRootEntities(derivateUuids); |
|
124 | 130 |
} |
125 |
//update tree |
|
126 |
DerivateViewEditorInput editorInput = (DerivateViewEditorInput)derivativeEditor.getEditorInput(); |
|
127 |
editorInput.updateRootEntities(derivateUuids); |
|
128 |
derivativeEditor.getViewer().setInput(editorInput.getRootEntities()); |
|
129 |
derivativeEditor.refreshTree(); |
|
130 | 131 |
} |
131 | 132 |
|
132 | 133 |
@Override |
Also available in: Unified diff
Implement taxon assignment filter and refactor DerivativeEditor