Revision a6d63028
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsPartE4.java | ||
---|---|---|
9 | 9 |
*/ |
10 | 10 |
package eu.etaxonomy.taxeditor.view.e4.details; |
11 | 11 |
|
12 |
import javax.annotation.PostConstruct; |
|
13 |
import javax.annotation.PreDestroy; |
|
14 | 12 |
import javax.inject.Inject; |
15 | 13 |
import javax.inject.Named; |
16 | 14 |
|
... | ... | |
19 | 17 |
import org.eclipse.e4.ui.services.IServiceConstants; |
20 | 18 |
import org.eclipse.jface.viewers.IStructuredSelection; |
21 | 19 |
import org.eclipse.jface.viewers.StructuredSelection; |
22 |
import org.eclipse.jface.viewers.Viewer; |
|
23 | 20 |
import org.eclipse.swt.widgets.Composite; |
24 | 21 |
import org.eclipse.ui.IEditorPart; |
25 | 22 |
|
26 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
|
27 | 23 |
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; |
28 | 24 |
import eu.etaxonomy.cdm.model.description.Feature; |
29 |
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap; |
|
30 | 25 |
import eu.etaxonomy.taxeditor.l10n.Messages; |
31 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
|
32 | 26 |
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer; |
33 |
import eu.etaxonomy.taxeditor.model.IDirtyMarkable; |
|
34 | 27 |
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails; |
28 |
import eu.etaxonomy.taxeditor.view.e4.AbstractCdmDataViewerE4; |
|
29 |
import eu.etaxonomy.taxeditor.view.e4.AbstractCdmEditorPartE4; |
|
35 | 30 |
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility; |
36 | 31 |
|
37 | 32 |
/** |
... | ... | |
39 | 34 |
* @date 18.07.2017 |
40 | 35 |
* |
41 | 36 |
*/ |
42 |
public class DetailsPartE4 implements IConversationEnabled, IDirtyMarkable{ |
|
43 |
|
|
44 |
private DetailsViewerE4 viewer; |
|
45 |
|
|
46 |
private MPart selectionProvidingPart; |
|
37 |
public class DetailsPartE4 extends AbstractCdmEditorPartE4{ |
|
47 | 38 |
|
48 | 39 |
@Inject |
49 | 40 |
public DetailsPartE4() { |
50 | 41 |
} |
51 | 42 |
|
52 |
@PostConstruct |
|
53 |
public void create(Composite parent) { |
|
54 |
viewer = new DetailsViewerE4(parent, this); |
|
43 |
/** |
|
44 |
* {@inheritDoc} |
|
45 |
*/ |
|
46 |
@Override |
|
47 |
protected AbstractCdmDataViewerE4 createViewer(Composite parent) { |
|
48 |
return new DetailsViewerE4(parent, this); |
|
55 | 49 |
} |
56 | 50 |
|
57 | 51 |
@Inject |
... | ... | |
98 | 92 |
} |
99 | 93 |
showViewer(structuredSelection); |
100 | 94 |
selectionProvidingPart = activePart; |
95 |
return; |
|
101 | 96 |
} |
102 | 97 |
else{ |
103 | 98 |
showEmptyPage(); |
... | ... | |
105 | 100 |
} |
106 | 101 |
} |
107 | 102 |
|
108 |
public void showEmptyPage() { |
|
109 |
if(viewer!=null){ |
|
110 |
viewer.showEmptyPage(); |
|
111 |
} |
|
112 |
selectionProvidingPart = null; |
|
113 |
} |
|
114 | 103 |
|
104 |
@Override |
|
115 | 105 |
protected String getViewName(){ |
116 | 106 |
return Messages.DetailsViewPart_VIEWER_NAME; |
117 | 107 |
} |
118 | 108 |
|
119 |
public Viewer getViewer() { |
|
120 |
return viewer; |
|
121 |
} |
|
122 |
|
|
123 |
|
|
124 |
@PreDestroy |
|
125 |
public void dispose() { |
|
126 |
} |
|
127 |
|
|
128 |
public void showViewer(IStructuredSelection selection){ |
|
129 |
if(getViewer()!=null){ |
|
130 |
Object element = selection.getFirstElement(); |
|
131 |
if(selection.getFirstElement()!=null){ |
|
132 |
getViewer().setInput(element); |
|
133 |
} |
|
134 |
} |
|
135 |
} |
|
136 |
|
|
137 |
/** |
|
138 |
* {@inheritDoc} |
|
139 |
*/ |
|
140 |
@Override |
|
141 |
public void update(CdmDataChangeMap arg0) { |
|
142 |
// TODO Auto-generated method stub |
|
143 |
|
|
144 |
} |
|
145 |
|
|
146 |
/** |
|
147 |
* {@inheritDoc} |
|
148 |
*/ |
|
149 |
@Override |
|
150 |
public ConversationHolder getConversationHolder() { |
|
151 |
if(selectionProvidingPart != null && selectionProvidingPart instanceof IConversationEnabled) { |
|
152 |
return ((IConversationEnabled) selectionProvidingPart).getConversationHolder(); |
|
153 |
} |
|
154 |
return null; |
|
155 |
} |
|
156 |
|
|
157 |
/** {@inheritDoc} */ |
|
158 |
@Override |
|
159 |
public void changed(Object object) { |
|
160 |
Object part = selectionProvidingPart.getObject(); |
|
161 |
if(part instanceof IDirtyMarkable){ |
|
162 |
((IDirtyMarkable) part).changed(object); |
|
163 |
} |
|
164 |
else { |
|
165 |
IEditorPart editor = AbstractUtility.getActiveEditor(); |
|
166 |
if (editor != null && editor instanceof IDirtyMarkable) { |
|
167 |
((IDirtyMarkable) editor).changed(object); |
|
168 |
} |
|
169 |
} |
|
170 |
} |
|
171 |
|
|
172 |
/** |
|
173 |
* {@inheritDoc} |
|
174 |
*/ |
|
175 |
@Override |
|
176 |
public void forceDirty() { |
|
177 |
// TODO Auto-generated method stub |
|
178 |
|
|
179 |
} |
|
180 | 109 |
} |
Also available in: Unified diff
ref #6905, #6597 Extract super class for details and supplemental viewer