4 package eu
.etaxonomy
.taxeditor
.forms
;
8 import org
.eclipse
.swt
.graphics
.Font
;
9 import org
.eclipse
.swt
.widgets
.Composite
;
10 import org
.eclipse
.swt
.widgets
.Display
;
11 import org
.eclipse
.ui
.forms
.FormColors
;
12 import org
.eclipse
.ui
.forms
.IFormColors
;
13 import org
.eclipse
.ui
.forms
.widgets
.FormToolkit
;
14 import org
.eclipse
.ui
.forms
.widgets
.Section
;
15 import org
.eclipse
.ui
.internal
.forms
.widgets
.FormFonts
;
17 import eu
.etaxonomy
.cdm
.model
.common
.AnnotatableEntity
;
18 import eu
.etaxonomy
.cdm
.model
.common
.Annotation
;
19 import eu
.etaxonomy
.cdm
.model
.common
.DescriptionElementSource
;
20 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
21 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
23 import eu
.etaxonomy
.taxeditor
.forms
.entitysections
.AnnotationComposite
;
24 import eu
.etaxonomy
.taxeditor
.forms
.entitysections
.AnnotationSection
;
25 import eu
.etaxonomy
.taxeditor
.forms
.entitysections
.DescriptionElementSourceComposite
;
26 import eu
.etaxonomy
.taxeditor
.forms
.entitysections
.OriginalSourceSection
;
27 import eu
.etaxonomy
.taxeditor
.forms
.selectioncomposites
.TaxonSelectionComposite
;
28 import eu
.etaxonomy
.taxeditor
.forms
.termcombos
.LanguageComboComposite
;
34 public class EditorFormToolkit
extends FormToolkit
{
36 private BoldFontHolder2 boldFontHolder2
;
41 public EditorFormToolkit(Display display
) {
50 boldFontHolder2
= new BoldFontHolder2();
56 public EditorFormToolkit(FormColors colors
) {
67 public Container
createContainer(Composite parent
, int style
){
68 return new Container(parent
, style
);
80 public MultilineTextWithLabel
createMultilineTextWithLabel(Composite parent
, String labelString
, int textHeight
, int style
){
81 return new MultilineTextWithLabel(parent
, labelString
, "", textHeight
, style
);
91 public DescriptionElementSourceComposite
createDescriptionElementSourceComposite(Composite parent
, DescriptionElementSource source
, int style
){
92 return new DescriptionElementSourceComposite(parent
, source
, style
);
103 public TextWithLabelComposite
createTextWithLabelComposite(Composite parent
, String labelString
, String initialText
, int style
){
104 return new TextWithLabelComposite(parent
, labelString
, initialText
, style
);
115 public LanguageComboComposite
createLanguageComboComposite(Composite parent
, String labelString
, Language selection
, int style
){
116 return new LanguageComboComposite(parent
, labelString
, selection
, style
);
126 public ImageComposite
createImageComposite(Composite parent
, URI imageUri
, int style
){
127 return new ImageComposite(parent
, imageUri
, style
);
138 public TextActionComposite
createTextActionComposite(Composite parent
, String labelString
, String initialText
, int style
){
139 return new TextActionComposite(parent
, labelString
, initialText
, style
);
149 public AnnotationComposite
createAnnotationComposite(Composite parent
, Annotation annotation
, int style
) {
150 return new AnnotationComposite(parent
, annotation
, style
);
160 public TaxonSelectionComposite
createTaxonSelectionComposite(Composite parent
, TaxonBase selection
, int style
) {
161 return new TaxonSelectionComposite(parent
, "Taxon", selection
, style
);
167 * @param annotatableEntity
171 public AnnotationSection
createAnnotationSection(Composite parent
, AnnotatableEntity annotatableEntity
, int style
){
172 return new AnnotationSection(parent
, annotatableEntity
, style
);
182 public OriginalSourceSection
createOriginalSourceSection(Composite parent
, DescriptionElementBase entity
, int style
){
183 return new OriginalSourceSection(parent
, entity
, style
);
188 * Creates a section as a part of the form.
192 * @param sectionStyle
194 * @return the section widget
196 public Section
adapt(AbstractEditorFormSection section
) {
197 section
.setMenu(section
.getParent().getMenu());
198 adapt(section
, true, true);
199 if (section
.getToggle() != null) {
200 section
.getToggle().setHoverDecorationColor(getColors()
201 .getColor(IFormColors
.TB_TOGGLE_HOVER
));
202 section
.getToggle().setDecorationColor(getColors()
203 .getColor(IFormColors
.TB_TOGGLE
));
206 section
.setFont(boldFontHolder2
.getBoldFont(section
.getParent().getFont()));
208 // if ((section.getStyle() & Section.TITLE_BAR) != 0
209 // || (section.getStyle() & Section.SHORT_TITLE_BAR) != 0) {
210 getColors().initializeSectionToolBarColors();
211 section
.setTitleBarBackground(getColors().getColor(IFormColors
.TB_BG
));
212 section
.setTitleBarBorderColor(getColors()
213 .getColor(IFormColors
.TB_BORDER
));
215 // call setTitleBarForeground regardless as it also sets the label color
216 section
.setTitleBarForeground(getColors()
217 .getColor(IFormColors
.TB_TOGGLE
));
221 private class BoldFontHolder2
{
222 private Font normalFont
;
224 private Font boldFont
;
226 public BoldFontHolder2() {
229 public Font
getBoldFont(Font font
) {
230 createBoldFont(font
);
234 private void createBoldFont(Font font
) {
235 if (normalFont
== null || !normalFont
.equals(font
)) {
239 if (boldFont
== null) {
240 boldFont
= FormFonts
.getInstance().getBoldFont(getColors().getDisplay(),
245 public void dispose() {
246 if (boldFont
!= null) {
247 FormFonts
.getInstance().markFinished(boldFont
);