Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E4C1DFB3D for ; Tue, 26 Mar 2013 16:44:07 +0000 (UTC) Received: (qmail 54279 invoked by uid 500); 26 Mar 2013 16:44:07 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 54197 invoked by uid 500); 26 Mar 2013 16:44:07 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 54189 invoked by uid 99); 26 Mar 2013 16:44:07 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Mar 2013 16:44:07 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Mar 2013 16:44:05 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 4533A238897F; Tue, 26 Mar 2013 16:43:45 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1461216 - in /directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui: UIAuthHandler.java dialogs/CredentialsDialog.java dialogs/PasswordDialog.java Date: Tue, 26 Mar 2013 16:43:45 -0000 To: commits@directory.apache.org From: pamarcelot@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130326164345.4533A238897F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pamarcelot Date: Tue Mar 26 16:43:44 2013 New Revision: 1461216 URL: http://svn.apache.org/r1461216 Log: Fix for DIRSTUDIO-895 (Add a 'Show password' checkbox to the CredentialsDialog used to ask the connection's password when it's not saved). Also renamed the class from 'CredentialsDialog' to 'PasswordDialog'. Added: directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/dialogs/PasswordDialog.java - copied, changed from r1459201, directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/dialogs/CredentialsDialog.java Removed: directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/dialogs/CredentialsDialog.java Modified: directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/UIAuthHandler.java Modified: directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/UIAuthHandler.java URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/UIAuthHandler.java?rev=1461216&r1=1461215&r2=1461216&view=diff ============================================================================== --- directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/UIAuthHandler.java (original) +++ directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/UIAuthHandler.java Tue Mar 26 16:43:44 2013 @@ -25,7 +25,7 @@ import org.apache.directory.studio.conne import org.apache.directory.studio.connection.core.Credentials; import org.apache.directory.studio.connection.core.IAuthHandler; import org.apache.directory.studio.connection.core.ICredentials; -import org.apache.directory.studio.connection.ui.dialogs.CredentialsDialog; +import org.apache.directory.studio.connection.ui.dialogs.PasswordDialog; import org.eclipse.osgi.util.NLS; import org.eclipse.ui.PlatformUI; @@ -60,15 +60,15 @@ public class UIAuthHandler implements IA { public void run() { - CredentialsDialog dialog = new CredentialsDialog( + PasswordDialog dialog = new PasswordDialog( PlatformUI.getWorkbench().getDisplay().getActiveShell(), NLS.bind( Messages.getString( "UIAuthHandler.EnterPasswordFor" ), new String[] { connectionParameter.getName() } ), //$NON-NLS-1$ NLS.bind( - Messages.getString( "UIAuthHandler.PleaseEnterPasswordOfUser" ), connectionParameter.getBindPrincipal() ), "", null ); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ - if ( dialog.open() == CredentialsDialog.OK ) + Messages.getString( "UIAuthHandler.PleaseEnterPasswordOfUser" ), connectionParameter.getBindPrincipal() ), "" ); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ + if ( dialog.open() == PasswordDialog.OK ) { - pw[0] = dialog.getValue(); + pw[0] = dialog.getPassword(); } else { Copied: directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/dialogs/PasswordDialog.java (from r1459201, directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/dialogs/CredentialsDialog.java) URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/dialogs/PasswordDialog.java?p2=directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/dialogs/PasswordDialog.java&p1=directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/dialogs/CredentialsDialog.java&r1=1459201&r2=1461216&rev=1461216&view=diff ============================================================================== --- directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/dialogs/CredentialsDialog.java (original) +++ directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/dialogs/PasswordDialog.java Tue Mar 26 16:43:44 2013 @@ -21,44 +21,149 @@ package org.apache.directory.studio.connection.ui.dialogs; -import org.eclipse.jface.dialogs.IInputValidator; -import org.eclipse.jface.dialogs.InputDialog; +import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; /** - * The CredentialsDialog is used to ask the user for credentials (paasword). + * The PasswordDialog is used to ask the user for password (credentials). + *

+ * It has a useful checkbox that can show/hide the typed password. * * @author Apache Directory Project */ -public class CredentialsDialog extends InputDialog +public class PasswordDialog extends Dialog { + /** The title of the dialog */ + private String title; + + /** The message to display, or null if none */ + private String message; + + /** The input value; the empty string by default */ + private String value = "";//$NON-NLS-1$ + + // UI Widgets + private Text text; + private Button showPasswordCheckbox; + /** * Creates a new instance of CredentialsDialog. * * @param parentShell the parent shell - * @param dialogTitle the dialog title - * @param dialogMessage the dialog message + * @param title the title + * @param message the dialog message * @param initialValue the initial value - * @param validator the validator */ - public CredentialsDialog( Shell parentShell, String dialogTitle, String dialogMessage, String initialValue, - IInputValidator validator ) + public PasswordDialog( Shell parentShell, String title, String message, String initialValue ) + { + super( parentShell ); + this.title = title; + this.message = message; + + if ( initialValue == null ) + { + value = "";//$NON-NLS-1$ + } + else + { + value = initialValue; + } + } + + + /** + * {@inheritDoc} + */ + protected void configureShell( Shell shell ) + { + super.configureShell( shell ); + + if ( title != null ) + { + shell.setText( title ); + } + } + + + /** + * {@inheritDoc} + */ + protected void buttonPressed( int buttonId ) { - super( parentShell, dialogTitle, dialogMessage, initialValue, validator ); + if ( buttonId == IDialogConstants.OK_ID ) + { + value = text.getText(); + } + else + { + value = null; + } + super.buttonPressed( buttonId ); } /** - * @see org.eclipse.jface.dialogs.InputDialog#createDialogArea(org.eclipse.swt.widgets.Composite) + * {@inheritDoc} */ protected Control createDialogArea( Composite parent ) { Composite composite = ( Composite ) super.createDialogArea( parent ); - super.getText().setEchoChar( '\u2022' ); + + if ( message != null ) + { + Label label = BaseWidgetUtils.createWrappedLabel( composite, message, 1 ); + GridData data = new GridData( GridData.GRAB_HORIZONTAL + | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL + | GridData.VERTICAL_ALIGN_CENTER ); + data.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH ); + label.setLayoutData( data ); + } + + // Password Text + text = BaseWidgetUtils.createText( composite, value, 1 ); + text.setEchoChar( '\u2022' ); + + // Show Password Checkbox + showPasswordCheckbox = BaseWidgetUtils.createCheckbox( composite, "Show password", 1 ); + showPasswordCheckbox.addSelectionListener( new SelectionAdapter() + { + public void widgetSelected( SelectionEvent e ) + { + if ( showPasswordCheckbox.getSelection() ) + { + text.setEchoChar( '\0' ); + } + else + { + text.setEchoChar( '\u2022' ); + } + } + } ); + + applyDialogFont( composite ); return composite; } + + + /** + * Returns the string typed into this password dialog. + * + * @return the input string + */ + public String getPassword() + { + return value; + } }