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
.ui
.section
.description
;
13 import org
.eclipse
.jface
.action
.Action
;
14 import org
.eclipse
.jface
.action
.IAction
;
15 import org
.eclipse
.jface
.action
.ToolBarManager
;
16 import org
.eclipse
.jface
.viewers
.ISelectionProvider
;
17 import org
.eclipse
.swt
.SWT
;
18 import org
.eclipse
.swt
.widgets
.Control
;
19 import org
.eclipse
.ui
.forms
.widgets
.ExpandableComposite
;
20 import org
.eclipse
.ui
.forms
.widgets
.TableWrapLayout
;
22 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
23 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
24 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
25 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
26 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailElement
;
27 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailSection
;
28 import eu
.etaxonomy
.taxeditor
.ui
.section
.media
.MediaMetaElement
;
31 * <p>MediaDetailsSection class.</p>
34 * @created Jun 15, 2010
37 public class MediaDetailsSection
extends AbstractCdmDetailSection
<Media
> {
39 private MediaMetaElement element_media
;
42 * <p>Constructor for MediaDetailsSection.</p>
44 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
45 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
46 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
47 * @param selectionProvider a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
50 public MediaDetailsSection(CdmFormFactory formFactory
, ConversationHolder conversation
,
51 ICdmFormElement parentElement
,
52 ISelectionProvider selectionProvider
, int style
) {
53 super(formFactory
, conversation
, parentElement
, selectionProvider
, style
);
58 protected void createControls(AbstractCdmDetailSection formElement
,
60 TableWrapLayout layout
= (TableWrapLayout
) getLayoutComposite().getLayout();
61 layout
.topMargin
= 10;
62 layout
.numColumns
= 2;
64 getLayoutComposite().setLayout(layout
);
70 protected Control
createToolbar() {
71 ToolBarManager toolBarManager
= new ToolBarManager(SWT
.FLAT
);
74 if(element_media
.isAdvancedMediaView()){
75 label
= "Use simple media view";
78 label
= "Use advanced media view";
81 Action addAction
= new Action("Use advanced media view", IAction
.AS_PUSH_BUTTON
) {
83 * @see org.eclipse.jface.action.Action#run()
87 element_media
.toggleAdvancedMediaView();
90 addAction
.setToolTipText(label
);
92 toolBarManager
.add(addAction
);
94 return toolBarManager
.createControl(this);
100 * @param entity a {@link eu.etaxonomy.cdm.model.media.Media} object.
103 public void setEntity(Media entity
) {
104 if(element_media
!= null){
105 this.removeElements();
107 element_media
= (MediaMetaElement
) formFactory
.createEntityCollectionElement(this, entity
, null, null, ExpandableComposite
.EXPANDED
);
108 super.setEntity(entity
);
110 setTextClient(createToolbar());
115 * @see eu.etaxonomy.taxeditor.section.AbstractCdmDetailSection#getHeading()
119 public String
getHeading() {
124 * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection#createCdmDetailElement(eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection, int)
127 protected AbstractCdmDetailElement
<Media
> createCdmDetailElement(AbstractCdmDetailSection
<Media
> parentElement
, int style
) {