X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/blobdiff_plain/148a888655e4efcd368f63cecaed586e2f230d2b..d58b8e3f77a8664b300c738c9678edb6024edf17:/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NameRelationshipWizardPage.java diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NameRelationshipWizardPage.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NameRelationshipWizardPage.java index 3acdf74bb..e8729b142 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NameRelationshipWizardPage.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NameRelationshipWizardPage.java @@ -1,84 +1,75 @@ -// $Id$ /** * Copyright (C) 2007 EDIT - * European Distributed Institute of Taxonomy + * 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.ui.section.name; -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.widgets.Composite; +import eu.etaxonomy.cdm.model.common.RelationshipTermBase; import eu.etaxonomy.cdm.model.name.NameRelationship; import eu.etaxonomy.cdm.model.name.NameRelationshipType; -import eu.etaxonomy.cdm.model.name.TaxonNameBase; -import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory; -import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.SelectionType; -import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.TermComboType; -import eu.etaxonomy.taxeditor.ui.forms.RootElement; -import eu.etaxonomy.taxeditor.ui.selection.NameSelectionElement; -import eu.etaxonomy.taxeditor.ui.term.NameRelationshipTypeComboElement; +import eu.etaxonomy.cdm.model.name.TaxonName; +import eu.etaxonomy.cdm.model.term.TermRelationshipType; +import eu.etaxonomy.taxeditor.l10n.Messages; +import eu.etaxonomy.taxeditor.ui.AbstractEntityCollectionElementWizardPage; +import eu.etaxonomy.taxeditor.ui.combo.RelationshipTypeCombo; +import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; +import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement; /** *

* NameRelationshipWizardPage class. *

- * + * * @author n.hoffmann * @created Jun 1, 2010 * @version 1.0 */ -public class NameRelationshipWizardPage extends WizardPage implements - IPropertyChangeListener { +public class NameRelationshipWizardPage extends AbstractEntityCollectionElementWizardPage { - private final CdmFormFactory formFactory; + private EntitySelectionElement selection_relatedTo; - private NameSelectionElement selection_relatedTo; + private RelationshipTypeCombo combo_relationshipType; - private NameRelationshipTypeComboElement combo_relationshipType; + private final TaxonName entity; - private final NameRelationshipDetailSection callingSection; + private RelationshipTermBase type; - private final TaxonNameBase entity; - - private NameRelationshipType type; - - private TaxonNameBase toName; - - private RootElement rootElement; + private TaxonName relatedName; + boolean inverse; /** *

* Constructor for NameRelationshipWizardPage. *

- * + * * @param callingSection * a * {@link eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection} * object. */ protected NameRelationshipWizardPage( - NameRelationshipDetailSection callingSection) { - super("NameRelationshipWizardPage"); - setTitle("New Name Relationship"); - setDescription(callingSection.getEntity().getTitleCache()); - this.callingSection = callingSection; + NameRelationshipDetailSection callingSection, CdmFormFactory formFactory) { + super("NameRelationshipWizardPage", formFactory); //$NON-NLS-1$ + setTitle("New Name Relationship"); //$NON-NLS-1$ + //setDescription(callingSection.getEntity().getTitleCache()); + setDescription(Messages.NameRelationshipWizardPage_description); this.entity = callingSection.getEntity(); - this.formFactory = callingSection.getFormFactory(); formFactory.addPropertyChangeListener(this); } /* * (non-Javadoc) - * + * * @see * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets * .Composite) @@ -86,37 +77,34 @@ public class NameRelationshipWizardPage extends WizardPage implements /** {@inheritDoc} */ @Override public void createControl(Composite parent) { - this.setPageComplete(false); - - Composite control = formFactory.createComposite(parent); - - control.setLayout(CdmFormFactory.LAYOUT(2, false)); + super.createControl(parent); - rootElement = new RootElement(formFactory, control); + combo_relationshipType = formFactory.createNameRelationshipTypeCombo(rootElement, + entity.getNameCache(), SWT.NULL, false,null); - combo_relationshipType = (NameRelationshipTypeComboElement) formFactory - .createTermComboElement(TermComboType.NAMERELATIONSHIP, - rootElement, "Name Relationship Type", null, SWT.NULL); - selection_relatedTo = (NameSelectionElement) formFactory - .createSelectionElement(SelectionType.NAME, - ((NameRelationshipWizard) getWizard()) - .getConversationHolder(), rootElement, - "Related to", null, NameSelectionElement.DEFAULT, - SWT.NULL); + selection_relatedTo = formFactory + .createSelectionElement(TaxonName.class, rootElement, + "",this.entity, EntitySelectionElement.ALL, + SWT.NULL, true); - setControl(control); } /** *

* getNameRelationship *

- * + * * @return a {@link eu.etaxonomy.cdm.model.name.NameRelationship} object. */ public NameRelationship getNameRelationship() { - return entity.addRelationshipToName(toName, type, null, null, null); + NameRelationship rel; + if (inverse){ + rel = entity.addRelationshipFromName(relatedName, (NameRelationshipType)type, null, null, null, null); + }else{ + rel = entity.addRelationshipToName(relatedName, (NameRelationshipType)type, null, null, null, null); + } + return rel; } /** {@inheritDoc} */ @@ -126,21 +114,16 @@ public class NameRelationshipWizardPage extends WizardPage implements return; } Object eventSource = event.getSource(); - if (eventSource == combo_relationshipType) { - type = combo_relationshipType.getSelection(); + if (eventSource == combo_relationshipType && combo_relationshipType.getSelection() != null) { + type = combo_relationshipType.getSelection().getTerm(); + this.inverse = combo_relationshipType.getSelection().isInverse(); } else if (eventSource == selection_relatedTo) { - toName = selection_relatedTo.getEntity(); + relatedName = selection_relatedTo.getEntity(); + } - boolean complete = type != null && toName != null; + boolean complete = type != null && relatedName != null; setPageComplete(complete); } - /** {@inheritDoc} */ - @Override - public void dispose() { - rootElement.removeElements(); - formFactory.removePropertyChangeListener(this); - super.dispose(); - } }