1
|
/**
|
2
|
* Copyright (C) 2017 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.taxeditor.view.e4;
|
10
|
|
11
|
import javax.annotation.PostConstruct;
|
12
|
import javax.annotation.PreDestroy;
|
13
|
|
14
|
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
15
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
16
|
import org.eclipse.swt.widgets.Composite;
|
17
|
import org.eclipse.ui.IEditorPart;
|
18
|
|
19
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
20
|
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
|
21
|
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
|
22
|
import eu.etaxonomy.taxeditor.model.AbstractUtility;
|
23
|
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
|
24
|
|
25
|
/**
|
26
|
* @author pplitzner
|
27
|
* @since Aug 10, 2017
|
28
|
*
|
29
|
*/
|
30
|
public abstract class AbstractCdmEditorPartE4 implements IConversationEnabled, IDirtyMarkable{
|
31
|
|
32
|
protected AbstractCdmDataViewerE4 viewer;
|
33
|
|
34
|
protected MPart selectionProvidingPart;
|
35
|
|
36
|
@PostConstruct
|
37
|
public void create(Composite parent) {
|
38
|
viewer = createViewer(parent);
|
39
|
}
|
40
|
|
41
|
/** {@inheritDoc} */
|
42
|
@Override
|
43
|
public void changed(Object object) {
|
44
|
if(selectionProvidingPart!=null){
|
45
|
Object part = selectionProvidingPart.getObject();
|
46
|
if(part instanceof IDirtyMarkable){
|
47
|
((IDirtyMarkable) part).changed(object);
|
48
|
}
|
49
|
else {
|
50
|
IEditorPart editor = AbstractUtility.getActiveEditor();
|
51
|
if (editor != null && editor instanceof IDirtyMarkable) {
|
52
|
((IDirtyMarkable) editor).changed(object);
|
53
|
}
|
54
|
}
|
55
|
}
|
56
|
}
|
57
|
|
58
|
public void showViewer(IStructuredSelection selection){
|
59
|
if(viewer!=null){
|
60
|
Object element = selection.getFirstElement();
|
61
|
if(selection.getFirstElement()!=null){
|
62
|
viewer.setInput(element);
|
63
|
}
|
64
|
}
|
65
|
}
|
66
|
|
67
|
public void showEmptyPage() {
|
68
|
if(viewer!=null){
|
69
|
viewer.showEmptyPage();
|
70
|
}
|
71
|
selectionProvidingPart = null;
|
72
|
}
|
73
|
|
74
|
/**
|
75
|
* {@inheritDoc}
|
76
|
*/
|
77
|
@Override
|
78
|
public ConversationHolder getConversationHolder() {
|
79
|
if(selectionProvidingPart != null && selectionProvidingPart instanceof IConversationEnabled) {
|
80
|
return ((IConversationEnabled) selectionProvidingPart).getConversationHolder();
|
81
|
}
|
82
|
return null;
|
83
|
}
|
84
|
|
85
|
@PreDestroy
|
86
|
public void dispose() {
|
87
|
}
|
88
|
|
89
|
/**
|
90
|
* {@inheritDoc}
|
91
|
*/
|
92
|
@Override
|
93
|
public void update(CdmDataChangeMap arg0) {
|
94
|
}
|
95
|
|
96
|
/**
|
97
|
* {@inheritDoc}
|
98
|
*/
|
99
|
@Override
|
100
|
public void forceDirty() {
|
101
|
}
|
102
|
|
103
|
protected abstract String getViewName();
|
104
|
|
105
|
protected abstract AbstractCdmDataViewerE4 createViewer(Composite parent);
|
106
|
}
|