1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2017 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
package eu.etaxonomy.taxeditor.view.e4.details;
|
11
|
|
12
|
import javax.annotation.PostConstruct;
|
13
|
import javax.inject.Inject;
|
14
|
|
15
|
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
16
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
17
|
import org.eclipse.swt.widgets.Composite;
|
18
|
|
19
|
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
|
20
|
import eu.etaxonomy.cdm.model.description.Feature;
|
21
|
import eu.etaxonomy.taxeditor.l10n.Messages;
|
22
|
import eu.etaxonomy.taxeditor.model.AbstractUtility;
|
23
|
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
|
24
|
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
|
25
|
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
|
26
|
import eu.etaxonomy.taxeditor.view.e4.AbstractCdmEditorPartE4;
|
27
|
import eu.etaxonomy.taxeditor.workbench.part.ISelectionElementEditingPart;
|
28
|
|
29
|
/**
|
30
|
* @author pplitzner
|
31
|
* @date 18.07.2017
|
32
|
*
|
33
|
*/
|
34
|
public class DetailsPartE4 extends AbstractCdmEditorPartE4 implements IPartContentHasSupplementalData {
|
35
|
|
36
|
@Inject
|
37
|
public DetailsPartE4() {
|
38
|
}
|
39
|
|
40
|
@PostConstruct
|
41
|
public void create(Composite parent) {
|
42
|
viewer = new DetailsViewerE4(parent, this);
|
43
|
|
44
|
// Propagate selection from viewer
|
45
|
selectionChangedListener = (event -> selService.setSelection(AbstractUtility.getElementsFromSelectionChangedEvent(event)));
|
46
|
viewer.addSelectionChangedListener(selectionChangedListener);
|
47
|
}
|
48
|
|
49
|
@Override
|
50
|
public void selectionChanged_internal(Object selection, MPart activePart, MPart thisPart) {
|
51
|
if (activePart==thisPart){
|
52
|
return;
|
53
|
}
|
54
|
|
55
|
Object partObject = createPartObject(activePart);
|
56
|
|
57
|
if(partObject instanceof IPartContentHasDetails){
|
58
|
IStructuredSelection structuredSelection = createSelection(selection);
|
59
|
if(structuredSelection==null || structuredSelection.isEmpty()){
|
60
|
showEmptyPage();
|
61
|
return;
|
62
|
}
|
63
|
if(!(partObject instanceof ISelectionElementEditingPart) &&
|
64
|
partObject instanceof IConversationEnabled && ((IConversationEnabled) partObject).getConversationHolder()==null) {
|
65
|
//TODO show specific message (refactor EmptyElement to allow specific messages)
|
66
|
showEmptyPage();
|
67
|
return;
|
68
|
}
|
69
|
// do not show details for feature nodes TODO strange check to avoid having shown the distribution map for every FeatureNodeContainer
|
70
|
if(structuredSelection.getFirstElement() instanceof FeatureNodeContainer){
|
71
|
// do show the map for distributions
|
72
|
Feature feature = ((FeatureNodeContainer) structuredSelection.getFirstElement()).getFeature();
|
73
|
if(!feature.equals(Feature.DISTRIBUTION())){
|
74
|
showEmptyPage();
|
75
|
return;
|
76
|
}
|
77
|
}
|
78
|
showViewer(structuredSelection, activePart, viewer);
|
79
|
return;
|
80
|
}
|
81
|
else{
|
82
|
showEmptyPage();
|
83
|
return;
|
84
|
}
|
85
|
}
|
86
|
|
87
|
@Override
|
88
|
protected void showEmptyPage() {
|
89
|
super.showEmptyPage();
|
90
|
if(viewer!=null && !viewer.getControl().isDisposed()){
|
91
|
((DetailsViewerE4)viewer).destroySections();
|
92
|
}
|
93
|
}
|
94
|
|
95
|
@Override
|
96
|
protected String getViewName(){
|
97
|
return Messages.DetailsViewPart_VIEWER_NAME;
|
98
|
}
|
99
|
|
100
|
}
|