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
.editor
.view
.media
;
13 import org
.eclipse
.jface
.action
.GroupMarker
;
14 import org
.eclipse
.jface
.action
.MenuManager
;
15 import org
.eclipse
.jface
.viewers
.ISelection
;
16 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
17 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
18 import org
.eclipse
.jface
.viewers
.TreeViewer
;
19 import org
.eclipse
.jface
.viewers
.Viewer
;
20 import org
.eclipse
.swt
.SWT
;
21 import org
.eclipse
.swt
.widgets
.Composite
;
22 import org
.eclipse
.swt
.widgets
.Control
;
23 import org
.eclipse
.swt
.widgets
.Menu
;
24 import org
.eclipse
.swt
.widgets
.Tree
;
25 import org
.eclipse
.ui
.IEditorInput
;
26 import org
.eclipse
.ui
.IEditorPart
;
27 import org
.eclipse
.ui
.IWorkbenchActionConstants
;
28 import org
.eclipse
.ui
.IWorkbenchPart
;
30 import eu
.etaxonomy
.taxeditor
.bulkeditor
.BulkEditor
;
31 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
32 import eu
.etaxonomy
.taxeditor
.editor
.MultiPageTaxonEditor
;
33 import eu
.etaxonomy
.taxeditor
.model
.IPartContentHasDetails
;
34 import eu
.etaxonomy
.taxeditor
.model
.IPartContentHasSupplementalData
;
35 import eu
.etaxonomy
.taxeditor
.view
.AbstractCdmEditorViewPart
;
38 * <p>MediaViewPart class.</p>
41 * @created Jun 15, 2010
44 public class MediaViewPart
extends AbstractCdmEditorViewPart
implements IPartContentHasDetails
, IPartContentHasSupplementalData
{
46 /** Constant <code>ID="eu.etaxonomy.taxeditor.editor.view.medi"{trunked}</code> */
47 public static final String ID
= "eu.etaxonomy.taxeditor.editor.view.media";
49 private TreeViewer viewer
;
53 * @see eu.etaxonomy.taxeditor.model.AbstractCdmViewPart#createViewer(org.eclipse.swt.widgets.Composite)
57 public void createViewer(Composite parent
) {
59 viewer
= new TreeViewer(new Tree(parent
, SWT
.NULL
));
61 viewer
.setContentProvider(new MediaContentProvider());
62 viewer
.setLabelProvider(new MediaLabelProvider());
63 viewer
.setAutoExpandLevel(2);
65 // Propagate selection from viewer
66 getSite().setSelectionProvider(viewer
);
68 // Add context menu to tree
69 MenuManager menuMgr
= new MenuManager();
70 menuMgr
.add(new GroupMarker(IWorkbenchActionConstants
.MB_ADDITIONS
));
71 getSite().registerContextMenu(menuMgr
, viewer
);
73 Control control
= viewer
.getControl();
74 Menu menu
= menuMgr
.createContextMenu(control
);
75 control
.setMenu(menu
);
80 * @see eu.etaxonomy.taxeditor.model.AbstractCdmViewPart#getInitialSelection()
84 protected ISelection
getInitialSelection() {
85 if(getEditor() != null){
86 return new StructuredSelection(getEditor().getEditorInput());
89 return super.getInitialSelection();
93 public void selectionChanged(IWorkbenchPart part
, ISelection selection
) {
94 if(EditorUtil
.getActiveEditor() == null){
99 if(part
instanceof MultiPageTaxonEditor
){
100 IEditorInput input
= ((IEditorPart
) part
).getEditorInput();
101 showViewer(part
, new StructuredSelection(input
));
104 if(part
instanceof BulkEditor
&& selection
instanceof IStructuredSelection
){
105 showViewer(part
, (IStructuredSelection
) selection
);
111 public void changed(Object object
) {
113 super.changed(object
);
118 public Viewer
getViewer() {
127 public boolean onComplete() {