2 * Created on 28-ago-2003
5 package com.quantum.ui.dialog;
7 import com.quantum.Messages;
8 import com.quantum.model.PasswordFinder;
10 import org.eclipse.jface.dialogs.InputDialog;
11 import org.eclipse.swt.widgets.Composite;
12 import org.eclipse.swt.widgets.Control;
13 import org.eclipse.swt.widgets.Shell;
14 import org.eclipse.swt.widgets.Text;
20 public class PasswordDialog extends InputDialog {
22 static class PasswordFinderImpl implements PasswordFinder {
23 private boolean passwordMeantToBeSaved = false;
24 private String password;
25 private boolean prompted = false;
28 PasswordFinderImpl(Shell shell) {
32 protected void prompt() {
33 PasswordDialog dialog =
36 Messages.getString("MultiSQLServer.PasswordNotProvided"),
37 Messages.getString("MultiSQLServer.Enter_Password"),
47 public String getPassword() {
57 public boolean isPasswordMeantToBeSaved() {
61 return passwordMeantToBeSaved;
67 public void setPassword(String string) {
74 public void setPasswordMeantToBeSaved(boolean b) {
75 passwordMeantToBeSaved = b;
80 private PasswordFinderImpl passwordFinderImpl;
85 * @param dialogMessage
89 protected PasswordDialog(
94 PasswordFinderImpl passwordFinderImpl) {
95 super(parentShell, dialogTitle, dialogMessage, initialValue, null);
96 this.passwordFinderImpl = passwordFinderImpl;
100 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
102 protected Control createDialogArea(Composite parent) {
104 Control control = super.createDialogArea(parent);
105 Text text = getText();
106 text.setEchoChar('*');
110 public static PasswordFinder createPasswordFinder(Shell parentShell) {
111 PasswordFinderImpl passwordFinder = new PasswordFinderImpl(parentShell);
112 return passwordFinder;
115 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
117 protected void okPressed() {
118 this.passwordFinderImpl.setPassword(getText().getText());