// $Id$
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
-*
+*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
/**
* <p>Abstract AbstractCdmViewPart class.</p>
* @version 1.0
*/
public abstract class AbstractCdmViewPart extends ViewPart implements ISelectionListener, IPostOperationEnabled, IConversationEnabled, IDirtyMarkableSelectionProvider{
-
+
protected ISelectionService selectionService;
public static IStructuredSelection EMPTY_SELECTION = new StructuredSelection();
-
+
protected IWorkbenchPart part;
-
+
private PageBook pageBook;
private Label emptySelectionLabel;
private Composite viewerComposite;
-
+
/** {@inheritDoc} */
@Override
public void createPartControl(Composite parent) {
selectionService = getSite().getWorkbenchWindow().getSelectionService();
selectionService.addSelectionListener(this);
-
+
pageBook = new PageBook(parent, SWT.NULL);
- createViewerComposite(pageBook);
+ //create viewerComposite
+ viewerComposite = new SashForm(pageBook, SWT.HORIZONTAL);
createViewer(viewerComposite);
-
+
// Page 2: Nothing selected
emptySelectionLabel = new Label(pageBook, SWT.TOP + SWT.LEFT + SWT.WRAP);
-
+
setInitialSelection();
}
-
+
/**
- *
+ *
*/
private void setInitialSelection() {
- selectionChanged(StoreUtil.getActivePart(), getInitialSelection());
+ selectionChanged(AbstractUtility.getActivePart(), getInitialSelection());
}
/**
protected ISelection getInitialSelection() {
return selectionService.getSelection();
}
-
- private void createViewerComposite(Composite parent) {
- viewerComposite = new SashForm(parent, SWT.HORIZONTAL);
- }
-
+
/**
* <p>showEmptyPage</p>
*/
public void showEmptyPage(){
pageBook.showPage(emptySelectionLabel);
}
-
+
/**
* <p>showViewer</p>
*
* @param selection a {@link org.eclipse.jface.viewers.ISelection} object.
*/
public void showViewer(IWorkbenchPart part, IStructuredSelection selection){
- this.part = part;
-
+ this.part = part;
+
Object element = selection.getFirstElement();
-
+
getViewer().setInput(element);
-
+
showViewer();
}
-
+
/**
* <p>getViewer</p>
*
public void showViewer(){
pageBook.showPage(viewerComposite);
}
-
+
public void setEnabled(boolean enabled){
pageBook.setEnabled(enabled);
}
-
+
/** {@inheritDoc} */
@Override
public void setFocus() {
if(getConversationHolder() != null){
getConversationHolder().bind();
- }
- getViewer().getControl().setFocus();
+ }
+ getViewer().getControl().setFocus();
}
-
+
/**
* <p>createViewer</p>
*
* @param parent a {@link org.eclipse.swt.widgets.Composite} object.
*/
public abstract void createViewer(Composite parent);
-
+
/** {@inheritDoc} */
- public boolean postOperation(CdmBase objectAffectedByOperation) {
+ @Override
+ public boolean postOperation(CdmBase objectAffectedByOperation) {
changed(objectAffectedByOperation);
return true;
}
-
+
/** {@inheritDoc} */
- public abstract void changed(Object object);
-
+ @Override
+ public abstract void changed(Object object);
+
/**
* <p>getConversationHolder</p>
*
* @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
*/
- public ConversationHolder getConversationHolder() {
- if(part != null)
- return ((IConversationEnabled) part).getConversationHolder();
-
+ @Override
+ public ConversationHolder getConversationHolder() {
+ if(part != null) {
+ //FIXME what if part is not an IConversationEnabled? ClassCastException?
+ return ((IConversationEnabled) part).getConversationHolder();
+ }
+
return null;
}
-
+
/** {@inheritDoc} */
- public void update(CdmDataChangeMap changeEvents) {
-
+ @Override
+ public void update(CdmDataChangeMap changeEvents) {
+
}
-
+
/** {@inheritDoc} */
@Override
public void dispose() {