3 * Copyright (C) 2017 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.view
.e4
.details
;
12 import javax
.annotation
.PostConstruct
;
13 import javax
.inject
.Inject
;
15 import org
.eclipse
.e4
.ui
.model
.application
.ui
.basic
.MPart
;
16 import org
.eclipse
.e4
.ui
.workbench
.modeling
.ESelectionService
;
17 import org
.eclipse
.jface
.viewers
.ISelectionChangedListener
;
18 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
19 import org
.eclipse
.swt
.widgets
.Composite
;
21 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
22 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
23 import eu
.etaxonomy
.taxeditor
.l10n
.Messages
;
24 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
25 import eu
.etaxonomy
.taxeditor
.model
.FeatureNodeContainer
;
26 import eu
.etaxonomy
.taxeditor
.model
.IPartContentHasDetails
;
27 import eu
.etaxonomy
.taxeditor
.view
.e4
.AbstractCdmEditorPartE4
;
28 import eu
.etaxonomy
.taxeditor
.workbench
.part
.ISelectionElementEditingPart
;
35 public class DetailsPartE4
extends AbstractCdmEditorPartE4
{
37 private ISelectionChangedListener selectionChangedListener
;
40 private ESelectionService selService
;
43 public DetailsPartE4() {
47 public void create(Composite parent
, MPart thisPart
) {
49 this.thisPart
= thisPart
;
51 viewer
= new DetailsViewerE4(parent
, this);
53 // Propagate selection from viewer
54 selectionChangedListener
= (event
-> selService
.setSelection(AbstractUtility
.getElementsFromSelectionChangedEvent(event
)));
55 viewer
.addSelectionChangedListener(selectionChangedListener
);
59 public void selectionChanged_internal(Object selection
, MPart activePart
, MPart thisPart
) {
60 if (activePart
==thisPart
){
64 Object partObject
= createPartObject(activePart
);
66 if(partObject
instanceof IPartContentHasDetails
){
67 IStructuredSelection structuredSelection
= createSelection(selection
);
68 if(structuredSelection
==null || structuredSelection
.isEmpty()){
72 if(!(partObject
instanceof ISelectionElementEditingPart
) &&
73 partObject
instanceof IConversationEnabled
&& ((IConversationEnabled
) partObject
).getConversationHolder()==null) {
74 //TODO show specific message (refactor EmptyElement to allow specific messages)
78 // do not show details for feature nodes TODO strange check to avoid having shown the distribution map for every FeatureNodeContainer
79 if(structuredSelection
.getFirstElement() instanceof FeatureNodeContainer
){
80 // do show the map for distributions
81 Feature feature
= ((FeatureNodeContainer
) structuredSelection
.getFirstElement()).getFeature();
82 if(!feature
.equals(Feature
.DISTRIBUTION())){
87 showViewer(structuredSelection
, activePart
, viewer
);
90 else if(selectionProvidingPart
!=null && selectionProvidingPart
.isVisible()){
99 // protected void showEmptyPage() {
100 // super.showEmptyPage();
102 // viewer.showEmptyPage();
104 // selectionProvidingPart = null;
108 protected String
getViewName(){
109 return Messages
.DetailsViewPart_VIEWER_NAME
;