p2izing the editor
[taxeditor.git] / eclipseprojects / eu.etaxonomy.taxeditor / src / eu / etaxonomy / taxeditor / propertysheet / type / TypePropertyDescriptor.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.type;
11
12 import org.apache.log4j.Logger;
13 import org.eclipse.jface.viewers.CellEditor;
14 import org.eclipse.jface.viewers.DialogCellEditor;
15 import org.eclipse.jface.wizard.Wizard;
16 import org.eclipse.jface.wizard.WizardDialog;
17 import org.eclipse.swt.widgets.Composite;
18 import org.eclipse.swt.widgets.Control;
19 import org.eclipse.ui.views.properties.PropertyDescriptor;
20
21 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
22 import eu.etaxonomy.taxeditor.controller.GlobalController;
23 import eu.etaxonomy.taxeditor.model.CdmUtil;
24 import eu.etaxonomy.taxeditor.propertysheet.type.wizard.TypeListWizard;
25
26 /**
27 * Property sheet descriptor that pops up a dialog window
28 * returning a set.
29 *
30 * @author p.ciardelli
31 * @created 19.05.2008
32 * @version 1.0
33 */
34 public class TypePropertyDescriptor extends PropertyDescriptor {
35 private static final Logger logger = Logger
36 .getLogger(TypePropertyDescriptor.class);
37
38 private TaxonNameBase name;
39
40 public TypePropertyDescriptor(Object id, String displayName, TaxonNameBase name) {
41 super(id, displayName);
42 this.name = name;
43 }
44
45 public CellEditor createPropertyEditor(Composite parent) {
46 CellEditor editor = new DialogCellEditor(parent) {
47
48 @Override
49 protected Object openDialogBox(
50 Control cellEditorWindow) {
51
52 Wizard wizard = new TypeListWizard(name);
53
54 // Instantiates the wizard container with the wizard and opens it
55 WizardDialog dialog = new WizardDialog(GlobalController.getShell(), wizard);
56 dialog.create();
57 dialog.open();
58
59 if (CdmUtil.isNameSupraSpecific(name)) {
60 return new TypeCollectionPropertySource(name, name.getNameTypeDesignations());
61 } else {
62 return new TypeCollectionPropertySource(name, name.getSpecimenTypeDesignations());
63 }
64 }
65
66 };
67 if (getValidator() != null) {
68 editor.setValidator(getValidator());
69 }
70 return editor;
71 }
72 }