ref #7849: improve DB preference handling and use editorpreferencePredicates keys...
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / description / MediaDetailsSection.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9
10 package eu.etaxonomy.taxeditor.ui.section.description;
11
12 import org.eclipse.jface.action.ToolBarManager;
13 import org.eclipse.jface.viewers.ISelectionProvider;
14 import org.eclipse.swt.SWT;
15 import org.eclipse.swt.widgets.Control;
16 import org.eclipse.ui.forms.widgets.ExpandableComposite;
17
18 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
19 import eu.etaxonomy.cdm.model.media.Media;
20 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
21 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
22 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
23 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
24 import eu.etaxonomy.taxeditor.ui.section.media.MediaMetaElement;
25 import eu.etaxonomy.taxeditor.ui.section.media.MediaViewSwitch;
26
27 /**
28 * <p>MediaDetailsSection class.</p>
29 *
30 * @author n.hoffmann
31 * @created Jun 15, 2010
32 * @version 1.0
33 */
34 public class MediaDetailsSection extends AbstractCdmDetailSection<Media> {
35
36 private MediaMetaElement mediaMetaElement;
37
38 public MediaDetailsSection(CdmFormFactory formFactory, ConversationHolder conversation,
39 ICdmFormElement parentElement,
40 ISelectionProvider selectionProvider, int style) {
41 super(formFactory, conversation, parentElement, selectionProvider, style);
42 }
43
44 @Override
45 public void setEntity(Media entity) {
46 if(mediaMetaElement != null){
47 this.removeElements();
48 }
49 mediaMetaElement = (MediaMetaElement) formFactory.createEntityCollectionElement(this, entity, null, null, ExpandableComposite.EXPANDED);
50 super.setEntity(entity);
51 setSectionTitle();
52 setTextClient(createToolbar());
53 layout();
54 }
55
56 /** {@inheritDoc} */
57 @Override
58 public String getHeading() {
59 return "Image";
60 }
61
62 @Override
63 protected AbstractCdmDetailElement<Media> createCdmDetailElement(AbstractCdmDetailSection<Media> parentElement, int style) {
64 return null;
65 }
66
67
68
69 @Override
70 protected Control createToolbar() {
71 ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
72 toolBarManager.add(MediaViewSwitch.createSwitch(mediaMetaElement));
73 return toolBarManager.createControl(this);
74 }
75
76 }