Project

General

Profile

Download (21.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.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
    public static final String INPUT_ID = ID+".editorInput"; //$NON-NLS-1$
88

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

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

    
108
	private static final int WARN_THRESHOLD = 200;
109

    
110

    
111
	private ConversationHolder conversation;
112

    
113
	private TreeViewer viewer;
114

    
115
    private final int dndOperations = DND.DROP_MOVE;
116

    
117
    private DerivateLabelProvider labelProvider;
118

    
119
    private DerivateContentProvider contentProvider;
120

    
121
    private DerivateSearchCompositeController derivateSearchCompositeController;
122

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

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

    
134
    private ICdmEntitySession cdmEntitySession;
135

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

    
141
    private Taxon selectedTaxon;
142

    
143
    @Inject
144
    private ESelectionService selService;
145

    
146
    @Inject
147
    private MDirtyable dirty;
148

    
149
    @Inject
150
    private EPartService partService;
151

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

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

    
166
        //init tree
167
        Collection<UUID> derivativeUuids = editorInput.getDerivativeUuids();
168
        checkWarnThreshold(derivativeUuids);
169
        updateRootEntities(derivativeUuids);
170
        //set taxon filter
171
        derivateSearchCompositeController.setTaxonFilter(editorInput.getTaxonUuid());
172
        //reset status bar
173
        //TODO e4
174
//        getEditorSite().getActionBars().getStatusLineManager().setMessage(""); //$NON-NLS-1$
175
    }
176

    
177
    @PostConstruct
178
    public void createPartControl(Composite parent, EMenuService menuService) {
179
        if (CdmStore.isActive() && conversation == null) {
180
            conversation = CdmStore.createConversation();
181
        }
182
        if (CdmStore.isActive()) {
183
            cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
184
        }
185
        //listen to context changes
186
        CdmStore.getContextManager().addContextListener(this);
187

    
188
        parent.setLayout(new GridLayout());
189

    
190
        //---search and filter---
191
        derivateSearchCompositeController = new DerivateSearchCompositeController(parent, this);
192
        GridData gridDataSearchBar = new GridData();
193
        gridDataSearchBar.horizontalAlignment = GridData.FILL;
194
        gridDataSearchBar.grabExcessHorizontalSpace = true;
195
        derivateSearchCompositeController.setLayoutData(gridDataSearchBar);
196
        derivateSearchCompositeController.setEnabled(CdmStore.isActive());
197

    
198
        //---tree viewer---
199
        viewer = new TreeViewer(new Tree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION));
200
        GridData gridDataTree = new GridData();
201
        gridDataTree.horizontalAlignment = GridData.FILL;
202
        gridDataTree.verticalAlignment = GridData.FILL;
203
        gridDataTree.grabExcessVerticalSpace = true;
204
        gridDataTree.grabExcessHorizontalSpace = true;
205
        viewer.getTree().setLayoutData(gridDataTree);
206
        contentProvider = new DerivateContentProvider();
207
        viewer.setContentProvider(contentProvider);
208
        labelProvider = new DerivateLabelProvider();
209
        labelProvider.setConversation(conversation);
210
        viewer.setLabelProvider(labelProvider);
211
        viewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
212
        viewer.getTree().setEnabled(CdmStore.isActive());
213

    
214
        // Propagate selection from viewer
215
        viewer.addSelectionChangedListener((SelectionChangedEvent event) -> {
216
            IStructuredSelection isel = (IStructuredSelection) event.getSelection();
217
            selService.setSelection((isel.size() == 1 ? isel.getFirstElement() : isel.toArray()));
218
        });
219

    
220
        //create context menu
221
        menuService.registerContextMenu(viewer.getControl(), "eu.etaxonomy.taxeditor.editor.popupmenu.specimeneditor");
222

    
223
        //add drag'n'drop support
224
        Transfer[] transfers = new Transfer[] {LocalSelectionTransfer.getTransfer(),};
225
        viewer.addDragSupport(dndOperations, transfers, new DerivateDragListener(this));
226
        viewer.addDropSupport(dndOperations, transfers, new DerivateDropListener(this));
227
    }
228

    
229
    public void updateRootEntities() {
230
        updateRootEntities((Collection)null);
231
    }
232

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

    
252
            List<SpecimenOrObservationBase> derivates = null;
253
            if(derivativeUuids!=null){
254
                this.derivateToRootEntityMap = new HashMap<SpecimenOrObservationBase<?>, SpecimenOrObservationBase<?>>();
255
                this.rootElements = new HashSet<SpecimenOrObservationBase<?>>();
256
                derivates = CdmStore.getService(IOccurrenceService.class).load(new ArrayList(derivativeUuids), SPECIMEN_INIT_STRATEGY);
257
            }
258
            updateRootEntities(derivates);
259
            previousCdmEntitySession.bind();
260
        }
261
    }
262

    
263

    
264
    public void updateRootEntities(List<SpecimenOrObservationBase> derivates) {
265
            if(derivates!=null){
266
                this.derivateToRootEntityMap = new HashMap<SpecimenOrObservationBase<?>, SpecimenOrObservationBase<?>>();
267
                this.rootElements = new HashSet<SpecimenOrObservationBase<?>>();
268
                for (SpecimenOrObservationBase derivate : derivates) {
269

    
270
                    if(derivate instanceof FieldUnit){
271
                        derivateToRootEntityMap.put(derivate, derivate);
272
                    }
273
                    else {
274
                        SpecimenOrObservationBase<?> topMostDerivate = EditorUtil.getTopMostDerivate(derivate);
275
                        if(topMostDerivate!=null){
276
                            derivateToRootEntityMap.put(derivate, topMostDerivate);
277
                        }
278
                        else{
279
                            derivateToRootEntityMap.put(derivate, derivate);
280
                        }
281
                    }
282
                }
283
                for (SpecimenOrObservationBase<?> specimen : derivateToRootEntityMap.values()) {
284
                    rootElements.add(specimen);
285
                }
286
            }
287
            labelProvider.updateLabelCache(rootElements);
288
            viewer.setInput(rootElements);
289

    
290
            //TODO e4
291
//            getEditorSite().getActionBars().getStatusLineManager().setMessage(String.format(Messages.DerivateView_CNT_DERIVATIVES_FOUND, rootElements.size()));
292

    
293
            //set selection to derivatives if the filter criteria
294
            //taxon assignment or derivative type are set
295
            if(derivates!=null && !derivateSearchCompositeController.isDefaultSearch()){
296
                List<TreeNode> nodesToSelect = new ArrayList<TreeNode>();
297
                for (SpecimenOrObservationBase specimenOrObservationBase : derivates) {
298
                    nodesToSelect.add(new TreeNode(specimenOrObservationBase));
299
                }
300
                viewer.setSelection(new StructuredSelection(nodesToSelect));
301
            }
302
            else{
303
                viewer.setSelection(null);
304
            }
305

    
306
    }
307

    
308
    public void updateLabelCache(){
309
        labelProvider.updateLabelCache(rootElements);
310
    }
311

    
312
    @Persist
313
    public void doSave(IProgressMonitor monitor) {
314
        String taskName = Messages.DerivateView_SAVING_HIERARCHY;
315
        monitor.beginTask(taskName, 3);
316
        if (!conversation.isBound()) {
317
            conversation.bind();
318
        }
319
        monitor.worked(1);
320

    
321
        // commit the conversation and start a new transaction immediately
322
        conversation.commit(true);
323

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

    
326
        monitor.worked(1);
327

    
328
        this.setDirty(false);
329
        monitor.worked(1);
330
        monitor.done();
331
        dirty.setDirty(false);
332
        refreshTree();
333
    }
334

    
335
    /**
336
     * @param isDirty the isDirty to set
337
     */
338
    public void setDirty(boolean isDirty) {
339
        dirty.setDirty(isDirty);
340
    }
341

    
342
    @Focus
343
    public void setFocus() {
344
        //make sure to bind again if maybe in another view the conversation was unbound
345
        if(conversation!=null && !conversation.isBound()){
346
            conversation.bind();
347
        }
348
        if(cdmEntitySession != null) {
349
            cdmEntitySession.bind();
350
        }
351
        derivateSearchCompositeController.setFocusOnSearchField();
352
    }
353

    
354
    @Override
355
    public void update(CdmDataChangeMap changeEvents) {
356
    }
357

    
358
    @Override
359
    public ConversationHolder getConversationHolder() {
360
        return conversation;
361
    }
362

    
363
    @Override
364
    public void changed(Object element) {
365
        setDirty(true);
366
//        firePropertyChange(IEditorPart.PROP_DIRTY);
367
        viewer.update(new TreeNode(element), null);
368
    }
369

    
370
    @Override
371
    public void forceDirty() {
372
        changed(null);
373
    }
374

    
375
    @Override
376
    public Map<Object, List<String>> getPropertyPathsMap() {
377
        List<String> specimenPropertyPaths = Arrays.asList(new String[] {
378
                "descriptions", //$NON-NLS-1$
379
                "derivationEvents.derivates", //$NON-NLS-1$
380
                "annotations", //$NON-NLS-1$
381
                "markers", //$NON-NLS-1$
382
                "credits", //$NON-NLS-1$
383
                "extensions", //$NON-NLS-1$
384
                "rights", //$NON-NLS-1$
385
                "sources" //$NON-NLS-1$
386
        });
387
        Map<Object, List<String>> specimenPropertyPathMap =
388
                new HashMap<Object, List<String>>();
389
        specimenPropertyPathMap.put(SpecimenOrObservationBase.class,specimenPropertyPaths);
390
        return specimenPropertyPathMap;
391
    }
392

    
393
    /**
394
     * Refreshes the derivate hierarchy tree and expands the tree
395
     * to show and select the given object.
396
     *
397
     * @param expandTo the object to which the tree should be expanded
398
     */
399
    public void refreshTree(Object expandTo){
400
        refreshTree();
401
        TreeSelection selection = (TreeSelection) viewer.getSelection();
402
        viewer.expandToLevel(selection.getFirstElement(), 1);
403
        viewer.setSelection(new StructuredSelection(new TreeNode(expandTo)));
404
    }
405

    
406
    /**
407
     * Refreshes the derivate hierarchy tree
408
     */
409
    public void refreshTree(){
410
    	if(!viewer.getTree().isDisposed()){
411
    		viewer.refresh();
412
    	}
413
    }
414

    
415
    //FIXME:Remoting hack to make this work for remoting
416
    //This should actually be resolved using remoting post operations
417
    public void remove(Object obj) {
418
        if (obj instanceof TreeNode){
419
            obj = ((TreeNode)obj).getValue();
420
        }
421
        rootElements.remove(obj);
422
        Object o = this.derivateToRootEntityMap.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
    @PreDestroy
472
    public void dispose() {
473
        if(conversation!=null){
474
            conversation.close();
475
        }
476
        if(cdmEntitySession != null) {
477
            cdmEntitySession.dispose();
478
        }
479
    }
480

    
481

    
482
    @Inject
483
    @Optional
484
    public void selectionChanged(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) ISelection selection,
485
            @Named(IServiceConstants.ACTIVE_PART) MPart activePart, MPart thisPart)
486
    {
487
    	if(activePart == this || viewer==null){
488
            return;
489
        }
490
        if(viewer.getTree().isDisposed()){
491
            return;
492
        }
493
        if(listenToSelectionChange){
494
            selectedTaxon = null;
495
            if(activePart instanceof MultiPageTaxonEditor){
496
                selectedTaxon = ((MultiPageTaxonEditor) activePart).getTaxon();
497
            }
498
            else if(selection instanceof IStructuredSelection){
499
                Object selectedElement = ((IStructuredSelection) selection).getFirstElement();
500
                if(selectedElement instanceof CdmBase){
501
                    if(((CdmBase) selectedElement).isInstanceOf(TaxonNode.class)){
502
                        selectedTaxon = HibernateProxyHelper.deproxy(selectedElement, TaxonNode.class).getTaxon();
503
                    }
504
                    else if(((CdmBase) selectedElement).isInstanceOf(Taxon.class)){
505
                        selectedTaxon = HibernateProxyHelper.deproxy(selectedElement, Taxon.class);
506
                    }
507
                }
508
            }
509
            if(selectedTaxon!=null){
510
                Collection<SpecimenOrObservationBase> fieldUnits = CdmStore.getService(IOccurrenceService.class).listFieldUnitsByAssociatedTaxon(selectedTaxon, null, null);
511
                Collection<UUID> uuids = new HashSet<UUID>();
512
                for (SpecimenOrObservationBase specimenOrObservationBase : fieldUnits) {
513
                    uuids.add(specimenOrObservationBase.getUuid());
514
                }
515
                checkWarnThreshold(uuids);
516
                updateRootEntities(uuids);
517

    
518
                thisPart.setLabel(SPECIMEN_EDITOR+": " + selectedTaxon.getName()); //$NON-NLS-1$
519
            }
520
            else{
521
                updateRootEntities((Collection<UUID>)Collections.EMPTY_LIST);
522
            }
523
        }
524
    }
525

    
526
	private void checkWarnThreshold(Collection<UUID> uuids) {
527
		if(uuids!=null && uuids.size()>WARN_THRESHOLD){
528
			MessagingUtils.warningDialog(Messages.DerivateView_PERF_WARNING, this.getClass(), String.format(Messages.DerivateView_PERF_WARNING_MESSAGE, uuids.size()));
529
			uuids.clear();
530
		}
531
	}
532

    
533
    public TreeViewer getViewer() {
534
        return viewer;
535
    }
536

    
537
    /**
538
     * {@inheritDoc}
539
     */
540
    @Override
541
    public List<SpecimenOrObservationBase<?>> getRootEntities() {
542
        return new ArrayList<SpecimenOrObservationBase<?>>(rootElements);
543
    }
544

    
545
    public void toggleListenToSelectionChange(MPart part) {
546
        listenToSelectionChange = !listenToSelectionChange;
547
        derivateSearchCompositeController.setEnabled(!listenToSelectionChange);
548
        if(!listenToSelectionChange){
549
            selectedTaxon = null;
550
            part.setLabel(SPECIMEN_EDITOR);
551
        }
552
        else if(selectedTaxon==null){
553
            part.setLabel(SPECIMEN_EDITOR+Messages.DerivateView_NO_TAXON_SELECTED);
554
        }
555
    }
556

    
557
    public boolean isListenToSelectionChange(){
558
        return listenToSelectionChange;
559
    }
560

    
561
    /**
562
     * {@inheritDoc}
563
     */
564
    @Override
565
    public void contextAboutToStop(IMemento memento, IProgressMonitor monitor) {
566
    }
567

    
568
    /**
569
     * {@inheritDoc}
570
     */
571
    @Override
572
    public void contextStop(IMemento memento, IProgressMonitor monitor) {
573
        derivateSearchCompositeController.setEnabled(false);
574
        if(!viewer.getTree().isDisposed()) {
575
            viewer.getTree().setEnabled(false);
576
            viewer.setInput(null);
577
        }
578
    }
579

    
580
    /**
581
     * {@inheritDoc}
582
     */
583
    @Override
584
    public void contextStart(IMemento memento, IProgressMonitor monitor) {
585
        derivateSearchCompositeController.setEnabled(!listenToSelectionChange);
586
        if(!viewer.getTree().isDisposed()){
587
            viewer.getTree().setEnabled(true);
588
        }
589
        refreshTree();
590
    }
591

    
592
    /**
593
     * {@inheritDoc}
594
     */
595
    @Override
596
    public void contextRefresh(IProgressMonitor monitor) {
597
    }
598

    
599
    /**
600
     * {@inheritDoc}
601
     */
602
    @Override
603
    public void workbenchShutdown(IMemento memento, IProgressMonitor monitor) {
604
    }
605

    
606

    
607
    public boolean isDirty() {
608
        return dirty.isDirty();
609
    }
610

    
611
}
(3-3/6)