package net.sourceforge.phpeclipse.wiki.internal;
import net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin;
+import net.sourceforge.phpeclipse.wiki.preferences.UserValidationDialog;
+import net.sourceforge.phpeclipse.wiki.preferences.Util;
+
+import org.eclipse.swt.widgets.Shell;
/**
*
return new String(out);
}
+ public boolean isUserComplete() {
+ if (fUser==null || fUser.equals("")) {
+ return false;
+ }
+ if (fPassword==null || fPassword.equals("")) {
+ return false;
+ }
+ return true;
+ }
+ /**
+ * Asks the User to enter a Password. Places the results in the supplied string[]. result[0] must contain the username, result[1]
+ * must contain the fPassword. If the fUser canceled, both values must be zero.
+ *
+ * @param location
+ * the location to obtain the fPassword for
+ * @param username
+ * the username
+ * @param message
+ * a message to display to the fUser
+ * @param userMutable
+ * whether the fUser can be changed in the dialog
+ * @param result
+ * a String array of length two in which to put the result
+ */
+ public boolean promptForPassword(final String username, final String message, final boolean userMutable, final String[] result) {
+ if (isUserComplete()) {
+ result[0] = fUser;
+ result[1] = fPassword;
+ return true;
+ }
+ Shell shell = Util.findShell();
+ if (shell == null) {
+ return false;
+ }
+ UserValidationDialog dialog = new UserValidationDialog(shell, fUrl, (username == null) ? "" : username, message);//$NON-NLS-1$
+ dialog.setUsernameMutable(userMutable);
+ dialog.open();
+ result[0] = dialog.getUsername();
+ result[1] = dialog.getPassword();
+ if (dialog.getAllowCaching()) {
+ fUser = result[0];
+ fPassword = result[1];
+ }
+ return dialog.getAllowCaching();
+ }
}
\ No newline at end of file