Project

General

Profile

Download (22.2 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.ISelectionChangedListener;
34
import org.eclipse.jface.viewers.IStructuredSelection;
35
import org.eclipse.jface.viewers.StructuredSelection;
36
import org.eclipse.jface.viewers.TreeNode;
37
import org.eclipse.jface.viewers.TreeSelection;
38
import org.eclipse.jface.viewers.TreeViewer;
39
import org.eclipse.swt.SWT;
40
import org.eclipse.swt.dnd.DND;
41
import org.eclipse.swt.dnd.Transfer;
42
import org.eclipse.swt.layout.GridData;
43
import org.eclipse.swt.layout.GridLayout;
44
import org.eclipse.swt.widgets.Composite;
45
import org.eclipse.swt.widgets.Tree;
46
import org.eclipse.ui.IMemento;
47

    
48
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
49
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
50
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
51
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
52
import eu.etaxonomy.cdm.model.common.CdmBase;
53
import eu.etaxonomy.cdm.model.molecular.SingleRead;
54
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
55
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
56
import eu.etaxonomy.cdm.model.taxon.Taxon;
57
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
58
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
59
import eu.etaxonomy.taxeditor.editor.EditorUtil;
60
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
61
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
62
import eu.etaxonomy.taxeditor.editor.view.derivate.searchFilter.DerivateSearchCompositeController;
63
import eu.etaxonomy.taxeditor.model.IContextListener;
64
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
65
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
66
import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData;
67
import eu.etaxonomy.taxeditor.model.IPartContentHasMedia;
68
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
69
import eu.etaxonomy.taxeditor.model.MessagingUtils;
70
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
71
import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
72
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
73
import eu.etaxonomy.taxeditor.store.CdmStore;
74
import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateContentProvider;
75
import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateLabelProvider;
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 {
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.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
222
        viewer.getTree().setEnabled(CdmStore.isActive());
223

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

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

    
231
        //add drag'n'drop support
232
        Transfer[] transfers = new Transfer[] {LocalSelectionTransfer.getTransfer(),};
233
        viewer.addDragSupport(dndOperations, transfers, new DerivateDragListener(this));
234
        DerivateDropListener dropListener = new DerivateDropListener(this);
235
        ContextInjectionFactory.inject(dropListener, context);
236
        viewer.addDropSupport(dndOperations, transfers, dropListener);
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<>();
265
                this.rootElements = new HashSet<>();
266
                derivates = CdmStore.getService(IOccurrenceService.class).load(new ArrayList(derivativeUuids), SPECIMEN_INIT_STRATEGY);
267
            }
268
            updateRootEntities(derivates);
269
            if(previousCdmEntitySession!=null){
270
                previousCdmEntitySession.bind();
271
            }
272
        }
273
    }
274

    
275

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

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

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

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

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

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

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

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

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

    
347
        monitor.worked(1);
348

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
480

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

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

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

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

    
509

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

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

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

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

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

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

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

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

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

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

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

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

    
631

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

    
636
}
(3-3/6)