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
.core
.services
.log
.Logger
;
18 import org
.eclipse
.e4
.ui
.model
.application
.ui
.basic
.MPart
;
19 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
20 import org
.eclipse
.swt
.SWTException
;
21 import org
.eclipse
.swt
.widgets
.Composite
;
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
.AbstractUtility
;
27 import eu
.etaxonomy
.taxeditor
.model
.FeatureNodeContainer
;
28 import eu
.etaxonomy
.taxeditor
.model
.IPartContentHasDetails
;
29 import eu
.etaxonomy
.taxeditor
.model
.IPartContentHasSupplementalData
;
30 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
31 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
32 import eu
.etaxonomy
.taxeditor
.view
.e4
.AbstractCdmEditorPartE4
;
33 import eu
.etaxonomy
.taxeditor
.view
.e4
.supplementaldata
.SupplementalDataPartE4
;
34 import eu
.etaxonomy
.taxeditor
.workbench
.part
.ISelectionElementEditingPart
;
41 public class DetailsPartE4
extends AbstractCdmEditorPartE4
implements IPartContentHasSupplementalData
{
43 private Logger logger
;
46 public DetailsPartE4() {
50 public void create(Composite parent
, MPart thisPart
, IEclipseContext context
) {
52 this.thisPart
= thisPart
;
54 viewer
= ContextInjectionFactory
.make(DetailsViewerE4
.class, context
);
55 ((DetailsViewerE4
)viewer
).init(parent
, this);
57 // Propagate selection from viewer
58 selectionChangedListener
= (event
-> selService
.setSelection(AbstractUtility
.getElementsFromSelectionChangedEvent(event
)));
59 viewer
.addSelectionChangedListener(selectionChangedListener
);
63 public void selectionChanged_internal(Object selection
, MPart activePart
, MPart thisPart
) {
64 if (activePart
==thisPart
){
68 Object partObject
= createPartObject(activePart
);
69 if (partObject
instanceof SupplementalDataPartE4
) {
70 // do not show empty page
74 if(partObject
instanceof IPartContentHasDetails
){
75 IStructuredSelection structuredSelection
= createSelection(selection
);
76 if(structuredSelection
==null || structuredSelection
.isEmpty()){
80 if(!(partObject
instanceof ISelectionElementEditingPart
) &&
81 partObject
instanceof IConversationEnabled
&& ((IConversationEnabled
) partObject
).getConversationHolder()==null) {
82 //TODO show specific message (refactor EmptyElement to allow specific messages)
86 // do not show details for feature nodes TODO strange check to avoid having shown the distribution map for every FeatureNodeContainer
87 if(structuredSelection
.getFirstElement() instanceof FeatureNodeContainer
){
88 // do show the map for distributions
89 Feature feature
= ((FeatureNodeContainer
) structuredSelection
.getFirstElement()).getFeature();
90 if(!feature
.equals(Feature
.DISTRIBUTION())){
95 // if (partObject instanceof IDistributionEditor){
97 // showViewer(structuredSelection, activePart, viewer);
101 //FIXME this is a temporary workaround to fix selection handling for supplemental data view
102 // Now the supp data view gets double selection from details view and name editor (see #7126)
103 viewer
.setSelection(structuredSelection
, false);
104 showViewer(structuredSelection
, activePart
, viewer
);
114 protected void showEmptyPage() {
115 super.showEmptyPage();
116 if(viewer
!=null && viewer
.getControl()!=null && !viewer
.getControl().isDisposed() ){
118 ((DetailsViewerE4
)viewer
).destroySections();
119 }catch(SWTException e
){
120 if (PreferencesUtil
.isShowUpWidgetIsDisposedMessages() && e
.getMessage().equals("Widget is disposed")){
121 MessagingUtils
.errorDialog("Widget is disposed",
123 MessagingUtils
.WIDGET_IS_DISPOSED_MESSAGE
,
134 protected String
getViewName(){
135 return Messages
.DetailsViewPart_VIEWER_NAME
;