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 java
.util
.Collection
;
15 import org
.eclipse
.jface
.action
.Action
;
16 import org
.eclipse
.jface
.action
.IAction
;
17 import org
.eclipse
.jface
.action
.ToolBarManager
;
18 import org
.eclipse
.swt
.SWT
;
19 import org
.eclipse
.swt
.widgets
.Control
;
21 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
22 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
23 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
24 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
25 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
26 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
27 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractEntityCollectionSection
;
28 import eu
.etaxonomy
.taxeditor
.ui
.section
.media
.ITogglableMediaElement
;
31 * <p>DescriptionElementMediaSection class.</p>
34 * @created Mar 18, 2010
37 public class DescriptionElementMediaSection
extends
38 AbstractEntityCollectionSection
<DescriptionElementBase
, Media
> {
40 public DescriptionElementMediaSection(CdmFormFactory cdmFormFactory
, ConversationHolder conversation
,
41 ICdmFormElement parentElement
, int style
) {
42 super(cdmFormFactory
, conversation
, parentElement
, "Media", style
);
47 public void setEntity(DescriptionElementBase entity
) {
48 if(entity
.getFeature().equals(Feature
.IMAGE())){
49 this.setVisible(false);
51 super.setEntity(entity
);
56 public void addElement(Media element
) {
57 getEntity().addMedia(element
);
62 public Media
createNewElement() {
63 return Media
.NewInstance();
68 public Collection
<Media
> getCollection(DescriptionElementBase entity
) {
69 return entity
.getMedia();
74 public String
getEmptyString() {
75 return "No media yet.";
80 protected String
getTooltipString() {
81 return "Create new media";
86 public void removeElement(Media element
) {
87 getEntity().removeMedia(element
);
91 protected Control
createToolbar() {
92 ToolBarManager toolBarManager
= new ToolBarManager(SWT
.FLAT
);
94 final String label
= "Change View Type";
96 Action addAction
= new Action(label
, IAction
.AS_PUSH_BUTTON
) {
100 if(getEntityCollectionElement() instanceof ITogglableMediaElement
){
101 ((ITogglableMediaElement
) getEntityCollectionElement()).toggleAdvancedMediaView();
106 addAction
.setToolTipText(label
);
108 toolBarManager
.add(addAction
);
110 return toolBarManager
.createControl(this);