package com.example.e4.rcp.todo.dialogs;

import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
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;

public class PasswordDialog extends Dialog {
	private Text txtUser;
	private Text txtPassword;
	private String user="";
	private String password="";

	public PasswordDialog(Shell parentShell) {
		super(parentShell);
	}
	
	@Override
	protected Control createDialogArea(Composite parent) {
		Composite container = (Composite) super.createDialogArea(parent);
		GridLayout layout = new GridLayout(2, false);
		layout.marginRight = 5;
		layout.marginLeft = 10;
		container.setLayout(layout);

		Label lblUser = new Label(container, SWT.NONE);
		lblUser.setText("User:");

		txtUser = new Text(container, SWT.BORDER);
		txtUser.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false,
				1, 1));
		txtUser.setText(user);

		Label lblPassword = new Label(container, SWT.NONE);
		GridData gd_lblNewLabel = new GridData(SWT.LEFT, SWT.CENTER, false,
				false, 1, 1);
		gd_lblNewLabel.horizontalIndent = 1;
		lblPassword.setLayoutData(gd_lblNewLabel);
		lblPassword.setText("Password:");

		txtPassword = new Text(container, SWT.BORDER);
		txtPassword.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
				false, 1, 1));
		txtPassword.setText(password);
		return container;
	}

	/**
	 * Return the initial size of the dialog.
	 */
	@Override
	protected Point getInitialSize() {
		return new Point(450, 300);
	}

	@Override
	protected void okPressed() {
		user = txtUser.getText();
		password = txtPassword.getText();

		super.okPressed();
	}

	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

}

@@ -76,16 +76,67 @@
 Dialog;%0A
+import org.eclipse.jface.dialogs.IDialogConstants;%0A
 import o
@@ -587,17 +587,19 @@
 ing user
-=
+ = 
 %22%22;%0A%09pri
@@ -618,17 +618,19 @@
 password
-=
+ = 
 %22%22;%0A%0A%09pu
@@ -695,17 +695,16 @@
 ll);%0A%09%7D%0A
-%09
 %0A%09@Overr
@@ -1654,16 +1654,345 @@
 er;%0A%09%7D%0A%0A
+%09// Override method to use %22Login%22 as label for the OK button%0A%09// You could add more buttons%0A%09%0A%09@Override%0A%09protected void createButtonsForButtonBar(Composite parent) %7B%0A%09%09createButton(parent, IDialogConstants.OK_ID, %22Login%22, true);%0A%09%09createButton(parent, IDialogConstants.CANCEL_ID,%0A%09%09%09%09IDialogConstants.CANCEL_LABEL, false);%0A%09%7D%0A%0A
 %09/**%0A%09 *

Update buttons in PasswordDialog to be called "Login" instead of OK