2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.propertysheet
.namerelations
.wizard
;
12 import org
.apache
.log4j
.Logger
;
13 import org
.eclipse
.jface
.util
.IPropertyChangeListener
;
14 import org
.eclipse
.jface
.util
.PropertyChangeEvent
;
15 import org
.eclipse
.jface
.wizard
.IWizardPage
;
16 import org
.eclipse
.jface
.wizard
.Wizard
;
18 import eu
.etaxonomy
.taxeditor
.ITaxEditorConstants
;
19 import eu
.etaxonomy
.taxeditor
.actions
.cdm
.CreateNameRelationAction
;
26 public class NameRelationWizard
extends Wizard
{
27 private static final Logger logger
= Logger
28 .getLogger(NameRelationWizard
.class);
30 public static final String ID
= "eu.etaxonomy.taxeditor.namerelationwizard";
32 private NameRelationWizardModel relationModel
;
34 public NameRelationWizard(NameRelationWizardModel relationModel
) {
37 this.relationModel
= relationModel
;
41 * @see org.eclipse.jface.wizard.Wizard#addPages()
43 public void addPages() {
44 IWizardPage chooseNamePage
= new ChooseRelatedNameWizardPage(relationModel
);
45 addPage(chooseNamePage
);
46 IWizardPage chooseRelationPage
= new ChooseRelationTypeWizardPage(relationModel
);
47 addPage(chooseRelationPage
);
51 public boolean performFinish() {
52 CreateNameRelationAction nameRelationAction
= new CreateNameRelationAction(relationModel
.getFromName(),
53 relationModel
.getType(),
54 relationModel
.getToName());
55 // if (relationModel.getNameRelationsList() != null) {
57 // Action will notify when relation has been created
58 nameRelationAction
.addPropertyChangeListener(new IPropertyChangeListener() {
59 public void propertyChange(PropertyChangeEvent event
) {
60 logger
.warn(event
.getProperty());
61 if (event
.getProperty().equals(
62 ITaxEditorConstants
.NAMERELATION
)) {
63 if (relationModel
.getNameRelationsList() != null) {
64 relationModel
.getNameRelationsList().clear();
65 relationModel
.getNameRelationsList().addAll(relationModel
.getBaseName().getNameRelations());
72 nameRelationAction
.run();