1
|
/**
|
2
|
*
|
3
|
*/
|
4
|
package eu.etaxonomy.taxeditor.ui.section.user;
|
5
|
|
6
|
import eu.etaxonomy.cdm.api.service.IUserService;
|
7
|
import eu.etaxonomy.cdm.model.common.User;
|
8
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
9
|
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
|
10
|
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.SelectionType;
|
11
|
import eu.etaxonomy.taxeditor.ui.forms.CdmPropertyChangeEvent;
|
12
|
import eu.etaxonomy.taxeditor.ui.forms.CheckboxElement;
|
13
|
import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
|
14
|
import eu.etaxonomy.taxeditor.ui.forms.TextWithLabelElement;
|
15
|
import eu.etaxonomy.taxeditor.ui.forms.password.EditPasswordElement;
|
16
|
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
|
17
|
import eu.etaxonomy.taxeditor.ui.selection.PersonSelectionElement;
|
18
|
|
19
|
/**
|
20
|
* @author n.hoffmann
|
21
|
*
|
22
|
*/
|
23
|
public class UserDetailElement extends AbstractCdmDetailElement<User> {
|
24
|
|
25
|
private TextWithLabelElement text_username;
|
26
|
private EditPasswordElement element_editPassword;
|
27
|
private TextWithLabelElement text_emailAdress;
|
28
|
private PersonSelectionElement selection_person;
|
29
|
private CheckboxElement checkbox_credentialsNonExpired;
|
30
|
private CheckboxElement checkbox_enabled;
|
31
|
private CheckboxElement checkbox_accountNonLocked;
|
32
|
private CheckboxElement checkbox_accountNonExpired;
|
33
|
|
34
|
public UserDetailElement(CdmFormFactory formFactory,
|
35
|
ICdmFormElement formElement) {
|
36
|
super(formFactory, formElement);
|
37
|
}
|
38
|
|
39
|
/*
|
40
|
* (non-Javadoc)
|
41
|
*
|
42
|
* @see
|
43
|
* eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
|
44
|
* (eu.etaxonomy.taxeditor.forms.ICdmFormElement, java.lang.Object, int)
|
45
|
*/
|
46
|
@Override
|
47
|
protected void createControls(ICdmFormElement formElement, User entity,
|
48
|
int style) {
|
49
|
text_username = formFactory.createTextWithLabelElement(formElement,
|
50
|
"Username", entity.getUsername(), style);
|
51
|
|
52
|
if (userIsAuthenticated() || CdmStore.getLoginManager().isAdmin()) {
|
53
|
element_editPassword = formFactory.createEditPasswordElement(
|
54
|
formElement, "Change Password", getConversationHolder(),
|
55
|
entity, style);
|
56
|
}
|
57
|
|
58
|
text_emailAdress = formFactory.createTextWithLabelElement(formElement,
|
59
|
"Email Adress", entity.getEmailAddress(), style);
|
60
|
|
61
|
selection_person = (PersonSelectionElement) formFactory
|
62
|
.createSelectionElement(SelectionType.PERSON,
|
63
|
getConversationHolder(), formElement, "Person",
|
64
|
entity.getPerson(), PersonSelectionElement.DEFAULT,
|
65
|
style);
|
66
|
|
67
|
checkbox_accountNonExpired = formFactory.createCheckbox(formElement,
|
68
|
"Account Non Expired", entity.isAccountNonExpired(), style);
|
69
|
checkbox_accountNonLocked = formFactory.createCheckbox(formElement,
|
70
|
"Account Non Locked", entity.isAccountNonLocked(), style);
|
71
|
checkbox_enabled = formFactory.createCheckbox(formElement, "Enabled",
|
72
|
entity.isEnabled(), style);
|
73
|
checkbox_credentialsNonExpired = formFactory.createCheckbox(
|
74
|
formElement, "Credentials Non Expired",
|
75
|
entity.isCredentialsNonExpired(), style);
|
76
|
}
|
77
|
|
78
|
/**
|
79
|
*
|
80
|
* @return
|
81
|
*/
|
82
|
private boolean userIsAuthenticated() {
|
83
|
return getEntity().equals(
|
84
|
CdmStore.getLoginManager().getAuthenticatedUser());
|
85
|
}
|
86
|
|
87
|
/*
|
88
|
* (non-Javadoc)
|
89
|
*
|
90
|
* @see
|
91
|
* eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
|
92
|
* .lang.Object)
|
93
|
*/
|
94
|
@Override
|
95
|
public void handleEvent(Object eventSource) {
|
96
|
if (eventSource == text_username) {
|
97
|
getEntity().setUsername(text_username.getText());
|
98
|
} else if (eventSource == text_emailAdress) {
|
99
|
getEntity().setEmailAddress(text_emailAdress.getText());
|
100
|
} else if (eventSource == selection_person) {
|
101
|
getEntity().setPerson(selection_person.getSelection());
|
102
|
} else if (eventSource == checkbox_accountNonExpired) {
|
103
|
getEntity().setAccountNonExpired(
|
104
|
checkbox_accountNonExpired.getSelection());
|
105
|
} else if (eventSource == checkbox_accountNonLocked) {
|
106
|
getEntity().setAccountNonLocked(
|
107
|
checkbox_accountNonLocked.getSelection());
|
108
|
} else if (eventSource == checkbox_enabled) {
|
109
|
getEntity().setEnabled(checkbox_enabled.getSelection());
|
110
|
} else if (eventSource == checkbox_credentialsNonExpired) {
|
111
|
getEntity().setCredentialsNonExpired(
|
112
|
checkbox_credentialsNonExpired.getSelection());
|
113
|
}
|
114
|
}
|
115
|
|
116
|
}
|