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
.jface
.viewers
.IStructuredSelection
;
17 import org
.eclipse
.swt
.widgets
.Composite
;
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
;
34 public class DetailsPartE4
extends AbstractCdmEditorPartE4
implements IPartContentHasSupplementalData
{
37 public DetailsPartE4() {
41 public void create(Composite parent
, MPart thisPart
) {
43 this.thisPart
= thisPart
;
45 viewer
= new DetailsViewerE4(parent
, this);
47 // Propagate selection from viewer
48 selectionChangedListener
= (event
-> selService
.setSelection(AbstractUtility
.getElementsFromSelectionChangedEvent(event
)));
49 viewer
.addSelectionChangedListener(selectionChangedListener
);
53 public void selectionChanged_internal(Object selection
, MPart activePart
, MPart thisPart
) {
54 if (activePart
==thisPart
){
58 Object partObject
= createPartObject(activePart
);
60 if(partObject
instanceof IPartContentHasDetails
){
61 IStructuredSelection structuredSelection
= createSelection(selection
);
62 if(structuredSelection
==null || structuredSelection
.isEmpty()){
66 if(!(partObject
instanceof ISelectionElementEditingPart
) &&
67 partObject
instanceof IConversationEnabled
&& ((IConversationEnabled
) partObject
).getConversationHolder()==null) {
68 //TODO show specific message (refactor EmptyElement to allow specific messages)
72 // do not show details for feature nodes TODO strange check to avoid having shown the distribution map for every FeatureNodeContainer
73 if(structuredSelection
.getFirstElement() instanceof FeatureNodeContainer
){
74 // do show the map for distributions
75 Feature feature
= ((FeatureNodeContainer
) structuredSelection
.getFirstElement()).getFeature();
76 if(!feature
.equals(Feature
.DISTRIBUTION())){
81 showViewer(structuredSelection
, activePart
, viewer
);
91 protected void showEmptyPage() {
92 super.showEmptyPage();
93 if(viewer
!=null && !viewer
.getControl().isDisposed()){
94 ((DetailsViewerE4
)viewer
).destroySections();
99 protected String
getViewName(){
100 return Messages
.DetailsViewPart_VIEWER_NAME
;