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
.reference
;
12 import org
.eclipse
.jface
.viewers
.CellEditor
;
13 import org
.eclipse
.jface
.viewers
.DialogCellEditor
;
14 import org
.eclipse
.swt
.widgets
.Composite
;
15 import org
.eclipse
.swt
.widgets
.Control
;
16 import org
.eclipse
.swt
.widgets
.Dialog
;
17 import org
.eclipse
.ui
.views
.properties
.PropertyDescriptor
;
19 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceBase
;
26 abstract public class ReferenceSearchDescriptor
extends PropertyDescriptor
{
30 public ReferenceSearchDescriptor(Object id
, String displayName
, int searchType
) {
31 super(id
, displayName
);
33 this.searchType
= searchType
;
36 public CellEditor
createPropertyEditor(Composite parent
) {
37 CellEditor editor
= new DialogCellEditor(parent
) {
39 protected Object
openDialogBox(
40 Control cellEditorWindow
) {
41 Dialog dialog
= new ReferenceSearchDialog(cellEditorWindow
.getShell(),
43 Object value
= ((ReferenceSearchDialog
) dialog
).open();
44 if (value
instanceof ReferenceBase
) {
46 ReferenceBase
<?
> reference
= (ReferenceBase
<?
>) value
;
47 saveReference(reference
);
48 return new ReferencePropertySource(reference
);
53 if (getValidator() != null) {
54 editor
.setValidator(getValidator());
59 abstract protected void saveReference(ReferenceBase
<?
> reference
);