Source Code Cross Referenced for UserEditBase.java in  » ESB » cbesb-1.2 » com » bostechcorp » cbesb » console » client » useredit » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ESB » cbesb 1.2 » com.bostechcorp.cbesb.console.client.useredit 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * ChainBuilder ESB
003:         *          Visual Enterprise Integration
004:         * 
005:         * Copyright (C) 2006 Bostech Corporation
006:         * 
007:         * This program is free software; you can redistribute it and/or modify it 
008:         * under the terms of the GNU General Public License as published by the 
009:         * Free Software Foundation; either version 2 of the License, or (at your option) 
010:         * any later version.
011:         *
012:         * This program is distributed in the hope that it will be useful, 
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
014:         * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
015:         * for more details.
016:         * 
017:         * You should have received a copy of the GNU General Public License along with 
018:         * this program; if not, write to the Free Software Foundation, Inc., 
019:         * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020:         *
021:         * UserEditEditablePanel
022:         * LPS
023:         * Oct 26, 2007
024:         */package com.bostechcorp.cbesb.console.client.useredit;
025:
026:        import java.util.Date;
027:        import java.util.Iterator;
028:        import java.util.List;
029:
030:        import com.bostechcorp.cbesb.console.client.Admin;
031:        import com.bostechcorp.cbesb.console.client.ConsoleCallback;
032:        import com.bostechcorp.cbesb.console.client.ICallbackHandler;
033:        import com.bostechcorp.cbesb.console.client.Validators;
034:        import com.bostechcorp.cbesb.console.client.dialogs.MessageViewDialog;
035:        import com.bostechcorp.cbesb.console.client.useredit.ObedientStackPanel.SelectionListener;
036:        import com.bostechcorp.cbesb.console.common.ConsoleUserInfo;
037:        import com.bostechcorp.cbesb.console.common.Constants;
038:        import com.bostechcorp.cbesb.console.common.SecurityLoginInfo;
039:        import com.bostechcorp.cbesb.console.i18n.ConsoleMessages;
040:        import com.bostechcorp.cbesb.console.rpc.SecurityOperations;
041:        import com.bostechcorp.cbesb.console.rpc.SecurityOperationsAsync;
042:        import com.google.gwt.core.client.GWT;
043:        import com.google.gwt.user.client.Window;
044:        import com.google.gwt.user.client.rpc.ServiceDefTarget;
045:        import com.google.gwt.user.client.ui.ClickListener;
046:        import com.google.gwt.user.client.ui.FlexTable;
047:        import com.google.gwt.user.client.ui.HasHorizontalAlignment;
048:        import com.google.gwt.user.client.ui.HorizontalPanel;
049:        import com.google.gwt.user.client.ui.HorizontalSplitPanel;
050:        import com.google.gwt.user.client.ui.Label;
051:        import com.google.gwt.user.client.ui.ListBox;
052:        import com.google.gwt.user.client.ui.PasswordTextBox;
053:        import com.google.gwt.user.client.ui.PushButton;
054:        import com.google.gwt.user.client.ui.TextArea;
055:        import com.google.gwt.user.client.ui.TextBox;
056:        import com.google.gwt.user.client.ui.VerticalPanel;
057:        import com.google.gwt.user.client.ui.Widget;
058:
059:        /**
060:         * @author LPS
061:         * 
062:         */
063:        public abstract class UserEditBase extends Admin {
064:
065:            protected SecurityLoginInfo logedInUser;
066:
067:            private HorizontalSplitPanel container = new HorizontalSplitPanel();
068:            private ObedientStackPanel userList = new ObedientStackPanel();
069:
070:            private VerticalPanel userDataAndActions = new VerticalPanel();
071:
072:            private TextBox userLoginTextBox = new TextBox();
073:
074:            //	private TextBox userNameTextBox = new TextBox();
075:
076:            private ListBox userTypesListBox = new ListBox();
077:
078:            private TextArea userNotesTextArea = new TextArea();
079:
080:            //	private TextBox userIdTextBox = new TextBox();
081:
082:            private TextBox userEmailTextBox = new TextBox();
083:
084:            private PasswordTextBox userPasswordTextBox = new PasswordTextBox();
085:
086:            private PasswordTextBox userConfirmTextBox = new PasswordTextBox();
087:
088:            private PushButton okSavePushButton = new PushButton();
089:
090:            private PushButton cancelHideFieldsPushButton = new PushButton();
091:
092:            private HorizontalPanel okCancelButtonsPanel = new HorizontalPanel();
093:
094:            private HorizontalPanel addDeleteButtonsPanel = new HorizontalPanel();
095:
096:            //private TextArea errorTextArea = new TextArea();
097:
098:            //private DisclosurePanel errorContainer = new DisclosurePanel();
099:
100:            //
101:            private List allUsers;
102:
103:            private ConsoleUserInfo currentUser;
104:
105:            private ConsoleUserInfo backupCurrentUser;
106:
107:            private ConsoleUserInfo tempSaveOperationBuffer;
108:
109:            private ConsoleUserInfo tempDeleteOperationBuffer;
110:
111:            /**
112:             * specify what operation to execute on server, insert or update
113:             */
114:            private boolean saveAsUpdate = true;
115:
116:            private boolean saveCancelButtonsEnabled = false;
117:
118:            private boolean deleteButtonEnable = false;
119:
120:            private boolean addUserEnabled = true;
121:
122:            //
123:
124:            private ListBox administrators = new ListBox();
125:
126:            private ListBox operators = new ListBox();
127:
128:            private ListBox users = new ListBox();
129:
130:            private TextBox userLastUpdateTextBox = new TextBox();
131:
132:            private TextBox userTimeoutTextBox = new TextBox();
133:
134:            private Label userConfirmLabel = new Label(((ConsoleMessages) GWT
135:                    .create(ConsoleMessages.class)).ConfirmPassword(), true);
136:
137:            private Label userPasswordLabel = new Label(((ConsoleMessages) GWT
138:                    .create(ConsoleMessages.class)).InputPassword(), true);
139:
140:            private Label userLastUpdateLabel = new Label(
141:                    ((ConsoleMessages) GWT.create(ConsoleMessages.class))
142:                            .LastUpdate(), true);
143:
144:            private Label userNotesLabel = new Label(((ConsoleMessages) GWT
145:                    .create(ConsoleMessages.class)).Notes(), true);
146:
147:            private Label userEmailLabel = new Label(((ConsoleMessages) GWT
148:                    .create(ConsoleMessages.class)).Email(), true);
149:
150:            private Label userTimeoutLabel = new Label(((ConsoleMessages) GWT
151:                    .create(ConsoleMessages.class)).Timeout(), true);
152:
153:            private Label userTimeoutUnitLabel = new Label(
154:                    ((ConsoleMessages) GWT.create(ConsoleMessages.class))
155:                            .TimeoutUnit(), true);
156:            private HorizontalPanel timeoutPanel = new HorizontalPanel();
157:
158:            private Label userTypeLabel = new Label(((ConsoleMessages) GWT
159:                    .create(ConsoleMessages.class)).Type(), true);
160:
161:            //	private Label userNameLabel = new Label(((ConsoleMessages) GWT
162:            //			.create(ConsoleMessages.class)).Name(), true);
163:
164:            private Label userLoginLabel = new Label(((ConsoleMessages) GWT
165:                    .create(ConsoleMessages.class)).Name(), true);
166:
167:            //	private Label userIdLabel = new Label(((ConsoleMessages) GWT
168:            //			.create(ConsoleMessages.class)).UserId(), true);
169:
170:            private VerticalPanel userListContainer = new VerticalPanel();
171:
172:            private PushButton addUserPushButton = new PushButton(
173:                    ((ConsoleMessages) GWT.create(ConsoleMessages.class))
174:                            .AddUser());
175:
176:            private PushButton deleteUserPushButton = new PushButton(
177:                    ((ConsoleMessages) GWT.create(ConsoleMessages.class))
178:                            .DeleteUser());
179:
180:            private VerticalPanel userInformationContainer = new VerticalPanel();
181:
182:            //	private Label errorContainerHeader = new Label(((ConsoleMessages) GWT
183:            //			.create(ConsoleMessages.class)).Errorview());
184:
185:            ListBoxListener listBoxClickListener = new ListBoxListener();
186:
187:            private boolean readOnly;
188:
189:            private boolean isAdd;
190:
191:            /**
192:             * @wbp.parser.constructor
193:             */
194:            public void init(boolean mode, SecurityLoginInfo user) {
195:                this .logedInUser = user;
196:                this .readOnly = mode;
197:                createAdministrator();
198:                setStyles();
199:                container.setWidth("100%");
200:                container.setHeight("100%");
201:                initWidget(container);
202:            }
203:
204:            private void setStyles() {
205:                okSavePushButton.setStyleName("gwt-PushButton");
206:                cancelHideFieldsPushButton.setStyleName("gwt-PushButton");
207:
208:                // labels
209:                //		userIdLabel.setStyleName("gwt-Label");
210:                userConfirmLabel.setStyleName("gwt-Label");
211:                userTimeoutLabel.setStyleName("gwt-Label");
212:                userEmailLabel.setStyleName("gwt-Label");
213:                userLastUpdateLabel.setStyleName("gwt-Label");
214:                userLoginLabel.setStyleName("gwt-Label");
215:                //		userNameLabel.setStyleName("gwt-Label");
216:                userNotesLabel.setStyleName("gwt-Label");
217:                userPasswordLabel.setStyleName("gwt-Label");
218:                userTypeLabel.setStyleName("gwt-Label");
219:                //
220:                //		userIdTextBox.setStyleName("gwt-TextField");
221:                userConfirmTextBox.setStyleName("gwt-TextField");
222:                userTimeoutTextBox.setStyleName("gwt-TextField");
223:                userEmailTextBox.setStyleName("gwt-TextField");
224:                userLastUpdateTextBox.setStyleName("gwt-TextField");
225:                userLoginTextBox.setStyleName("gwt-TextField");
226:                //		userNameTextBox.setStyleName("gwt-TextField");
227:                userNotesTextArea.setStyleName("gwt-TextField");
228:                userPasswordTextBox.setStyleName("gwt-TextField");
229:                userTypesListBox.setStyleName("gwt-TextField");
230:                //
231:                //	errorContainerHeader.setStyleName("body-userEdit-gwt-CaptionLabel");
232:                //
233:                userList.setStyleName("gwt-StackPanel");
234:            }
235:
236:            /**
237:             * creates the panel in user mode
238:             */
239:
240:            /**
241:             * creates the panel in administrator mode
242:             */
243:            private void createAdministrator() {
244:                // adding buttons
245:                userListContainer.add(addDeleteButtonsPanel);
246:                userListContainer.setWidth("100%");
247:                addDeleteButtonsPanel.setWidth("100%");
248:                addDeleteButtonsPanel.add(addUserPushButton);
249:                addDeleteButtonsPanel.add(deleteUserPushButton);
250:                addDeleteButtonsPanel.setCellHorizontalAlignment(
251:                        addUserPushButton, HasHorizontalAlignment.ALIGN_LEFT);
252:                addDeleteButtonsPanel
253:                        .setCellHorizontalAlignment(deleteUserPushButton,
254:                                HasHorizontalAlignment.ALIGN_LEFT);
255:                deleteUserPushButton.setEnabled(false);
256:
257:                addUserPushButton.addClickListener(new AddUserListener());
258:                deleteUserPushButton.addClickListener(new DeleteUserListener(
259:                        this ));
260:                userLoginTextBox.setEnabled(false);
261:
262:                // creating layout
263:                if (!readOnly) {
264:                    container.setSplitPosition("25%");
265:                    container.setLeftWidget(userListContainer);
266:                } else {
267:                    container.setSplitPosition("0px");
268:                    userTypesListBox.setEnabled(false);
269:                }
270:                //			container.getRightWidget().setWidth("100%");
271:                container.setRightWidget(userDataAndActions);
272:
273:                userListContainer.add(userList);
274:                userList.setWidth("100%");
275:                userDataAndActions.setWidth("100%");
276:                userInformationContainer.setWidth("100%");
277:                userDataAndActions.add(userInformationContainer);
278:                // adding user fields
279:                createUserEditWidget();
280:                // adding user list
281:                createUserList();
282:            }
283:
284:            private void createUserList() {
285:                administrators.setVisibleItemCount(12);
286:                operators.setVisibleItemCount(12);
287:                users.setVisibleItemCount(12);
288:
289:                administrators.addClickListener(listBoxClickListener);
290:                operators.addClickListener(listBoxClickListener);
291:                users.addClickListener(listBoxClickListener);
292:
293:                administrators.setWidth("100%");
294:                operators.setWidth("100%");
295:                users.setWidth("100%");
296:                userList.setSelectionListener(new UserTypeSelectionListener());
297:                userList.add(administrators, ((ConsoleMessages) GWT
298:                        .create(ConsoleMessages.class)).Administrators());
299:                userList.add(operators, ((ConsoleMessages) GWT
300:                        .create(ConsoleMessages.class)).Operators());
301:                userList.add(users, ((ConsoleMessages) GWT
302:                        .create(ConsoleMessages.class)).Users());
303:                getUserList();
304:            }
305:
306:            private void createUserEditWidget() {
307:                // Buttons
308:                okSavePushButton.setText(((ConsoleMessages) GWT
309:                        .create(ConsoleMessages.class)).Save());
310:                cancelHideFieldsPushButton.setText(((ConsoleMessages) GWT
311:                        .create(ConsoleMessages.class)).Cancel());
312:                okCancelButtonsPanel.add(okSavePushButton);
313:                okCancelButtonsPanel.add(cancelHideFieldsPushButton);
314:                okCancelButtonsPanel.setCellHorizontalAlignment(
315:                        okSavePushButton, HasHorizontalAlignment.ALIGN_RIGHT);
316:                okCancelButtonsPanel.setCellHorizontalAlignment(
317:                        cancelHideFieldsPushButton,
318:                        HasHorizontalAlignment.ALIGN_RIGHT);
319:                okSavePushButton
320:                        .addClickListener(new OkSaveButtonClickListener(this ));
321:                cancelHideFieldsPushButton
322:                        .addClickListener(new CancelHideFieldsButtonClickListener());
323:                //
324:                userTypesListBox.addItem(SecurityLoginInfo.administrator);
325:                userTypesListBox.addItem(SecurityLoginInfo.operator);
326:                userTypesListBox.addItem(SecurityLoginInfo.user);
327:                //		userTypesListBox.setEnabled(false);
328:
329:                userNotesTextArea.setVisibleLines(3);
330:                userNotesTextArea.setWidth("100%");
331:                // userNotesTextArea.setCharacterWidth("40");
332:                //		userIdTextBox.setEnabled(false);
333:                userLastUpdateTextBox.setEnabled(false);
334:                //		userLoginTextBox.setEnabled(false);
335:                timeoutPanel.add(userTimeoutTextBox);
336:                timeoutPanel.add(userTimeoutUnitLabel);
337:                //
338:                FlexTable grid = new FlexTable();// Grid(9, 2);
339:                //		grid.setWidget(0, 0, userIdLabel);
340:                grid.getCellFormatter().setWidth(0, 0, "20%");
341:                grid.setWidget(0, 0, userLoginLabel);
342:                //		grid.setWidget(1, 0, userNameLabel);
343:                grid.setWidget(1, 0, userEmailLabel);
344:                grid.setWidget(2, 0, userTypeLabel);
345:                grid.setWidget(3, 0, userTimeoutLabel);
346:                grid.setWidget(4, 0, userLastUpdateLabel);
347:                grid.setWidget(5, 0, userNotesLabel);
348:                grid.setWidget(6, 0, userPasswordLabel);
349:                grid.setWidget(7, 0, userConfirmLabel);
350:                //		grid.setWidget(0, 1, userIdTextBox);
351:                grid.setWidget(0, 1, userLoginTextBox);
352:                //		grid.setWidget(2, 1, userNameTextBox);
353:                grid.setWidget(1, 1, userEmailTextBox);
354:                grid.setWidget(2, 1, userTypesListBox);
355:                grid.setWidget(3, 1, timeoutPanel);
356:                grid.setWidget(4, 1, userLastUpdateTextBox);
357:                grid.setWidget(5, 1, userNotesTextArea);
358:                grid.setWidget(6, 1, userPasswordTextBox);
359:                grid.setWidget(7, 1, userConfirmTextBox);
360:
361:                // listening for any changes
362:                //FieldsModificationListener modif = new FieldsModificationListener();
363:                //		userIdTextBox.addChangeListener(modif);
364:                //		userLastUpdateTextBox.addChangeListener(modif);
365:                //		userEmailTextBox.addChangeListener(modif);
366:                //		userLoginTextBox.addChangeListener(modif);
367:                //		userNotesTextArea.addChangeListener(modif);
368:                //		userPasswordTextBox.addChangeListener(modif);
369:                //		userComfirmTextBox.addChangeListener(modif);
370:                //		userNameTextBox.addChangeListener(modif);
371:                //		userTypesListBox.addChangeListener(modif);
372:                //
373:                //		userIdTextBox.addKeyboardListener(modif);
374:                //		userLastUpdateTextBox.addKeyboardListener(modif);
375:                //		userEmailTextBox.addKeyboardListener(modif);
376:                //		userLoginTextBox.addKeyboardListener(modif);
377:                //		userNotesTextArea.addKeyboardListener(modif);
378:                //		userPasswordTextBox.addKeyboardListener(modif);
379:                //		userComfirmTextBox.addKeyboardListener(modif);
380:                //		userNameTextBox.addKeyboardListener(modif);
381:                //		userTypesListBox.addKeyboardListener(modif);
382:                // some more layouting
383:                //		userIdTextBox.setWidth("100%");
384:                userTypesListBox.setWidth("100%");
385:                userNotesTextArea.setWidth("100%");
386:                userPasswordTextBox.setWidth("100%");
387:                //		userNameTextBox.setWidth("100%");
388:                userLastUpdateTextBox.setWidth("100%");
389:                userLoginTextBox.setWidth("100%");
390:                userConfirmTextBox.setWidth("100%");
391:                userEmailTextBox.setWidth("100%");
392:
393:                // Error Area
394:                //		errorContainer.setHeader(errorContainerHeader);
395:                //		errorContainer.setWidth("100%");
396:                //		errorTextArea.setWidth("100%");
397:                //		errorTextArea.setVisibleLines(5);
398:                //		errorContainer.add(errorTextArea);
399:                //		errorContainer.setOpen(false);
400:                //
401:                userInformationContainer.add(okCancelButtonsPanel);
402:                userInformationContainer.add(grid);
403:                userInformationContainer.setCellWidth(grid, "100%");
404:                grid.setWidth("100%");
405:                //userInformationContainer.add(errorContainer);
406:                userInformationContainer.setCellHorizontalAlignment(
407:                        okCancelButtonsPanel,
408:                        HasHorizontalAlignment.ALIGN_RIGHT);
409:            }
410:
411:            public void getUserList() {
412:                SecurityOperationsAsync operations;
413:                operations = (SecurityOperationsAsync) GWT
414:                        .create(SecurityOperations.class);
415:                ServiceDefTarget consoleUserOperation = (ServiceDefTarget) operations;
416:                String relativeUrl = GWT.getModuleBaseURL()
417:                        + Constants.JMX_CONSOLE_USER_SERVLET;
418:                consoleUserOperation.setServiceEntryPoint(relativeUrl);
419:                operations.getUserList(new UserListAsyncCallnack(this ));
420:            }
421:
422:            /**
423:             * @param logedInUser
424:             *            the logedInUser to set
425:             */
426:            public void setLogedInUser(SecurityLoginInfo logedInUser) {
427:                this .logedInUser = logedInUser;
428:            }
429:
430:            private ConsoleUserInfo findConsoleUserInfo(String login) {
431:                ConsoleUserInfo user = null;
432:                for (Iterator iter = allUsers.iterator(); iter.hasNext();) {
433:                    ConsoleUserInfo ement = (ConsoleUserInfo) iter.next();
434:                    if (ement.getLogin().equals(login))
435:                        return ement;
436:                }
437:                return user;
438:            }
439:
440:            /**
441:             * @param currentUser
442:             *            the currentUser to disply
443:             */
444:            public void setCurrentUser(ConsoleUserInfo currentUser) {
445:                if (this .currentUser != null) {
446:                    this .backupCurrentUser = this .currentUser.clone();
447:                } else {
448:                    this .backupCurrentUser = currentUser.clone();
449:                }
450:                this .currentUser = currentUser;
451:
452:                //setSaveCancelButtonsEnabled(false);
453:                displayCurrentUser();
454:            }
455:
456:            private void controlToModel() {
457:                boolean valid = isUserInfoValid();
458:                if (valid) {
459:                    //			Long l = new Long(userIdTextBox.getText());
460:                    Long timeout = new Long(userTimeoutTextBox.getText());
461:                    //			currentUser.setUserId(l.longValue());
462:                    currentUser.setTimeout(timeout.longValue());
463:                    currentUser.setLogin(userLoginTextBox.getText());
464:                    //			currentUser.setName(userNameTextBox.getText());
465:                    currentUser.setEmail(userEmailTextBox.getText());
466:                    currentUser.setNotes(userNotesTextArea.getText());
467:                    currentUser.setPassword(userPasswordTextBox.getText());
468:                    currentUser.setType(userTypesListBox
469:                            .getItemText(userTypesListBox.getSelectedIndex()));
470:                }
471:                //setSaveCancelButtonsEnabled(valid);
472:            }
473:
474:            private void displayCurrentUser() {
475:                //		userIdTextBox.setText("" + currentUser.getUserId());
476:                userLoginTextBox.setText("" + currentUser.getLogin());
477:                //		userNameTextBox.setText("" + currentUser.getName());
478:                userEmailTextBox.setText("" + currentUser.getEmail());
479:                userNotesTextArea.setText("" + currentUser.getNotes());
480:                userPasswordTextBox.setText("" + currentUser.getPassword());
481:                userConfirmTextBox.setText("" + currentUser.getPassword());
482:                userLastUpdateTextBox
483:                        .setText("" + currentUser.getLastUpdated());
484:                userTimeoutTextBox.setText("" + currentUser.getTimeout());
485:
486:                if (currentUser.getType().equals(
487:                        SecurityLoginInfo.administrator)) {
488:                    userTypesListBox.setSelectedIndex(0);
489:                } else if (currentUser.getType().equals(
490:                        SecurityLoginInfo.operator)) {
491:                    userTypesListBox.setSelectedIndex(1);
492:                } else if (currentUser.getType().equals(SecurityLoginInfo.user)) {
493:                    userTypesListBox.setSelectedIndex(2);
494:                }
495:            }
496:
497:            /**
498:             * sets the message into ErrorTextArea, in the bottom of the userInformation
499:             * panel, and opens the disclosure panel.
500:             * 
501:             * @param message
502:             * @param append,
503:             *            if tru the message will be appended to the current content
504:             * @deprecated
505:             */
506:            public void setErrorMessage(String message, boolean append) {
507:                //		errorContainer.setOpen(true);
508:                //		String s = "";
509:                //		if (append) {
510:                //			s = errorTextArea.getText();
511:                //		}
512:                //		s += "\n";
513:                //		errorTextArea.setText(s + message);
514:                //		errorTextArea.setCursorPos(errorTextArea.getText().length());
515:            }
516:
517:            /**
518:             * just popup the error message
519:             * @param message
520:             */
521:            public void setErrorMessage(String message) {
522:                MessageViewDialog.showInfo(message);
523:            }
524:
525:            /**
526:             * @param saveCancelButtonsEnabled
527:             *            the saveCancelButtonsEnabled to set
528:             */
529:            //	public void setSaveCancelButtonsEnabled(boolean saveCancelButtonsEnabled) {
530:            //		this.saveCancelButtonsEnabled = saveCancelButtonsEnabled;
531:            //		okSavePushButton.setEnabled(saveCancelButtonsEnabled);
532:            //		cancelHideFieldsPushButton.setEnabled(saveCancelButtonsEnabled);
533:            //	}
534:            /**
535:             * @param operable
536:             *            the deleteButtonEnable to set
537:             */
538:            public void setOperable(boolean operable) {
539:                if (currentUser.getLogin().equals(logedInUser.getLogin())
540:                        || currentUser.getLogin().equals("cbesb")) {
541:                    this .deleteButtonEnable = false;
542:                    userTypesListBox.setEnabled(false);
543:                } else {
544:                    this .deleteButtonEnable = operable;
545:                    userTypesListBox.setEnabled(operable);
546:                }
547:                deleteUserPushButton.setEnabled(this .deleteButtonEnable);
548:            }
549:
550:            /**
551:             * @param addUserEnabled
552:             *            the addUserEnabled to set
553:             */
554:            public void setAddUserEnabled(boolean addUserEnabled) {
555:                this .addUserEnabled = addUserEnabled;
556:                addUserPushButton.setEnabled(addUserEnabled);
557:            }
558:
559:            /**
560:             * what king of operation should be executed onSaveButton click? insert or
561:             * update?
562:             * 
563:             * @param saveAsUpdate
564:             *            the saveAsUpdate to set
565:             */
566:            public void setSaveAsUpdate(boolean saveAsUpdate) {
567:                this .saveAsUpdate = saveAsUpdate;
568:                // addUserPushButton.setEnabled(!saveAsUpdate);
569:            }
570:
571:            // some operational Listeners
572:
573:            class OkSaveButtonClickListener extends ConsoleCallback implements 
574:                    ClickListener {
575:
576:                public OkSaveButtonClickListener(ICallbackHandler handler) {
577:                    super (handler);
578:                    // TODO Auto-generated constructor stub
579:                }
580:
581:                public void onClick(Widget sender) {
582:                    if (isUserInfoValid())
583:                    //			if (!UserEditBase.this.backupCurrentUser
584:                    //					.equals(UserEditBase.this.currentUser))
585:                    {
586:                        //
587:                        controlToModel();
588:                        // get the operations servlet
589:                        SecurityOperationsAsync operations;
590:                        operations = (SecurityOperationsAsync) GWT
591:                                .create(SecurityOperations.class);
592:                        ServiceDefTarget consoleUserOperation = (ServiceDefTarget) operations;
593:                        String relativeUrl = GWT.getModuleBaseURL()
594:                                + Constants.JMX_CONSOLE_USER_SERVLET;
595:                        consoleUserOperation.setServiceEntryPoint(relativeUrl);
596:                        // execute one of the operations
597:                        if (saveAsUpdate) {
598:                            operations.update(currentUser,
599:                                    OkSaveButtonClickListener.this );
600:                        } else {
601:                            isAdd = userLoginTextBox.isEnabled();
602:                            if (isAdd) {
603:                                //						if (!UserEditBase.this.backupCurrentUser
604:                                //								.equals(UserEditBase.this.currentUser))
605:                                operations.add(currentUser,
606:                                        OkSaveButtonClickListener.this );
607:                                //						else
608:                                //							MessageViewDialog.showInfo("User already exists.");
609:                            } else
610:                                operations.update(currentUser,
611:                                        OkSaveButtonClickListener.this );
612:                            tempSaveOperationBuffer = currentUser;
613:                        }
614:                        //setSaveCancelButtonsEnabled(false);
615:                        setSaveAsUpdate(true);
616:                        userLoginTextBox.setEnabled(false);
617:                        addUserPushButton.setEnabled(true);
618:                        deleteUserPushButton.setEnabled(true);
619:                        enableLeftSide(true);
620:                        MessageViewDialog.showInfo(((ConsoleMessages) GWT
621:                                .create(ConsoleMessages.class))
622:                                .saveSuccessfully());
623:                    }
624:                }
625:
626:                public void handleSuccess(Object result) {
627:                    if (result instanceof  Boolean) {
628:                        if (((Boolean) result).booleanValue()) {
629:                            setSaveAsUpdate(true);
630:                            UserEditBase.this .backupCurrentUser = UserEditBase.this .currentUser;
631:
632:                            if (tempSaveOperationBuffer != null) {
633:                                //
634:                                // also adding user to the current list
635:                                if (currentUser.getType().equals(
636:                                        SecurityLoginInfo.administrator)) {
637:                                    administrators.addItem(currentUser
638:                                            .getLogin());
639:                                } else if (currentUser.getType().equals(
640:                                        SecurityLoginInfo.operator)) {
641:                                    operators.addItem(currentUser.getLogin());
642:                                } else {
643:                                    users.addItem(currentUser.getLogin());
644:                                }
645:                                // also add user to container
646:                                allUsers.add(tempSaveOperationBuffer);
647:                            } else {
648:                                checkCurrentUserForTypeChanges();
649:                            }
650:                            tempSaveOperationBuffer = null;
651:                        } else {
652:                            MessageViewDialog.showInfo(((ConsoleMessages) GWT
653:                                    .create(ConsoleMessages.class))
654:                                    .RCPFalseError());
655:                        }
656:                    } else {
657:                        MessageViewDialog.showInfo(((ConsoleMessages) GWT
658:                                .create(ConsoleMessages.class))
659:                                .RCPInvalidError());
660:
661:                    }
662:
663:                }
664:
665:            }
666:
667:            class CancelHideFieldsButtonClickListener implements  ClickListener {
668:
669:                public void onClick(Widget sender) {
670:                    setCurrentUser(UserEditBase.this .backupCurrentUser);
671:                    //setSaveCancelButtonsEnabled(false);
672:                    addUserPushButton.setEnabled(true);
673:                    deleteUserPushButton.setEnabled(true);
674:                    enableLeftSide(true);
675:                }
676:            }
677:
678:            class UserListAsyncCallnack extends ConsoleCallback {
679:                public UserListAsyncCallnack(ICallbackHandler handler) {
680:                    super (handler);
681:                }
682:
683:                public void handleSuccess(Object result) {
684:                    if (result instanceof  List) {
685:                        allUsers = (List) result;
686:                        administrators.clear();
687:                        operators.clear();
688:                        users.clear();
689:                        for (Iterator i = allUsers.iterator(); i.hasNext();) {
690:                            Object userObject = i.next();
691:                            if (userObject instanceof  ConsoleUserInfo) {
692:                                if (((ConsoleUserInfo) userObject)
693:                                        .getType()
694:                                        .equals(SecurityLoginInfo.administrator)) {
695:                                    administrators
696:                                            .addItem(((ConsoleUserInfo) userObject)
697:                                                    .getLogin());
698:                                } else if (((ConsoleUserInfo) userObject)
699:                                        .getType().equals(
700:                                                SecurityLoginInfo.operator)) {
701:                                    operators
702:                                            .addItem(((ConsoleUserInfo) userObject)
703:                                                    .getLogin());
704:                                } else if (((ConsoleUserInfo) userObject)
705:                                        .getType().equals(
706:                                                SecurityLoginInfo.user)) {
707:                                    users
708:                                            .addItem(((ConsoleUserInfo) userObject)
709:                                                    .getLogin());
710:                                } else {
711:                                    MessageViewDialog
712:                                            .showInfo(((ConsoleMessages) GWT
713:                                                    .create(ConsoleMessages.class))
714:                                                    .unknownUserType()
715:                                                    + ":"
716:                                                    + ((ConsoleUserInfo) userObject)
717:                                                            .getType());
718:                                }
719:
720:                            } else {
721:                                MessageViewDialog
722:                                        .showInfo(((ConsoleMessages) GWT
723:                                                .create(ConsoleMessages.class))
724:                                                .invalidConsoleUserInfo()
725:                                                + userObject.toString());
726:                            }
727:                        }
728:                        // Also displaying current user's informations
729:                        ConsoleUserInfo founduser = findConsoleUserInfo(UserEditBase.this 
730:                                .getLogedInUser().getLogin());
731:                        if (founduser != null) {
732:                            setCurrentUser(founduser);
733:                        } else {
734:                            MessageViewDialog.showInfo(((ConsoleMessages) GWT
735:                                    .create(ConsoleMessages.class))
736:                                    .noUserError(UserEditBase.this 
737:                                            .getLogedInUser().getLogin()));
738:                        }
739:                    } else {
740:                        MessageViewDialog.showInfo(((ConsoleMessages) GWT
741:                                .create(ConsoleMessages.class))
742:                                .invalidUserList()
743:                                + result.toString());
744:                    }
745:
746:                }
747:            }
748:
749:            class ListBoxListener implements  ClickListener {
750:                public void onClick(Widget sender) {
751:                    if (sender instanceof  ListBox) {
752:                        int index = ((ListBox) sender).getSelectedIndex();
753:                        if (index != -1) {
754:                            setDisplayMode();
755:                            String login = ((ListBox) sender)
756:                                    .getItemText(index);
757:                            setCurrentUser(findConsoleUserInfo(login));
758:                            ConsoleUserInfo founduser = findConsoleUserInfo(login);
759:                            if (founduser != null) {
760:                                setCurrentUser(founduser);
761:                            } else {
762:                                MessageViewDialog
763:                                        .showInfo(((ConsoleMessages) GWT
764:                                                .create(ConsoleMessages.class))
765:                                                .noUserError(login));
766:                            }
767:                            setOperable(true);
768:                            userLoginTextBox.setEnabled(false);
769:                        }
770:                    }
771:                }
772:
773:            }
774:
775:            class AddUserListener implements  ClickListener {
776:                public void onClick(Widget sender) {
777:                    setAddUserMode();
778:                    setSaveAsUpdate(false);
779:                    ConsoleUserInfo newUser = new ConsoleUserInfo();
780:                    newUser.setUserId(0);
781:                    newUser
782:                            .setLastUpdated(new Date(System.currentTimeMillis()));
783:                    newUser.setLogin("");
784:                    newUser.setName("");
785:                    newUser.setNotes("");
786:                    newUser.setPassword("");
787:                    newUser.setType(SecurityLoginInfo.user);
788:                    newUser.setEmail("");
789:                    setCurrentUser(newUser);
790:
791:                }
792:            }
793:
794:            class DeleteUserListener extends ConsoleCallback implements 
795:                    ClickListener {
796:                public DeleteUserListener(ICallbackHandler handler) {
797:                    super (handler);
798:
799:                }
800:
801:                public void onClick(Widget sender) {
802:                    if (Window.confirm(((ConsoleMessages) GWT
803:                            .create(ConsoleMessages.class)).DeleteConfirm())) {
804:                        SecurityOperationsAsync operations;
805:                        operations = (SecurityOperationsAsync) GWT
806:                                .create(SecurityOperations.class);
807:                        ServiceDefTarget consoleUserOperation = (ServiceDefTarget) operations;
808:                        String relativeUrl = GWT.getModuleBaseURL()
809:                                + Constants.JMX_CONSOLE_USER_SERVLET;
810:                        consoleUserOperation.setServiceEntryPoint(relativeUrl);
811:                        tempDeleteOperationBuffer = currentUser;
812:                        operations.delete(currentUser, DeleteUserListener.this );
813:                    }
814:                }
815:
816:                public void handleSuccess(Object result) {
817:                    if (result instanceof  Boolean) {
818:                        if (((Boolean) result).booleanValue()) {
819:                            setSaveAsUpdate(true);
820:                            setCurrentUser(findConsoleUserInfo(logedInUser
821:                                    .getLogin()));
822:                            setOperable(true);
823:
824:                            if (tempDeleteOperationBuffer != null) {
825:                                allUsers.remove(tempDeleteOperationBuffer);
826:                                getUserList();
827:                            }
828:
829:                        } else {
830:                            MessageViewDialog.showInfo(((ConsoleMessages) GWT
831:                                    .create(ConsoleMessages.class))
832:                                    .RCPFalseError());
833:                        }
834:
835:                    }
836:
837:                }
838:            }
839:
840:            /**
841:             * @return
842:             */
843:            private boolean isUserInfoValid() {
844:                if (!Validators.isLogin(userLoginTextBox.getText())) {
845:                    setErrorMessage(((ConsoleMessages) GWT
846:                            .create(ConsoleMessages.class)).invalidLogin());
847:                    return false;
848:                } else if (!Validators.isNumber(userTimeoutTextBox.getText())) {
849:                    setErrorMessage(((ConsoleMessages) GWT
850:                            .create(ConsoleMessages.class))
851:                            .invalidSessionTimeoutConfirm());
852:                    return false;
853:                } else if (!Validators.isEmail(userEmailTextBox.getText())) {
854:                    setErrorMessage(((ConsoleMessages) GWT
855:                            .create(ConsoleMessages.class)).invalidEmail());
856:                    return false;
857:                } else if (!Validators
858:                        .isPassword(userPasswordTextBox.getText())) {
859:                    setErrorMessage(((ConsoleMessages) GWT
860:                            .create(ConsoleMessages.class)).invalidPassword());
861:                    return false;
862:                } else if (!Validators.isPasswordConfirmed(userPasswordTextBox
863:                        .getText(), userConfirmTextBox.getText())) {
864:                    setErrorMessage(((ConsoleMessages) GWT
865:                            .create(ConsoleMessages.class))
866:                            .invalidPasswordConfirm());
867:                    return false;
868:                }
869:                return true;
870:            }
871:
872:            public void enableLeftSide(boolean enable) {
873:                operators.setEnabled(enable);
874:                administrators.setEnabled(enable);
875:                users.setEnabled(enable);
876:                addUserPushButton.setEnabled(enable);
877:            }
878:
879:            /**
880:             * checks the current user to be displayed in the right user list :
881:             * administrators, operators or users
882:             */
883:            public void checkCurrentUserForTypeChanges() {
884:                boolean found = false;
885:                if (!found)
886:                    for (int i = 0; i < administrators.getItemCount(); i++) {
887:                        if (administrators.getItemText(i).equals(
888:                                currentUser.getLogin()))
889:                            if (!currentUser.getType().equals(
890:                                    SecurityLoginInfo.administrator)) {
891:                                administrators.removeItem(i);
892:                                if (currentUser.getType().equals(
893:                                        SecurityLoginInfo.operator)) {
894:                                    operators.addItem(currentUser.getLogin());
895:                                } else {
896:                                    users.addItem(currentUser.getLogin());
897:                                }
898:                            }
899:                    }
900:
901:                if (!found)
902:                    for (int i = 0; i < operators.getItemCount(); i++) {
903:                        if (operators.getItemText(i).equals(
904:                                currentUser.getLogin()))
905:                            if (!currentUser.getType().equals(
906:                                    SecurityLoginInfo.operator)) {
907:                                operators.removeItem(i);
908:                                if (currentUser.getType().equals(
909:                                        SecurityLoginInfo.administrator)) {
910:                                    administrators.addItem(currentUser
911:                                            .getLogin());
912:                                } else {
913:                                    users.addItem(currentUser.getLogin());
914:                                }
915:                            }
916:                    }
917:
918:                if (!found)
919:                    for (int i = 0; i < users.getItemCount(); i++) {
920:                        if (users.getItemText(i).equals(currentUser.getLogin()))
921:                            if (!currentUser.getType().equals(
922:                                    SecurityLoginInfo.user)) {
923:                                users.removeItem(i);
924:                                if (currentUser.getType().equals(
925:                                        SecurityLoginInfo.operator)) {
926:                                    operators.addItem(currentUser.getLogin());
927:                                } else {
928:                                    administrators.addItem(currentUser
929:                                            .getLogin());
930:                                }
931:                            }
932:                    }
933:            }
934:
935:            /* (non-Javadoc)
936:             * @see com.bostechcorp.cbesb.console.client.Admin#onHide()
937:             */
938:            public void onHide() {
939:
940:            }
941:
942:            /* (non-Javadoc)
943:             * @see com.bostechcorp.cbesb.console.client.Admin#refresh()
944:             */
945:            public void refresh() {
946:
947:            }
948:
949:            /* (non-Javadoc)
950:             * @see com.bostechcorp.cbesb.console.client.Admin#onShow()
951:             */
952:            public void onShow() {
953:
954:            }
955:
956:            /**
957:             * @return the logedInUser
958:             */
959:            public SecurityLoginInfo getLogedInUser() {
960:                return logedInUser;
961:            }
962:
963:            class UserTypeSelectionListener implements  SelectionListener {
964:                public void onSelect(int index) {
965:                    Widget w = userList.getWidget(index);
966:                    //assume that all widgets are listBoxes
967:                    if (w instanceof  ListBox) {
968:                        ListBox lbw = (ListBox) w;
969:                        int selectedItem = lbw.getSelectedIndex();
970:                        if (selectedItem == -1)
971:                            selectedItem = 0;
972:                        lbw.setSelectedIndex(selectedItem);
973:                        // some dangerous call
974:                        listBoxClickListener.onClick(lbw);
975:                    }
976:                }
977:
978:            }
979:
980:            public void setDisplayMode() {
981:                //	userLoginTextBox.setEnabled(false);
982:                //	userPasswordLabel.setVisible(false);
983:                //	userPasswordTextBox.setVisible(false);
984:                //	userConfirmLabel.setVisible(false);
985:                //	userConfirmTextBox.setVisible(false);
986:            }
987:
988:            public void setAddUserMode() {
989:                userTypesListBox.setEnabled(true);
990:                userLoginTextBox.setEnabled(true);
991:                userPasswordLabel.setVisible(true);
992:                userPasswordTextBox.setVisible(true);
993:                userConfirmLabel.setVisible(true);
994:                userConfirmTextBox.setVisible(true);
995:                addUserPushButton.setEnabled(false);
996:                deleteUserPushButton.setEnabled(false);
997:            }
998:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.