Revision 604e7242
Added by Andreas Müller over 1 year ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/FactualDataPartE4.java | ||
---|---|---|
52 | 52 |
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementTransfer; |
53 | 53 |
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveContentProvider; |
54 | 54 |
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveLabelProvider; |
55 |
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewerSorter;
|
|
55 |
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewerComparator;
|
|
56 | 56 |
import eu.etaxonomy.taxeditor.editor.view.descriptive.NameDescriptionFilter; |
57 | 57 |
import eu.etaxonomy.taxeditor.editor.view.media.e4.MediaViewPartE4; |
58 | 58 |
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants; |
... | ... | |
72 | 72 |
* @author pplitzner |
73 | 73 |
* @date 15.08.2017 |
74 | 74 |
*/ |
75 |
public class FactualDataPartE4 extends AbstractCdmEditorPart |
|
75 |
public class FactualDataPartE4 extends AbstractCdmEditorPart<TreeViewer>
|
|
76 | 76 |
implements IPartContentHasDetails, IPartContentHasSupplementalData, |
77 | 77 |
ICdmEntitySessionEnabled<CdmBase>, ICollapsableExpandable { |
78 | 78 |
|
... | ... | |
97 | 97 |
provider = new DescriptiveContentProvider(featureNodeContainerCache); |
98 | 98 |
treeViewer.setContentProvider(provider); |
99 | 99 |
treeViewer.setLabelProvider(new DescriptiveLabelProvider()); |
100 |
treeViewer.setSorter(new DescriptiveViewerSorter());
|
|
100 |
treeViewer.setComparator(new DescriptiveViewerComparator());
|
|
101 | 101 |
treeViewer.setFilters(new NameDescriptionFilter()); |
102 | 102 |
treeViewer.setAutoExpandLevel(2); |
103 | 103 |
Transfer[] transfers = new Transfer[] { DescriptionElementTransfer.getInstance() }; |
104 | 104 |
treeViewer.addDragSupport(dndOperations, transfers, new DescriptionElementDragListener( |
105 | 105 |
this)); |
106 | 106 |
|
107 |
|
|
108 | 107 |
viewer = treeViewer; |
109 | 108 |
|
110 | 109 |
// Propagate selection from viewer |
... | ... | |
132 | 131 |
|| partObject instanceof SupplementalDataPartE4 |
133 | 132 |
|| partObject instanceof MediaViewPartE4 |
134 | 133 |
|| partObject instanceof ConceptViewPartE4 |
135 |
|| ((partObject instanceof AbstractCdmEditorPart) &&(((AbstractCdmEditorPart)partObject).getViewer().getInput() instanceof DescriptionElementBase))) { |
|
134 |
|| ((partObject instanceof AbstractCdmEditorPart) &&(((AbstractCdmEditorPart<?>)partObject).getViewer().getInput() instanceof DescriptionElementBase))) {
|
|
136 | 135 |
// do not show empty page as these views are also used to edit the |
137 | 136 |
// description selected in this view |
138 | 137 |
return; |
... | ... | |
195 | 194 |
public void changed(Object object) { |
196 | 195 |
Object[] expandedObjects = null; |
197 | 196 |
if (!viewer.getControl().isDisposed()){ |
198 |
expandedObjects = ((TreeViewer)viewer).getExpandedElements();
|
|
197 |
expandedObjects = viewer.getExpandedElements();
|
|
199 | 198 |
}else{ |
200 | 199 |
return; |
201 | 200 |
} |
... | ... | |
205 | 204 |
|
206 | 205 |
viewer.refresh(); |
207 | 206 |
super.changed(object); |
208 |
((TreeViewer) viewer).setExpandedElements(expandedObjects);
|
|
207 |
viewer.setExpandedElements(expandedObjects);
|
|
209 | 208 |
if(object instanceof DescriptionElementBase){ |
210 | 209 |
DescriptionElementBase descriptionElement = (DescriptionElementBase) object; |
211 | 210 |
DescriptionBase<?> description = descriptionElement.getInDescription(); |
... | ... | |
219 | 218 |
} |
220 | 219 |
((AbstractTreeViewer) viewer).expandToLevel(featureNodeContainer, 2); |
221 | 220 |
} |
222 |
if (object != null){ |
|
223 |
StructuredSelection selection = new StructuredSelection(object); |
|
224 |
viewer.setSelection(selection, true); |
|
225 |
} |
|
226 |
|
|
221 |
StructuredSelection selection = new StructuredSelection(object); |
|
222 |
viewer.setSelection(selection, true); |
|
227 | 223 |
} |
228 |
|
|
229 |
|
|
230 |
|
|
231 | 224 |
} |
232 | 225 |
|
233 | 226 |
@Inject |
234 | 227 |
@Optional |
235 | 228 |
private void updateView(@UIEventTopic(WorkbenchEventConstants.SAVE_TAXON)boolean refresh){ |
236 | 229 |
if(refresh){ |
237 |
Object[] expandedObjects = ((TreeViewer)viewer).getExpandedElements();
|
|
230 |
Object[] expandedObjects = viewer.getExpandedElements();
|
|
238 | 231 |
viewer.refresh(); |
239 |
((TreeViewer)viewer).collapseAll();
|
|
232 |
viewer.collapseAll();
|
|
240 | 233 |
if (expandedObjects.length>0){ |
241 |
((TreeViewer)viewer).setExpandedElements(expandedObjects);
|
|
234 |
viewer.setExpandedElements(expandedObjects);
|
|
242 | 235 |
} |
243 | 236 |
} |
244 | 237 |
} |
245 | 238 |
|
246 |
|
|
247 | 239 |
@Inject |
248 | 240 |
@Optional |
249 | 241 |
private void updateView(@UIEventTopic(WorkbenchEventConstants.CURRENT_ACTIVE_EDITOR)ITaxonEditor editor){ |
... | ... | |
252 | 244 |
} |
253 | 245 |
} |
254 | 246 |
|
255 |
/** |
|
256 |
* {@inheritDoc} |
|
257 |
*/ |
|
258 | 247 |
@Override |
259 | 248 |
public void collapse() { |
260 |
if(viewer instanceof TreeViewer) { |
|
261 |
((TreeViewer) viewer).collapseAll(); |
|
262 |
} |
|
249 |
viewer.collapseAll(); |
|
263 | 250 |
} |
264 | 251 |
|
265 |
/** |
|
266 |
* {@inheritDoc} |
|
267 |
*/ |
|
268 | 252 |
@Override |
269 | 253 |
public void expand() { |
270 |
if(viewer instanceof TreeViewer) { |
|
271 |
((TreeViewer) viewer).expandAll(); |
|
272 |
} |
|
254 |
viewer.expandAll(); |
|
273 | 255 |
} |
274 | 256 |
|
275 | 257 |
public void toggleShowOnlyIndividualAssociations(){ |
... | ... | |
289 | 271 |
public List<CdmBase> getRootEntities() { |
290 | 272 |
return Arrays.asList((CdmBase)getViewer().getInput()); |
291 | 273 |
} |
274 |
|
|
292 | 275 |
@Override |
293 | 276 |
public Map<Object, List<String>> getPropertyPathsMap() { |
294 | 277 |
return null; |
... | ... | |
297 | 280 |
@Override |
298 | 281 |
protected void showViewer(IStructuredSelection selection, MPart activePart, Viewer viewer){ |
299 | 282 |
Object[] expandedObjects = null; |
300 |
if (!((TreeViewer)this.getViewer()).getControl().isDisposed()){
|
|
301 |
expandedObjects = ((TreeViewer)this.getViewer()).getExpandedElements();
|
|
283 |
if (!this.getViewer().getControl().isDisposed()){
|
|
284 |
expandedObjects = this.getViewer().getExpandedElements();
|
|
302 | 285 |
} |
303 | 286 |
super.showViewer(selection, activePart, viewer); |
304 | 287 |
if (expandedObjects == null || expandedObjects.length == 0){ |
305 |
((TreeViewer)this.viewer).expandToLevel(2);
|
|
288 |
this.viewer.expandToLevel(2);
|
|
306 | 289 |
}else{ |
307 |
((TreeViewer)this.viewer).setExpandedElements(expandedObjects);
|
|
290 |
this.viewer.setExpandedElements(expandedObjects);
|
|
308 | 291 |
} |
309 | 292 |
} |
310 | 293 |
} |
Also available in: Unified diff
add viewer generics to AbstractCdmEditorPart, remove deprecated ViewerSorter and some other cleanup