001: /*
002: * uDig - User Friendly Desktop Internet GIS client
003: * http://udig.refractions.net
004: * (C) 2004, Refractions Research Inc.
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: */
017: package net.refractions.udig.internal.ui;
018:
019: import net.refractions.udig.ui.internal.Messages;
020:
021: import org.eclipse.jface.dialogs.IconAndMessageDialog;
022: import org.eclipse.swt.SWT;
023: import org.eclipse.swt.graphics.Image;
024: import org.eclipse.swt.layout.GridData;
025: import org.eclipse.swt.layout.GridLayout;
026: import org.eclipse.swt.widgets.Button;
027: import org.eclipse.swt.widgets.Composite;
028: import org.eclipse.swt.widgets.Control;
029: import org.eclipse.swt.widgets.Label;
030: import org.eclipse.swt.widgets.Shell;
031: import org.eclipse.swt.widgets.Text;
032:
033: public class AuthenticationDialog extends IconAndMessageDialog {
034:
035: private String username;
036: private String password;
037: private Text usernameText;
038: private Text passwordText;
039: private boolean shouldRemember;
040: private Button rememberCheckbox;
041:
042: public AuthenticationDialog(Shell parentShell) {
043: super (parentShell);
044: setShellStyle(getShellStyle() | SWT.RESIZE);
045:
046: }
047:
048: // protected Point getInitialSize() {
049: // return new Point(400, 400);
050: // }
051:
052: @Override
053: protected Image getImage() {
054: return getWarningImage();
055: }
056:
057: protected Control createDialogArea(Composite parent) {
058: message = Messages.AuthenticationDialog_label_prompt;
059:
060: Composite composite = (Composite) super
061: .createDialogArea(parent);
062: ((GridLayout) composite.getLayout()).numColumns = 2;
063: ((GridLayout) composite.getLayout()).makeColumnsEqualWidth = false;
064:
065: createMessageArea(composite);
066:
067: Label usernameLabel = new Label(composite, SWT.NONE);
068: usernameLabel
069: .setText(Messages.AuthenticationDialog_label_username);
070: usernameText = new Text(composite, SWT.BORDER);
071: usernameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
072: true, false));
073: Label passwordLabel = new Label(composite, SWT.NONE);
074: passwordLabel
075: .setText(Messages.AuthenticationDialog_label_password);
076: passwordText = new Text(composite, SWT.BORDER | SWT.PASSWORD);
077: passwordText.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
078: true, false));
079:
080: rememberCheckbox = new Button(composite, SWT.CHECK);
081: rememberCheckbox
082: .setText(Messages.AuthenticationDialog_label_rememberPassword);
083: GridData gridData = new GridData(SWT.LEFT, SWT.FILL, true,
084: false);
085: gridData.horizontalSpan = 2;
086: rememberCheckbox.setLayoutData(gridData);
087: rememberCheckbox.setSelection(true);
088:
089: return composite;
090: }
091:
092: protected void okPressed() {
093: username = usernameText.getText();
094: password = passwordText.getText();
095: shouldRemember = rememberCheckbox.getSelection();
096: super .okPressed();
097: }
098:
099: public String getPassword() {
100: return password;
101: }
102:
103: public String getUsername() {
104: return username;
105: }
106:
107: public boolean shouldRemember() {
108: return shouldRemember;
109: }
110:
111: protected void configureShell(Shell newShell) {
112: newShell.setText(Messages.AuthenticationDialog_dialog_title);
113: newShell.setImage(UiPlugin.getDefault()
114: .create("icon32.gif").createImage()); //$NON-NLS-1$
115: }
116: }
|