1
|
package eu.etaxonomy.taxeditor.editor.view.derivate;
|
2
|
|
3
|
import java.util.ArrayList;
|
4
|
import java.util.Arrays;
|
5
|
import java.util.Collection;
|
6
|
import java.util.HashMap;
|
7
|
import java.util.HashSet;
|
8
|
import java.util.List;
|
9
|
import java.util.Map;
|
10
|
import java.util.Set;
|
11
|
import java.util.UUID;
|
12
|
|
13
|
import org.eclipse.core.runtime.IProgressMonitor;
|
14
|
import org.eclipse.jface.action.MenuManager;
|
15
|
import org.eclipse.jface.util.LocalSelectionTransfer;
|
16
|
import org.eclipse.jface.viewers.AbstractTreeViewer;
|
17
|
import org.eclipse.jface.viewers.ISelection;
|
18
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
19
|
import org.eclipse.jface.viewers.StructuredSelection;
|
20
|
import org.eclipse.jface.viewers.TreeNode;
|
21
|
import org.eclipse.jface.viewers.TreeSelection;
|
22
|
import org.eclipse.jface.viewers.TreeViewer;
|
23
|
import org.eclipse.swt.SWT;
|
24
|
import org.eclipse.swt.dnd.DND;
|
25
|
import org.eclipse.swt.dnd.Transfer;
|
26
|
import org.eclipse.swt.layout.GridData;
|
27
|
import org.eclipse.swt.layout.GridLayout;
|
28
|
import org.eclipse.swt.widgets.Composite;
|
29
|
import org.eclipse.swt.widgets.Control;
|
30
|
import org.eclipse.swt.widgets.Menu;
|
31
|
import org.eclipse.swt.widgets.Tree;
|
32
|
import org.eclipse.ui.IEditorInput;
|
33
|
import org.eclipse.ui.IEditorPart;
|
34
|
import org.eclipse.ui.IEditorSite;
|
35
|
import org.eclipse.ui.IMemento;
|
36
|
import org.eclipse.ui.ISelectionListener;
|
37
|
import org.eclipse.ui.ISelectionService;
|
38
|
import org.eclipse.ui.IWorkbenchPart;
|
39
|
import org.eclipse.ui.PartInitException;
|
40
|
import org.eclipse.ui.part.EditorPart;
|
41
|
|
42
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
43
|
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
|
44
|
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
|
45
|
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
46
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
47
|
import eu.etaxonomy.cdm.model.molecular.SingleRead;
|
48
|
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
|
49
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
|
50
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
51
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
52
|
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
|
53
|
import eu.etaxonomy.taxeditor.editor.EditorUtil;
|
54
|
import eu.etaxonomy.taxeditor.editor.Messages;
|
55
|
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
|
56
|
import eu.etaxonomy.taxeditor.editor.view.derivate.searchFilter.DerivateSearchCompositeController;
|
57
|
import eu.etaxonomy.taxeditor.model.IContextListener;
|
58
|
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
|
59
|
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
|
60
|
import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData;
|
61
|
import eu.etaxonomy.taxeditor.model.IPartContentHasMedia;
|
62
|
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
|
63
|
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
|
64
|
import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
|
65
|
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
|
66
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
67
|
import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateContentProvider;
|
68
|
import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateLabelProvider;
|
69
|
|
70
|
/**
|
71
|
* Displays the derivate hierarchy of the specimen specified in the editor input.
|
72
|
*
|
73
|
*/
|
74
|
public class DerivateView extends EditorPart implements IPartContentHasFactualData, IConversationEnabled,
|
75
|
ICdmEntitySessionEnabled, IDirtyMarkable, IPostOperationEnabled, IPartContentHasDetails, IPartContentHasSupplementalData, IPartContentHasMedia,
|
76
|
IContextListener, ISelectionListener {
|
77
|
public static final String ID = "eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView"; //$NON-NLS-1$
|
78
|
|
79
|
public static final String YOU_NEED_TO_SAVE_BEFORE_PERFORMING_THIS_ACTION = Messages.DerivateView_YOU_NEED_TO_SAVE;
|
80
|
public static final String VIEW_HAS_UNSAVED_CHANGES = Messages.DerivateView_UNSAVED_CHANGES;
|
81
|
|
82
|
private static final List<String> SPECIMEN_INIT_STRATEGY = Arrays.asList(new String[] {
|
83
|
"descriptions",
|
84
|
"annotations",
|
85
|
"markers",
|
86
|
"credits",
|
87
|
"extensions",
|
88
|
"rights",
|
89
|
"sources",
|
90
|
"derivationEvents.derivatives.annotations",
|
91
|
"derivationEvents.derivatives.markers",
|
92
|
"derivationEvents.derivatives.credits",
|
93
|
"derivationEvents.derivatives.extensions",
|
94
|
"derivationEvents.derivatives.rights",
|
95
|
"derivationEvents.derivatives.sources"
|
96
|
});
|
97
|
|
98
|
private ConversationHolder conversation;
|
99
|
|
100
|
private TreeViewer viewer;
|
101
|
|
102
|
private boolean isDirty;
|
103
|
|
104
|
private final int dndOperations = DND.DROP_MOVE;
|
105
|
|
106
|
private DerivateLabelProvider labelProvider;
|
107
|
|
108
|
private DerivateContentProvider contentProvider;
|
109
|
|
110
|
private DerivateSearchCompositeController derivateSearchCompositeController;
|
111
|
|
112
|
/**
|
113
|
* A map with keys being the derivative entities belonging to the {@link UUID}s passed to the constructor
|
114
|
* and values being the root elements of the hierarchy (may be the same objects as the derivative entities)
|
115
|
*/
|
116
|
private Map<SpecimenOrObservationBase<?>, SpecimenOrObservationBase<?>> derivateToRootEntityMap;
|
117
|
|
118
|
/**
|
119
|
* The set of root elements
|
120
|
*/
|
121
|
private Set<SpecimenOrObservationBase<?>> rootElements;
|
122
|
|
123
|
private ICdmEntitySession cdmEntitySession;
|
124
|
|
125
|
/**
|
126
|
* <code>true</code> if this view is listening to selection changes
|
127
|
*/
|
128
|
private boolean listenToSelectionChange;
|
129
|
|
130
|
private Taxon selectedTaxon;
|
131
|
|
132
|
private ISelectionService selectionService;
|
133
|
|
134
|
/**
|
135
|
* Default constructor
|
136
|
*/
|
137
|
public DerivateView() {
|
138
|
}
|
139
|
|
140
|
|
141
|
/**
|
142
|
* {@inheritDoc}
|
143
|
*/
|
144
|
@Override
|
145
|
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
|
146
|
this.setSite(site);
|
147
|
this.setInput(input);
|
148
|
this.derivateToRootEntityMap = new HashMap<SpecimenOrObservationBase<?>, SpecimenOrObservationBase<?>>();
|
149
|
this.rootElements = new HashSet<SpecimenOrObservationBase<?>>();
|
150
|
|
151
|
if (CdmStore.isActive() && conversation == null) {
|
152
|
conversation = CdmStore.createConversation();
|
153
|
}
|
154
|
if (CdmStore.isActive()) {
|
155
|
cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
|
156
|
}
|
157
|
//listen to context changes
|
158
|
CdmStore.getContextManager().addContextListener(this);
|
159
|
}
|
160
|
|
161
|
@Override
|
162
|
public void createPartControl(Composite parent) {
|
163
|
|
164
|
parent.setLayout(new GridLayout());
|
165
|
|
166
|
//---search and filter---
|
167
|
derivateSearchCompositeController = new DerivateSearchCompositeController(parent, this);
|
168
|
GridData gridDataSearchBar = new GridData();
|
169
|
gridDataSearchBar.horizontalAlignment = GridData.FILL;
|
170
|
gridDataSearchBar.grabExcessHorizontalSpace = true;
|
171
|
derivateSearchCompositeController.setLayoutData(gridDataSearchBar);
|
172
|
derivateSearchCompositeController.setEnabled(CdmStore.isActive());
|
173
|
|
174
|
//---tree viewer---
|
175
|
viewer = new TreeViewer(new Tree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION));
|
176
|
GridData gridDataTree = new GridData();
|
177
|
gridDataTree.horizontalAlignment = GridData.FILL;
|
178
|
gridDataTree.verticalAlignment = GridData.FILL;
|
179
|
gridDataTree.grabExcessVerticalSpace = true;
|
180
|
gridDataTree.grabExcessHorizontalSpace = true;
|
181
|
viewer.getTree().setLayoutData(gridDataTree);
|
182
|
contentProvider = new DerivateContentProvider();
|
183
|
viewer.setContentProvider(contentProvider);
|
184
|
labelProvider = new DerivateLabelProvider();
|
185
|
labelProvider.setConversation(conversation);
|
186
|
viewer.setLabelProvider(labelProvider);
|
187
|
viewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
|
188
|
viewer.getTree().setEnabled(CdmStore.isActive());
|
189
|
// Propagate selection from viewer
|
190
|
getSite().setSelectionProvider(viewer);
|
191
|
|
192
|
//listen to selection changes
|
193
|
selectionService = getSite().getWorkbenchWindow().getSelectionService();
|
194
|
selectionService.addSelectionListener(this);
|
195
|
|
196
|
//create context menu
|
197
|
MenuManager menuManager = new MenuManager();
|
198
|
menuManager.setRemoveAllWhenShown(true);
|
199
|
getSite().registerContextMenu(menuManager, viewer);
|
200
|
Control control = viewer.getControl();
|
201
|
Menu menu = menuManager.createContextMenu(control);
|
202
|
control.setMenu(menu);
|
203
|
|
204
|
//init tree
|
205
|
updateRootEntities();
|
206
|
//reset status bar
|
207
|
getEditorSite().getActionBars().getStatusLineManager().setMessage("");
|
208
|
|
209
|
//add drag'n'drop support
|
210
|
Transfer[] transfers = new Transfer[] {LocalSelectionTransfer.getTransfer(),};
|
211
|
viewer.addDragSupport(dndOperations, transfers, new DerivateDragListener(this));
|
212
|
viewer.addDropSupport(dndOperations, transfers, new DerivateDropListener(this));
|
213
|
}
|
214
|
|
215
|
public void updateRootEntities() {
|
216
|
updateRootEntities((Collection)null);
|
217
|
}
|
218
|
|
219
|
public void updateRootEntities(Collection<UUID> derivativeUuids) {
|
220
|
if(conversation!=null){
|
221
|
if (!conversation.isBound()) {
|
222
|
conversation.bind();
|
223
|
}
|
224
|
/*
|
225
|
* If the active session is not the session of the Derivative Editor
|
226
|
* then we will save the active session for later, bind temporarily
|
227
|
* to our session and rebind to the original session when we are
|
228
|
* done. This happens e.g. if a selection change happens in the
|
229
|
* taxon editor and "Link with editor" is enabled. The selection
|
230
|
* change event and thus the loading in updateRootEntities() happens
|
231
|
* in the session of the taxon editor.
|
232
|
*/
|
233
|
ICdmEntitySession previousCdmEntitySession = CdmStore.getCurrentSessionManager().getActiveSession();
|
234
|
if(cdmEntitySession != null) {
|
235
|
cdmEntitySession.bind();
|
236
|
}
|
237
|
|
238
|
List<SpecimenOrObservationBase> derivates = null;
|
239
|
if(derivativeUuids!=null){
|
240
|
this.derivateToRootEntityMap = new HashMap<SpecimenOrObservationBase<?>, SpecimenOrObservationBase<?>>();
|
241
|
this.rootElements = new HashSet<SpecimenOrObservationBase<?>>();
|
242
|
derivates = CdmStore.getService(IOccurrenceService.class).load(new ArrayList(derivativeUuids), SPECIMEN_INIT_STRATEGY);
|
243
|
}
|
244
|
updateRootEntities(derivates);
|
245
|
previousCdmEntitySession.bind();
|
246
|
}
|
247
|
}
|
248
|
|
249
|
|
250
|
public void updateRootEntities(List<SpecimenOrObservationBase> derivates) {
|
251
|
|
252
|
if(derivates!=null){
|
253
|
this.derivateToRootEntityMap = new HashMap<SpecimenOrObservationBase<?>, SpecimenOrObservationBase<?>>();
|
254
|
this.rootElements = new HashSet<SpecimenOrObservationBase<?>>();
|
255
|
for (SpecimenOrObservationBase derivate : derivates) {
|
256
|
|
257
|
if(derivate instanceof FieldUnit){
|
258
|
derivateToRootEntityMap.put(derivate, derivate);
|
259
|
}
|
260
|
else {
|
261
|
SpecimenOrObservationBase<?> topMostDerivate = EditorUtil.getTopMostDerivate(derivate);
|
262
|
if(topMostDerivate!=null){
|
263
|
derivateToRootEntityMap.put(derivate, topMostDerivate);
|
264
|
}
|
265
|
else{
|
266
|
derivateToRootEntityMap.put(derivate, derivate);
|
267
|
}
|
268
|
}
|
269
|
}
|
270
|
for (SpecimenOrObservationBase<?> specimen : derivateToRootEntityMap.values()) {
|
271
|
rootElements.add(specimen);
|
272
|
}
|
273
|
}
|
274
|
labelProvider.updateLabelCache(rootElements);
|
275
|
viewer.setInput(rootElements);
|
276
|
|
277
|
getEditorSite().getActionBars().getStatusLineManager().setMessage(rootElements.size() +" derivative hierarchies found");
|
278
|
|
279
|
//set selection to derivatives if the filter criteria
|
280
|
//taxon assignment or or derivative type are set
|
281
|
if(derivates!=null && !derivateSearchCompositeController.isDefaultSearch()){
|
282
|
List<TreeNode> nodesToSelect = new ArrayList<TreeNode>();
|
283
|
for (SpecimenOrObservationBase specimenOrObservationBase : derivates) {
|
284
|
nodesToSelect.add(new TreeNode(specimenOrObservationBase));
|
285
|
}
|
286
|
viewer.setSelection(new StructuredSelection(nodesToSelect));
|
287
|
}
|
288
|
else{
|
289
|
viewer.setSelection(null);
|
290
|
}
|
291
|
|
292
|
}
|
293
|
|
294
|
public void updateLabelCache(){
|
295
|
labelProvider.updateLabelCache(rootElements);
|
296
|
}
|
297
|
|
298
|
@Override
|
299
|
public void doSave(IProgressMonitor monitor) {
|
300
|
String taskName = Messages.DerivateView_SAVING_HIERARCHY;
|
301
|
monitor.beginTask(taskName, 3);
|
302
|
if (!conversation.isBound()) {
|
303
|
conversation.bind();
|
304
|
}
|
305
|
monitor.worked(1);
|
306
|
|
307
|
// commit the conversation and start a new transaction immediately
|
308
|
conversation.commit(true);
|
309
|
|
310
|
if(CdmStore.getCurrentSessionManager().isRemoting()) {
|
311
|
CdmStore.getService(IOccurrenceService.class).merge(new ArrayList<SpecimenOrObservationBase>(rootElements), true);
|
312
|
}
|
313
|
monitor.worked(1);
|
314
|
|
315
|
this.setDirty(false);
|
316
|
monitor.worked(1);
|
317
|
monitor.done();
|
318
|
firePropertyChange(PROP_DIRTY);
|
319
|
refreshTree();
|
320
|
}
|
321
|
|
322
|
@Override
|
323
|
public void doSaveAs() {
|
324
|
}
|
325
|
|
326
|
@Override
|
327
|
public String getTitleToolTip() {
|
328
|
return Messages.DerivateView_DERIVATIVE_EDITOR;
|
329
|
}
|
330
|
|
331
|
@Override
|
332
|
public boolean isDirty() {
|
333
|
return isDirty;
|
334
|
}
|
335
|
|
336
|
/**
|
337
|
* @param isDirty the isDirty to set
|
338
|
*/
|
339
|
public void setDirty(boolean isDirty) {
|
340
|
this.isDirty = isDirty;
|
341
|
}
|
342
|
|
343
|
@Override
|
344
|
public boolean isSaveAsAllowed() {
|
345
|
return false;
|
346
|
}
|
347
|
|
348
|
@Override
|
349
|
public void setFocus() {
|
350
|
viewer.getControl().setFocus();
|
351
|
//make sure to bind again if maybe in another view the conversation was unbound
|
352
|
if(conversation!=null && !conversation.isBound()){
|
353
|
conversation.bind();
|
354
|
}
|
355
|
if(cdmEntitySession != null) {
|
356
|
cdmEntitySession.bind();
|
357
|
}
|
358
|
}
|
359
|
|
360
|
@Override
|
361
|
public void update(CdmDataChangeMap changeEvents) {
|
362
|
}
|
363
|
|
364
|
@Override
|
365
|
public ConversationHolder getConversationHolder() {
|
366
|
return conversation;
|
367
|
}
|
368
|
|
369
|
@Override
|
370
|
public void changed(Object element) {
|
371
|
setDirty(true);
|
372
|
firePropertyChange(IEditorPart.PROP_DIRTY);
|
373
|
viewer.update(new TreeNode(element), null);
|
374
|
}
|
375
|
|
376
|
@Override
|
377
|
public void forceDirty() {
|
378
|
changed(null);
|
379
|
}
|
380
|
|
381
|
@Override
|
382
|
public Map<Object, List<String>> getPropertyPathsMap() {
|
383
|
List<String> specimenPropertyPaths = Arrays.asList(new String[] {
|
384
|
"descriptions",
|
385
|
"derivationEvents.derivates",
|
386
|
"annotations",
|
387
|
"markers",
|
388
|
"credits",
|
389
|
"extensions",
|
390
|
"rights",
|
391
|
"sources"
|
392
|
});
|
393
|
Map<Object, List<String>> specimenPropertyPathMap =
|
394
|
new HashMap<Object, List<String>>();
|
395
|
specimenPropertyPathMap.put(SpecimenOrObservationBase.class,specimenPropertyPaths);
|
396
|
return specimenPropertyPathMap;
|
397
|
}
|
398
|
|
399
|
/**
|
400
|
* Refreshes the derivate hierarchy tree and expands the tree
|
401
|
* to show and select the given object.
|
402
|
*
|
403
|
* @param expandTo the object to which the tree should be expanded
|
404
|
*/
|
405
|
public void refreshTree(Object expandTo){
|
406
|
refreshTree();
|
407
|
TreeSelection selection = (TreeSelection) viewer.getSelection();
|
408
|
viewer.expandToLevel(selection.getFirstElement(), 1);
|
409
|
viewer.setSelection(new StructuredSelection(new TreeNode(expandTo)));
|
410
|
}
|
411
|
|
412
|
/**
|
413
|
* Refreshes the derivate hierarchy tree
|
414
|
*/
|
415
|
public void refreshTree(){
|
416
|
viewer.refresh();
|
417
|
}
|
418
|
|
419
|
//FIXME:Remoting hack to make this work for remoting
|
420
|
//This should actually be resolved using remoting post operations
|
421
|
public void remove(Object obj) {
|
422
|
rootElements.remove(obj);
|
423
|
viewer.setInput(rootElements);
|
424
|
}
|
425
|
|
426
|
/**
|
427
|
* @return a set of {@link SingleRead}s that have multiple parents
|
428
|
*/
|
429
|
public Set<SingleRead> getMultiLinkSingleReads() {
|
430
|
return DerivateLabelProvider.getMultiLinkSingleReads();
|
431
|
}
|
432
|
|
433
|
public Object getSelectionInput() {
|
434
|
return selectedTaxon;
|
435
|
}
|
436
|
|
437
|
public DerivateLabelProvider getLabelProvider() {
|
438
|
return labelProvider;
|
439
|
}
|
440
|
|
441
|
@Override
|
442
|
public boolean postOperation(CdmBase objectAffectedByOperation) {
|
443
|
refreshTree();
|
444
|
if(objectAffectedByOperation!=null){
|
445
|
changed(objectAffectedByOperation);
|
446
|
}
|
447
|
return true;
|
448
|
}
|
449
|
|
450
|
@Override
|
451
|
public boolean onComplete() {
|
452
|
return true;
|
453
|
}
|
454
|
|
455
|
|
456
|
@Override
|
457
|
public boolean canAttachMedia() {
|
458
|
return true;
|
459
|
}
|
460
|
|
461
|
public void addFieldUnit(FieldUnit fieldUnit) {
|
462
|
rootElements.add(fieldUnit);
|
463
|
derivateToRootEntityMap.put(fieldUnit, fieldUnit);
|
464
|
}
|
465
|
|
466
|
@Override
|
467
|
public ICdmEntitySession getCdmEntitySession() {
|
468
|
return cdmEntitySession;
|
469
|
}
|
470
|
|
471
|
@Override
|
472
|
public void dispose() {
|
473
|
super.dispose();
|
474
|
if(conversation!=null){
|
475
|
conversation.close();
|
476
|
}
|
477
|
if(cdmEntitySession != null) {
|
478
|
cdmEntitySession.dispose();
|
479
|
}
|
480
|
}
|
481
|
|
482
|
@Override
|
483
|
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
|
484
|
if(viewer.getTree().isDisposed()){
|
485
|
return;
|
486
|
}
|
487
|
if(listenToSelectionChange){
|
488
|
if(part instanceof MultiPageTaxonEditor){
|
489
|
selectedTaxon = ((MultiPageTaxonEditor) part).getTaxon();
|
490
|
}
|
491
|
else if(selection instanceof IStructuredSelection){
|
492
|
Object selectedElement = ((IStructuredSelection) selection).getFirstElement();
|
493
|
if(selectedElement instanceof CdmBase){
|
494
|
if(((CdmBase) selectedElement).isInstanceOf(TaxonNode.class)){
|
495
|
selectedTaxon = HibernateProxyHelper.deproxy(selectedElement, TaxonNode.class).getTaxon();
|
496
|
}
|
497
|
else if(((CdmBase) selectedElement).isInstanceOf(Taxon.class)){
|
498
|
selectedTaxon = HibernateProxyHelper.deproxy(selectedElement, Taxon.class);
|
499
|
}
|
500
|
}
|
501
|
}
|
502
|
if(selectedTaxon!=null){
|
503
|
Collection<SpecimenOrObservationBase> fieldUnits = CdmStore.getService(IOccurrenceService.class).listFieldUnitsByAssociatedTaxon(selectedTaxon, null, null);
|
504
|
Collection<UUID> uuids = new HashSet<UUID>();
|
505
|
for (SpecimenOrObservationBase specimenOrObservationBase : fieldUnits) {
|
506
|
uuids.add(specimenOrObservationBase.getUuid());
|
507
|
}
|
508
|
updateRootEntities(uuids);
|
509
|
setPartName("Derivative Editor: " + selectedTaxon.getName());
|
510
|
}
|
511
|
}
|
512
|
}
|
513
|
|
514
|
public TreeViewer getViewer() {
|
515
|
return viewer;
|
516
|
}
|
517
|
|
518
|
/**
|
519
|
* {@inheritDoc}
|
520
|
*/
|
521
|
@Override
|
522
|
public List<SpecimenOrObservationBase<?>> getRootEntities() {
|
523
|
return new ArrayList<SpecimenOrObservationBase<?>>(rootElements);
|
524
|
}
|
525
|
|
526
|
public void toggleListenToSelectionChange() {
|
527
|
listenToSelectionChange = !listenToSelectionChange;
|
528
|
derivateSearchCompositeController.setEnabled(!listenToSelectionChange);
|
529
|
if(!listenToSelectionChange){
|
530
|
selectedTaxon = null;
|
531
|
setPartName("Derivative Editor");
|
532
|
}
|
533
|
else if(selectedTaxon==null){
|
534
|
setPartName("Derivative Editor [no taxon selected]");
|
535
|
}
|
536
|
}
|
537
|
|
538
|
public boolean isListenToSelectionChange(){
|
539
|
return listenToSelectionChange;
|
540
|
}
|
541
|
|
542
|
/**
|
543
|
* {@inheritDoc}
|
544
|
*/
|
545
|
@Override
|
546
|
public void contextAboutToStop(IMemento memento, IProgressMonitor monitor) {
|
547
|
}
|
548
|
|
549
|
/**
|
550
|
* {@inheritDoc}
|
551
|
*/
|
552
|
@Override
|
553
|
public void contextStop(IMemento memento, IProgressMonitor monitor) {
|
554
|
derivateSearchCompositeController.setEnabled(false);
|
555
|
if(!viewer.getTree().isDisposed()) {
|
556
|
viewer.getTree().setEnabled(false);
|
557
|
viewer.setInput(null);
|
558
|
}
|
559
|
}
|
560
|
|
561
|
/**
|
562
|
* {@inheritDoc}
|
563
|
*/
|
564
|
@Override
|
565
|
public void contextStart(IMemento memento, IProgressMonitor monitor) {
|
566
|
derivateSearchCompositeController.setEnabled(!listenToSelectionChange);
|
567
|
viewer.getTree().setEnabled(true);
|
568
|
refreshTree();
|
569
|
}
|
570
|
|
571
|
/**
|
572
|
* {@inheritDoc}
|
573
|
*/
|
574
|
@Override
|
575
|
public void contextRefresh(IProgressMonitor monitor) {
|
576
|
}
|
577
|
|
578
|
/**
|
579
|
* {@inheritDoc}
|
580
|
*/
|
581
|
@Override
|
582
|
public void workbenchShutdown(IMemento memento, IProgressMonitor monitor) {
|
583
|
}
|
584
|
|
585
|
}
|