Checking in before moving references' search button up in the hierarchy.
[taxeditor.git] / taxeditor-editor / src / main / java / eu / etaxonomy / taxeditor / propertysheet / name / AuthorshipSearchDescriptor.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.name;
11
12 import org.eclipse.jface.dialogs.MessageDialog;
13 import org.eclipse.jface.viewers.CellEditor;
14 import org.eclipse.jface.viewers.DialogCellEditor;
15 import org.eclipse.swt.widgets.Composite;
16 import org.eclipse.swt.widgets.Control;
17 import org.eclipse.ui.views.properties.PropertyDescriptor;
18
19 import eu.etaxonomy.cdm.model.agent.AgentBase;
20 import eu.etaxonomy.cdm.model.agent.INomenclaturalAuthor;
21 import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
22 import eu.etaxonomy.taxeditor.dialogs.filteredSelection.FilteredAgentSelectionDialog;
23 import eu.etaxonomy.taxeditor.dialogs.filteredSelection.FilteredTeamOrPersonBaseSelectionDialog;
24
25 /**
26 * @author p.ciardelli
27 * @created 19.05.2008
28 * @version 1.0
29 */
30 public class AuthorshipSearchDescriptor extends PropertyDescriptor {
31
32 private TeamOrPersonBase teamOrPerson;
33
34 public AuthorshipSearchDescriptor(Object id, String displayName) {
35 super(id, displayName);
36 }
37
38 /**
39 * @param idAuthorshipcache
40 * @param authorshipcache
41 * @param combinationAuthorTeam
42 */
43 public AuthorshipSearchDescriptor(Object id, String displayName, TeamOrPersonBase teamOrPerson) {
44 this(id, displayName);
45 this.teamOrPerson = teamOrPerson;
46 }
47
48 public CellEditor createPropertyEditor(Composite parent) {
49 CellEditor editor = new DialogCellEditor(parent) {
50
51 /* (non-Javadoc)
52 * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control)
53 */
54 protected Object openDialogBox(
55 Control cellEditorWindow) {
56 // AgentBase agent = FilteredAgentSelectionDialog.selectAgent(cellEditorWindow.getShell(), teamOrPerson);
57 AgentBase agent = FilteredTeamOrPersonBaseSelectionDialog.selectTeamOrPersonBase(cellEditorWindow.getShell(), teamOrPerson);
58 if (agent instanceof INomenclaturalAuthor) {
59 return agent;
60 } else {
61 MessageDialog.openError(cellEditorWindow.getShell(), "Not a nomenclatural author",
62 "'" + agent.getTitleCache() + "' is not a nomenclatural author.");
63 }
64 return agent;
65 }
66 };
67 if (getValidator() != null) {
68 editor.setValidator(getValidator());
69 }
70 return editor;
71 }
72 }