-// $Id$
/**
* Copyright (C) 2007 EDIT
* European Distributed Institute of Taxonomy
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPart;
+import eu.etaxonomy.cdm.model.description.IDescribable;
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
-import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
+import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart;
import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
import eu.etaxonomy.taxeditor.model.IPartContentHasMedia;
import eu.etaxonomy.taxeditor.view.supplementaldata.SupplementalDataViewPart;
/**
- * <p>MediaViewPart class.</p>
- *
* @author n.hoffmann
* @created Jun 15, 2010
* @version 1.0
*/
public class MediaViewPart extends AbstractCdmEditorViewPart implements IPartContentHasDetails, IPartContentHasSupplementalData {
- /** Constant <code>ID="eu.etaxonomy.taxeditor.editor.view.medi"{trunked}</code> */
public static final String ID = "eu.etaxonomy.taxeditor.editor.view.media";
private TreeViewer viewer;
- /*
- * (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.model.AbstractCdmViewPart#createViewer(org.eclipse.swt.widgets.Composite)
- */
/** {@inheritDoc} */
@Override
public void createViewer(Composite parent) {
}
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.model.AbstractCdmViewPart#getInitialSelection()
- */
/** {@inheritDoc} */
@Override
protected ISelection getInitialSelection() {
return;
}
- if(part instanceof DetailsViewPart || part instanceof SupplementalDataViewPart){
- // do not show empty page as these views are also used to edit the description selected in this view
+ if (part instanceof DetailsViewPart || part instanceof SupplementalDataViewPart
+ || part instanceof DescriptiveViewPart) {
+ // do not show empty page as these views are also used to edit the
+ // description selected in this view
return;
}
- if(part instanceof IPartContentHasMedia){
- if(part instanceof MultiPageTaxonEditor){
- IEditorInput input = ((IEditorPart) part).getEditorInput();
- showViewer(part, new StructuredSelection(input));
- }
- else if(selection instanceof IStructuredSelection){
+ if(part instanceof IPartContentHasMedia && ((IPartContentHasMedia) part).canAttachMedia()){
+ if(selection instanceof IStructuredSelection){
Object firstElement = ((IStructuredSelection) selection).getFirstElement();
if(firstElement instanceof TreeNode){
showViewer(part, new StructuredSelection(((TreeNode) firstElement).getValue()));
+ return;
}
- else{
+ else if(firstElement!=null
+ && firstElement instanceof IDescribable<?>){
showViewer(part, (IStructuredSelection) selection);
+ return;
}
- }else{
- showEmptyPage();
}
}
- else{
- showEmptyPage();
- }
+ showEmptyPage();
}
/** {@inheritDoc} */
@Override
public void changed(Object object) {
- viewer.refresh();
- //TODO: should be replaced with the possibility to set views dirty
- // when we move to Eclipse 4
- // take a look at ISaveblePart
- if(part instanceof BulkEditor && !(object instanceof SpecimenOrObservationBase<?>)){
- ((BulkEditor) part).forceDirty();
- }
- super.changed(object);
+ viewer.expandToLevel(2);
+ viewer.refresh();
+ if(object != null){
+ StructuredSelection selection = new StructuredSelection(object);
+ viewer.setSelection(selection, true);
+ }
+ //TODO: should be replaced with the possibility to set views dirty
+ // when we move to Eclipse 4
+ // take a look at ISaveblePart
+ if(part instanceof BulkEditor && !(object instanceof SpecimenOrObservationBase<?>)){
+ ((BulkEditor) part).forceDirty();
+ IStructuredSelection selection = (IStructuredSelection) ((BulkEditor) part).getSelectionProvider().getSelection();
+ ((BulkEditor) part).changed(selection.getFirstElement());
+
+ }
+ super.changed(object);
}
/** {@inheritDoc} */
return viewer;
}
- /**
- * <p>onComplete</p>
- *
- * @return a boolean.
- */
@Override
public boolean onComplete() {
return true;
}
+
+ @Override
+ protected String getViewName() {
+ return "Media";
+ }
}