1 /*******************************************************************************
2 * Copyright (c) 2012 - 2015 hangum.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser Public License v2.1
5 * which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
9 * hangum - initial API and implementation
10 ******************************************************************************/
11 package com
.hangum
.tadpole
.engine
.security
;
13 import org
.apache
.commons
.lang
.StringUtils
;
14 import org
.apache
.log4j
.Logger
;
15 import org
.eclipse
.jface
.dialogs
.IDialogConstants
;
16 import org
.eclipse
.jface
.dialogs
.MessageDialog
;
17 import org
.eclipse
.swt
.SWT
;
18 import org
.eclipse
.swt
.events
.KeyAdapter
;
19 import org
.eclipse
.swt
.events
.KeyEvent
;
20 import org
.eclipse
.swt
.graphics
.Point
;
21 import org
.eclipse
.swt
.layout
.GridData
;
22 import org
.eclipse
.swt
.layout
.GridLayout
;
23 import org
.eclipse
.swt
.widgets
.Composite
;
24 import org
.eclipse
.swt
.widgets
.Control
;
25 import org
.eclipse
.swt
.widgets
.Label
;
26 import org
.eclipse
.swt
.widgets
.Shell
;
27 import org
.eclipse
.swt
.widgets
.Text
;
29 import com
.hangum
.tadpole
.commons
.libs
.core
.message
.CommonMessages
;
30 import com
.hangum
.tadpole
.engine
.Messages
;
31 import com
.hangum
.tadpole
.engine
.manager
.TadpoleSQLManager
;
32 import com
.hangum
.tadpole
.engine
.query
.dao
.system
.UserDBDAO
;
43 public class DBPasswordDialog
extends PasswordDialog
{
44 private static final Logger logger
= Logger
.getLogger(DBPasswordDialog
.class);
50 public DBPasswordDialog(Shell parentShell
, UserDBDAO userDB
) {
51 super(parentShell
, userDB
);
55 protected void configureShell(Shell newShell
) {
56 super.configureShell(newShell
);
57 newShell
.setText(Messages
.get().DBLockDialog_0
);
61 * Create contents of the dialog.
65 protected Control
createDialogArea(Composite parent
) {
66 Composite container
= (Composite
) super.createDialogArea(parent
);
67 container
.setLayout(new GridLayout(2, false));
69 Label lblDbPassword
= new Label(container
, SWT
.NONE
);
70 lblDbPassword
.setText(CommonMessages
.get().Password
);
72 textPassword
= new Text(container
, SWT
.BORDER
| SWT
.PASSWORD
);
73 textPassword
.addKeyListener(new KeyAdapter() {
75 public void keyReleased(KeyEvent e
) {
76 if(e
.keyCode
== SWT
.Selection
) {
81 textPassword
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 1, 1));
82 textPassword
.setFocus();
90 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
93 protected void okPressed() {
96 userDB
.setPasswd(StringUtils
.trim(textPassword
.getText()));
97 TadpoleSQLManager
.getInstance(userDB
);
98 } catch(Exception e
) {
99 logger
.error("test passwd Connection error ");
101 String msg
= e
.getMessage();
102 if(StringUtils
.contains(msg
, "No more data to read from socket")) {
103 MessageDialog
.openWarning(getShell(), CommonMessages
.get().Warning
, msg
+ CommonMessages
.get().Check_DBAccessSystem
);
105 MessageDialog
.openWarning(getShell(), CommonMessages
.get().Warning
, msg
);
108 textPassword
.setFocus();
117 * Create contents of the button bar.
121 protected void createButtonsForButtonBar(Composite parent
) {
122 createButton(parent
, IDialogConstants
.OK_ID
, CommonMessages
.get().Confirm
, true);
123 createButton(parent
, IDialogConstants
.CANCEL_ID
, CommonMessages
.get().Cancel
, false);
127 * Return the initial size of the dialog.
130 protected Point
getInitialSize() {
131 return new Point(402, 118);