2 * Copyright (C) 2007 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.
10 package eu
.etaxonomy
.taxeditor
.view
.detail
;
12 import org
.eclipse
.jface
.viewers
.ISelection
;
13 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
14 import org
.eclipse
.jface
.viewers
.TreeNode
;
15 import org
.eclipse
.jface
.viewers
.Viewer
;
16 import org
.eclipse
.swt
.widgets
.Composite
;
17 import org
.eclipse
.ui
.IEditorPart
;
18 import org
.eclipse
.ui
.IWorkbenchPart
;
20 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
21 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
22 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
23 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
24 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
25 import eu
.etaxonomy
.taxeditor
.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
.view
.AbstractCdmEditorViewPart
;
33 * <p>DetailsViewPart class.</p>
36 * @created Jun 10, 2010
39 public class DetailsViewPart
extends AbstractCdmEditorViewPart
implements IPartContentHasSupplementalData
{
41 /** Constant <code>ID="eu.etaxonomy.taxeditor.editor.forms.det"{trunked}</code> */
42 public static String ID
= "eu.etaxonomy.taxeditor.view.detail"; //$NON-NLS-1$
44 private DetailsViewer viewer
;
48 public void createViewer(Composite parent
) {
50 viewer
= new DetailsViewer(parent
, this);
51 getSite().setSelectionProvider(viewer
);
55 protected void selectionChanged_internal(IWorkbenchPart part
, ISelection selection
){
56 if(AbstractUtility
.getActiveEditor() == null && !(AbstractUtility
.getActivePart() instanceof IConversationEnabled
)){
65 if(!(selection
instanceof IStructuredSelection
)){
69 IStructuredSelection structuredSelection
= (IStructuredSelection
) selection
;
71 if((part
instanceof IEditorPart
) || (part
instanceof IPartContentHasDetails
)) {
72 if(structuredSelection
.size() != 1){
77 // do not show details for feature nodes TODO really?
78 if(structuredSelection
.getFirstElement() instanceof FeatureNodeContainer
){
79 // do show the map for distributions
80 Feature feature
= ((FeatureNodeContainer
) ((IStructuredSelection
) selection
).getFirstElement()).getFeature();
81 if(!feature
.equals(Feature
.DISTRIBUTION())){
86 showViewer(part
, structuredSelection
);
93 protected String
getViewName(){
94 return Messages
.DetailsViewPart_VIEWER_NAME
;
98 protected String
createPartTitle(Object selectedObject
){
99 if(selectedObject
!=null){
100 if(selectedObject
instanceof TreeNode
){
101 selectedObject
= ((TreeNode
) selectedObject
).getValue();
103 if(selectedObject
instanceof SpecimenOrObservationBase
){
104 return getViewName()+": "+HibernateProxyHelper
.deproxy(selectedObject
, SpecimenOrObservationBase
.class).getRecordBasis(); //$NON-NLS-1$
106 if(selectedObject
instanceof CdmBase
){
107 return getViewName()+": "+HibernateProxyHelper
.deproxy(selectedObject
, CdmBase
.class).getClass().getSimpleName(); //$NON-NLS-1$
109 return getViewName()+": "+selectedObject
.getClass().getSimpleName(); //$NON-NLS-1$
111 return getViewName();
115 public void showEmptyPage() {
116 viewer
.setSelection(null);
117 super.showEmptyPage();
122 public boolean postOperation(CdmBase objectAffectedByOperation
) {
124 viewer
.setInput(objectAffectedByOperation
);
126 return super.postOperation(objectAffectedByOperation
);
132 public Viewer
getViewer() {
139 public void dispose() {
140 selectionService
.removePostSelectionListener(this);
146 public boolean onComplete() {