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