-
Notifications
You must be signed in to change notification settings - Fork 477
/
UserProfileViewImpl.java
145 lines (114 loc) · 4.29 KB
/
UserProfileViewImpl.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
* Copyright 2014-2016 CyberVision, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.kaaproject.kaa.server.admin.client.mvp.view.user;
import org.kaaproject.avro.ui.gwt.client.widget.SizedTextBox;
import org.kaaproject.kaa.server.admin.client.mvp.view.UserProfileView;
import org.kaaproject.kaa.server.admin.client.mvp.view.base.BaseDetailsViewImpl;
import org.kaaproject.kaa.server.admin.client.mvp.view.widget.KaaAdminSizedTextBox;
import org.kaaproject.kaa.server.admin.client.util.Utils;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HasValue;
import com.google.gwt.user.client.ui.Label;
public class UserProfileViewImpl extends BaseDetailsViewImpl implements UserProfileView {
private static final String REQUIRED = Utils.avroUiStyle.requiredField();
private SizedTextBox authority;
private SizedTextBox firstName;
private SizedTextBox lastName;
private SizedTextBox email;
private Button changePasswordButton;
public UserProfileViewImpl() {
super(false);
}
@Override
protected String getCreateTitle() {
return "";
}
@Override
protected String getViewTitle() {
return Utils.constants.user();
}
@Override
protected String getSubTitle() {
return Utils.constants.accountProfile();
}
@Override
protected void initDetailsTable() {
authority = new KaaAdminSizedTextBox(-1, false);
authority.setWidth("100%");
Label authorityLabel = new Label(Utils.constants.accountRole());
detailsTable.setWidget(0, 0, authorityLabel);
detailsTable.setWidget(0, 1, authority);
firstName = new KaaAdminSizedTextBox(DEFAULT_TEXTBOX_SIZE);
firstName.setWidth("100%");
firstName.addInputHandler(this);
Label firstNameLabel = new Label(Utils.constants.firstName());
firstNameLabel.addStyleName(REQUIRED);
detailsTable.setWidget(1, 0, firstNameLabel);
detailsTable.setWidget(1, 1, firstName);
lastName = new KaaAdminSizedTextBox(DEFAULT_TEXTBOX_SIZE);
lastName.setWidth("100%");
lastName.addInputHandler(this);
Label lastNameLabel = new Label(Utils.constants.lastName());
lastNameLabel.addStyleName(REQUIRED);
detailsTable.setWidget(2, 0, lastNameLabel);
detailsTable.setWidget(2, 1, lastName);
email = new KaaAdminSizedTextBox(DEFAULT_TEXTBOX_SIZE);
email.setWidth("100%");
email.addInputHandler(this);
Label emailLabel = new Label(Utils.constants.email());
emailLabel.addStyleName(REQUIRED);
detailsTable.setWidget(3, 0, emailLabel);
detailsTable.setWidget(3, 1, email);
changePasswordButton = new Button(Utils.constants.changePassword());
detailsTable.setWidget(4, 0, changePasswordButton);
firstName.setFocus(true);
}
@Override
protected void resetImpl() {
authority.setValue("");
firstName.setValue("");
lastName.setValue("");
email.setValue("");
}
@Override
protected boolean validate() {
boolean result = firstName.getValue().length()>0;
result &= lastName.getValue().length()>0;
result &= Utils.validateEmail(email.getValue());
return result;
}
@Override
public HasValue<String> getAuthority() {
return authority;
}
@Override
public HasValue<String> getEmail() {
return email;
}
@Override
public HasValue<String> getFirstName() {
return firstName;
}
@Override
public HasValue<String> getLastName() {
return lastName;
}
@Override
public HasClickHandlers getChangePasswordButton() {
return changePasswordButton;
}
}