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.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.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.AbstractUtility;
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
        if (CdmStore.isActive()){
184
            if(conversation == null){
185
                conversation = CdmStore.createConversation();
186
            }
187
            if(cdmEntitySession!=null){
188
                cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
189
            }
190
        }
191
        else{
192
            return;
193
        }
194
        //listen to context changes
195
        CdmStore.getContextManager().addContextListener(this);
196

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

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

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

    
223
        //propagate selection
224
        selectionChangedListener = (event -> selService.setSelection(AbstractUtility.getElementsFromSelectionChangedEvent(event)));
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
        viewer.addDropSupport(dndOperations, transfers, new DerivateDropListener(this));
234
    }
235

    
236
    public void updateRootEntities() {
237
        updateRootEntities((Collection)null);
238
    }
239

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

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

    
272

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

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

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

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

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

    
322
    public void updateLabelCache(){
323
        labelProvider.updateLabelCache(rootElements);
324
    }
325

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

    
336
        // commit the conversation and start a new transaction immediately
337
        conversation.commit(true);
338

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

    
341
        monitor.worked(1);
342

    
343
        this.setDirty(false);
344
        monitor.worked(1);
345
        monitor.done();
346
        dirty.setDirty(false);
347
        refreshTree();
348
    }
349

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

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

    
372
    @Override
373
    public void update(CdmDataChangeMap changeEvents) {
374
    }
375

    
376
    @Override
377
    public ConversationHolder getConversationHolder() {
378
        return conversation;
379
    }
380

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

    
389
    @Override
390
    public void forceDirty() {
391
        changed(null);
392
    }
393

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

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

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

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

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

    
452
    public Object getSelectionInput() {
453
        return selectedTaxon;
454
    }
455

    
456
    public DerivateLabelProvider getLabelProvider() {
457
        return labelProvider;
458
    }
459

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

    
469
    @Override
470
    public boolean onComplete() {
471
        return true;
472
    }
473

    
474

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

    
480
    public void addFieldUnit(FieldUnit fieldUnit) {
481
        rootElements.add(fieldUnit);
482
        derivateToRootEntityMap.put(fieldUnit, fieldUnit);
483
    }
484

    
485
    @Override
486
    public ICdmEntitySession getCdmEntitySession() {
487
        return cdmEntitySession;
488
    }
489

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

    
500

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

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

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

    
552
    public TreeViewer getViewer() {
553
        return viewer;
554
    }
555

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

    
564
    public void toggleListenToSelectionChange(MPart part) {
565
        listenToSelectionChange = !listenToSelectionChange;
566
        derivateSearchCompositeController.setEnabled(!listenToSelectionChange);
567
        if(!listenToSelectionChange){
568
            selectedTaxon = null;
569
            part.setLabel(SPECIMEN_EDITOR);
570
        }
571
        else if(selectedTaxon==null){
572
            part.setLabel(SPECIMEN_EDITOR+Messages.DerivateView_NO_TAXON_SELECTED);
573
        }
574
    }
575

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

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

    
587
    /**
588
     * {@inheritDoc}
589
     */
590
    @Override
591
    public void contextStop(IMemento memento, IProgressMonitor monitor) {
592
        //close view when workbench closes
593
        try{
594
            thisPart.getContext().get(EPartService.class).hidePart(thisPart);
595
        }
596
        catch(Exception e){
597
            //nothing
598
        }
599
    }
600

    
601
    /**
602
     * {@inheritDoc}
603
     */
604
    @Override
605
    public void contextStart(IMemento memento, IProgressMonitor monitor) {
606
    }
607

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

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

    
622

    
623
    public boolean isDirty() {
624
        return dirty.isDirty();
625
    }
626

    
627
}
(3-3/6)