1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
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.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.taxeditor.ui.section.description;
|
12
|
|
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;
|
21
|
|
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;
|
29
|
|
30
|
/**
|
31
|
* <p>MediaDetailsSection class.</p>
|
32
|
*
|
33
|
* @author n.hoffmann
|
34
|
* @created Jun 15, 2010
|
35
|
* @version 1.0
|
36
|
*/
|
37
|
public class MediaDetailsSection extends AbstractCdmDetailSection<Media> {
|
38
|
|
39
|
private MediaMetaElement element_media;
|
40
|
|
41
|
/**
|
42
|
* <p>Constructor for MediaDetailsSection.</p>
|
43
|
*
|
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.
|
48
|
* @param style a int.
|
49
|
*/
|
50
|
public MediaDetailsSection(CdmFormFactory formFactory, ConversationHolder conversation,
|
51
|
ICdmFormElement parentElement,
|
52
|
ISelectionProvider selectionProvider, int style) {
|
53
|
super(formFactory, conversation, parentElement, selectionProvider, style);
|
54
|
}
|
55
|
|
56
|
/** {@inheritDoc} */
|
57
|
@Override
|
58
|
protected void createControls(AbstractCdmDetailSection formElement,
|
59
|
int style) {
|
60
|
TableWrapLayout layout = (TableWrapLayout) getLayoutComposite().getLayout();
|
61
|
layout.topMargin = 10;
|
62
|
layout.numColumns = 2;
|
63
|
|
64
|
getLayoutComposite().setLayout(layout);
|
65
|
|
66
|
|
67
|
}
|
68
|
|
69
|
@Override
|
70
|
protected Control createToolbar() {
|
71
|
ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
|
72
|
|
73
|
//FIXME: duplicate code (see #4598)
|
74
|
final String label = "Change View Type";
|
75
|
|
76
|
Action addAction = new Action(label, IAction.AS_PUSH_BUTTON) {
|
77
|
/* (non-Javadoc)
|
78
|
* @see org.eclipse.jface.action.Action#run()
|
79
|
*/
|
80
|
@Override
|
81
|
public void run() {
|
82
|
element_media.toggleAdvancedMediaView();
|
83
|
}
|
84
|
};
|
85
|
addAction.setToolTipText(label);
|
86
|
|
87
|
toolBarManager.add(addAction);
|
88
|
|
89
|
return toolBarManager.createControl(this);
|
90
|
}
|
91
|
|
92
|
/**
|
93
|
* <p>setEntity</p>
|
94
|
*
|
95
|
* @param entity a {@link eu.etaxonomy.cdm.model.media.Media} object.
|
96
|
*/
|
97
|
@Override
|
98
|
public void setEntity(Media entity) {
|
99
|
if(element_media != null){
|
100
|
this.removeElements();
|
101
|
}
|
102
|
element_media = (MediaMetaElement) formFactory.createEntityCollectionElement(this, entity, null, null, ExpandableComposite.EXPANDED);
|
103
|
super.setEntity(entity);
|
104
|
setSectionTitle();
|
105
|
setTextClient(createToolbar());
|
106
|
layout();
|
107
|
}
|
108
|
|
109
|
/* (non-Javadoc)
|
110
|
* @see eu.etaxonomy.taxeditor.section.AbstractCdmDetailSection#getHeading()
|
111
|
*/
|
112
|
/** {@inheritDoc} */
|
113
|
@Override
|
114
|
public String getHeading() {
|
115
|
return "Image";
|
116
|
}
|
117
|
|
118
|
/* (non-Javadoc)
|
119
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection#createCdmDetailElement(eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection, int)
|
120
|
*/
|
121
|
@Override
|
122
|
protected AbstractCdmDetailElement<Media> createCdmDetailElement(AbstractCdmDetailSection<Media> parentElement, int style) {
|
123
|
return null;
|
124
|
}
|
125
|
}
|