4 package eu
.etaxonomy
.taxeditor
.ui
.section
.user
;
6 import eu
.etaxonomy
.cdm
.model
.agent
.Person
;
7 import eu
.etaxonomy
.cdm
.model
.permission
.User
;
8 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
9 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
10 import eu
.etaxonomy
.taxeditor
.ui
.element
.CheckboxElement
;
11 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
12 import eu
.etaxonomy
.taxeditor
.ui
.element
.TextWithLabelElement
;
13 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailElement
;
14 import eu
.etaxonomy
.taxeditor
.ui
.selection
.EntitySelectionElement
;
20 public class UserDetailElement
extends AbstractCdmDetailElement
<User
> {
22 private TextWithLabelElement text_username
;
23 private TextWithLabelElement text_emailAdress
;
24 private EntitySelectionElement
<Person
> selection_person
;
25 private CheckboxElement checkbox_credentialsNonExpired
;
26 private CheckboxElement checkbox_enabled
;
27 private CheckboxElement checkbox_accountNonLocked
;
28 private CheckboxElement checkbox_accountNonExpired
;
30 public UserDetailElement(CdmFormFactory formFactory
,
31 ICdmFormElement formElement
) {
32 super(formFactory
, formElement
);
39 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
40 * (eu.etaxonomy.taxeditor.forms.ICdmFormElement, java.lang.Object, int)
43 protected void createControls(ICdmFormElement formElement
, User entity
,
46 text_username
= formFactory
.createTextWithLabelElement(formElement
,
47 "Username", entity
.getUsername(), style
);
48 // Disabling the text field since the user entity is immutable
49 text_username
.setEnabled(false);
51 if (userIsAuthenticated() || CdmStore
.getLoginManager().isAdmin()) {
52 formFactory
.createEditPasswordElement(
53 formElement
, "Change Password", getConversationHolder(),
57 text_emailAdress
= formFactory
.createTextWithLabelElement(formElement
,
58 "Email Adress", entity
.getEmailAddress(), style
);
60 selection_person
= formFactory
61 .createSelectionElement(Person
.class,
62 //getConversationHolder(),
66 EntitySelectionElement
.EDITABLE
| EntitySelectionElement
.SELECTABLE
,
69 // checkbox_accountNonExpired = formFactory.createCheckbox(formElement,
70 // "Account Non Expired", entity.isAccountNonExpired(), style);
71 // checkbox_accountNonLocked = formFactory.createCheckbox(formElement,
72 // "Account Non Locked", entity.isAccountNonLocked(), style);
73 checkbox_enabled
= formFactory
.createCheckbox(formElement
, "Enabled",
74 entity
.isEnabled(), style
);
75 // checkbox_credentialsNonExpired = formFactory.createCheckbox(
76 // formElement, "Credentials Non Expired",
77 // entity.isCredentialsNonExpired(), style);
84 private boolean userIsAuthenticated() {
85 return getEntity().equals(
86 CdmStore
.getLoginManager().getAuthenticatedUser());
93 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
97 public void handleEvent(Object eventSource
) {
98 if (eventSource
== text_username
) {
99 getEntity().setUsername(text_username
.getText());
100 } else if (eventSource
== text_emailAdress
) {
101 getEntity().setEmailAddress(text_emailAdress
.getText());
102 } else if (eventSource
== selection_person
) {
103 getEntity().setPerson(selection_person
.getSelection());
104 } else if (eventSource
== checkbox_accountNonExpired
) {
105 getEntity().setAccountNonExpired(
106 checkbox_accountNonExpired
.getSelection());
107 } else if (eventSource
== checkbox_accountNonLocked
) {
108 getEntity().setAccountNonLocked(
109 checkbox_accountNonLocked
.getSelection());
110 } else if (eventSource
== checkbox_enabled
) {
111 getEntity().setEnabled(checkbox_enabled
.getSelection());
112 } else if (eventSource
== checkbox_credentialsNonExpired
) {
113 getEntity().setCredentialsNonExpired(
114 checkbox_credentialsNonExpired
.getSelection());