--- /dev/null
+package net.sourceforge.phpeclipse.wiki.blog;
+
+import net.sourceforge.phpeclipse.wiki.preferences.AlternateUserValidationDialog;
+import net.sourceforge.phpeclipse.wiki.preferences.UserValidationDialog;
+import net.sourceforge.phpeclipse.wiki.preferences.Util;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.widgets.Shell;
+
+public class Configuration {
+ String fUrl;
+
+ String fBlogID;
+
+ String fUser;
+
+ String fPassword;
+
+ public Configuration(String url, String blogId, String user, String password) {
+ fUrl = url;
+ fBlogID = blogId;
+ fUser = user;
+ fPassword = password;
+ }
+
+ /**
+ * @return Returns the blogID.
+ */
+ public String getBlogID() {
+ return fBlogID;
+ }
+
+ /**
+ * @param blogID
+ * The blogID to set.
+ */
+ public void setBlogID(String blogID) {
+ fBlogID = blogID;
+ }
+
+ /**
+ * @return Returns the fPassword.
+ */
+ public String getPassword() {
+ return fPassword;
+ }
+
+ /**
+ * @param fPassword
+ * The fPassword to set.
+ */
+ public void setPassword(String password) {
+ fPassword = password;
+ }
+
+ /**
+ * @return Returns the url.
+ */
+ public String getUrl() {
+ return fUrl;
+ }
+
+ /**
+ * @param url
+ * The url to set.
+ */
+ public void setUrl(String url) {
+ fUrl = url;
+ }
+
+ /**
+ * @return Returns the fUser.
+ */
+ public String getUser() {
+ return fUser;
+ }
+
+ /**
+ * @param fUser
+ * The fUser to set.
+ */
+ public void setUser(String user) {
+ fUser = user;
+ }
+
+ public boolean isUserComplete() {
+ if (fUser==null || fUser.equals("")) {
+ return false;
+ }
+ if (fPassword==null || fPassword.equals("")) {
+ return false;
+ }
+ return true;
+ }
+ /**
+ * Special alternate prompting. Returns the fPassword. Username must be fixed.
+ *
+ *
+ * String passWord = Configuration.alternatePromptForPassword(config.getUser());
+ * if (passWord==null||passWord.equals("")) {
+ * return;
+ * }
+ * config.setPassword(passWord);
+ */
+ public String alternatePromptForPassword(final String username) {
+ Shell shell = Util.findShell();
+ AlternateUserValidationDialog dialog = new AlternateUserValidationDialog(shell, (username == null) ? "" : username); //$NON-NLS-1$
+ dialog.setUsername(username);
+ int result = dialog.open();
+ if (result == Dialog.CANCEL)
+ return null;
+ return dialog.getPassword();
+ }
+
+ /**
+ * 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 false;
+ }
+ Shell shell = Util.findShell();
+ if (shell == null) {
+ return false;
+ }
+ String domain = "<test>"; //location == null ? null : location.getLocation();
+ UserValidationDialog dialog = new UserValidationDialog(shell, domain, (username == null) ? "" : username, message);//$NON-NLS-1$
+ dialog.setUsernameMutable(userMutable);
+ dialog.open();
+ result[0] = dialog.getUsername();
+ result[1] = dialog.getPassword();
+ return dialog.getAllowCaching();
+ }
+
+}
\ No newline at end of file