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
;
13 import org
.eclipse
.jface
.action
.ToolBarManager
;
14 import org
.eclipse
.jface
.viewers
.ISelectionProvider
;
15 import org
.eclipse
.swt
.SWT
;
16 import org
.eclipse
.swt
.graphics
.Color
;
17 import org
.eclipse
.swt
.widgets
.Control
;
18 import org
.eclipse
.ui
.forms
.events
.ExpansionEvent
;
19 import org
.eclipse
.ui
.forms
.events
.IExpansionListener
;
20 import org
.eclipse
.ui
.forms
.widgets
.Section
;
21 import org
.eclipse
.ui
.forms
.widgets
.TableWrapLayout
;
23 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
24 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableEntity
;
25 import eu
.etaxonomy
.taxeditor
.ui
.forms
.AbstractFormSection
;
26 import eu
.etaxonomy
.taxeditor
.ui
.forms
.CdmFormFactory
;
27 import eu
.etaxonomy
.taxeditor
.ui
.forms
.ICdmFormElement
;
28 import eu
.etaxonomy
.taxeditor
.ui
.forms
.IEnableableFormElement
;
29 import eu
.etaxonomy
.taxeditor
.ui
.forms
.ISelectableElement
;
30 import eu
.etaxonomy
.taxeditor
.ui
.forms
.CdmFormFactory
.DetailType
;
33 * <p>Abstract AbstractCdmDetailSection class.</p>
36 * @created Feb 26, 2010
39 public abstract class AbstractCdmDetailSection
<ENTITY
> extends AbstractFormSection
<ENTITY
> implements IEnableableFormElement
, IExpansionListener
{
41 protected AbstractCdmDetailElement
<ENTITY
> detailElement
;
44 * <p>Constructor for AbstractCdmDetailSection.</p>
46 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
47 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
48 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
49 * @param selectionProvider a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
51 * @param <ENTITY> a ENTITY object.
53 public AbstractCdmDetailSection(CdmFormFactory formFactory
,
54 ConversationHolder conversation
, ICdmFormElement parentElement
, ISelectionProvider selectionProvider
, int style
) {
55 super(formFactory
, conversation
, parentElement
, selectionProvider
, Section
.CLIENT_INDENT
| style
);
57 setText(getHeading());
59 addExpansionListener(this);
61 createControls(this, SWT
.NULL
);
66 * <p>createControls</p>
68 * @param formElement a {@link eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection} object.
71 protected void createControls(AbstractCdmDetailSection
<ENTITY
> formElement
, int style
) {
72 TableWrapLayout layout
= (TableWrapLayout
) getLayoutComposite().getLayout();
73 layout
.topMargin
= 10;
74 layout
.numColumns
= 2;
76 getLayoutComposite().setLayout(layout
);
77 detailElement
= formFactory
.createCdmDetailElement(getDetailType(), formElement
, style
);
81 * <p>getDetailType</p>
83 * @return a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.DetailType} object.
85 protected abstract DetailType
getDetailType();
90 * @return the heading for this section
92 public abstract String
getHeading();
96 public void dispose() {
97 if(detailElement
instanceof ISelectableElement
){
98 ISelectableElement selectableElement
= (ISelectableElement
) detailElement
;
99 if(selectableElement
.getSelectionArbitrator() != null){
100 formFactory
.destroySelectionArbitrator(selectableElement
.getSelectionArbitrator());
107 * @see eu.etaxonomy.taxeditor.forms.section.AbstractEditorFormSection#setBackground(org.eclipse.swt.graphics.Color)
111 public void setBackground(Color color
) {
112 if(detailElement
!= null){
113 // detailComposite.setBackground(color);
115 super.setBackground(color
);
121 * @param entity a ENTITY object.
123 public void setEntity(ENTITY entity
) {
124 if(detailElement
!= null){
125 detailElement
.setEntity(entity
);
127 super.setEntity(entity
);
133 * <p>setSectionTitle</p>
135 protected void setSectionTitle(){
137 if(getEntity() != null && (getEntity() instanceof IdentifiableEntity
)){
138 title
= ": " + ((IdentifiableEntity
) getEntity()).getTitleCache();
140 this.setText(getHeading() + title
);
141 setTextClient(createToolbar());
148 protected Control
createToolbar() {
149 ToolBarManager toolBarManager
= new ToolBarManager(SWT
.FLAT
);
150 return toolBarManager
.createControl(this);
156 public void updateTitle(){
164 public void setIrrelevant(boolean irrelevant
) {
165 if(detailElement
!= null){
166 detailElement
.setIrrelevant(irrelevant
);
171 public void expansionStateChanging(ExpansionEvent e
) {
172 // logger.warn("Expansion State Changing");
176 public void expansionStateChanged(ExpansionEvent e
) {
177 // logger.warn("Expansion State Changed");