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
;
17 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
18 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
19 import eu
.etaxonomy
.cdm
.model
.common
.IIdentifiableEntity
;
20 import eu
.etaxonomy
.cdm
.persistence
.hibernate
.CdmDataChangeMap
;
21 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailElement
;
24 * <p>Abstract AbstractCdmEntityWizardPage class.</p>
27 * @created Jun 1, 2010
30 public abstract class AbstractCdmEntityWizardPage
<T
> extends WizardPage
implements IConversationEnabled
{
32 protected CdmFormFactory formFactory
;
35 AbstractCdmDetailElement
<T
> detailElement
;
36 private ConversationHolder conversation
;
39 * <p>Constructor for AbstractCdmEntityWizardPage.</p>
41 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
42 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
43 * @param entity a T object.
44 * @param <T> a T object.
46 protected AbstractCdmEntityWizardPage(CdmFormFactory formFactory
, ConversationHolder conversation
, T entity
) {
48 this.formFactory
= formFactory
;
50 this.conversation
= conversation
;
51 setDescription(getEntityTitle());
57 private String
getEntityTitle() {
58 if(entity
instanceof IIdentifiableEntity
){
59 ((IIdentifiableEntity
) entity
).getTitleCache();
66 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
69 public void createControl(Composite parent
) {
70 Composite control
= formFactory
.createComposite(parent
);
72 control
.setLayout(CdmFormFactory
.LAYOUT(2, false));
73 WizardPageRootElement rootElement
= new WizardPageRootElement(formFactory
, control
, getConversationHolder());
75 Color bgColor
= getShell().getBackground();
77 detailElement
= createElement(rootElement
);
79 rootElement
.setBackground(bgColor
);
80 control
.setBackground(bgColor
);
86 * <p>Getter for the field <code>entity</code>.</p>
90 public T
getEntity() {
95 * Creates the detail element for this wizard page
97 * @param rootElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
98 * @return a {@link eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement} object.
100 public abstract AbstractCdmDetailElement
createElement(ICdmFormElement rootElement
);
102 private class WizardPageRootElement
extends RootElement
implements IConversationEnabled
{
104 private ConversationHolder conversation
;
106 public WizardPageRootElement(CdmFormFactory formFactory
,
107 Composite layoutComposite
, ConversationHolder conversation
) {
108 super(formFactory
, layoutComposite
);
109 this.conversation
= conversation
;
113 public void refresh() {
115 this.removeElements();
116 detailElement
= createElement(this);
117 ((Composite
) getControl()).layout();
120 public ConversationHolder
getConversationHolder() {
124 public void update(CdmDataChangeMap changeEvents
) {}
128 * <p>getConversationHolder</p>
130 * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
132 public ConversationHolder
getConversationHolder() {
138 public void dispose() {
140 detailElement
.removeElements();
144 * <p>Getter for the field <code>detailElement</code>.</p>
146 * @return a {@link eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement} object.
148 public AbstractCdmDetailElement
<T
> getDetailElement() {
149 return detailElement
;
153 public void update(CdmDataChangeMap changeEvents
) {}