2 * Copyright (C) 2017 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.taxeditor
.view
.e4
.details
;
11 import javax
.annotation
.PostConstruct
;
12 import javax
.inject
.Inject
;
14 import org
.eclipse
.e4
.core
.contexts
.ContextInjectionFactory
;
15 import org
.eclipse
.e4
.core
.contexts
.IEclipseContext
;
16 import org
.eclipse
.e4
.ui
.model
.application
.ui
.basic
.MPart
;
17 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
18 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
19 import org
.eclipse
.swt
.SWTException
;
20 import org
.eclipse
.swt
.widgets
.Composite
;
22 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
23 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
24 import eu
.etaxonomy
.taxeditor
.l10n
.Messages
;
25 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
26 import eu
.etaxonomy
.taxeditor
.model
.FeatureNodeContainer
;
27 import eu
.etaxonomy
.taxeditor
.model
.IPartContentHasDetails
;
28 import eu
.etaxonomy
.taxeditor
.model
.IPartContentHasFactualData
;
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
;
40 public class DetailsPartE4
extends AbstractCdmEditorPartE4
implements IPartContentHasSupplementalData
, IPartContentHasFactualData
{
43 public DetailsPartE4() {
47 public void create(Composite parent
, MPart thisPart
, IEclipseContext context
) {
49 this.thisPart
= thisPart
;
51 viewer
= ContextInjectionFactory
.make(DetailsViewerE4
.class, context
);
52 ((DetailsViewerE4
)viewer
).init(parent
, this);
54 // Propagate selection from viewer
55 selectionChangedListener
= (event
-> selService
.setSelection(AbstractUtility
.getElementsFromSelectionChangedEvent(event
)));
56 viewer
.addSelectionChangedListener(selectionChangedListener
);
60 public void selectionChanged_internal(Object selection
, MPart activePart
, MPart thisPart
) {
61 if (activePart
==thisPart
){
65 Object partObject
= createPartObject(activePart
);
66 if (partObject
instanceof SupplementalDataPartE4
) {
67 // do not show empty page
71 if(partObject
instanceof IPartContentHasDetails
){
72 IStructuredSelection structuredSelection
= createSelection(selection
);
73 if(structuredSelection
==null || structuredSelection
.isEmpty()){
77 if(!(partObject
instanceof ISelectionElementEditingPart
) &&
78 partObject
instanceof IConversationEnabled
&& ((IConversationEnabled
) partObject
).getConversationHolder()==null) {
79 //TODO show specific message (refactor EmptyElement to allow specific messages)
83 // do not show details for feature nodes TODO strange check to avoid having shown the distribution map for every FeatureNodeContainer
84 if(structuredSelection
.getFirstElement() instanceof FeatureNodeContainer
){
85 // do show the map for distributions
86 Feature feature
= ((FeatureNodeContainer
) structuredSelection
.getFirstElement()).getFeature();
87 if(!feature
.equals(Feature
.DISTRIBUTION())){
93 //FIXME this is a temporary workaround to fix selection handling for supplemental data view
94 // Now the supp data view gets double selection from details view and name editor (see #7126)
96 viewer
.setSelection(structuredSelection
, false);
98 showViewer(structuredSelection
, activePart
, viewer
);
110 public void refreshSelection(){
111 selectionChanged_internal(new StructuredSelection(this.viewer
.getInput()), selectionProvidingPart
, thisPart
);
115 protected void showEmptyPage() {
116 super.showEmptyPage();
117 if(viewer
!=null && viewer
.getControl()!=null && !viewer
.getControl().isDisposed() ){
119 ((DetailsViewerE4
)viewer
).destroySections();
120 }catch(SWTException e
){
121 if (PreferencesUtil
.isShowUpWidgetIsDisposedMessages() && e
.getMessage().equals("Widget is disposed")){
122 MessagingUtils
.errorDialog("Widget is disposed",
124 MessagingUtils
.WIDGET_IS_DISPOSED_MESSAGE
,
135 protected String
getViewName(){
136 return Messages
.DetailsViewPart_VIEWER_NAME
;