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.ISelectionChangedListener;
33
import org.eclipse.jface.viewers.IStructuredSelection;
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.l10n.Messages;
60
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
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
import eu.etaxonomy.taxeditor.workbench.part.ICollapsableExpandable;
76
import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
77

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

    
86
    private static final String SPECIMEN_EDITOR = Messages.DerivateView_SPECIMEN_EDITOR;
87

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

    
91
    public static final String YOU_NEED_TO_SAVE_BEFORE_PERFORMING_THIS_ACTION = Messages.DerivateView_YOU_NEED_TO_SAVE;
92
    public static final String VIEW_HAS_UNSAVED_CHANGES = Messages.DerivateView_UNSAVED_CHANGES;
93

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

    
110
	private static final int WARN_THRESHOLD = 200;
111

    
112

    
113
	private ConversationHolder conversation;
114

    
115
	private TreeViewer viewer;
116

    
117
    private final int dndOperations = DND.DROP_MOVE;
118

    
119
    private DerivateLabelProvider labelProvider;
120

    
121
    private DerivateContentProvider contentProvider;
122

    
123
    private DerivateSearchCompositeController derivateSearchCompositeController;
124

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

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

    
136
    private ICdmEntitySession cdmEntitySession;
137

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

    
143
    private Taxon selectedTaxon;
144

    
145
    @Inject
146
    private ESelectionService selService;
147

    
148
    @Inject
149
    private MDirtyable dirty;
150

    
151
    private ISelectionChangedListener selectionChangedListener;
152

    
153
    @Inject
154
    private MPart thisPart;
155

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

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

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

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

    
198
        parent.setLayout(new GridLayout());
199

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

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

    
223
        //propagate selection
224
        selectionChangedListener = (event -> selService.setSelection(event.getSelection()));
225
        viewer.addSelectionChangedListener(selectionChangedListener);
226

    
227
        //create context menu
228
        menuService.registerContextMenu(viewer.getControl(), "eu.etaxonomy.taxeditor.editor.popupmenu.specimeneditor");
229

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

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

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

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

    
274

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

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

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

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

    
318
    private void setSelection(StructuredSelection selection){
319
        viewer.removeSelectionChangedListener(selectionChangedListener);
320
        viewer.setSelection(selection);
321
        viewer.addSelectionChangedListener(selectionChangedListener);
322
    }
323

    
324
    public void updateLabelCache(){
325
        labelProvider.updateLabelCache(rootElements);
326
    }
327

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

    
341
        // commit the conversation and start a new transaction immediately
342
        conversation.commit(true);
343

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

    
346
        monitor.worked(1);
347

    
348
        this.setDirty(false);
349
        monitor.worked(1);
350
        monitor.done();
351
        dirty.setDirty(false);
352
        refreshTree();
353
    }
354

    
355
    /**
356
     * @param isDirty the isDirty to set
357
     */
358
    public void setDirty(boolean isDirty) {
359
        dirty.setDirty(isDirty);
360
    }
361

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

    
377
    @Override
378
    public void update(CdmDataChangeMap changeEvents) {
379
    }
380

    
381
    @Override
382
    public ConversationHolder getConversationHolder() {
383
        return conversation;
384
    }
385

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

    
394
    @Override
395
    public void forceDirty() {
396
        changed(null);
397
    }
398

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

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

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

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

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

    
457
    public Object getSelectionInput() {
458
        return selectedTaxon;
459
    }
460

    
461
    public DerivateLabelProvider getLabelProvider() {
462
        return labelProvider;
463
    }
464

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

    
474
    @Override
475
    public boolean onComplete() {
476
        return true;
477
    }
478

    
479

    
480
    @Override
481
    public boolean canAttachMedia() {
482
        return true;
483
    }
484

    
485
    public void addFieldUnit(FieldUnit fieldUnit) {
486
        rootElements.add(fieldUnit);
487
        derivateToRootEntityMap.put(fieldUnit, fieldUnit);
488
    }
489

    
490
    @Override
491
    public ICdmEntitySession getCdmEntitySession() {
492
        return cdmEntitySession;
493
    }
494

    
495
    @PreDestroy
496
    public void dispose() {
497
        if(conversation!=null){
498
            conversation.close();
499
            conversation = null;
500
        }
501
        if(cdmEntitySession != null) {
502
            cdmEntitySession.dispose();
503
            cdmEntitySession = null;
504
        }
505
        dirty.setDirty(false);
506
    }
507

    
508

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

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

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

    
560
    public TreeViewer getViewer() {
561
        return viewer;
562
    }
563

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

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

    
584
    public boolean isListenToSelectionChange(){
585
        return listenToSelectionChange;
586
    }
587

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

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

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

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

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

    
630

    
631
    public boolean isDirty() {
632
        return dirty.isDirty();
633
    }
634

    
635
    @Override
636
    public void collapse() {
637
        viewer.collapseAll();
638
    }
639

    
640
    @Override
641
    public void expand() {
642
        viewer.expandAll();
643
    }
644

    
645
}
(3-3/6)