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
.core
.runtime
.IProgressMonitor
;
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
.IMemento
;
20 import org
.eclipse
.ui
.IWorkbenchPart
;
22 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
23 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
24 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
25 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
26 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
27 import eu
.etaxonomy
.taxeditor
.Messages
;
28 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
29 import eu
.etaxonomy
.taxeditor
.model
.FeatureNodeContainer
;
30 import eu
.etaxonomy
.taxeditor
.model
.IContextListener
;
31 import eu
.etaxonomy
.taxeditor
.model
.IPartContentHasDetails
;
32 import eu
.etaxonomy
.taxeditor
.model
.IPartContentHasSupplementalData
;
33 import eu
.etaxonomy
.taxeditor
.view
.AbstractCdmEditorViewPart
;
36 * <p>DetailsViewPart class.</p>
39 * @created Jun 10, 2010
42 public class DetailsViewPart
extends AbstractCdmEditorViewPart
implements IPartContentHasSupplementalData
, IContextListener
{
44 /** Constant <code>ID="eu.etaxonomy.taxeditor.editor.forms.det"{trunked}</code> */
45 public static String ID
= "eu.etaxonomy.taxeditor.view.detail"; //$NON-NLS-1$
47 private DetailsViewer viewer
;
51 public void createViewer(Composite parent
) {
53 viewer
= new DetailsViewer(parent
, this);
54 getSite().setSelectionProvider(viewer
);
58 protected void selectionChanged_internal(IWorkbenchPart part
, ISelection selection
){
59 if(AbstractUtility
.getActiveEditor() == null && !(AbstractUtility
.getActivePart() instanceof IConversationEnabled
)){
64 if(AbstractUtility
.getActiveEditor() == null &&
65 selection
instanceof IStructuredSelection
&& ((IStructuredSelection
) selection
).getFirstElement() !=null){
66 //special case where the details view still open with details about the closed object #5495
74 if(!(selection
instanceof IStructuredSelection
)){
78 IStructuredSelection structuredSelection
= (IStructuredSelection
) selection
;
80 if((part
instanceof IEditorPart
) || (part
instanceof IPartContentHasDetails
)) {
81 if(structuredSelection
.size() != 1){
86 // do not show details for feature nodes TODO really?
87 if(structuredSelection
.getFirstElement() instanceof FeatureNodeContainer
){
88 // do show the map for distributions
89 Feature feature
= ((FeatureNodeContainer
) ((IStructuredSelection
) selection
).getFirstElement()).getFeature();
90 if(!feature
.equals(Feature
.DISTRIBUTION())){
95 showViewer(part
, structuredSelection
);
102 protected String
getViewName(){
103 return Messages
.DetailsViewPart_VIEWER_NAME
;
107 protected String
createPartTitle(Object selectedObject
){
108 if(selectedObject
!=null){
109 if(selectedObject
instanceof TreeNode
){
110 selectedObject
= ((TreeNode
) selectedObject
).getValue();
112 if(selectedObject
instanceof SpecimenOrObservationBase
){
113 return getViewName()+": "+HibernateProxyHelper
.deproxy(selectedObject
, SpecimenOrObservationBase
.class).getRecordBasis(); //$NON-NLS-1$
115 if(selectedObject
instanceof CdmBase
){
116 return getViewName()+": "+HibernateProxyHelper
.deproxy(selectedObject
, CdmBase
.class).getClass().getSimpleName(); //$NON-NLS-1$
118 return getViewName()+": "+selectedObject
.getClass().getSimpleName(); //$NON-NLS-1$
120 return getViewName();
124 public void showEmptyPage() {
125 viewer
.setSelection(null);
126 super.showEmptyPage();
131 public boolean postOperation(CdmBase objectAffectedByOperation
) {
133 viewer
.setInput(objectAffectedByOperation
);
135 return super.postOperation(objectAffectedByOperation
);
141 public Viewer
getViewer() {
148 public void dispose() {
149 selectionService
.removePostSelectionListener(this);
155 public boolean onComplete() {
163 public void contextAboutToStop(IMemento memento
, IProgressMonitor monitor
) {
170 public void contextStop(IMemento memento
, IProgressMonitor monitor
) {
178 public void contextStart(IMemento memento
, IProgressMonitor monitor
) {
185 public void contextRefresh(IProgressMonitor monitor
) {
192 public void workbenchShutdown(IMemento memento
, IProgressMonitor monitor
) {