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.FilteredAgentSelectionDialog;
|
23
|
|
24
|
/**
|
25
|
* @author p.ciardelli
|
26
|
* @created 19.05.2008
|
27
|
* @version 1.0
|
28
|
*/
|
29
|
public class AuthorshipSearchDescriptor extends PropertyDescriptor {
|
30
|
|
31
|
private TeamOrPersonBase teamOrPerson;
|
32
|
|
33
|
public AuthorshipSearchDescriptor(Object id, String displayName) {
|
34
|
super(id, displayName);
|
35
|
}
|
36
|
|
37
|
/**
|
38
|
* @param idAuthorshipcache
|
39
|
* @param authorshipcache
|
40
|
* @param combinationAuthorTeam
|
41
|
*/
|
42
|
public AuthorshipSearchDescriptor(Object id, String displayName, TeamOrPersonBase teamOrPerson) {
|
43
|
this(id, displayName);
|
44
|
this.teamOrPerson = teamOrPerson;
|
45
|
}
|
46
|
|
47
|
public CellEditor createPropertyEditor(Composite parent) {
|
48
|
CellEditor editor = new DialogCellEditor(parent) {
|
49
|
|
50
|
/* (non-Javadoc)
|
51
|
* @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control)
|
52
|
*/
|
53
|
protected Object openDialogBox(
|
54
|
Control cellEditorWindow) {
|
55
|
AgentBase agent = FilteredAgentSelectionDialog.selectAgent(cellEditorWindow.getShell(), teamOrPerson);
|
56
|
if (agent instanceof INomenclaturalAuthor) {
|
57
|
return agent;
|
58
|
} else {
|
59
|
MessageDialog.openError(cellEditorWindow.getShell(), "Not a nomenclatural author",
|
60
|
"'" + agent.getTitleCache() + "' is not a nomenclatural author.");
|
61
|
}
|
62
|
return agent;
|
63
|
}
|
64
|
};
|
65
|
if (getValidator() != null) {
|
66
|
editor.setValidator(getValidator());
|
67
|
}
|
68
|
return editor;
|
69
|
}
|
70
|
}
|