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