Project

General

Profile

Download (22.4 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.Collections;
7
import java.util.HashMap;
8
import java.util.HashSet;
9
import java.util.List;
10
import java.util.Map;
11
import java.util.Set;
12
import java.util.UUID;
13

    
14
import javax.annotation.PostConstruct;
15
import javax.annotation.PreDestroy;
16
import javax.inject.Inject;
17
import javax.inject.Named;
18

    
19
import org.eclipse.core.runtime.IProgressMonitor;
20
import org.eclipse.e4.core.di.annotations.Optional;
21
import org.eclipse.e4.ui.di.Focus;
22
import org.eclipse.e4.ui.di.Persist;
23
import org.eclipse.e4.ui.model.application.ui.MDirtyable;
24
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
25
import org.eclipse.e4.ui.services.EMenuService;
26
import org.eclipse.e4.ui.services.IServiceConstants;
27
import org.eclipse.e4.ui.workbench.modeling.EPartService;
28
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
29
import org.eclipse.jface.util.LocalSelectionTransfer;
30
import org.eclipse.jface.viewers.AbstractTreeViewer;
31
import org.eclipse.jface.viewers.ISelection;
32
import org.eclipse.jface.viewers.IStructuredSelection;
33
import org.eclipse.jface.viewers.SelectionChangedEvent;
34
import org.eclipse.jface.viewers.StructuredSelection;
35
import org.eclipse.jface.viewers.TreeNode;
36
import org.eclipse.jface.viewers.TreeSelection;
37
import org.eclipse.jface.viewers.TreeViewer;
38
import org.eclipse.swt.SWT;
39
import org.eclipse.swt.dnd.DND;
40
import org.eclipse.swt.dnd.Transfer;
41
import org.eclipse.swt.layout.GridData;
42
import org.eclipse.swt.layout.GridLayout;
43
import org.eclipse.swt.widgets.Composite;
44
import org.eclipse.swt.widgets.Tree;
45
import org.eclipse.ui.IMemento;
46

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

    
76
/**
77
 * Displays the derivate hierarchy of the specimen specified in the editor input.
78
 *
79
 */
80
public class DerivateView implements IPartContentHasFactualData, IConversationEnabled,
81
        ICdmEntitySessionEnabled, IDirtyMarkable, IPostOperationEnabled, IPartContentHasDetails, IPartContentHasSupplementalData, IPartContentHasMedia,
82
        IContextListener {
83

    
84
    private static final String SPECIMEN_EDITOR = Messages.DerivateView_SPECIMEN_EDITOR;
85

    
86
    public static final String ID = "eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView"; //$NON-NLS-1$
87

    
88
    public static final String YOU_NEED_TO_SAVE_BEFORE_PERFORMING_THIS_ACTION = Messages.DerivateView_YOU_NEED_TO_SAVE;
89
    public static final String VIEW_HAS_UNSAVED_CHANGES = Messages.DerivateView_UNSAVED_CHANGES;
90

    
91
    private static final List<String> SPECIMEN_INIT_STRATEGY = Arrays.asList(new String[] {
92
            "descriptions", //$NON-NLS-1$
93
            "annotations", //$NON-NLS-1$
94
            "markers", //$NON-NLS-1$
95
            "credits", //$NON-NLS-1$
96
            "extensions", //$NON-NLS-1$
97
            "rights", //$NON-NLS-1$
98
            "sources", //$NON-NLS-1$
99
            "derivationEvents.derivatives.annotations", //$NON-NLS-1$
100
            "derivationEvents.derivatives.markers", //$NON-NLS-1$
101
            "derivationEvents.derivatives.credits", //$NON-NLS-1$
102
            "derivationEvents.derivatives.extensions", //$NON-NLS-1$
103
            "derivationEvents.derivatives.rights", //$NON-NLS-1$
104
            "derivationEvents.derivatives.sources" //$NON-NLS-1$
105
    });
106

    
107
	private static final int WARN_THRESHOLD = 200;
108

    
109

    
110
	private ConversationHolder conversation;
111

    
112
	private TreeViewer viewer;
113

    
114
    private final int dndOperations = DND.DROP_MOVE;
115

    
116
    private DerivateLabelProvider labelProvider;
117

    
118
    private DerivateContentProvider contentProvider;
119

    
120
    private DerivateSearchCompositeController derivateSearchCompositeController;
121

    
122
    /**
123
     * A map with keys being the derivative entities belonging to the {@link UUID}s passed to the constructor
124
     * and values being the root elements of the hierarchy (may be the same objects as the derivative entities)
125
     */
126
    private Map<SpecimenOrObservationBase<?>, SpecimenOrObservationBase<?>> derivateToRootEntityMap;
127

    
128
    /**
129
     * The set of root elements
130
     */
131
    private Set<SpecimenOrObservationBase<?>> rootElements;
132

    
133
    private ICdmEntitySession cdmEntitySession;
134

    
135
    /**
136
     * <code>true</code> if this view is listening to selection  changes
137
     */
138
    private boolean listenToSelectionChange;
139

    
140
    private Taxon selectedTaxon;
141

    
142
    @Inject
143
    private ESelectionService selService;
144

    
145
    @Inject
146
    private MDirtyable dirty;
147

    
148
    @Inject
149
    private EPartService partService;
150

    
151
    /**
152
     * Default constructor
153
     */
154
    @Inject
155
    public DerivateView() {
156
    }
157

    
158

    
159
    /**
160
     * {@inheritDoc}
161
     */
162
    private void init(){
163
        this.derivateToRootEntityMap = new HashMap<SpecimenOrObservationBase<?>, SpecimenOrObservationBase<?>>();
164
        this.rootElements = new HashSet<SpecimenOrObservationBase<?>>();
165

    
166
        if (CdmStore.isActive() && conversation == null) {
167
            conversation = CdmStore.createConversation();
168
        }
169
        if (CdmStore.isActive()) {
170
            cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
171
        }
172
        //listen to context changes
173
        CdmStore.getContextManager().addContextListener(this);
174
    }
175

    
176
    @PostConstruct
177
    public void createPartControl(Composite parent, EMenuService menuService) {
178
        init();
179

    
180
        parent.setLayout(new GridLayout());
181

    
182
        //---search and filter---
183
        derivateSearchCompositeController = new DerivateSearchCompositeController(parent, this);
184
        GridData gridDataSearchBar = new GridData();
185
        gridDataSearchBar.horizontalAlignment = GridData.FILL;
186
        gridDataSearchBar.grabExcessHorizontalSpace = true;
187
        derivateSearchCompositeController.setLayoutData(gridDataSearchBar);
188
        derivateSearchCompositeController.setEnabled(CdmStore.isActive());
189

    
190
        //---tree viewer---
191
        viewer = new TreeViewer(new Tree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION));
192
        GridData gridDataTree = new GridData();
193
        gridDataTree.horizontalAlignment = GridData.FILL;
194
        gridDataTree.verticalAlignment = GridData.FILL;
195
        gridDataTree.grabExcessVerticalSpace = true;
196
        gridDataTree.grabExcessHorizontalSpace = true;
197
        viewer.getTree().setLayoutData(gridDataTree);
198
        contentProvider = new DerivateContentProvider();
199
        viewer.setContentProvider(contentProvider);
200
        labelProvider = new DerivateLabelProvider();
201
        labelProvider.setConversation(conversation);
202
        viewer.setLabelProvider(labelProvider);
203
        viewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
204
        viewer.getTree().setEnabled(CdmStore.isActive());
205

    
206
        // Propagate selection from viewer
207
        viewer.addSelectionChangedListener((SelectionChangedEvent event) -> {
208
            IStructuredSelection isel = (IStructuredSelection) event.getSelection();
209
            selService.setSelection((isel.size() == 1 ? isel.getFirstElement() : isel.toArray()));
210
        });
211

    
212
        //create context menu
213
        menuService.registerContextMenu(viewer.getControl(), "eu.etaxonomy.taxeditor.editor.popupmenu.specimeneditor");
214
//        MenuManager menuManager = new MenuManager();
215
//        menuManager.setRemoveAllWhenShown(true);
216
//        getSite().registerContextMenu(menuManager, viewer);
217
//        Control control = viewer.getControl();
218
//        Menu menu = menuManager.createContextMenu(control);
219
//        control.setMenu(menu);
220

    
221
        //init tree
222
        //TODO e4
223
//        Collection<UUID> derivativeUuids = ((DerivateViewEditorInput)getEditorInput()).getDerivativeUuids();
224
//        checkWarnThreshold(derivativeUuids);
225
//        updateRootEntities(derivativeUuids);
226
//        set taxon filter
227
		//TODO e4
228
//        derivateSearchCompositeController.setTaxonFilter(((DerivateViewEditorInput) getEditorInput()).getTaxonUuid());
229
        //reset status bar
230
        //TODO e4
231
//        getEditorSite().getActionBars().getStatusLineManager().setMessage(""); //$NON-NLS-1$
232

    
233
        //add drag'n'drop support
234
        Transfer[] transfers = new Transfer[] {LocalSelectionTransfer.getTransfer(),};
235
        viewer.addDragSupport(dndOperations, transfers, new DerivateDragListener(this));
236
        viewer.addDropSupport(dndOperations, transfers, new DerivateDropListener(this));
237
    }
238

    
239
    public void updateRootEntities() {
240
        updateRootEntities((Collection)null);
241
    }
242

    
243
    public void updateRootEntities(Collection<UUID> derivativeUuids) {
244
        if(conversation!=null){
245
            if (!conversation.isBound()) {
246
                conversation.bind();
247
            }
248
            /*
249
             * If the active session is not the session of the Derivative Editor
250
             * then we will save the active session for later, bind temporarily
251
             * to our session and rebind to the original session when we are
252
             * done. This happens e.g. if a selection change happens in the
253
             * taxon editor and "Link with editor" is enabled. The selection
254
             * change event and thus the loading in updateRootEntities() happens
255
             * in the session of the taxon editor.
256
             */
257
            ICdmEntitySession previousCdmEntitySession = CdmStore.getCurrentSessionManager().getActiveSession();
258
            if(cdmEntitySession != null) {
259
                cdmEntitySession.bind();
260
            }
261

    
262
            List<SpecimenOrObservationBase> derivates = null;
263
            if(derivativeUuids!=null){
264
                this.derivateToRootEntityMap = new HashMap<SpecimenOrObservationBase<?>, SpecimenOrObservationBase<?>>();
265
                this.rootElements = new HashSet<SpecimenOrObservationBase<?>>();
266
                derivates = CdmStore.getService(IOccurrenceService.class).load(new ArrayList(derivativeUuids), SPECIMEN_INIT_STRATEGY);
267
            }
268
            updateRootEntities(derivates);
269
            previousCdmEntitySession.bind();
270
        }
271
    }
272

    
273

    
274
    public void updateRootEntities(List<SpecimenOrObservationBase> derivates) {
275
            if(derivates!=null){
276
                this.derivateToRootEntityMap = new HashMap<SpecimenOrObservationBase<?>, SpecimenOrObservationBase<?>>();
277
                this.rootElements = new HashSet<SpecimenOrObservationBase<?>>();
278
                for (SpecimenOrObservationBase derivate : derivates) {
279

    
280
                    if(derivate instanceof FieldUnit){
281
                        derivateToRootEntityMap.put(derivate, derivate);
282
                    }
283
                    else {
284
                        SpecimenOrObservationBase<?> topMostDerivate = EditorUtil.getTopMostDerivate(derivate);
285
                        if(topMostDerivate!=null){
286
                            derivateToRootEntityMap.put(derivate, topMostDerivate);
287
                        }
288
                        else{
289
                            derivateToRootEntityMap.put(derivate, derivate);
290
                        }
291
                    }
292
                }
293
                for (SpecimenOrObservationBase<?> specimen : derivateToRootEntityMap.values()) {
294
                    rootElements.add(specimen);
295
                }
296
            }
297
            labelProvider.updateLabelCache(rootElements);
298
            viewer.setInput(rootElements);
299

    
300
            //TODO e4
301
//            getEditorSite().getActionBars().getStatusLineManager().setMessage(String.format(Messages.DerivateView_CNT_DERIVATIVES_FOUND, rootElements.size()));
302

    
303
            //set selection to derivatives if the filter criteria
304
            //taxon assignment or derivative type are set
305
            if(derivates!=null && !derivateSearchCompositeController.isDefaultSearch()){
306
                List<TreeNode> nodesToSelect = new ArrayList<TreeNode>();
307
                for (SpecimenOrObservationBase specimenOrObservationBase : derivates) {
308
                    nodesToSelect.add(new TreeNode(specimenOrObservationBase));
309
                }
310
                viewer.setSelection(new StructuredSelection(nodesToSelect));
311
            }
312
            else{
313
                viewer.setSelection(null);
314
            }
315

    
316
    }
317

    
318
    public void updateLabelCache(){
319
        labelProvider.updateLabelCache(rootElements);
320
    }
321

    
322
    @Persist
323
    public void doSave(IProgressMonitor monitor) {
324
        String taskName = Messages.DerivateView_SAVING_HIERARCHY;
325
        monitor.beginTask(taskName, 3);
326
        if (!conversation.isBound()) {
327
            conversation.bind();
328
        }
329
        monitor.worked(1);
330

    
331
        // commit the conversation and start a new transaction immediately
332
        conversation.commit(true);
333

    
334
        CdmStore.getService(IOccurrenceService.class).merge(new ArrayList<SpecimenOrObservationBase>(rootElements), true);
335

    
336
        monitor.worked(1);
337

    
338
        this.setDirty(false);
339
        monitor.worked(1);
340
        monitor.done();
341
        dirty.setDirty(false);
342
        refreshTree();
343
    }
344

    
345
//    @Override
346
//    public String getTitleToolTip() {
347
    //TODO e4
348
//        return Messages.DerivateView_DERIVATIVE_EDITOR;
349
//    }
350

    
351
    /**
352
     * @param isDirty the isDirty to set
353
     */
354
    public void setDirty(boolean isDirty) {
355
        dirty.setDirty(isDirty);
356
    }
357

    
358
    @Focus
359
    public void setFocus() {
360
        //make sure to bind again if maybe in another view the conversation was unbound
361
        if(conversation!=null && !conversation.isBound()){
362
            conversation.bind();
363
        }
364
        if(cdmEntitySession != null) {
365
            cdmEntitySession.bind();
366
        }
367
        derivateSearchCompositeController.setFocusOnSearchField();
368
    }
369

    
370
    @Override
371
    public void update(CdmDataChangeMap changeEvents) {
372
    }
373

    
374
    @Override
375
    public ConversationHolder getConversationHolder() {
376
        return conversation;
377
    }
378

    
379
    @Override
380
    public void changed(Object element) {
381
        setDirty(true);
382
//        firePropertyChange(IEditorPart.PROP_DIRTY);
383
        viewer.update(new TreeNode(element), null);
384
    }
385

    
386
    @Override
387
    public void forceDirty() {
388
        changed(null);
389
    }
390

    
391
    @Override
392
    public Map<Object, List<String>> getPropertyPathsMap() {
393
        List<String> specimenPropertyPaths = Arrays.asList(new String[] {
394
                "descriptions", //$NON-NLS-1$
395
                "derivationEvents.derivates", //$NON-NLS-1$
396
                "annotations", //$NON-NLS-1$
397
                "markers", //$NON-NLS-1$
398
                "credits", //$NON-NLS-1$
399
                "extensions", //$NON-NLS-1$
400
                "rights", //$NON-NLS-1$
401
                "sources" //$NON-NLS-1$
402
        });
403
        Map<Object, List<String>> specimenPropertyPathMap =
404
                new HashMap<Object, List<String>>();
405
        specimenPropertyPathMap.put(SpecimenOrObservationBase.class,specimenPropertyPaths);
406
        return specimenPropertyPathMap;
407
    }
408

    
409
    /**
410
     * Refreshes the derivate hierarchy tree and expands the tree
411
     * to show and select the given object.
412
     *
413
     * @param expandTo the object to which the tree should be expanded
414
     */
415
    public void refreshTree(Object expandTo){
416
        refreshTree();
417
        TreeSelection selection = (TreeSelection) viewer.getSelection();
418
        viewer.expandToLevel(selection.getFirstElement(), 1);
419
        viewer.setSelection(new StructuredSelection(new TreeNode(expandTo)));
420
    }
421

    
422
    /**
423
     * Refreshes the derivate hierarchy tree
424
     */
425
    public void refreshTree(){
426
    	if(!viewer.getTree().isDisposed()){
427
    		viewer.refresh();
428
    	}
429
    }
430

    
431
    //FIXME:Remoting hack to make this work for remoting
432
    //This should actually be resolved using remoting post operations
433
    public void remove(Object obj) {
434
        if (obj instanceof TreeNode){
435
            obj = ((TreeNode)obj).getValue();
436
        }
437
        rootElements.remove(obj);
438
        Object o = this.derivateToRootEntityMap.remove(obj);
439
        viewer.setInput(rootElements);
440
    }
441

    
442
    /**
443
     * @return a set of {@link SingleRead}s that have multiple parents
444
     */
445
    public Set<SingleRead> getMultiLinkSingleReads() {
446
        return DerivateLabelProvider.getMultiLinkSingleReads();
447
    }
448

    
449
    public Object getSelectionInput() {
450
        return selectedTaxon;
451
    }
452

    
453
    public DerivateLabelProvider getLabelProvider() {
454
        return labelProvider;
455
    }
456

    
457
    @Override
458
    public boolean postOperation(CdmBase objectAffectedByOperation) {
459
        refreshTree();
460
        if(objectAffectedByOperation!=null){
461
            changed(objectAffectedByOperation);
462
        }
463
        return true;
464
    }
465

    
466
    @Override
467
    public boolean onComplete() {
468
        return true;
469
    }
470

    
471

    
472
    @Override
473
    public boolean canAttachMedia() {
474
        return true;
475
    }
476

    
477
    public void addFieldUnit(FieldUnit fieldUnit) {
478
        rootElements.add(fieldUnit);
479
        derivateToRootEntityMap.put(fieldUnit, fieldUnit);
480
    }
481

    
482
    @Override
483
    public ICdmEntitySession getCdmEntitySession() {
484
        return cdmEntitySession;
485
    }
486

    
487
    @PreDestroy
488
    public void dispose() {
489
        if(conversation!=null){
490
            conversation.close();
491
        }
492
        if(cdmEntitySession != null) {
493
            cdmEntitySession.dispose();
494
        }
495
    }
496

    
497

    
498
    @Inject
499
    @Optional
500
    public void selectionChanged(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) ISelection selection,
501
            @Named(IServiceConstants.ACTIVE_PART) MPart activePart, MPart thisPart)
502
    {
503
    	if(activePart == this || viewer==null){
504
            return;
505
        }
506
        if(viewer.getTree().isDisposed()){
507
            return;
508
        }
509
        if(listenToSelectionChange){
510
            selectedTaxon = null;
511
            if(activePart instanceof MultiPageTaxonEditor){
512
                selectedTaxon = ((MultiPageTaxonEditor) activePart).getTaxon();
513
            }
514
            else if(selection instanceof IStructuredSelection){
515
                Object selectedElement = ((IStructuredSelection) selection).getFirstElement();
516
                if(selectedElement instanceof CdmBase){
517
                    if(((CdmBase) selectedElement).isInstanceOf(TaxonNode.class)){
518
                        selectedTaxon = HibernateProxyHelper.deproxy(selectedElement, TaxonNode.class).getTaxon();
519
                    }
520
                    else if(((CdmBase) selectedElement).isInstanceOf(Taxon.class)){
521
                        selectedTaxon = HibernateProxyHelper.deproxy(selectedElement, Taxon.class);
522
                    }
523
                }
524
            }
525
            if(selectedTaxon!=null){
526
                Collection<SpecimenOrObservationBase> fieldUnits = CdmStore.getService(IOccurrenceService.class).listFieldUnitsByAssociatedTaxon(selectedTaxon, null, null);
527
                Collection<UUID> uuids = new HashSet<UUID>();
528
                for (SpecimenOrObservationBase specimenOrObservationBase : fieldUnits) {
529
                    uuids.add(specimenOrObservationBase.getUuid());
530
                }
531
                checkWarnThreshold(uuids);
532
                updateRootEntities(uuids);
533

    
534
                thisPart.setLabel(SPECIMEN_EDITOR+": " + selectedTaxon.getName()); //$NON-NLS-1$
535
            }
536
            else{
537
                updateRootEntities((Collection<UUID>)Collections.EMPTY_LIST);
538
            }
539
        }
540
    }
541

    
542
	private void checkWarnThreshold(Collection<UUID> uuids) {
543
		if(uuids!=null && uuids.size()>WARN_THRESHOLD){
544
			MessagingUtils.warningDialog(Messages.DerivateView_PERF_WARNING, this.getClass(), String.format(Messages.DerivateView_PERF_WARNING_MESSAGE, uuids.size()));
545
			uuids.clear();
546
		}
547
	}
548

    
549
    public TreeViewer getViewer() {
550
        return viewer;
551
    }
552

    
553
    /**
554
     * {@inheritDoc}
555
     */
556
    @Override
557
    public List<SpecimenOrObservationBase<?>> getRootEntities() {
558
        return new ArrayList<SpecimenOrObservationBase<?>>(rootElements);
559
    }
560

    
561
    public void toggleListenToSelectionChange() {
562
        listenToSelectionChange = !listenToSelectionChange;
563
        derivateSearchCompositeController.setEnabled(!listenToSelectionChange);
564
        if(!listenToSelectionChange){
565
            selectedTaxon = null;
566
            //TODO e4
567
//            setPartName(SPECIMEN_EDITOR);
568
        }
569
        else if(selectedTaxon==null){
570
            //TODO e4
571
//            setPartName(SPECIMEN_EDITOR+Messages.DerivateView_NO_TAXON_SELECTED);
572
        }
573
    }
574

    
575
    public boolean isListenToSelectionChange(){
576
        return listenToSelectionChange;
577
    }
578

    
579
    /**
580
     * {@inheritDoc}
581
     */
582
    @Override
583
    public void contextAboutToStop(IMemento memento, IProgressMonitor monitor) {
584
    }
585

    
586
    /**
587
     * {@inheritDoc}
588
     */
589
    @Override
590
    public void contextStop(IMemento memento, IProgressMonitor monitor) {
591
        derivateSearchCompositeController.setEnabled(false);
592
        if(!viewer.getTree().isDisposed()) {
593
            viewer.getTree().setEnabled(false);
594
            viewer.setInput(null);
595
        }
596
    }
597

    
598
    /**
599
     * {@inheritDoc}
600
     */
601
    @Override
602
    public void contextStart(IMemento memento, IProgressMonitor monitor) {
603
        derivateSearchCompositeController.setEnabled(!listenToSelectionChange);
604
        if(!viewer.getTree().isDisposed()){
605
            viewer.getTree().setEnabled(true);
606
        }
607
        refreshTree();
608
    }
609

    
610
    /**
611
     * {@inheritDoc}
612
     */
613
    @Override
614
    public void contextRefresh(IProgressMonitor monitor) {
615
    }
616

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

    
624

    
625
    public boolean isDirty() {
626
        return dirty.isDirty();
627
    }
628

    
629
}
(3-3/6)