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
.section
;
13 import org
.eclipse
.jface
.viewers
.ISelectionProvider
;
14 import org
.eclipse
.swt
.SWT
;
15 import org
.eclipse
.swt
.graphics
.Color
;
16 import org
.eclipse
.ui
.forms
.events
.ExpansionEvent
;
17 import org
.eclipse
.ui
.forms
.events
.IExpansionListener
;
18 import org
.eclipse
.ui
.forms
.widgets
.Section
;
19 import org
.eclipse
.ui
.forms
.widgets
.TableWrapLayout
;
21 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
22 import eu
.etaxonomy
.cdm
.model
.common
.IAnnotatableEntity
;
23 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableEntity
;
24 import eu
.etaxonomy
.taxeditor
.forms
.AbstractFormSection
;
25 import eu
.etaxonomy
.taxeditor
.forms
.CdmFormFactory
;
26 import eu
.etaxonomy
.taxeditor
.forms
.CdmFormFactory
.DetailType
;
27 import eu
.etaxonomy
.taxeditor
.forms
.ICdmFormElement
;
28 import eu
.etaxonomy
.taxeditor
.forms
.IEnableableFormElement
;
29 import eu
.etaxonomy
.taxeditor
.forms
.ISelectableElement
;
30 import eu
.etaxonomy
.taxeditor
.forms
.SelectionArbitrator
;
33 * <p>Abstract AbstractCdmDetailSection class.</p>
36 * @created Feb 26, 2010
39 public abstract class AbstractCdmDetailSection
<ENTITY
extends IAnnotatableEntity
> extends AbstractFormSection
<ENTITY
> implements IEnableableFormElement
, IExpansionListener
{
41 protected AbstractCdmDetailElement
<ENTITY
> detailElement
;
43 protected SelectionArbitrator selectionArbitrator
;
46 * <p>Constructor for AbstractCdmDetailSection.</p>
48 * @param formFactory a {@link eu.etaxonomy.taxeditor.forms.CdmFormFactory} object.
49 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
50 * @param parentElement a {@link eu.etaxonomy.taxeditor.forms.ICdmFormElement} object.
51 * @param selectionProvider a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
53 * @param <ENTITY> a ENTITY object.
55 public AbstractCdmDetailSection(CdmFormFactory formFactory
,
56 ConversationHolder conversation
, ICdmFormElement parentElement
, ISelectionProvider selectionProvider
, int style
) {
57 super(formFactory
, conversation
, parentElement
, selectionProvider
, Section
.CLIENT_INDENT
| style
);
58 this.setText(getHeading());
60 this.addExpansionListener(this);
62 createControls(this, SWT
.NULL
);
67 * <p>createControls</p>
69 * @param formElement a {@link eu.etaxonomy.taxeditor.section.AbstractCdmDetailSection} object.
72 protected void createControls(AbstractCdmDetailSection
<ENTITY
> formElement
, int style
) {
73 TableWrapLayout layout
= (TableWrapLayout
) getLayoutComposite().getLayout();
74 layout
.topMargin
= 10;
75 layout
.numColumns
= 2;
77 getLayoutComposite().setLayout(layout
);
78 detailElement
= formFactory
.createCdmDetailElement(getDetailType(), formElement
, style
);
82 * <p>getDetailType</p>
84 * @return a {@link eu.etaxonomy.taxeditor.forms.CdmFormFactory.DetailType} object.
86 protected abstract DetailType
getDetailType();
91 * @return the heading for this section
93 public abstract String
getHeading();
97 public void dispose() {
98 if(detailElement
instanceof ISelectableElement
){
99 formFactory
.destroySelectionArbitrator(((ISelectableElement
)detailElement
).getSelectionArbitrator());
105 * @see eu.etaxonomy.taxeditor.forms.section.AbstractEditorFormSection#setBackground(org.eclipse.swt.graphics.Color)
109 public void setBackground(Color color
) {
110 if(detailElement
!= null){
111 // detailComposite.setBackground(color);
113 super.setBackground(color
);
119 * @param entity a ENTITY object.
121 public void setEntity(ENTITY entity
) {
122 if(detailElement
!= null){
123 detailElement
.setEntity(entity
);
125 super.setEntity(entity
);
131 * <p>setSectionTitle</p>
133 protected void setSectionTitle(){
135 if(getEntity() != null && (getEntity() instanceof IdentifiableEntity
)){
136 title
= ": " + ((IdentifiableEntity
) getEntity()).getTitleCache();
138 this.setText(getHeading() + title
);
144 public void updateTitle(){
152 public void setIrrelevant(boolean irrelevant
) {
153 if(detailElement
!= null){
154 detailElement
.setIrrelevant(irrelevant
);
159 public void expansionStateChanging(ExpansionEvent e
) {
160 // logger.warn("Expansion State Changing");
164 public void expansionStateChanged(ExpansionEvent e
) {
165 // logger.warn("Expansion State Changed");