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