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
.annotation
.PreDestroy
;
14 import javax
.inject
.Inject
;
15 import javax
.inject
.Named
;
17 import org
.eclipse
.e4
.core
.di
.annotations
.Optional
;
18 import org
.eclipse
.e4
.ui
.model
.application
.ui
.basic
.MPart
;
19 import org
.eclipse
.e4
.ui
.services
.IServiceConstants
;
20 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
21 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
22 import org
.eclipse
.jface
.viewers
.Viewer
;
23 import org
.eclipse
.swt
.widgets
.Composite
;
24 import org
.eclipse
.ui
.IEditorPart
;
26 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
27 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
28 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
29 import eu
.etaxonomy
.cdm
.persistence
.hibernate
.CdmDataChangeMap
;
30 import eu
.etaxonomy
.taxeditor
.l10n
.Messages
;
31 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
32 import eu
.etaxonomy
.taxeditor
.model
.FeatureNodeContainer
;
33 import eu
.etaxonomy
.taxeditor
.model
.IDirtyMarkable
;
34 import eu
.etaxonomy
.taxeditor
.model
.IPartContentHasDetails
;
35 import eu
.etaxonomy
.taxeditor
.workbench
.WorkbenchUtility
;
42 public class DetailsPartE4
implements IConversationEnabled
, IDirtyMarkable
{
44 private DetailsViewerE4 viewer
;
46 private MPart selectionProvidingPart
;
49 public DetailsPartE4() {
53 public void create(Composite parent
) {
54 viewer
= new DetailsViewerE4(parent
, this);
59 public void selectionChanged(
60 @Named(IServiceConstants
.ACTIVE_SELECTION
)Object selection
,
61 @Named(IServiceConstants
.ACTIVE_PART
)MPart activePart
,
63 if(activePart
==thisPart
|| selection
==null){
67 Object partObject
= activePart
;
68 Object wrappedPart
= WorkbenchUtility
.getE4WrappedPart(activePart
);
69 if(wrappedPart
!=null){
70 partObject
= wrappedPart
;
73 IStructuredSelection structuredSelection
;
74 if(!(selection
instanceof IStructuredSelection
)){
75 structuredSelection
= new StructuredSelection(selection
);
78 structuredSelection
= (IStructuredSelection
) selection
;
80 if((partObject
instanceof IEditorPart
) || (partObject
instanceof IPartContentHasDetails
)
81 && partObject
instanceof IConversationEnabled
) {
82 // do not show details for feature nodes TODO strange check to avoid having shown the distribution map for every FeatureNodeContainer
83 if(structuredSelection
.getFirstElement() instanceof FeatureNodeContainer
){
84 // do show the map for distributions
85 Feature feature
= ((FeatureNodeContainer
) ((IStructuredSelection
) selection
).getFirstElement()).getFeature();
86 if(!feature
.equals(Feature
.DISTRIBUTION())){
91 showViewer(structuredSelection
);
92 selectionProvidingPart
= activePart
;
99 public void showEmptyPage() {
100 viewer
.showEmptyPage();
101 selectionProvidingPart
= null;
104 protected String
getViewName(){
105 return Messages
.DetailsViewPart_VIEWER_NAME
;
108 public Viewer
getViewer() {
114 public void dispose() {
117 public void showViewer(IStructuredSelection selection
){
118 if(getViewer()!=null){
119 Object element
= selection
.getFirstElement();
120 if(selection
.getFirstElement()!=null){
121 getViewer().setInput(element
);
130 public void update(CdmDataChangeMap arg0
) {
131 // TODO Auto-generated method stub
139 public ConversationHolder
getConversationHolder() {
140 if(selectionProvidingPart
!= null && selectionProvidingPart
instanceof IConversationEnabled
) {
141 return ((IConversationEnabled
) selectionProvidingPart
).getConversationHolder();
148 public void changed(Object object
) {
149 Object part
= selectionProvidingPart
.getObject();
150 if(part
instanceof IDirtyMarkable
){
151 ((IDirtyMarkable
) part
).changed(object
);
154 IEditorPart editor
= AbstractUtility
.getActiveEditor();
155 if (editor
!= null && editor
instanceof IDirtyMarkable
) {
156 ((IDirtyMarkable
) editor
).changed(object
);
165 public void forceDirty() {
166 // TODO Auto-generated method stub