4fc292375f2b2e883b9cd185272f41200eace076
[taxeditor.git] / eclipseprojects / eu.etaxonomy.taxeditor / src / eu / etaxonomy / taxeditor / actions / ui / OpenNameRelationWizardAction.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.actions.ui;
11
12 import java.util.List;
13
14 import org.apache.log4j.Logger;
15 import org.eclipse.jface.action.Action;
16 import org.eclipse.jface.resource.ImageDescriptor;
17 import org.eclipse.jface.wizard.Wizard;
18 import org.eclipse.jface.wizard.WizardDialog;
19
20 import eu.etaxonomy.cdm.model.name.NameRelationship;
21 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
22 import eu.etaxonomy.taxeditor.controller.GlobalController;
23 import eu.etaxonomy.taxeditor.propertysheet.namerelations.wizard.NameRelationWizard;
24 import eu.etaxonomy.taxeditor.propertysheet.namerelations.wizard.NameRelationWizardModel;
25
26 /**
27 * @author p.ciardelli
28 * @created 04.06.2008
29 * @version 1.0
30 */
31 public class OpenNameRelationWizardAction extends Action {
32 private static final Logger logger = Logger
33 .getLogger(OpenNameRelationWizardAction.class);
34
35 private static String text = "Create name relation ...";
36 // private ImageDescriptor image = TaxEditorPlugin.getDefault()
37 // .getImageDescriptor(ITaxEditorConstants.ACTIVE_DELETE_ICON);
38 private ImageDescriptor image = null;
39 public static final String ID = "eu.etaxonomy.taxeditor.actions.opennamerelationswizard"; //$NON-NLS-1$
40
41 private NameRelationWizardModel relationModel;
42
43 private OpenNameRelationWizardAction() {
44 super(text);
45 setImageDescriptor(image);
46 setId(ID);
47 }
48
49 public OpenNameRelationWizardAction(TaxonNameBase name) {
50 this();
51
52 this.relationModel = new NameRelationWizardModel(name);
53 }
54
55 public OpenNameRelationWizardAction(TaxonNameBase name,
56 List<NameRelationship> nameRelationsList) {
57 this(name);
58
59 this.relationModel.setNameRelationsList(nameRelationsList);
60 }
61
62 public OpenNameRelationWizardAction(TaxonNameBase name,
63 NameRelationship relation) {
64 this(name);
65
66 this.relationModel.setRelation(relation);
67 }
68
69 public void run() {
70 if (relationModel.getBaseName() == null) {
71 return;
72 }
73
74 Wizard wizard = new NameRelationWizard(relationModel);
75
76 WizardDialog dialog = new WizardDialog(GlobalController.getShell(), wizard);
77 dialog.create();
78 dialog.open();
79 }
80 }