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.inject.Inject;
|
13
|
import javax.inject.Named;
|
14
|
|
15
|
import org.eclipse.e4.core.di.annotations.Optional;
|
16
|
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
17
|
import org.eclipse.e4.ui.services.IServiceConstants;
|
18
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
19
|
import org.eclipse.jface.viewers.StructuredSelection;
|
20
|
import org.eclipse.swt.widgets.Composite;
|
21
|
|
22
|
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
|
23
|
import eu.etaxonomy.cdm.model.description.Feature;
|
24
|
import eu.etaxonomy.taxeditor.l10n.Messages;
|
25
|
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
|
26
|
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
|
27
|
import eu.etaxonomy.taxeditor.view.e4.AbstractCdmDataViewerE4;
|
28
|
import eu.etaxonomy.taxeditor.view.e4.AbstractCdmEditorPartE4;
|
29
|
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
|
30
|
|
31
|
/**
|
32
|
* @author pplitzner
|
33
|
* @date 18.07.2017
|
34
|
*
|
35
|
*/
|
36
|
public class DetailsPartE4 extends AbstractCdmEditorPartE4{
|
37
|
|
38
|
@Inject
|
39
|
public DetailsPartE4() {
|
40
|
}
|
41
|
|
42
|
/**
|
43
|
* {@inheritDoc}
|
44
|
*/
|
45
|
@Override
|
46
|
protected AbstractCdmDataViewerE4 createViewer(Composite parent) {
|
47
|
return new DetailsViewerE4(parent, this);
|
48
|
}
|
49
|
|
50
|
@Inject
|
51
|
@Optional
|
52
|
public void selectionChanged(
|
53
|
@Named(IServiceConstants.ACTIVE_SELECTION)Object selection,
|
54
|
@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
|
55
|
MPart thisPart){
|
56
|
if(activePart==thisPart){
|
57
|
return;
|
58
|
}
|
59
|
if(selection==null){
|
60
|
showEmptyPage();
|
61
|
return;
|
62
|
}
|
63
|
|
64
|
Object partObject = activePart;
|
65
|
Object wrappedPart = WorkbenchUtility.getE4WrappedPart(activePart);
|
66
|
if(wrappedPart!=null){
|
67
|
partObject = wrappedPart;
|
68
|
}
|
69
|
|
70
|
IStructuredSelection structuredSelection;
|
71
|
if(!(selection instanceof IStructuredSelection)){
|
72
|
structuredSelection = new StructuredSelection(selection);
|
73
|
}
|
74
|
else{
|
75
|
structuredSelection = (IStructuredSelection) selection;
|
76
|
}
|
77
|
if(structuredSelection.isEmpty()){
|
78
|
showEmptyPage();
|
79
|
return;
|
80
|
}
|
81
|
if(partObject instanceof IPartContentHasDetails){
|
82
|
if(partObject instanceof IConversationEnabled && ((IConversationEnabled) partObject).getConversationHolder()==null) {
|
83
|
//TODO show specific message (refactor EmptyElement to allow specific messages)
|
84
|
showEmptyPage();
|
85
|
return;
|
86
|
}
|
87
|
// do not show details for feature nodes TODO strange check to avoid having shown the distribution map for every FeatureNodeContainer
|
88
|
if(structuredSelection.getFirstElement() instanceof FeatureNodeContainer){
|
89
|
// do show the map for distributions
|
90
|
Feature feature = ((FeatureNodeContainer) ((IStructuredSelection) selection).getFirstElement()).getFeature();
|
91
|
if(!feature.equals(Feature.DISTRIBUTION())){
|
92
|
showEmptyPage();
|
93
|
return;
|
94
|
}
|
95
|
}
|
96
|
showViewer(structuredSelection, activePart);
|
97
|
return;
|
98
|
}
|
99
|
else{
|
100
|
showEmptyPage();
|
101
|
return;
|
102
|
}
|
103
|
}
|
104
|
|
105
|
|
106
|
@Override
|
107
|
protected String getViewName(){
|
108
|
return Messages.DetailsViewPart_VIEWER_NAME;
|
109
|
}
|
110
|
|
111
|
}
|