1 package net.sourceforge.phpeclipse.wiki.blog;
3 import net.sourceforge.phpeclipse.wiki.preferences.AlternateUserValidationDialog;
4 import net.sourceforge.phpeclipse.wiki.preferences.UserValidationDialog;
5 import net.sourceforge.phpeclipse.wiki.preferences.Util;
7 import org.eclipse.jface.dialogs.Dialog;
8 import org.eclipse.swt.widgets.Shell;
10 public class Configuration {
19 public Configuration(String url, String blogId, String user, String password) {
27 * @return Returns the blogID.
29 public String getBlogID() {
37 public void setBlogID(String blogID) {
42 * @return Returns the fPassword.
44 public String getPassword() {
50 * The fPassword to set.
52 public void setPassword(String password) {
57 * @return Returns the url.
59 public String getUrl() {
67 public void setUrl(String url) {
72 * @return Returns the fUser.
74 public String getUser() {
82 public void setUser(String user) {
86 public boolean isUserComplete() {
87 if (fUser==null || fUser.equals("")) {
90 if (fPassword==null || fPassword.equals("")) {
96 * Special alternate prompting. Returns the fPassword. Username must be fixed.
99 * String passWord = Configuration.alternatePromptForPassword(config.getUser());
100 * if (passWord==null||passWord.equals("")) {
103 * config.setPassword(passWord);
105 public String alternatePromptForPassword(final String username) {
106 Shell shell = Util.findShell();
107 AlternateUserValidationDialog dialog = new AlternateUserValidationDialog(shell, (username == null) ? "" : username); //$NON-NLS-1$
108 dialog.setUsername(username);
109 int result = dialog.open();
110 if (result == Dialog.CANCEL)
112 return dialog.getPassword();
116 * Asks the User to enter a Password. Places the results in the supplied string[]. result[0] must contain the username, result[1]
117 * must contain the fPassword. If the fUser canceled, both values must be zero.
120 * the location to obtain the fPassword for
124 * a message to display to the fUser
126 * whether the fUser can be changed in the dialog
128 * a String array of length two in which to put the result
130 public boolean promptForPassword(final String username, final String message, final boolean userMutable, final String[] result) {
131 if (isUserComplete()) {
133 result[1] = fPassword;
136 Shell shell = Util.findShell();
140 String domain = "<test>"; //location == null ? null : location.getLocation();
141 UserValidationDialog dialog = new UserValidationDialog(shell, domain, (username == null) ? "" : username, message);//$NON-NLS-1$
142 dialog.setUsernameMutable(userMutable);
144 result[0] = dialog.getUsername();
145 result[1] = dialog.getPassword();
146 return dialog.getAllowCaching();