import javax.security.auth.callback.PasswordCallback;
import javax.security.auth.callback.TextOutputCallback;
-import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
protected DefaultLoginDialog(Shell parentShell) {
super(parentShell);
+ // setBlockOnOpen(false);
}
protected Point getInitialSize() {
- return new Point(300, 150);
+ return new Point(300, 180);
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ Control control = super.createContents(parent);
+ parent.pack();
+ return control;
}
protected Control createDialogArea(Composite parent) {
Composite dialogarea = (Composite) super.createDialogArea(parent);
- // dialogarea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
- // true));
Composite composite = new Composite(dialogarea, SWT.NONE);
composite.setLayout(new GridLayout(2, false));
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
createCallbackHandlers(composite);
- parent.pack();
+ // parent.pack();
return composite;
}
for (int i = 0; i < callbacks.length; i++) {
Callback callback = callbacks[i];
if (callback instanceof TextOutputCallback) {
- createTextoutputHandler(composite,
+ createLabelTextoutputHandler(composite,
(TextOutputCallback) callback);
} else if (callback instanceof NameCallback) {
createNameHandler(composite, (NameCallback) callback);
passwordText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
+ // FIXME use getTextChars() in Eclipse 3.7
callback.setPassword(passwordText.getText().toCharArray());
}
});
});
}
- private void createTextoutputHandler(Composite composite,
- TextOutputCallback callback) {
- int messageType = callback.getMessageType();
- int dialogMessageType = IMessageProvider.NONE;
- switch (messageType) {
- case TextOutputCallback.INFORMATION:
- dialogMessageType = IMessageProvider.INFORMATION;
- break;
- case TextOutputCallback.WARNING:
- dialogMessageType = IMessageProvider.WARNING;
- break;
- case TextOutputCallback.ERROR:
- dialogMessageType = IMessageProvider.ERROR;
- break;
- }
- //setMessage(callback.getMessage(), dialogMessageType);
+ private void createLabelTextoutputHandler(Composite composite,
+ final TextOutputCallback callback) {
+ Label label = new Label(composite, SWT.NONE);
+ label.setText(callback.getMessage());
+ GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
+ data.horizontalSpan = 2;
+ label.setLayoutData(data);
+ // TODO: find a way to pass this information
+ // int messageType = callback.getMessageType();
+ // int dialogMessageType = IMessageProvider.NONE;
+ // switch (messageType) {
+ // case TextOutputCallback.INFORMATION:
+ // dialogMessageType = IMessageProvider.INFORMATION;
+ // break;
+ // case TextOutputCallback.WARNING:
+ // dialogMessageType = IMessageProvider.WARNING;
+ // break;
+ // case TextOutputCallback.ERROR:
+ // dialogMessageType = IMessageProvider.ERROR;
+ // break;
+ // }
+ // setMessage(callback.getMessage(), dialogMessageType);
}
public void internalHandle() {
}
+
+ // hack to simulate modal
+ // see
+ // http://dev.eclipse.org/mhonarc/newsLists/news.eclipse.platform.jface/msg00181.html
+ // protected void setShellStyle(int newShellStyle) {
+ // // turn off APPLICATION_MODAL
+ // int newstyle = newShellStyle & ~SWT.APPLICATION_MODAL;
+ // // turn on MODELESS
+ // newstyle |= SWT.MODELESS;
+ // super.setShellStyle(newstyle);
+ // }
+ //
+ // public int open() {
+ //
+ // int retVal = super.open();
+ // // this will let the caller wait till OK, Cancel is
+ // // pressed, but will let the other GUI responsive
+ // pumpMessages();
+ // return retVal;
+ // }
+ //
+ // protected void pumpMessages() {
+ // Shell sh = getShell();
+ // Display disp = sh.getDisplay();
+ // while (!sh.isDisposed()) {
+ // if (!disp.readAndDispatch())
+ // disp.sleep();
+ // }
+ // disp.update();
+ // }
+
}