3 * Copyright (C) 2007 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.
11 package eu
.etaxonomy
.taxeditor
.view
.detail
;
13 import org
.eclipse
.jface
.viewers
.ISelection
;
14 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
15 import org
.eclipse
.jface
.viewers
.TreeNode
;
16 import org
.eclipse
.jface
.viewers
.Viewer
;
17 import org
.eclipse
.swt
.widgets
.Composite
;
18 import org
.eclipse
.ui
.IEditorPart
;
19 import org
.eclipse
.ui
.IWorkbenchPart
;
21 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
22 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
23 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
24 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
25 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
26 import eu
.etaxonomy
.taxeditor
.Messages
;
27 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
28 import eu
.etaxonomy
.taxeditor
.model
.FeatureNodeContainer
;
29 import eu
.etaxonomy
.taxeditor
.model
.IPartContentHasDetails
;
30 import eu
.etaxonomy
.taxeditor
.model
.IPartContentHasSupplementalData
;
31 import eu
.etaxonomy
.taxeditor
.view
.AbstractCdmEditorViewPart
;
34 * <p>DetailsViewPart class.</p>
37 * @created Jun 10, 2010
40 public class DetailsViewPart
extends AbstractCdmEditorViewPart
implements IPartContentHasSupplementalData
{
42 /** Constant <code>ID="eu.etaxonomy.taxeditor.editor.forms.det"{trunked}</code> */
43 public static String ID
= "eu.etaxonomy.taxeditor.view.detail"; //$NON-NLS-1$
45 private DetailsViewer viewer
;
49 public void createViewer(Composite parent
) {
51 viewer
= new DetailsViewer(parent
, this);
52 getSite().setSelectionProvider(viewer
);
56 protected void selectionChanged_internal(IWorkbenchPart part
, ISelection selection
){
57 if(AbstractUtility
.getActiveEditor() == null && !(AbstractUtility
.getActivePart() instanceof IConversationEnabled
)){
66 if(!(selection
instanceof IStructuredSelection
)){
70 IStructuredSelection structuredSelection
= (IStructuredSelection
) selection
;
72 if((part
instanceof IEditorPart
) || (part
instanceof IPartContentHasDetails
)) {
73 if(structuredSelection
.size() != 1){
78 // do not show details for feature nodes TODO really?
79 if(structuredSelection
.getFirstElement() instanceof FeatureNodeContainer
){
80 // do show the map for distributions
81 Feature feature
= ((FeatureNodeContainer
) ((IStructuredSelection
) selection
).getFirstElement()).getFeature();
82 if(!feature
.equals(Feature
.DISTRIBUTION())){
87 showViewer(part
, structuredSelection
);
94 protected String
getViewName(){
95 return Messages
.DetailsViewPart_VIEWER_NAME
;
99 protected String
createPartTitle(Object selectedObject
){
100 if(selectedObject
!=null){
101 if(selectedObject
instanceof TreeNode
){
102 selectedObject
= ((TreeNode
) selectedObject
).getValue();
104 if(selectedObject
instanceof SpecimenOrObservationBase
){
105 return getViewName()+": "+HibernateProxyHelper
.deproxy(selectedObject
, SpecimenOrObservationBase
.class).getRecordBasis(); //$NON-NLS-1$
107 if(selectedObject
instanceof CdmBase
){
108 return getViewName()+": "+HibernateProxyHelper
.deproxy(selectedObject
, CdmBase
.class).getClass().getSimpleName(); //$NON-NLS-1$
110 return getViewName()+": "+selectedObject
.getClass().getSimpleName(); //$NON-NLS-1$
112 return getViewName();
116 public void showEmptyPage() {
117 viewer
.setSelection(null);
118 super.showEmptyPage();
123 public boolean postOperation(CdmBase objectAffectedByOperation
) {
125 viewer
.setInput(objectAffectedByOperation
);
127 return super.postOperation(objectAffectedByOperation
);
133 public Viewer
getViewer() {
140 public void dispose() {
141 selectionService
.removePostSelectionListener(this);
147 public boolean onComplete() {