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
.CdmFormFactory
.DetailType
;
28 import eu
.etaxonomy
.taxeditor
.ui
.forms
.ICdmFormElement
;
29 import eu
.etaxonomy
.taxeditor
.ui
.forms
.IEnableableFormElement
;
30 import eu
.etaxonomy
.taxeditor
.ui
.forms
.ISelectableElement
;
34 * Abstract AbstractCdmDetailSection class.
38 * @created Feb 26, 2010
41 public abstract class AbstractCdmDetailSection
<ENTITY
> extends
42 AbstractFormSection
<ENTITY
> implements IEnableableFormElement
,
45 protected AbstractCdmDetailElement
<ENTITY
> detailElement
;
49 * Constructor for AbstractCdmDetailSection.
53 * a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory}
56 * a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
58 * @param parentElement
59 * a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
61 * @param selectionProvider
62 * a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
68 public AbstractCdmDetailSection(CdmFormFactory formFactory
,
69 ConversationHolder conversation
, ICdmFormElement parentElement
,
70 ISelectionProvider selectionProvider
, int style
) {
71 super(formFactory
, conversation
, parentElement
, selectionProvider
,
72 Section
.CLIENT_INDENT
| style
);
74 setText(getHeading());
76 addExpansionListener(this);
78 createControls(this, SWT
.NULL
);
88 * {@link eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection}
93 protected void createControls(AbstractCdmDetailSection
<ENTITY
> formElement
,
95 TableWrapLayout layout
= (TableWrapLayout
) getLayoutComposite()
97 layout
.topMargin
= 10;
98 layout
.numColumns
= 2;
100 getLayoutComposite().setLayout(layout
);
101 detailElement
= formFactory
.createCdmDetailElement(getDetailType(),
111 * {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.DetailType}
114 protected abstract DetailType
getDetailType();
121 * @return the heading for this section
123 public abstract String
getHeading();
127 public void dispose() {
128 if (detailElement
instanceof ISelectableElement
) {
129 ISelectableElement selectableElement
= (ISelectableElement
) detailElement
;
130 if (selectableElement
.getSelectionArbitrator() != null) {
131 formFactory
.destroySelectionArbitrator(selectableElement
132 .getSelectionArbitrator());
142 * eu.etaxonomy.taxeditor.forms.section.AbstractEditorFormSection#setBackground
143 * (org.eclipse.swt.graphics.Color)
147 public void setBackground(Color color
) {
148 if (detailElement
!= null) {
149 // detailComposite.setBackground(color);
151 super.setBackground(color
);
163 public void setEntity(ENTITY entity
) {
164 if (detailElement
!= null) {
165 detailElement
.setEntity(entity
);
167 super.setEntity(entity
);
177 protected void setSectionTitle() {
179 if (getEntity() != null && (getEntity() instanceof IdentifiableEntity
)) {
180 title
= ": " + ((IdentifiableEntity
) getEntity()).getTitleCache();
182 this.setText(String
.format("%s%s", getHeading(), title
));
183 setTextClient(createToolbar());
189 protected Control
createToolbar() {
190 ToolBarManager toolBarManager
= new ToolBarManager(SWT
.FLAT
);
191 return toolBarManager
.createControl(this);
199 public void updateTitle() {
207 public void setIrrelevant(boolean irrelevant
) {
208 if (detailElement
!= null) {
209 detailElement
.setIrrelevant(irrelevant
);
214 public void expansionStateChanging(ExpansionEvent e
) {
215 // logger.warn("Expansion State Changing");
219 public void expansionStateChanged(ExpansionEvent e
) {
220 // logger.warn("Expansion State Changed");