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
);
73 //FIXME: duplicate code (see #4598)
74 final String label
= "Change View Type";
76 Action addAction
= new Action(label
, IAction
.AS_PUSH_BUTTON
) {
78 * @see org.eclipse.jface.action.Action#run()
82 element_media
.toggleAdvancedMediaView();
85 addAction
.setToolTipText(label
);
87 toolBarManager
.add(addAction
);
89 return toolBarManager
.createControl(this);
95 * @param entity a {@link eu.etaxonomy.cdm.model.media.Media} object.
98 public void setEntity(Media entity
) {
99 if(element_media
!= null){
100 this.removeElements();
102 element_media
= (MediaMetaElement
) formFactory
.createEntityCollectionElement(this, entity
, null, null, ExpandableComposite
.EXPANDED
);
103 super.setEntity(entity
);
105 setTextClient(createToolbar());
110 * @see eu.etaxonomy.taxeditor.section.AbstractCdmDetailSection#getHeading()
114 public String
getHeading() {
119 * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection#createCdmDetailElement(eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection, int)
122 protected AbstractCdmDetailElement
<Media
> createCdmDetailElement(AbstractCdmDetailSection
<Media
> parentElement
, int style
) {