+++ /dev/null
-// $Id$
-/**
-* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
-* http://www.e-taxonomy.eu
-*
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
-
-package eu.etaxonomy.taxeditor.newWizard;
-
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
-import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
-import eu.etaxonomy.cdm.common.CdmUtils;
-import eu.etaxonomy.cdm.model.name.TaxonNameBase;
-import eu.etaxonomy.cdm.model.reference.Reference;
-import eu.etaxonomy.cdm.model.taxon.Classification;
-import eu.etaxonomy.cdm.model.taxon.ITreeNode;
-import eu.etaxonomy.cdm.model.taxon.Taxon;
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;
-import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
-import eu.etaxonomy.taxeditor.parser.ParseHandler;
-import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
-import eu.etaxonomy.taxeditor.ui.forms.CheckboxElement;
-import eu.etaxonomy.taxeditor.ui.forms.RootElement;
-import eu.etaxonomy.taxeditor.ui.forms.TextWithLabelElement;
-import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.SelectionType;
-import eu.etaxonomy.taxeditor.ui.selection.ClassificationSelectionElement;
-import eu.etaxonomy.taxeditor.ui.selection.NameSelectionElement;
-import eu.etaxonomy.taxeditor.ui.selection.TaxonNodeSelectionElement;
-import eu.etaxonomy.taxeditor.ui.selection.TaxonSelectionElement;
-
-/**
- * <p>NewTaxonNodeWizardPage class.</p>
- *
- * @author n.hoffmann
- * @created Sep 29, 2010
- * @version 1.0
- */
-@Deprecated //delete this file when refactoring is complete
-public class NewTaxonNodeWizardPage extends WizardPage implements IPropertyChangeListener, IConversationEnabled{
- private ClassificationSelectionElement selection_classification;
- private TaxonNodeSelectionElement selection_parentTaxonNode;
- private TaxonSelectionElement selection_reuseExistingTaxon;
- private TextWithLabelElement text_newTaxonName;
- private CheckboxElement checkbox_openInEditor;
- private CdmFormFactory formFactory;
- private NameSelectionElement selection_reuseExistingName;
- private ITreeNode parentTreeNode;
- private Classification classification;
- private Taxon taxon;
- private boolean openInEditor = true;
- private ConversationHolder conversation;
- private ITreeNode initiallySelectedNode;
-
- /**
- * <p>Constructor for NewTaxonNodeWizardPage.</p>
- *
- * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
- * @param selectedNode a {@link eu.etaxonomy.cdm.model.taxon.ITreeNode} object.
- */
- protected NewTaxonNodeWizardPage(ConversationHolder conversation, ITreeNode selectedNode) {
- super("Taxon");
-
- setTitle("Taxon");
-
- this.conversation = conversation;
- this.formFactory = new CdmFormFactory(Display.getCurrent());
-
- formFactory.addPropertyChangeListener(this);
-
- initiallySelectedNode = selectedNode;
-
- }
-
- /**
- * <p>openInEditor</p>
- *
- * @return a boolean.
- */
- public boolean openInEditor(){
- return openInEditor;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
- /** {@inheritDoc} */
- @Override
- public void propertyChange(PropertyChangeEvent event) {
-
- Object eventSource = event.getSource();
- if(eventSource == selection_classification){
- setClassification(selection_classification.getEntity());
- }
- else if(eventSource == selection_parentTaxonNode){
- setParentTreeNode(selection_parentTaxonNode.getEntity());
- }
- else if(eventSource == selection_reuseExistingTaxon){
- boolean enabled = selection_reuseExistingTaxon.getEntity() == null;
- selection_reuseExistingName.setEnabled(enabled);
- text_newTaxonName.setEnabled(enabled);
-
- setTaxon(selection_reuseExistingTaxon.getEntity());
- }
- else if(eventSource == selection_reuseExistingName){
- boolean enabled = selection_reuseExistingName.getEntity() == null;
- selection_reuseExistingTaxon.setEnabled(enabled);
- text_newTaxonName.setEnabled(enabled);
-
- setTaxon(selection_reuseExistingName.getEntity());
- }
- else if(eventSource == text_newTaxonName){
- boolean enabled = CdmUtils.isEmpty(text_newTaxonName.getText());
- selection_reuseExistingTaxon.setEnabled(enabled);
- selection_reuseExistingName.setEnabled(enabled);
-
- setTaxon(text_newTaxonName.getText());
- }
- else if(eventSource == checkbox_openInEditor){
- setOpenInEditor(checkbox_openInEditor.getSelection());
- }
-
- checkComplete();
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- /** {@inheritDoc} */
- @Override
- public void createControl(Composite parent) {
- Composite control = formFactory.createComposite(parent);
-
- control.setLayout(CdmFormFactory.LAYOUT(2, false));
- RootElement rootElement = new RootElement(formFactory, control);
-
- selection_classification = (ClassificationSelectionElement) formFactory.createSelectionElement(SelectionType.CLASSIFICATION, getConversationHolder(), rootElement, "Classification", null, SWT.NULL);
- selection_parentTaxonNode = (TaxonNodeSelectionElement) formFactory.createSelectionElement(SelectionType.TAXON_NODE, getConversationHolder(), rootElement, "Parent", null, SWT.NULL);
- selection_reuseExistingTaxon = (TaxonSelectionElement) formFactory.createSelectionElement(SelectionType.TAXON, getConversationHolder(), rootElement, "Reuse existing Taxon", null, SWT.NULL);
-
- selection_reuseExistingName = (NameSelectionElement) formFactory.createSelectionElement(SelectionType.NAME, getConversationHolder(), rootElement, "Reuse existing name", null, SWT.NULL);
-
- text_newTaxonName = formFactory.createTextWithLabelElement(rootElement, "New Taxon", "", SWT.NULL);
- text_newTaxonName.setFocus();
-
- checkbox_openInEditor = formFactory.createCheckbox(rootElement, "Open in Editor", openInEditor, SWT.NULL);
-
- setParentTreeNode(initiallySelectedNode);
-
- Color bgColor = getShell().getBackground();
-
- rootElement.setBackground(bgColor);
- control.setBackground(bgColor);
-
- setControl(control);
-
- }
-
- /**
- * @param classification the classification to set
- */
- private void setClassification(Classification classification) {
- this.classification = classification;
- setParentTreeNode(classification);
- }
-
- /**
- * @param parentTreeNode the parentTreeNode to set
- */
- private void setParentTreeNode(ITreeNode parentTreeNode) {
- if(parentTreeNode == null){
- setPageComplete(false);
- return;
- }
-
- this.parentTreeNode = parentTreeNode;
-
- if(parentTreeNode instanceof Classification){
- classification = (Classification) parentTreeNode;
- selection_classification.setEntity(classification);
- selection_parentTaxonNode.setEntity(null);
- }
- else if(parentTreeNode instanceof TaxonNode){
- classification = ((TaxonNode) parentTreeNode).getClassification();
- selection_classification.setEntity(classification);
- selection_parentTaxonNode.setEntity((TaxonNode) parentTreeNode);
- }
- }
-
- /**
- *
- * @param taxon
- */
- private void setTaxon(Taxon taxon) {
- this.taxon = taxon;
- }
-
- private void setTaxon(String taxonNameString){
- TaxonNameBase taxonName = ParseHandler.parseReferencedName(taxonNameString, null);
- setTaxon(taxonName);
- }
-
- private void setTaxon(TaxonNameBase taxonName){
- Reference secundum = null;
- if(getParentTreeNode() != null){
- if(getParentTreeNode() instanceof Classification){
- secundum = ((Classification) getParentTreeNode()).getReference();
- }
- else if(getParentTreeNode() instanceof TaxonNode){
- secundum = ((TaxonNode) getParentTreeNode()).getTaxon().getSec();
- }
- }
- taxon = Taxon.NewInstance(taxonName, secundum);
- }
-
- /**
- * @param openInEditor the openInEditor to set
- */
- private void setOpenInEditor(boolean openInEditor) {
- this.openInEditor = openInEditor;
- }
-
- /**
- * <p>Getter for the field <code>parentTreeNode</code>.</p>
- *
- * @return a {@link eu.etaxonomy.cdm.model.taxon.ITreeNode} object.
- */
- public ITreeNode getParentTreeNode() {
- return parentTreeNode;
- }
-
- /**
- * <p>Getter for the field <code>taxon</code>.</p>
- *
- * @return the taxon
- */
- public Taxon getTaxon() {
- return taxon;
- }
-
- /**
- *
- */
- private void checkComplete() {
- if(classification == null){
- setMessage("No classification", WARNING);
- setPageComplete(false);
- }else{
- setMessage(null);
- setPageComplete(true);
- }
-
-
- }
-
- /* (non-Javadoc)
- * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
- */
- /** {@inheritDoc} */
- @Override
- public void update(CdmDataChangeMap changeEvents) {
-
- }
-
-
- /* (non-Javadoc)
- * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
- */
- /** {@inheritDoc} */
- @Override
- public ConversationHolder getConversationHolder() {
- return conversation;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.DialogPage#dispose()
- */
- /** {@inheritDoc} */
- @Override
- public void dispose() {
- formFactory.removePropertyChangeListener(this);
- super.dispose();
- }
-}