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
.forms
;
13 import org
.eclipse
.jface
.wizard
.WizardPage
;
14 import org
.eclipse
.swt
.graphics
.Color
;
15 import org
.eclipse
.swt
.widgets
.Composite
;
16 import org
.eclipse
.ui
.forms
.widgets
.ScrolledForm
;
18 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
19 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
20 import eu
.etaxonomy
.cdm
.model
.common
.IIdentifiableEntity
;
21 import eu
.etaxonomy
.cdm
.persistence
.hibernate
.CdmDataChangeMap
;
22 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailElement
;
25 * <p>Abstract AbstractCdmEntityWizardPage class.</p>
28 * @created Jun 1, 2010
31 public abstract class AbstractCdmEntityWizardPage
<T
> extends WizardPage
implements IConversationEnabled
{
33 protected CdmFormFactory formFactory
;
36 AbstractCdmDetailElement
<T
> detailElement
;
37 private ConversationHolder conversation
;
40 * <p>Constructor for AbstractCdmEntityWizardPage.</p>
42 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
43 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
44 * @param entity a T object.
45 * @param <T> a T object.
47 protected AbstractCdmEntityWizardPage(CdmFormFactory formFactory
, ConversationHolder conversation
, T entity
) {
49 this.formFactory
= formFactory
;
51 this.conversation
= conversation
;
52 setDescription(getEntityTitle());
58 private String
getEntityTitle() {
59 if(entity
instanceof IIdentifiableEntity
){
60 ((IIdentifiableEntity
) entity
).getTitleCache();
67 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
70 public void createControl(Composite parent
) {
71 ScrolledForm scrolledForm
= formFactory
.createScrolledForm(parent
);
72 scrolledForm
.getBody().setLayout(CdmFormFactory
.LAYOUT());
74 Composite control
= formFactory
.createComposite(scrolledForm
.getBody());
75 control
.setLayoutData(CdmFormFactory
.FILL());
77 control
.setLayout(CdmFormFactory
.LAYOUT(2, false));
78 WizardPageRootElement rootElement
= new WizardPageRootElement(formFactory
, control
, getConversationHolder());
80 Color bgColor
= getShell().getBackground();
82 detailElement
= createElement(rootElement
);
84 rootElement
.setBackground(bgColor
);
85 control
.setBackground(bgColor
);
86 scrolledForm
.setBackground(bgColor
);
88 setControl(scrolledForm
);
92 * <p>Getter for the field <code>entity</code>.</p>
96 public T
getEntity() {
101 * Creates the detail element for this wizard page
103 * @param rootElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
104 * @return a {@link eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement} object.
106 public abstract AbstractCdmDetailElement
<T
> createElement(ICdmFormElement rootElement
);
108 private class WizardPageRootElement
extends RootElement
implements IConversationEnabled
{
110 private ConversationHolder conversation
;
112 public WizardPageRootElement(CdmFormFactory formFactory
,
113 Composite layoutComposite
, ConversationHolder conversation
) {
114 super(formFactory
, layoutComposite
);
115 this.conversation
= conversation
;
119 public void refresh() {
121 this.removeElements();
122 detailElement
= createElement(this);
123 ((Composite
) getControl()).layout();
126 public ConversationHolder
getConversationHolder() {
130 public void update(CdmDataChangeMap changeEvents
) {}
134 * <p>getConversationHolder</p>
136 * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
138 public ConversationHolder
getConversationHolder() {
144 public void dispose() {
146 detailElement
.removeElements();
150 * <p>Getter for the field <code>detailElement</code>.</p>
152 * @return a {@link eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement} object.
154 public AbstractCdmDetailElement
<T
> getDetailElement() {
155 return detailElement
;
159 public void update(CdmDataChangeMap changeEvents
) {}