p2izing the editor
[taxeditor.git] / eclipseprojects / eu.etaxonomy.taxeditor / src / eu / etaxonomy / taxeditor / propertysheet / namerelations / wizard / NameRelationWizard.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
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.
8 */
9
10 package eu.etaxonomy.taxeditor.propertysheet.namerelations.wizard;
11
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;
17
18 import eu.etaxonomy.taxeditor.ITaxEditorConstants;
19 import eu.etaxonomy.taxeditor.actions.cdm.CreateNameRelationAction;
20
21 /**
22 * @author p.ciardelli
23 * @created 04.06.2008
24 * @version 1.0
25 */
26 public class NameRelationWizard extends Wizard {
27 private static final Logger logger = Logger
28 .getLogger(NameRelationWizard.class);
29
30 public static final String ID = "eu.etaxonomy.taxeditor.namerelationwizard";
31
32 private NameRelationWizardModel relationModel;
33
34 public NameRelationWizard(NameRelationWizardModel relationModel) {
35 super();
36
37 this.relationModel = relationModel;
38 }
39
40 /* (non-Javadoc)
41 * @see org.eclipse.jface.wizard.Wizard#addPages()
42 */
43 public void addPages() {
44 IWizardPage chooseNamePage = new ChooseRelatedNameWizardPage(relationModel);
45 addPage(chooseNamePage);
46 IWizardPage chooseRelationPage = new ChooseRelationTypeWizardPage(relationModel);
47 addPage(chooseRelationPage);
48 }
49
50 @Override
51 public boolean performFinish() {
52 CreateNameRelationAction nameRelationAction = new CreateNameRelationAction(relationModel.getFromName(),
53 relationModel.getType(),
54 relationModel.getToName());
55 // if (relationModel.getNameRelationsList() != null) {
56
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());
66 }
67 }
68
69 }
70 });
71 // }
72 nameRelationAction.run();
73 return true;
74 }
75 }