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
.core
.contexts
.ContextInjectionFactory
;
16 import org
.eclipse
.e4
.core
.contexts
.IEclipseContext
;
17 import org
.eclipse
.e4
.ui
.model
.application
.ui
.basic
.MPart
;
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
.model
.IPartContentHasSupplementalData
;
28 import eu
.etaxonomy
.taxeditor
.view
.e4
.AbstractCdmEditorPartE4
;
29 import eu
.etaxonomy
.taxeditor
.view
.e4
.supplementaldata
.SupplementalDataPartE4
;
30 import eu
.etaxonomy
.taxeditor
.workbench
.part
.ISelectionElementEditingPart
;
37 public class DetailsPartE4
extends AbstractCdmEditorPartE4
implements IPartContentHasSupplementalData
{
40 public DetailsPartE4() {
44 public void create(Composite parent
, MPart thisPart
, IEclipseContext context
) {
46 this.thisPart
= thisPart
;
48 viewer
= ContextInjectionFactory
.make(DetailsViewerE4
.class, context
);
49 ((DetailsViewerE4
)viewer
).init(parent
, this);
51 // Propagate selection from viewer
52 selectionChangedListener
= (event
-> selService
.setSelection(AbstractUtility
.getElementsFromSelectionChangedEvent(event
)));
53 viewer
.addSelectionChangedListener(selectionChangedListener
);
57 public void selectionChanged_internal(Object selection
, MPart activePart
, MPart thisPart
) {
58 if (activePart
==thisPart
){
62 Object partObject
= createPartObject(activePart
);
63 if (partObject
instanceof SupplementalDataPartE4
) {
64 // do not show empty page
68 if(partObject
instanceof IPartContentHasDetails
){
69 IStructuredSelection structuredSelection
= createSelection(selection
);
70 if(structuredSelection
==null || structuredSelection
.isEmpty()){
74 if(!(partObject
instanceof ISelectionElementEditingPart
) &&
75 partObject
instanceof IConversationEnabled
&& ((IConversationEnabled
) partObject
).getConversationHolder()==null) {
76 //TODO show specific message (refactor EmptyElement to allow specific messages)
80 // do not show details for feature nodes TODO strange check to avoid having shown the distribution map for every FeatureNodeContainer
81 if(structuredSelection
.getFirstElement() instanceof FeatureNodeContainer
){
82 // do show the map for distributions
83 Feature feature
= ((FeatureNodeContainer
) structuredSelection
.getFirstElement()).getFeature();
84 if(!feature
.equals(Feature
.DISTRIBUTION())){
89 // if (partObject instanceof IDistributionEditor){
91 // showViewer(structuredSelection, activePart, viewer);
95 //FIXME this is a temporary workaround to fix selection handling for supplemental data view
96 // Now the supp data view gets double selection from details view and name editor (see #7126)
97 viewer
.setSelection(structuredSelection
, false);
98 showViewer(structuredSelection
, activePart
, viewer
);
108 protected void showEmptyPage() {
109 super.showEmptyPage();
110 if(viewer
!=null && viewer
.getControl()!=null && !viewer
.getControl().isDisposed() ){
111 ((DetailsViewerE4
)viewer
).destroySections();
116 protected String
getViewName(){
117 return Messages
.DetailsViewPart_VIEWER_NAME
;