Project

General

Profile

Download (22.9 KB) Statistics
| Branch: | Tag: | Revision:
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.Display;
31
import org.eclipse.swt.widgets.Menu;
32
import org.eclipse.swt.widgets.Tree;
33
import org.eclipse.ui.IEditorInput;
34
import org.eclipse.ui.IEditorPart;
35
import org.eclipse.ui.IEditorSite;
36
import org.eclipse.ui.IMemento;
37
import org.eclipse.ui.ISelectionListener;
38
import org.eclipse.ui.ISelectionService;
39
import org.eclipse.ui.IWorkbenchPart;
40
import org.eclipse.ui.PartInitException;
41
import org.eclipse.ui.part.EditorPart;
42

    
43
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
44
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
45
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
46
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
47
import eu.etaxonomy.cdm.model.common.CdmBase;
48
import eu.etaxonomy.cdm.model.molecular.SingleRead;
49
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
50
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
51
import eu.etaxonomy.cdm.model.taxon.Taxon;
52
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
53
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
54
import eu.etaxonomy.taxeditor.editor.EditorUtil;
55
import eu.etaxonomy.taxeditor.editor.Messages;
56
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
57
import eu.etaxonomy.taxeditor.editor.view.derivate.searchFilter.DerivateSearchCompositeController;
58
import eu.etaxonomy.taxeditor.model.IContextListener;
59
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
60
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
61
import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData;
62
import eu.etaxonomy.taxeditor.model.IPartContentHasMedia;
63
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
64
import eu.etaxonomy.taxeditor.model.MessagingUtils;
65
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
66
import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
67
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
68
import eu.etaxonomy.taxeditor.store.CdmStore;
69
import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateContentProvider;
70
import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateLabelProvider;
71

    
72
/**
73
 * Displays the derivate hierarchy of the specimen specified in the editor input.
74
 *
75
 */
76
public class DerivateView extends EditorPart implements IPartContentHasFactualData, IConversationEnabled,
77
        ICdmEntitySessionEnabled, IDirtyMarkable, IPostOperationEnabled, IPartContentHasDetails, IPartContentHasSupplementalData, IPartContentHasMedia,
78
        IContextListener, ISelectionListener {
79
    public static final String ID = "eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView"; //$NON-NLS-1$
80

    
81
    public static final String YOU_NEED_TO_SAVE_BEFORE_PERFORMING_THIS_ACTION = Messages.DerivateView_YOU_NEED_TO_SAVE;
82
    public static final String VIEW_HAS_UNSAVED_CHANGES = Messages.DerivateView_UNSAVED_CHANGES;
83

    
84
    private static final List<String> SPECIMEN_INIT_STRATEGY = Arrays.asList(new String[] {
85
            "descriptions",
86
            "annotations",
87
            "markers",
88
            "credits",
89
            "extensions",
90
            "rights",
91
            "sources",
92
            "derivationEvents.derivatives.annotations",
93
            "derivationEvents.derivatives.markers",
94
            "derivationEvents.derivatives.credits",
95
            "derivationEvents.derivatives.extensions",
96
            "derivationEvents.derivatives.rights",
97
            "derivationEvents.derivatives.sources"
98
    });
99

    
100
	private static final int WARN_THRESHOLD = 200;
101

    
102
    private DelaySelection delaySelection = null;
103
    /**
104
     * This is the monitor for the DelaySelection runnable.
105
     * If it is <code>true</code> then it is currently delaying a selection.
106
     */
107
    private boolean isInDelay;
108

    
109

    
110
    /**
111
     * This class invokes internal_selectionChanged() in a separate thread.
112
     * This allows an asynchronous and/or delayed handling of selection changes
113
     */
114
    private class DelaySelection implements Runnable{
115
        private IWorkbenchPart part;
116
        private ISelection selection;
117

    
118
        public DelaySelection(IWorkbenchPart part, ISelection selection) {
119
            super();
120
            this.part = part;
121
            this.selection = selection;
122
        }
123

    
124
        @Override
125
        public void run() {
126
            try{
127
                selectionChanged_internal(part, selection);
128
            }
129
            finally{
130
                isInDelay = false;
131
            }
132
        }
133

    
134
        public synchronized void setSelection(ISelection selection) {
135
            this.selection = selection;
136
        }
137

    
138
        public synchronized void setPart(IWorkbenchPart part) {
139
            this.part = part;
140
        }
141

    
142
    }
143

    
144
	private ConversationHolder conversation;
145

    
146
	private TreeViewer viewer;
147

    
148
    private boolean isDirty;
149

    
150
    private final int dndOperations = DND.DROP_MOVE;
151

    
152
    private DerivateLabelProvider labelProvider;
153

    
154
    private DerivateContentProvider contentProvider;
155

    
156
    private DerivateSearchCompositeController derivateSearchCompositeController;
157

    
158
    /**
159
     * A map with keys being the derivative entities belonging to the {@link UUID}s passed to the constructor
160
     * and values being the root elements of the hierarchy (may be the same objects as the derivative entities)
161
     */
162
    private Map<SpecimenOrObservationBase<?>, SpecimenOrObservationBase<?>> derivateToRootEntityMap;
163

    
164
    /**
165
     * The set of root elements
166
     */
167
    private Set<SpecimenOrObservationBase<?>> rootElements;
168

    
169
    private ICdmEntitySession cdmEntitySession;
170

    
171
    /**
172
     * <code>true</code> if this view is listening to selection  changes
173
     */
174
    private boolean listenToSelectionChange;
175

    
176
    private Taxon selectedTaxon;
177

    
178
    private ISelectionService selectionService;
179

    
180
    /**
181
     * Default constructor
182
     */
183
    public DerivateView() {
184
    }
185

    
186

    
187
    /**
188
     * {@inheritDoc}
189
     */
190
    @Override
191
    public void init(IEditorSite site, IEditorInput input) throws PartInitException {
192
        this.setSite(site);
193
        this.setInput(input);
194
        this.derivateToRootEntityMap = new HashMap<SpecimenOrObservationBase<?>, SpecimenOrObservationBase<?>>();
195
        this.rootElements = new HashSet<SpecimenOrObservationBase<?>>();
196

    
197
        if (CdmStore.isActive() && conversation == null) {
198
            conversation = CdmStore.createConversation();
199
        }
200
        if (CdmStore.isActive()) {
201
            cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
202
        }
203
        //listen to context changes
204
        CdmStore.getContextManager().addContextListener(this);
205
    }
206

    
207
    @Override
208
    public void createPartControl(Composite parent) {
209

    
210
        parent.setLayout(new GridLayout());
211

    
212
        //---search and filter---
213
        derivateSearchCompositeController = new DerivateSearchCompositeController(parent, this);
214
        GridData gridDataSearchBar = new GridData();
215
        gridDataSearchBar.horizontalAlignment = GridData.FILL;
216
        gridDataSearchBar.grabExcessHorizontalSpace = true;
217
        derivateSearchCompositeController.setLayoutData(gridDataSearchBar);
218
        derivateSearchCompositeController.setEnabled(CdmStore.isActive());
219

    
220
        //---tree viewer---
221
        viewer = new TreeViewer(new Tree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION));
222
        GridData gridDataTree = new GridData();
223
        gridDataTree.horizontalAlignment = GridData.FILL;
224
        gridDataTree.verticalAlignment = GridData.FILL;
225
        gridDataTree.grabExcessVerticalSpace = true;
226
        gridDataTree.grabExcessHorizontalSpace = true;
227
        viewer.getTree().setLayoutData(gridDataTree);
228
        contentProvider = new DerivateContentProvider();
229
        viewer.setContentProvider(contentProvider);
230
        labelProvider = new DerivateLabelProvider();
231
        labelProvider.setConversation(conversation);
232
        viewer.setLabelProvider(labelProvider);
233
        viewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
234
        viewer.getTree().setEnabled(CdmStore.isActive());
235
        // Propagate selection from viewer
236
        getSite().setSelectionProvider(viewer);
237

    
238
        //listen to selection changes
239
        selectionService = getSite().getWorkbenchWindow().getSelectionService();
240
        selectionService.addSelectionListener(this);
241

    
242
        //create context menu
243
        MenuManager menuManager = new MenuManager();
244
        menuManager.setRemoveAllWhenShown(true);
245
        getSite().registerContextMenu(menuManager, viewer);
246
        Control control = viewer.getControl();
247
        Menu menu = menuManager.createContextMenu(control);
248
        control.setMenu(menu);
249

    
250
        //init tree
251
        Collection<UUID> derivativeUuids = ((DerivateViewEditorInput)getEditorInput()).getDerivativeUuids();
252
        checkWarnThreshold(derivativeUuids);
253
		updateRootEntities(derivativeUuids);
254
        //set taxon filter
255
        derivateSearchCompositeController.setTaxonFilter(((DerivateViewEditorInput) getEditorInput()).getTaxonUuid());
256
        //reset status bar
257
        getEditorSite().getActionBars().getStatusLineManager().setMessage("");
258

    
259
        //add drag'n'drop support
260
        Transfer[] transfers = new Transfer[] {LocalSelectionTransfer.getTransfer(),};
261
        viewer.addDragSupport(dndOperations, transfers, new DerivateDragListener(this));
262
        viewer.addDropSupport(dndOperations, transfers, new DerivateDropListener(this));
263
    }
264

    
265
    public void updateRootEntities() {
266
        updateRootEntities((Collection)null);
267
    }
268

    
269
    public void updateRootEntities(Collection<UUID> derivativeUuids) {
270
        if(conversation!=null){
271
            if (!conversation.isBound()) {
272
                conversation.bind();
273
            }
274
            /*
275
             * If the active session is not the session of the Derivative Editor
276
             * then we will save the active session for later, bind temporarily
277
             * to our session and rebind to the original session when we are
278
             * done. This happens e.g. if a selection change happens in the
279
             * taxon editor and "Link with editor" is enabled. The selection
280
             * change event and thus the loading in updateRootEntities() happens
281
             * in the session of the taxon editor.
282
             */
283
            ICdmEntitySession previousCdmEntitySession = CdmStore.getCurrentSessionManager().getActiveSession();
284
            if(cdmEntitySession != null) {
285
                cdmEntitySession.bind();
286
            }
287

    
288
            List<SpecimenOrObservationBase> derivates = null;
289
            if(derivativeUuids!=null){
290
                this.derivateToRootEntityMap = new HashMap<SpecimenOrObservationBase<?>, SpecimenOrObservationBase<?>>();
291
                this.rootElements = new HashSet<SpecimenOrObservationBase<?>>();
292
                derivates = CdmStore.getService(IOccurrenceService.class).load(new ArrayList(derivativeUuids), SPECIMEN_INIT_STRATEGY);
293
            }
294
            updateRootEntities(derivates);
295
            previousCdmEntitySession.bind();
296
        }
297
    }
298

    
299

    
300
    public void updateRootEntities(List<SpecimenOrObservationBase> derivates) {
301
            if(derivates!=null){
302
                this.derivateToRootEntityMap = new HashMap<SpecimenOrObservationBase<?>, SpecimenOrObservationBase<?>>();
303
                this.rootElements = new HashSet<SpecimenOrObservationBase<?>>();
304
                for (SpecimenOrObservationBase derivate : derivates) {
305

    
306
                    if(derivate instanceof FieldUnit){
307
                        derivateToRootEntityMap.put(derivate, derivate);
308
                    }
309
                    else {
310
                        SpecimenOrObservationBase<?> topMostDerivate = EditorUtil.getTopMostDerivate(derivate);
311
                        if(topMostDerivate!=null){
312
                            derivateToRootEntityMap.put(derivate, topMostDerivate);
313
                        }
314
                        else{
315
                            derivateToRootEntityMap.put(derivate, derivate);
316
                        }
317
                    }
318
                }
319
                for (SpecimenOrObservationBase<?> specimen : derivateToRootEntityMap.values()) {
320
                    rootElements.add(specimen);
321
                }
322
            }
323
            labelProvider.updateLabelCache(rootElements);
324
            viewer.setInput(rootElements);
325

    
326
            getEditorSite().getActionBars().getStatusLineManager().setMessage(rootElements.size() +" derivative hierarchies found");
327

    
328
            //set selection to derivatives if the filter criteria
329
            //taxon assignment or derivative type are set
330
            if(derivates!=null && !derivateSearchCompositeController.isDefaultSearch()){
331
                List<TreeNode> nodesToSelect = new ArrayList<TreeNode>();
332
                for (SpecimenOrObservationBase specimenOrObservationBase : derivates) {
333
                    nodesToSelect.add(new TreeNode(specimenOrObservationBase));
334
                }
335
                viewer.setSelection(new StructuredSelection(nodesToSelect));
336
            }
337
            else{
338
                viewer.setSelection(null);
339
            }
340

    
341
    }
342

    
343
    public void updateLabelCache(){
344
        labelProvider.updateLabelCache(rootElements);
345
    }
346

    
347
    @Override
348
    public void doSave(IProgressMonitor monitor) {
349
        String taskName = Messages.DerivateView_SAVING_HIERARCHY;
350
        monitor.beginTask(taskName, 3);
351
        if (!conversation.isBound()) {
352
            conversation.bind();
353
        }
354
        monitor.worked(1);
355

    
356
        // commit the conversation and start a new transaction immediately
357
        conversation.commit(true);
358

    
359
        CdmStore.getService(IOccurrenceService.class).merge(new ArrayList<SpecimenOrObservationBase>(rootElements), true);
360
        
361
        monitor.worked(1);
362

    
363
        this.setDirty(false);
364
        monitor.worked(1);
365
        monitor.done();
366
        firePropertyChange(PROP_DIRTY);
367
        refreshTree();
368
    }
369

    
370
    @Override
371
    public void doSaveAs() {
372
    }
373

    
374
    @Override
375
    public String getTitleToolTip() {
376
        return Messages.DerivateView_DERIVATIVE_EDITOR;
377
    }
378

    
379
    @Override
380
    public boolean isDirty() {
381
        return isDirty;
382
    }
383

    
384
    /**
385
     * @param isDirty the isDirty to set
386
     */
387
    public void setDirty(boolean isDirty) {
388
        this.isDirty = isDirty;
389
    }
390

    
391
    @Override
392
    public boolean isSaveAsAllowed() {
393
        return false;
394
    }
395

    
396
    @Override
397
    public void setFocus() {
398
        //make sure to bind again if maybe in another view the conversation was unbound
399
        if(conversation!=null && !conversation.isBound()){
400
            conversation.bind();
401
        }
402
        if(cdmEntitySession != null) {
403
            cdmEntitySession.bind();
404
        }
405
        derivateSearchCompositeController.setFocusOnSearchField();
406
    }
407

    
408
    @Override
409
    public void update(CdmDataChangeMap changeEvents) {
410
    }
411

    
412
    @Override
413
    public ConversationHolder getConversationHolder() {
414
        return conversation;
415
    }
416

    
417
    @Override
418
    public void changed(Object element) {
419
        setDirty(true);
420
        firePropertyChange(IEditorPart.PROP_DIRTY);
421
        viewer.update(new TreeNode(element), null);
422
    }
423

    
424
    @Override
425
    public void forceDirty() {
426
        changed(null);
427
    }
428

    
429
    @Override
430
    public Map<Object, List<String>> getPropertyPathsMap() {
431
        List<String> specimenPropertyPaths = Arrays.asList(new String[] {
432
                "descriptions",
433
                "derivationEvents.derivates",
434
                "annotations",
435
                "markers",
436
                "credits",
437
                "extensions",
438
                "rights",
439
                "sources"
440
        });
441
        Map<Object, List<String>> specimenPropertyPathMap =
442
                new HashMap<Object, List<String>>();
443
        specimenPropertyPathMap.put(SpecimenOrObservationBase.class,specimenPropertyPaths);
444
        return specimenPropertyPathMap;
445
    }
446

    
447
    /**
448
     * Refreshes the derivate hierarchy tree and expands the tree
449
     * to show and select the given object.
450
     *
451
     * @param expandTo the object to which the tree should be expanded
452
     */
453
    public void refreshTree(Object expandTo){
454
        refreshTree();
455
        TreeSelection selection = (TreeSelection) viewer.getSelection();
456
        viewer.expandToLevel(selection.getFirstElement(), 1);
457
        viewer.setSelection(new StructuredSelection(new TreeNode(expandTo)));
458
    }
459

    
460
    /**
461
     * Refreshes the derivate hierarchy tree
462
     */
463
    public void refreshTree(){
464
    	if(!viewer.getTree().isDisposed()){
465
    		viewer.refresh();
466
    	}
467
    }
468

    
469
    //FIXME:Remoting hack to make this work for remoting
470
    //This should actually be resolved using remoting post operations
471
    public void remove(Object obj) {
472
        rootElements.remove(obj);
473
        viewer.setInput(rootElements);
474
    }
475

    
476
    /**
477
     * @return a set of {@link SingleRead}s that have multiple parents
478
     */
479
    public Set<SingleRead> getMultiLinkSingleReads() {
480
        return DerivateLabelProvider.getMultiLinkSingleReads();
481
    }
482

    
483
    public Object getSelectionInput() {
484
        return selectedTaxon;
485
    }
486

    
487
    public DerivateLabelProvider getLabelProvider() {
488
        return labelProvider;
489
    }
490

    
491
    @Override
492
    public boolean postOperation(CdmBase objectAffectedByOperation) {
493
        refreshTree();
494
        if(objectAffectedByOperation!=null){
495
            changed(objectAffectedByOperation);
496
        }
497
        return true;
498
    }
499

    
500
    @Override
501
    public boolean onComplete() {
502
        return true;
503
    }
504

    
505

    
506
    @Override
507
    public boolean canAttachMedia() {
508
        return true;
509
    }
510

    
511
    public void addFieldUnit(FieldUnit fieldUnit) {
512
        rootElements.add(fieldUnit);
513
        derivateToRootEntityMap.put(fieldUnit, fieldUnit);
514
    }
515

    
516
    @Override
517
    public ICdmEntitySession getCdmEntitySession() {
518
        return cdmEntitySession;
519
    }
520

    
521
    @Override
522
    public void dispose() {
523
        super.dispose();
524
        if(conversation!=null){
525
            conversation.close();
526
        }
527
        if(cdmEntitySession != null) {
528
            cdmEntitySession.dispose();
529
        }
530
    }
531
    public void selectionChanged_internal(IWorkbenchPart part, ISelection selection) {
532
    	if(part == this){
533
            return;
534
        }
535
        if(viewer.getTree().isDisposed()){
536
            return;
537
        }
538
        if(listenToSelectionChange){
539
            if(part instanceof MultiPageTaxonEditor){
540
                selectedTaxon = ((MultiPageTaxonEditor) part).getTaxon();
541
            }
542
            else if(selection instanceof IStructuredSelection){
543
                Object selectedElement = ((IStructuredSelection) selection).getFirstElement();
544
                if(selectedElement instanceof CdmBase){
545
                    if(((CdmBase) selectedElement).isInstanceOf(TaxonNode.class)){
546
                        selectedTaxon = HibernateProxyHelper.deproxy(selectedElement, TaxonNode.class).getTaxon();
547
                    }
548
                    else if(((CdmBase) selectedElement).isInstanceOf(Taxon.class)){
549
                        selectedTaxon = HibernateProxyHelper.deproxy(selectedElement, Taxon.class);
550
                    }
551
                }
552
            }
553
            if(selectedTaxon!=null){
554
                Collection<SpecimenOrObservationBase> fieldUnits = CdmStore.getService(IOccurrenceService.class).listFieldUnitsByAssociatedTaxon(selectedTaxon, null, null);
555
                Collection<UUID> uuids = new HashSet<UUID>();
556
                for (SpecimenOrObservationBase specimenOrObservationBase : fieldUnits) {
557
                    uuids.add(specimenOrObservationBase.getUuid());
558
                }
559
                checkWarnThreshold(uuids);
560
                updateRootEntities(uuids);
561
                setPartName("Derivative Editor: " + selectedTaxon.getName());
562
            }
563
        }
564
    }
565

    
566
    @Override
567
    public void selectionChanged(IWorkbenchPart part, ISelection selection) {
568
    	if(delaySelection==null){
569
            delaySelection = new DelaySelection(part, selection);
570
        }
571
        delaySelection.setPart(part);
572
        delaySelection.setSelection(selection);
573
        if(!isInDelay){
574
            isInDelay = true;
575
            Display.getCurrent().asyncExec(delaySelection);
576
        }
577
    }
578

    
579

    
580
	private void checkWarnThreshold(Collection<UUID> uuids) {
581
		if(uuids!=null && uuids.size()>WARN_THRESHOLD){
582
			MessagingUtils.warningDialog("Performance warning", this.getClass(), String.format("Specimens will not be loaded!\n"
583
					+ "There are %d specimens associated with the current "
584
					+ "selection. If you really want to show all of them in the specimen editor please "
585
					+ "use the taxon filter in the search bar.", uuids.size()));
586
			uuids.clear();
587
		}
588
	}
589

    
590
    public TreeViewer getViewer() {
591
        return viewer;
592
    }
593

    
594
    /**
595
     * {@inheritDoc}
596
     */
597
    @Override
598
    public List<SpecimenOrObservationBase<?>> getRootEntities() {
599
        return new ArrayList<SpecimenOrObservationBase<?>>(rootElements);
600
    }
601

    
602
    public void toggleListenToSelectionChange() {
603
        listenToSelectionChange = !listenToSelectionChange;
604
        derivateSearchCompositeController.setEnabled(!listenToSelectionChange);
605
        if(!listenToSelectionChange){
606
            selectedTaxon = null;
607
            setPartName("Derivative Editor");
608
        }
609
        else if(selectedTaxon==null){
610
            setPartName("Derivative Editor [no taxon selected]");
611
        }
612
    }
613

    
614
    public boolean isListenToSelectionChange(){
615
        return listenToSelectionChange;
616
    }
617

    
618
    /**
619
     * {@inheritDoc}
620
     */
621
    @Override
622
    public void contextAboutToStop(IMemento memento, IProgressMonitor monitor) {
623
    }
624

    
625
    /**
626
     * {@inheritDoc}
627
     */
628
    @Override
629
    public void contextStop(IMemento memento, IProgressMonitor monitor) {
630
        derivateSearchCompositeController.setEnabled(false);
631
        if(!viewer.getTree().isDisposed()) {
632
            viewer.getTree().setEnabled(false);
633
            viewer.setInput(null);
634
        }
635
    }
636

    
637
    /**
638
     * {@inheritDoc}
639
     */
640
    @Override
641
    public void contextStart(IMemento memento, IProgressMonitor monitor) {
642
        derivateSearchCompositeController.setEnabled(!listenToSelectionChange);
643
        if(!viewer.getTree().isDisposed()){
644
            viewer.getTree().setEnabled(true);
645
        }
646
        refreshTree();
647
    }
648

    
649
    /**
650
     * {@inheritDoc}
651
     */
652
    @Override
653
    public void contextRefresh(IProgressMonitor monitor) {
654
    }
655

    
656
    /**
657
     * {@inheritDoc}
658
     */
659
    @Override
660
    public void workbenchShutdown(IMemento memento, IProgressMonitor monitor) {
661
    }
662

    
663
}
(3-3/6)