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
.newWizard
;
13 import org
.apache
.log4j
.Logger
;
14 import org
.eclipse
.jface
.util
.IPropertyChangeListener
;
15 import org
.eclipse
.jface
.util
.PropertyChangeEvent
;
16 import org
.eclipse
.jface
.wizard
.WizardPage
;
17 import org
.eclipse
.swt
.SWT
;
18 import org
.eclipse
.swt
.graphics
.Color
;
19 import org
.eclipse
.swt
.widgets
.Composite
;
20 import org
.eclipse
.swt
.widgets
.Display
;
22 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
23 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
24 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
25 import eu
.etaxonomy
.cdm
.model
.common
.LanguageString
;
26 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
27 import eu
.etaxonomy
.cdm
.persistence
.hibernate
.CdmDataChangeMap
;
28 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
29 import eu
.etaxonomy
.taxeditor
.ui
.forms
.CdmFormFactory
;
30 import eu
.etaxonomy
.taxeditor
.ui
.forms
.RootElement
;
31 import eu
.etaxonomy
.taxeditor
.ui
.forms
.TextWithLabelElement
;
32 import eu
.etaxonomy
.taxeditor
.ui
.forms
.CdmFormFactory
.SelectionType
;
33 import eu
.etaxonomy
.taxeditor
.ui
.selection
.ReferenceSelectionElement
;
36 * <p>ClassificationWizardPage class.</p>
39 * @created Sep 29, 2010
42 @Deprecated // remove this file when refactoring is complete
43 public class ClassificationWizardPage
extends WizardPage
implements IPropertyChangeListener
, IConversationEnabled
{
44 private static final Logger logger
= Logger
45 .getLogger(ClassificationWizardPage
.class);
46 private Classification classification
;
48 private ConversationHolder conversation
;
49 private CdmFormFactory formFactory
;
50 private Composite control
;
51 private TextWithLabelElement text_classificationLabel
;
52 private ReferenceSelectionElement selection_reference
;
53 private TextWithLabelElement text_referenceDetail
;
56 * <p>Constructor for ClassificationWizardPage.</p>
58 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
59 * @param classification a {@link eu.etaxonomy.cdm.model.taxon.TaxonomicTree} object.
61 protected ClassificationWizardPage(ConversationHolder conversation
, Classification classification
){
62 super("Classification");
63 this.setTitle("Classification");
64 this.setDescription(classification
== null ?
"Create a new Classification." : "Edit Classification.");
66 this.classification
= classification
;
67 this.conversation
= conversation
;
69 this.formFactory
= new CdmFormFactory(Display
.getCurrent());
71 formFactory
.addPropertyChangeListener(this);
78 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
81 public void createControl(Composite parent
) {
82 control
= formFactory
.createComposite(parent
);
84 control
.setLayout(CdmFormFactory
.LAYOUT(2, false));
85 RootElement rootElement
= new RootElement(formFactory
, control
);
87 text_classificationLabel
= formFactory
.createTextWithLabelElement(rootElement
, "Label", classification
.getName().getText(), SWT
.NULL
);
88 selection_reference
= (ReferenceSelectionElement
) formFactory
.createSelectionElement(SelectionType
.REFERENCE
, getConversationHolder(), rootElement
, "Reference", classification
.getReference(), SWT
.NULL
);
89 text_referenceDetail
= formFactory
.createTextWithLabelElement(rootElement
, "Reference Detail", classification
.getMicroReference(), SWT
.NULL
);
91 Color bgColor
= getShell().getBackground();
93 rootElement
.setBackground(bgColor
);
94 control
.setBackground(bgColor
);
99 private void initialize() {
100 if(classification
== null){
101 classification
= Classification
.NewInstance(null, null, CdmStore
.getDefaultLanguage());
106 * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
110 public void propertyChange(PropertyChangeEvent event
) {
111 Object eventSource
= event
.getSource();
113 if(eventSource
== text_classificationLabel
){
114 classification
.setName(LanguageString
.NewInstance(text_classificationLabel
.getText(), CdmStore
.getDefaultLanguage()));
116 else if(eventSource
== selection_reference
){
117 classification
.setReference(selection_reference
.getEntity());
119 else if(eventSource
== text_referenceDetail
){
120 classification
.setMicroReference(text_referenceDetail
.getText());
130 private void checkComplete() {
131 if(CdmUtils
.isEmpty(text_classificationLabel
.getText())){
132 setMessage("A Classifications label may not be empty");
133 setPageComplete(false);
136 setPageComplete(true);
141 * <p>Getter for the field <code>classification</code>.</p>
143 * @return a {@link eu.etaxonomy.cdm.model.taxon.TaxonomicTree} object.
145 public Classification
getClassification() {
146 return classification
;
151 * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
155 public void update(CdmDataChangeMap changeEvents
) {}
159 * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
163 public ConversationHolder
getConversationHolder() {
168 * @see org.eclipse.jface.dialogs.DialogPage#dispose()
172 public void dispose() {
173 formFactory
.removePropertyChangeListener(this);