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
.SWT
;
15 import org
.eclipse
.swt
.graphics
.Color
;
16 import org
.eclipse
.swt
.layout
.GridData
;
17 import org
.eclipse
.swt
.layout
.GridLayout
;
18 import org
.eclipse
.swt
.widgets
.Composite
;
19 import org
.eclipse
.ui
.forms
.widgets
.ScrolledForm
;
21 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
22 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
23 import eu
.etaxonomy
.cdm
.model
.common
.IIdentifiableEntity
;
24 import eu
.etaxonomy
.cdm
.persistence
.hibernate
.CdmDataChangeMap
;
25 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailElement
;
28 * <p>Abstract AbstractCdmEntityWizardPage class.</p>
31 * @created Jun 1, 2010
34 public abstract class AbstractCdmEntityWizardPage
<T
> extends WizardPage
implements IConversationEnabled
{
36 protected CdmFormFactory formFactory
;
39 AbstractCdmDetailElement
<T
> detailElement
;
40 private ConversationHolder conversation
;
43 * <p>Constructor for AbstractCdmEntityWizardPage.</p>
45 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
46 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
47 * @param entity a T object.
48 * @param <T> a T object.
50 protected AbstractCdmEntityWizardPage(CdmFormFactory formFactory
, ConversationHolder conversation
, T entity
) {
52 this.formFactory
= formFactory
;
54 this.conversation
= conversation
;
55 setDescription(getEntityTitle());
61 private String
getEntityTitle() {
62 if(entity
instanceof IIdentifiableEntity
){
63 ((IIdentifiableEntity
) entity
).getTitleCache();
70 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
73 public void createControl(Composite parent
) {
74 ScrolledForm scrolledForm
= formFactory
.createScrolledForm(parent
);
75 GridLayout layout
= new GridLayout();
76 scrolledForm
.getBody().setLayout(layout
);
78 Composite control
= formFactory
.createComposite(scrolledForm
.getBody());
79 control
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true));
81 control
.setLayout(CdmFormFactory
.LAYOUT(2, false));
82 WizardPageRootElement rootElement
= new WizardPageRootElement(formFactory
, control
, getConversationHolder());
84 Color bgColor
= getShell().getBackground();
86 detailElement
= createElement(rootElement
);
88 rootElement
.setBackground(bgColor
);
89 control
.setBackground(bgColor
);
90 scrolledForm
.setBackground(bgColor
);
92 setControl(scrolledForm
);
96 * <p>Getter for the field <code>entity</code>.</p>
100 public T
getEntity() {
105 * Creates the detail element for this wizard page
107 * @param rootElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
108 * @return a {@link eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement} object.
110 public abstract AbstractCdmDetailElement
<T
> createElement(ICdmFormElement rootElement
);
112 private class WizardPageRootElement
extends RootElement
implements IConversationEnabled
{
114 private ConversationHolder conversation
;
116 public WizardPageRootElement(CdmFormFactory formFactory
,
117 Composite layoutComposite
, ConversationHolder conversation
) {
118 super(formFactory
, layoutComposite
);
119 this.conversation
= conversation
;
123 public void refresh() {
125 this.removeElements();
126 detailElement
= createElement(this);
127 ((Composite
) getControl()).layout();
130 public ConversationHolder
getConversationHolder() {
134 public void update(CdmDataChangeMap changeEvents
) {}
138 * <p>getConversationHolder</p>
140 * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
142 public ConversationHolder
getConversationHolder() {
148 public void dispose() {
150 detailElement
.removeElements();
154 * <p>Getter for the field <code>detailElement</code>.</p>
156 * @return a {@link eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement} object.
158 public AbstractCdmDetailElement
<T
> getDetailElement() {
159 return detailElement
;
163 public void update(CdmDataChangeMap changeEvents
) {}