최신버전에 맞는 타겟플렛폼 설정.
[Tadpole.git] / com.hangum.tadpole.commons.sql / src / com / hangum / tadpole / engine / security / DBPasswordDialog.java
blob204a9725bf6f52f8ab3beef9790f45554b469f08
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
7 *
8 * Contributors:
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;
34 /**
35 * DB Lock Dialog
38 * @author hangum
39 * @version 1.6.1
40 * @since 2015. 3. 24.
43 public class DBPasswordDialog extends PasswordDialog {
44 private static final Logger logger = Logger.getLogger(DBPasswordDialog.class);
46 /**
47 * Create the dialog.
48 * @param parentShell
50 public DBPasswordDialog(Shell parentShell, UserDBDAO userDB) {
51 super(parentShell, userDB);
54 @Override
55 protected void configureShell(Shell newShell) {
56 super.configureShell(newShell);
57 newShell.setText(Messages.get().DBLockDialog_0);
60 /**
61 * Create contents of the dialog.
62 * @param parent
64 @Override
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() {
74 @Override
75 public void keyReleased(KeyEvent e) {
76 if(e.keyCode == SWT.Selection) {
77 okPressed();
80 });
81 textPassword.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
82 textPassword.setFocus();
84 initUI();
86 return container;
89 /* (non-Javadoc)
90 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
92 @Override
93 protected void okPressed() {
94 // 실제 접속 되는지 테스트해봅니다.
95 try {
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);
104 } else {
105 MessageDialog.openWarning(getShell(), CommonMessages.get().Warning, msg);
108 textPassword.setFocus();
110 return;
113 super.okPressed();
117 * Create contents of the button bar.
118 * @param parent
120 @Override
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.
129 @Override
130 protected Point getInitialSize() {
131 return new Point(402, 118);