Project

General

Profile

Download (22.3 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.contexts.ContextInjectionFactory;
21
import org.eclipse.e4.core.contexts.IEclipseContext;
22
import org.eclipse.e4.core.di.annotations.Optional;
23
import org.eclipse.e4.ui.di.Focus;
24
import org.eclipse.e4.ui.di.Persist;
25
import org.eclipse.e4.ui.model.application.ui.MDirtyable;
26
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
27
import org.eclipse.e4.ui.services.EMenuService;
28
import org.eclipse.e4.ui.services.IServiceConstants;
29
import org.eclipse.e4.ui.workbench.modeling.EPartService;
30
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
31
import org.eclipse.jface.util.LocalSelectionTransfer;
32
import org.eclipse.jface.viewers.AbstractTreeViewer;
33
import org.eclipse.jface.viewers.ISelection;
34
import org.eclipse.jface.viewers.ISelectionChangedListener;
35
import org.eclipse.jface.viewers.IStructuredSelection;
36
import org.eclipse.jface.viewers.StructuredSelection;
37
import org.eclipse.jface.viewers.TreeNode;
38
import org.eclipse.jface.viewers.TreeSelection;
39
import org.eclipse.jface.viewers.TreeViewer;
40
import org.eclipse.swt.SWT;
41
import org.eclipse.swt.dnd.DND;
42
import org.eclipse.swt.dnd.Transfer;
43
import org.eclipse.swt.layout.GridData;
44
import org.eclipse.swt.layout.GridLayout;
45
import org.eclipse.swt.widgets.Composite;
46
import org.eclipse.swt.widgets.Tree;
47
import org.eclipse.ui.IMemento;
48

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

    
80
/**
81
 * Displays the derivate hierarchy of the specimen specified in the editor input.
82
 *
83
 */
84
public class DerivateView implements IPartContentHasFactualData, IConversationEnabled,
85
        ICdmEntitySessionEnabled, IDirtyMarkable, IPostOperationEnabled, IPartContentHasDetails, IPartContentHasSupplementalData, IPartContentHasMedia,
86
        IContextListener, IE4SavablePart {
87

    
88
    private static final String SPECIMEN_EDITOR = Messages.DerivateView_SPECIMEN_EDITOR;
89

    
90
    public static final String ID = "eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView"; //$NON-NLS-1$
91
    public static final String INPUT_ID = ID+".editorInput"; //$NON-NLS-1$
92

    
93
    public static final String YOU_NEED_TO_SAVE_BEFORE_PERFORMING_THIS_ACTION = Messages.DerivateView_YOU_NEED_TO_SAVE;
94
    public static final String VIEW_HAS_UNSAVED_CHANGES = Messages.DerivateView_UNSAVED_CHANGES;
95

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

    
112
	private static final int WARN_THRESHOLD = 200;
113

    
114

    
115
	private ConversationHolder conversation;
116

    
117
	private TreeViewer viewer;
118

    
119
    private final int dndOperations = DND.DROP_MOVE;
120

    
121
    private DerivateLabelProvider labelProvider;
122

    
123
    private DerivateContentProvider contentProvider;
124

    
125
    private DerivateSearchCompositeController derivateSearchCompositeController;
126

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

    
133
    /**
134
     * The set of root elements
135
     */
136
    private Set<SpecimenOrObservationBase<?>> rootElements;
137

    
138
    private ICdmEntitySession cdmEntitySession;
139

    
140
    /**
141
     * <code>true</code> if this view is listening to selection  changes
142
     */
143
    private boolean listenToSelectionChange;
144

    
145
    private Taxon selectedTaxon;
146

    
147
    @Inject
148
    private ESelectionService selService;
149

    
150
    @Inject
151
    private MDirtyable dirty;
152

    
153
    private ISelectionChangedListener selectionChangedListener;
154

    
155
    @Inject
156
    private MPart thisPart;
157

    
158
    /**
159
     * Default constructor
160
     */
161
    @Inject
162
    public DerivateView() {
163
    }
164

    
165
    /**
166
     * {@inheritDoc}
167
     */
168
    public void init(DerivateViewEditorInput editorInput){
169
        this.derivateToRootEntityMap = new HashMap<>();
170
        this.rootElements = new HashSet<>();
171

    
172
        //init tree
173
        Collection<UUID> derivativeUuids = editorInput.getDerivativeUuids();
174
        checkWarnThreshold(derivativeUuids);
175
        updateRootEntities(derivativeUuids);
176
        //set taxon filter
177
        derivateSearchCompositeController.setTaxonFilter(editorInput.getTaxonUuid());
178
        //reset status bar
179
        //TODO e4
180
//        getEditorSite().getActionBars().getStatusLineManager().setMessage(""); //$NON-NLS-1$
181
    }
182

    
183
    @PostConstruct
184
    public void createPartControl(Composite parent, EMenuService menuService,
185
            IEclipseContext context) {
186
        if (CdmStore.isActive()){
187
            if(conversation == null){
188
                conversation = CdmStore.createConversation();
189
            }
190
            if(cdmEntitySession == null){
191
                cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
192
            }
193
        }
194
        else{
195
            return;
196
        }
197
        //listen to context changes
198
        CdmStore.getContextManager().addContextListener(this);
199

    
200
        parent.setLayout(new GridLayout());
201

    
202
        //---search and filter---
203
        derivateSearchCompositeController = new DerivateSearchCompositeController(parent, this);
204
        GridData gridDataSearchBar = new GridData();
205
        gridDataSearchBar.horizontalAlignment = GridData.FILL;
206
        gridDataSearchBar.grabExcessHorizontalSpace = true;
207
        derivateSearchCompositeController.setLayoutData(gridDataSearchBar);
208
        derivateSearchCompositeController.setEnabled(CdmStore.isActive());
209

    
210
        //---tree viewer---
211
        viewer = new TreeViewer(new Tree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION));
212
        GridData gridDataTree = new GridData();
213
        gridDataTree.horizontalAlignment = GridData.FILL;
214
        gridDataTree.verticalAlignment = GridData.FILL;
215
        gridDataTree.grabExcessVerticalSpace = true;
216
        gridDataTree.grabExcessHorizontalSpace = true;
217
        viewer.getTree().setLayoutData(gridDataTree);
218
        contentProvider = new DerivateContentProvider();
219
        viewer.setContentProvider(contentProvider);
220
        labelProvider = new DerivateLabelProvider();
221
        labelProvider.setConversation(conversation);
222
        viewer.setLabelProvider(labelProvider);
223
        viewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
224
        viewer.getTree().setEnabled(CdmStore.isActive());
225

    
226
        //propagate selection
227
        selectionChangedListener = (event -> selService.setSelection(AbstractUtility.getElementsFromSelectionChangedEvent(event)));
228
        viewer.addSelectionChangedListener(selectionChangedListener);
229

    
230
        //create context menu
231
        menuService.registerContextMenu(viewer.getControl(), "eu.etaxonomy.taxeditor.editor.popupmenu.specimeneditor");
232

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

    
241
    public void updateRootEntities() {
242
        updateRootEntities((Collection)null);
243
    }
244

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

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

    
277

    
278
    public void updateRootEntities(List<SpecimenOrObservationBase> derivates) {
279
        if(derivates!=null){
280
            this.derivateToRootEntityMap = new HashMap<>();
281
            this.rootElements = new HashSet<>();
282
            for (SpecimenOrObservationBase derivate : derivates) {
283

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

    
304
        //TODO e4
305
        //            getEditorSite().getActionBars().getStatusLineManager().setMessage(String.format(Messages.DerivateView_CNT_DERIVATIVES_FOUND, rootElements.size()));
306

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

    
321
    private void setSelection(StructuredSelection selection){
322
        viewer.removeSelectionChangedListener(selectionChangedListener);
323
        viewer.setSelection(selection);
324
        viewer.addSelectionChangedListener(selectionChangedListener);
325
    }
326

    
327
    public void updateLabelCache(){
328
        labelProvider.updateLabelCache(rootElements);
329
    }
330

    
331
    @Persist
332
    @Override
333
    public void save(IProgressMonitor monitor) {
334
        String taskName = Messages.DerivateView_SAVING_HIERARCHY;
335
        monitor.beginTask(taskName, 3);
336
        if (!conversation.isBound()) {
337
            conversation.bind();
338
            if (!cdmEntitySession.isActive()){
339
                cdmEntitySession.bind();
340
            }
341
        }
342
        monitor.worked(1);
343

    
344
        // commit the conversation and start a new transaction immediately
345
        conversation.commit(true);
346

    
347
        CdmStore.getService(IOccurrenceService.class).merge(new ArrayList<>(rootElements), true);
348

    
349
        monitor.worked(1);
350

    
351
        this.setDirty(false);
352
        monitor.worked(1);
353
        monitor.done();
354
        dirty.setDirty(false);
355
        refreshTree();
356
    }
357

    
358
    /**
359
     * @param isDirty the isDirty to set
360
     */
361
    public void setDirty(boolean isDirty) {
362
        dirty.setDirty(isDirty);
363
    }
364

    
365
    @Focus
366
    public void setFocus() {
367
        //make sure to bind again if maybe in another view the conversation was unbound
368
        if(conversation!=null && !conversation.isBound()){
369
            conversation.bind();
370
        }
371
        if(cdmEntitySession != null) {
372
            cdmEntitySession.bind();
373
        }
374
        if(viewer!=null && !viewer.getControl().isDisposed()) {
375
            viewer.getControl().setFocus();
376
            selService.setSelection(viewer.getSelection());
377
        }
378
    }
379

    
380
    @Override
381
    public void update(CdmDataChangeMap changeEvents) {
382
    }
383

    
384
    @Override
385
    public ConversationHolder getConversationHolder() {
386
        return conversation;
387
    }
388

    
389
    @Override
390
    public void changed(Object element) {
391
        setDirty(true);
392
        //firePropertyChange(IEditorPart.PROP_DIRTY);
393
        viewer.update(new TreeNode(element), null);
394
        viewer.refresh();
395
    }
396

    
397
    @Override
398
    public void forceDirty() {
399
        changed(null);
400
    }
401

    
402
    @Override
403
    public Map<Object, List<String>> getPropertyPathsMap() {
404
        List<String> specimenPropertyPaths = Arrays.asList(new String[] {
405
                "descriptions", //$NON-NLS-1$
406
                "derivationEvents.derivates", //$NON-NLS-1$
407
                "annotations", //$NON-NLS-1$
408
                "markers", //$NON-NLS-1$
409
                "credits", //$NON-NLS-1$
410
                "extensions", //$NON-NLS-1$
411
                "rights", //$NON-NLS-1$
412
                "sources" //$NON-NLS-1$
413
        });
414
        Map<Object, List<String>> specimenPropertyPathMap =
415
                new HashMap<>();
416
        specimenPropertyPathMap.put(SpecimenOrObservationBase.class,specimenPropertyPaths);
417
        return specimenPropertyPathMap;
418
    }
419

    
420
    /**
421
     * Refreshes the derivate hierarchy tree and expands the tree
422
     * to show and select the given object.
423
     *
424
     * @param expandTo the object to which the tree should be expanded
425
     */
426
    public void refreshTree(Object expandTo){
427
        refreshTree();
428
        TreeSelection selection = (TreeSelection) viewer.getSelection();
429
        viewer.expandToLevel(selection.getFirstElement(), 1);
430
        viewer.setSelection(new StructuredSelection(new TreeNode(expandTo)));
431
    }
432

    
433
    /**
434
     * Refreshes the derivate hierarchy tree
435
     */
436
    public void refreshTree(){
437
    	if(!viewer.getTree().isDisposed()){
438
    		viewer.refresh();
439
    	}
440
    }
441

    
442
    //FIXME:Remoting hack to make this work for remoting
443
    //This should actually be resolved using remoting post operations
444
    public void remove(Object obj) {
445
        if (obj instanceof TreeNode){
446
            obj = ((TreeNode)obj).getValue();
447
        }
448
        rootElements.remove(obj);
449
        Object o = this.derivateToRootEntityMap.remove(obj);
450
        viewer.setInput(rootElements);
451
    }
452

    
453
    /**
454
     * @return a set of {@link SingleRead}s that have multiple parents
455
     */
456
    public Set<SingleRead> getMultiLinkSingleReads() {
457
        return DerivateLabelProvider.getMultiLinkSingleReads();
458
    }
459

    
460
    public Object getSelectionInput() {
461
        return selectedTaxon;
462
    }
463

    
464
    public DerivateLabelProvider getLabelProvider() {
465
        return labelProvider;
466
    }
467

    
468
    @Override
469
    public boolean postOperation(CdmBase objectAffectedByOperation) {
470
        refreshTree();
471
        if(objectAffectedByOperation!=null){
472
            changed(objectAffectedByOperation);
473
        }
474
        return true;
475
    }
476

    
477
    @Override
478
    public boolean onComplete() {
479
        return true;
480
    }
481

    
482

    
483
    @Override
484
    public boolean canAttachMedia() {
485
        return true;
486
    }
487

    
488
    public void addFieldUnit(FieldUnit fieldUnit) {
489
        rootElements.add(fieldUnit);
490
        derivateToRootEntityMap.put(fieldUnit, fieldUnit);
491
    }
492

    
493
    @Override
494
    public ICdmEntitySession getCdmEntitySession() {
495
        return cdmEntitySession;
496
    }
497

    
498
    @PreDestroy
499
    public void dispose() {
500
        if(conversation!=null){
501
            conversation.close();
502
            conversation = null;
503
        }
504
        if(cdmEntitySession != null) {
505
            cdmEntitySession.dispose();
506
            cdmEntitySession = null;
507
        }
508
    }
509

    
510

    
511
    @Inject
512
    @Optional
513
    public void selectionChanged(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) ISelection selection,
514
            @Named(IServiceConstants.ACTIVE_PART) MPart activePart, MPart thisPart)
515
    {
516
    	if(activePart == thisPart || viewer==null){
517
            return;
518
        }
519
        if(viewer.getTree().isDisposed()){
520
            return;
521
        }
522
        if(listenToSelectionChange){
523
            selectedTaxon = null;
524
            if(activePart instanceof TaxonNameEditorE4){
525
                selectedTaxon = ((TaxonNameEditorE4) activePart).getTaxon();
526
            }
527
            else if(selection instanceof IStructuredSelection){
528
                Object selectedElement = ((IStructuredSelection) selection).getFirstElement();
529
                if(selectedElement instanceof CdmBase){
530
                    if(((CdmBase) selectedElement).isInstanceOf(TaxonNode.class)){
531
                        selectedTaxon = HibernateProxyHelper.deproxy(selectedElement, TaxonNode.class).getTaxon();
532
                    }
533
                    else if(((CdmBase) selectedElement).isInstanceOf(Taxon.class)){
534
                        selectedTaxon = HibernateProxyHelper.deproxy(selectedElement, Taxon.class);
535
                    }
536
                }
537
            }
538
            if(selectedTaxon!=null){
539
                Collection<SpecimenOrObservationBase> fieldUnits = CdmStore.getService(IOccurrenceService.class).listFieldUnitsByAssociatedTaxon(selectedTaxon, null, null);
540
                Collection<UUID> uuids = new HashSet<>();
541
                for (SpecimenOrObservationBase specimenOrObservationBase : fieldUnits) {
542
                    uuids.add(specimenOrObservationBase.getUuid());
543
                }
544
                checkWarnThreshold(uuids);
545
                updateRootEntities(uuids);
546

    
547
                thisPart.setLabel(SPECIMEN_EDITOR+": " + selectedTaxon.getName()); //$NON-NLS-1$
548
            }
549
            else{
550
                updateRootEntities((Collection<UUID>)Collections.EMPTY_LIST);
551
            }
552
        }
553
    }
554

    
555
	private void checkWarnThreshold(Collection<UUID> uuids) {
556
		if(uuids!=null && uuids.size()>WARN_THRESHOLD){
557
			MessagingUtils.warningDialog(Messages.DerivateView_PERF_WARNING, this.getClass(), String.format(Messages.DerivateView_PERF_WARNING_MESSAGE, uuids.size()));
558
			uuids.clear();
559
		}
560
	}
561

    
562
    public TreeViewer getViewer() {
563
        return viewer;
564
    }
565

    
566
    /**
567
     * {@inheritDoc}
568
     */
569
    @Override
570
    public List<SpecimenOrObservationBase<?>> getRootEntities() {
571
        return new ArrayList<>(rootElements);
572
    }
573

    
574
    public void toggleListenToSelectionChange(MPart part) {
575
        listenToSelectionChange = !listenToSelectionChange;
576
        derivateSearchCompositeController.setEnabled(!listenToSelectionChange);
577
        if(!listenToSelectionChange){
578
            selectedTaxon = null;
579
            part.setLabel(SPECIMEN_EDITOR);
580
        }
581
        else if(selectedTaxon==null){
582
            part.setLabel(SPECIMEN_EDITOR+Messages.DerivateView_NO_TAXON_SELECTED);
583
        }
584
    }
585

    
586
    public boolean isListenToSelectionChange(){
587
        return listenToSelectionChange;
588
    }
589

    
590
    /**
591
     * {@inheritDoc}
592
     */
593
    @Override
594
    public void contextAboutToStop(IMemento memento, IProgressMonitor monitor) {
595
    }
596

    
597
    /**
598
     * {@inheritDoc}
599
     */
600
    @Override
601
    public void contextStop(IMemento memento, IProgressMonitor monitor) {
602
        //close view when workbench closes
603
        try{
604
            thisPart.getContext().get(EPartService.class).hidePart(thisPart);
605
        }
606
        catch(Exception e){
607
            //nothing
608
        }
609
    }
610

    
611
    /**
612
     * {@inheritDoc}
613
     */
614
    @Override
615
    public void contextStart(IMemento memento, IProgressMonitor monitor) {
616
    }
617

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

    
625
    /**
626
     * {@inheritDoc}
627
     */
628
    @Override
629
    public void workbenchShutdown(IMemento memento, IProgressMonitor monitor) {
630
    }
631

    
632

    
633
    public boolean isDirty() {
634
        return dirty.isDirty();
635
    }
636

    
637
}
(3-3/6)