From 5e60646320f1ebf4a1b124a764fa4bba09106a4e Mon Sep 17 00:00:00 2001 From: axelcl Date: Thu, 9 Dec 2004 20:11:24 +0000 Subject: [PATCH 1/1] improved settings dialogs --- .../plugin.properties | 4 +- .../phpeclipse/wiki/editor/WikiEditorPlugin.java | 8 +- .../phpeclipse/wiki/internal/Configuration.java | 226 +++++---- .../wiki/internal/ConfigurationManager.java | 16 +- .../wiki/internal/ConfigurationWorkingCopy.java | 28 +- .../phpeclipse/wiki/internal/IConfiguration.java | 2 + .../wiki/internal/IConfigurationListener.java | 6 +- .../wiki/internal/IConfigurationWorkingCopy.java | 2 + .../wiki/preferences/UserValidationDialog.java | 532 ++++++++++---------- .../wiki/ui/internal/ConfigurationComposite.java | 14 +- .../ui/internal/ConfigurationContentProvider.java | 4 +- .../wiki/ui/internal/ConfigurationDialog.java | 50 ++- .../internal/ConfigurationTableLabelProvider.java | 187 ++++---- 13 files changed, 578 insertions(+), 501 deletions(-) diff --git a/archive/net.sourceforge.phpeclipse.wiki/plugin.properties b/archive/net.sourceforge.phpeclipse.wiki/plugin.properties index e3fe00c..24ee64b 100644 --- a/archive/net.sourceforge.phpeclipse.wiki/plugin.properties +++ b/archive/net.sourceforge.phpeclipse.wiki/plugin.properties @@ -4,6 +4,7 @@ HTTPQuery.label=HTTP Query # --------------- General UI --------------- preferenceDescription=Configure HTTP Actions for your Wiki texts. configurationsList=Configurations +columnName=Name columnUser=User Name columnURL=URL columnType=Type @@ -19,8 +20,9 @@ stopped=False newConfig=New Configuration editConfig=Edit Configuration +name=Name: user=User: -remoteGroup=Configuration +configGroup=Configuration url=URL: password=Password: parseType=Type: diff --git a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/editor/WikiEditorPlugin.java b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/editor/WikiEditorPlugin.java index 6226851..3e5c839 100644 --- a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/editor/WikiEditorPlugin.java +++ b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/editor/WikiEditorPlugin.java @@ -55,10 +55,10 @@ public class WikiEditorPlugin extends AbstractUIPlugin { public final static String WIKI_TEXTS_BASE_PATH = "__wiki_texts_base_path"; private static ConfigurationManager manager; - - public static final String IMG_MONITOR_ON = "monitorOn"; - - public static final String IMG_MONITOR_OFF = "monitorOff"; +// +// public static final String IMG_MONITOR_ON = "monitorOn"; +// +// public static final String IMG_MONITOR_OFF = "monitorOff"; /** * Creates an image and places it in the image registry. diff --git a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/internal/Configuration.java b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/internal/Configuration.java index 0b2c404..b27800d 100644 --- a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/internal/Configuration.java +++ b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/internal/Configuration.java @@ -4,7 +4,7 @@ * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html - * +  * * Contributors: * IBM - Initial API and implementation **********************************************************************/ @@ -12,102 +12,136 @@ package net.sourceforge.phpeclipse.wiki.internal; import net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin; - /** - * + * */ public class Configuration implements IConfiguration { - private static final String MEMENTO_ID = "id"; - private static final String MEMENTO_USER = "user"; - private static final String MEMENTO_URL = "url"; - private static final String MEMENTO_PASSWORD = "password"; - private static final String MEMENTO_TYPE_ID = "type-id"; - - protected String id; - protected String fUrl; - protected String fPassword; - protected String fUser; - protected String fType; - - public Configuration() { - this( WikiEditorPlugin.HTTP_QUERY ); // default type - } - - public Configuration(String type) { - this.fType = type; - } - - /* (non-Javadoc) - * @see org.eclipse.monitor.internal.IConfiguration#getId() - */ - public String getId() { - return id; - } - - public String getURL() { - return fUrl; - } - - /* (non-Javadoc) - * @see org.eclipse.monitor.internal.IConfiguration#getRemotePort() - */ - public String getPassword() { - return fPassword; - } - - /* (non-Javadoc) - * @see org.eclipse.monitor.internal.IConfiguration#getLocalPort() - */ - public String getUser() { - return fUser; - } - - /** - */ - public String getType() { - return fType; - } - - /* (non-Javadoc) - * @see org.eclipse.monitor.internal.IConfiguration#isRunning() - */ - public boolean isActive() { - return ConfigurationManager.getInstance().isActive(this); - } - - public void delete() { - ConfigurationManager.getInstance().removeConfiguration(this); - } - - public boolean isWorkingCopy() { - return false; - } - - public IConfigurationWorkingCopy getWorkingCopy() { - return new ConfigurationWorkingCopy(this); - } - - protected void setInternal(IConfiguration monitor) { - id = monitor.getId(); - fUrl = monitor.getURL(); - fPassword = monitor.getPassword(); - fUser = monitor.getUser(); - fType = monitor.getType(); - } - - protected void save(IMemento memento) { - memento.putString(MEMENTO_ID, id); - memento.putString(MEMENTO_TYPE_ID, fType); - memento.putString(MEMENTO_USER, fUser); - memento.putString(MEMENTO_URL, fUrl); - memento.putString(MEMENTO_PASSWORD, fPassword); - } - - protected void load(IMemento memento) { - id = memento.getString(MEMENTO_ID); - fType = memento.getString(MEMENTO_TYPE_ID); - fUser = memento.getString(MEMENTO_USER); - fUrl = memento.getString(MEMENTO_URL); - fPassword = memento.getString(MEMENTO_PASSWORD); - } + private static final String MEMENTO_ID = "id"; + + private static final String MEMENTO_NAME = "name"; + + private static final String MEMENTO_USER = "user"; + + private static final String MEMENTO_URL = "url"; + + private static final String MEMENTO_PASSWORD = "password"; + + private static final String MEMENTO_TYPE_ID = "type-id"; + + protected String fId = ""; + + protected String fName = ""; + + protected String fUrl = ""; + + protected String fPassword = ""; + + protected String fUser = ""; + + protected String fType = ""; + + public Configuration() { + this(WikiEditorPlugin.HTTP_QUERY); // default type + } + + public Configuration(String type) { + this.fType = type; + } + + public String getId() { + return fId; + } + + public String getName() { + return fName; + } + + public String getURL() { + return fUrl; + } + + public String getPassword() { + return fPassword; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.monitor.internal.IConfiguration#getLocalPort() + */ + public String getUser() { + return fUser; + } + + /** + */ + public String getType() { + return fType; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.monitor.internal.IConfiguration#isRunning() + */ + public boolean isActive() { + return ConfigurationManager.getInstance().isActive(this); + } + + public void delete() { + ConfigurationManager.getInstance().removeConfiguration(this); + } + + public boolean isWorkingCopy() { + return false; + } + + public IConfigurationWorkingCopy getWorkingCopy() { + return new ConfigurationWorkingCopy(this); + } + + protected void setInternal(IConfiguration monitor) { + fId = monitor.getId(); + fName = monitor.getName(); + fUrl = monitor.getURL(); + fPassword = monitor.getPassword(); + fUser = monitor.getUser(); + fType = monitor.getType(); + } + + protected void save(IMemento memento) { + memento.putString(MEMENTO_ID, fId); + memento.putString(MEMENTO_NAME, fName); + memento.putString(MEMENTO_TYPE_ID, fType); + memento.putString(MEMENTO_USER, fUser); + memento.putString(MEMENTO_URL, fUrl); + memento.putString(MEMENTO_PASSWORD, fPassword); + } + + protected void load(IMemento memento) { + fId = memento.getString(MEMENTO_ID); + if (fId == null) { + fId = ""; + } + fName = memento.getString(MEMENTO_NAME); + if (fName == null) { + fName = ""; + } + fType = memento.getString(MEMENTO_TYPE_ID); + if (fType == null) { + fType = ""; + } + fUser = memento.getString(MEMENTO_USER); + if (fUser == null) { + fUser = ""; + } + fUrl = memento.getString(MEMENTO_URL); + if (fUrl == null) { + fUrl = ""; + } + fPassword = memento.getString(MEMENTO_PASSWORD); + if (fPassword == null) { + fPassword = ""; + } + } } \ No newline at end of file diff --git a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/internal/ConfigurationManager.java b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/internal/ConfigurationManager.java index 034bb14..3713a9b 100644 --- a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/internal/ConfigurationManager.java +++ b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/internal/ConfigurationManager.java @@ -33,7 +33,7 @@ public class ConfigurationManager { protected List configurations; protected Map threads = new HashMap(); - protected List monitorListeners = new ArrayList(); + protected List configurationListeners = new ArrayList(); private Preferences.IPropertyChangeListener pcl; protected boolean ignorePreferenceChanges = false; @@ -103,7 +103,7 @@ public class ConfigurationManager { * @param listener */ public void addConfigurationListener(IConfigurationListener listener) { - monitorListeners.add(listener); + configurationListeners.add(listener); } /** @@ -112,7 +112,7 @@ public class ConfigurationManager { * @param listener */ public void removeConfigurationListener(IConfigurationListener listener) { - monitorListeners.remove(listener); + configurationListeners.remove(listener); } /** @@ -120,18 +120,18 @@ public class ConfigurationManager { * @param rr * @param fType */ - protected void fireConfigurationEvent(IConfiguration monitor, int type) { - Object[] obj = monitorListeners.toArray(); + protected void fireConfigurationEvent(IConfiguration configuration, int type) { + Object[] obj = configurationListeners.toArray(); int size = obj.length; for (int i = 0; i < size; i++) { IConfigurationListener listener = (IConfigurationListener) obj[i]; if (type == ADD) - listener.monitorAdded(monitor); + listener.configurationAdded(configuration); else if (type == CHANGE) - listener.monitorChanged(monitor); + listener.configurationChanged(configuration); else if (type == REMOVE) - listener.monitorRemoved(monitor); + listener.configurationRemoved(configuration); } } diff --git a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/internal/ConfigurationWorkingCopy.java b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/internal/ConfigurationWorkingCopy.java index c75a2fd..b0cafc5 100644 --- a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/internal/ConfigurationWorkingCopy.java +++ b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/internal/ConfigurationWorkingCopy.java @@ -14,19 +14,23 @@ package net.sourceforge.phpeclipse.wiki.internal; * */ public class ConfigurationWorkingCopy extends Configuration implements IConfigurationWorkingCopy { - protected Configuration monitor; + protected Configuration configuration; // creation public ConfigurationWorkingCopy() { } // working copy - public ConfigurationWorkingCopy(Configuration monitor) { - this.monitor = monitor; - setInternal(monitor); + public ConfigurationWorkingCopy(Configuration configuration) { + this.configuration = configuration; + setInternal(configuration); } public void setId(String newId) { - id = newId; + fId = newId; + } + + public void setName(String name) { + fName = name; } @@ -59,21 +63,21 @@ public class ConfigurationWorkingCopy extends Configuration implements IConfigur public IConfiguration save() { ConfigurationManager mm = ConfigurationManager.getInstance(); - if (monitor != null) { + if (configuration != null) { //boolean restart = false; // if (monitor.isRunning()) { // //restart = true; // mm.stopMonitor(monitor); // } - monitor.setInternal(this); - mm.configurationChanged(monitor); + configuration.setInternal(this); + mm.configurationChanged(configuration); //if (restart) // mm.startMonitor(monitor); } else { - monitor = new Configuration(); - monitor.setInternal(this); - mm.addConfiguration(monitor); + configuration = new Configuration(); + configuration.setInternal(this); + mm.addConfiguration(configuration); } - return monitor; + return configuration; } } \ No newline at end of file diff --git a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/internal/IConfiguration.java b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/internal/IConfiguration.java index 2d230ce..267a3b1 100644 --- a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/internal/IConfiguration.java +++ b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/internal/IConfiguration.java @@ -15,6 +15,8 @@ package net.sourceforge.phpeclipse.wiki.internal; public interface IConfiguration { public String getId(); + public String getName(); + public String getURL(); public String getType(); diff --git a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/internal/IConfigurationListener.java b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/internal/IConfigurationListener.java index d2e5f70..4704505 100644 --- a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/internal/IConfigurationListener.java +++ b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/internal/IConfigurationListener.java @@ -13,9 +13,9 @@ package net.sourceforge.phpeclipse.wiki.internal; * */ public interface IConfigurationListener { - public void monitorAdded(IConfiguration monitor); + public void configurationAdded(IConfiguration monitor); - public void monitorChanged(IConfiguration monitor); + public void configurationChanged(IConfiguration monitor); - public void monitorRemoved(IConfiguration monitor); + public void configurationRemoved(IConfiguration monitor); } \ No newline at end of file diff --git a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/internal/IConfigurationWorkingCopy.java b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/internal/IConfigurationWorkingCopy.java index 86634fb..c0c5f64 100644 --- a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/internal/IConfigurationWorkingCopy.java +++ b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/internal/IConfigurationWorkingCopy.java @@ -15,6 +15,8 @@ package net.sourceforge.phpeclipse.wiki.internal; public interface IConfigurationWorkingCopy extends IConfiguration { public void setId(String id); + public void setName(String name); + public void setURL(String url); public void setPassword(String port); diff --git a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/preferences/UserValidationDialog.java b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/preferences/UserValidationDialog.java index 652d150..50633da 100644 --- a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/preferences/UserValidationDialog.java +++ b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/preferences/UserValidationDialog.java @@ -10,9 +10,6 @@ *******************************************************************************/ package net.sourceforge.phpeclipse.wiki.preferences; - - - import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.window.Window; @@ -33,258 +30,277 @@ import org.eclipse.swt.widgets.Text; * A dialog for prompting for a username and fPassword */ public class UserValidationDialog extends Dialog { - // widgets - protected Text usernameField; - protected Text passwordField; - protected Button allowCachingButton; - - protected String domain; - protected String defaultUsername; - protected String password = null; - protected boolean allowCaching = false; - protected Image keyLockImage; - - // whether or not the username can be changed - protected boolean isUsernameMutable = true; - protected boolean showAllowCachingButton = true; - protected String username = null; - protected String message = null; - - /** - * Creates a new UserValidationDialog. - * - * @param parentShell the parent shell - * @param location the location - * @param defaultName the default fUser name - * @param message a mesage to display to the fUser - */ - public UserValidationDialog(Shell parentShell, String location, String defaultName, String message) { - super(parentShell); - this.defaultUsername = defaultName; - this.domain = location; - this.message = message; - } - /** - * @see Window#configureShell - */ - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - newShell.setText(Messages.getString("UserValidationDialog.required")); //$NON-NLS-1$ - // set F1 help -// WorkbenchHelp.setHelp(newShell, IHelpContextIds.USER_VALIDATION_DIALOG); - } - /** - * @see Window#create - */ - public void create() { - super.create(); - // add some default values - usernameField.setText(defaultUsername); - - if (isUsernameMutable) { - // give focus to username field - usernameField.selectAll(); - usernameField.setFocus(); - } else { - usernameField.setEditable(false); - passwordField.setFocus(); - } - } - - /** - * @see Dialog#createDialogArea - */ - protected Control createDialogArea(Composite parent) { - Composite top = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - - top.setLayout(layout); - top.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Composite imageComposite = new Composite(top, SWT.NONE); - layout = new GridLayout(); - imageComposite.setLayout(layout); - imageComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL)); - - Composite main = new Composite(top, SWT.NONE); - layout = new GridLayout(); - layout.numColumns = 3; - main.setLayout(layout); - main.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Label imageLabel = new Label(imageComposite, SWT.NONE); - keyLockImage = TeamImages.getImageDescriptor(ITeamUIImages.IMG_KEY_LOCK).createImage(); - imageLabel.setImage(keyLockImage); - GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); - imageLabel.setLayoutData(data); - - if (message != null) { - Label messageLabel = new Label(main, SWT.WRAP); - messageLabel.setText(message); - data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); - data.horizontalSpan = 3; - data.widthHint = 300; - messageLabel.setLayoutData(data); - } - if (domain != null) { - Label d = new Label(main, SWT.WRAP); - d.setText(Messages.getString("UserValidationDialog.5")); //$NON-NLS-1$ - data = new GridData(); - d.setLayoutData(data); - Label label = new Label(main, SWT.WRAP); - if (isUsernameMutable) { - label.setText(Messages.bind("UserValidationDialog.labelUser", domain)); //$NON-NLS-1$ - } else { - label.setText(Messages.bind("UserValidationDialog.labelPassword", new Object[]{defaultUsername, domain})); //$NON-NLS-1$ - } - data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); - data.horizontalSpan = 2; - data.widthHint = 300; - label.setLayoutData(data); - } - createUsernameFields(main); - createPasswordFields(main); - - if(domain != null && showAllowCachingButton) { - allowCachingButton = new Button(main, SWT.CHECK); - allowCachingButton.setText(Messages.getString("UserValidationDialog.6")); //$NON-NLS-1$ - data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); - data.horizontalSpan = 3; - allowCachingButton.setLayoutData(data); - allowCachingButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - allowCaching = allowCachingButton.getSelection(); - } - }); - Composite warningComposite = new Composite(main, SWT.NONE); - layout = new GridLayout(); - layout.numColumns = 2; - layout.marginHeight = 0; - layout.marginHeight = 0; - warningComposite.setLayout(layout); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 3; - warningComposite.setLayoutData(data); - Label warningLabel = new Label(warningComposite, SWT.NONE); - warningLabel.setImage(getImage(DLG_IMG_MESSAGE_WARNING)); - warningLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_BEGINNING)); - Label warningText = new Label(warningComposite, SWT.WRAP); - warningText.setText(Messages.getString("UserValidationDialog.7")); //$NON-NLS-1$ - data = new GridData(GridData.FILL_HORIZONTAL); - data.widthHint = 300; - warningText.setLayoutData(data); - } - - Dialog.applyDialogFont(parent); - - return main; - } - /** - * Create a spacer. - */ - protected void createSpacer(Composite top, int columnSpan, int vertSpan) { - Label l = new Label(top, SWT.NONE); - GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); - data.horizontalSpan = columnSpan; - data.verticalSpan = vertSpan; - l.setLayoutData(data); - } - - /** - * Creates the three widgets that represent the fPassword entry area. - * - * @param parent the parent of the widgets - */ - protected void createPasswordFields(Composite parent) { - new Label(parent, SWT.NONE).setText(Messages.getString("UserValidationDialog.fPassword")); //$NON-NLS-1$ - - passwordField = new Text(parent, SWT.BORDER | SWT.PASSWORD); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH); - passwordField.setLayoutData(data); - } - /** - * Creates the three widgets that represent the fUser name entry area. - * - * @param parent the parent of the widgets - */ - protected void createUsernameFields(Composite parent) { - new Label(parent, SWT.NONE).setText(Messages.getString("UserValidationDialog.fUser")); //$NON-NLS-1$ - - usernameField = new Text(parent, SWT.BORDER); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH); - usernameField.setLayoutData(data); - } - - /** - * Returns the fPassword entered by the fUser, or null - * if the fUser canceled. - * - * @return the entered fPassword - */ - public String getPassword() { - return password; - } - - /** - * Returns the username entered by the fUser, or null - * if the fUser canceled. - * - * @return the entered username - */ - public String getUsername() { - return username; - } - - /** - * Returns true if the save fPassword checkbox was selected. - * @return true if the save fPassword checkbox was selected and false - * otherwise. - */ - public boolean getAllowCaching() { - return allowCaching; - } - - /** - * Notifies that the ok button of this dialog has been pressed. - *

- * The default implementation of this framework method sets - * this dialog's return code to Window.OK - * and closes the dialog. Subclasses may override. - *

- */ - protected void okPressed() { - password = passwordField.getText(); - username = usernameField.getText(); - - super.okPressed(); - } - /** - * Sets whether or not the username field should be mutable. - * This method must be called before create(), otherwise it - * will be ignored. - * - * @param value whether the username is mutable - */ - public void setUsernameMutable(boolean value) { - isUsernameMutable = value; - } - - public void setShowAllowCachingButton(boolean value) { - showAllowCachingButton = value; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#close() - */ - public boolean close() { - if(keyLockImage != null) { - keyLockImage.dispose(); - } - return super.close(); - } -} + // widgets + protected Text usernameField; + + protected Text passwordField; + + protected Button allowCachingButton; + + protected String domain; + + protected String defaultUsername; + + protected String password = null; + + protected boolean allowCaching = false; + + protected Image keyLockImage; + + // whether or not the username can be changed + protected boolean isUsernameMutable = true; + + protected boolean showAllowCachingButton = true; + + protected String username = null; + + protected String message = null; + + /** + * Creates a new UserValidationDialog. + * + * @param parentShell + * the parent shell + * @param location + * the location + * @param defaultName + * the default fUser name + * @param message + * a mesage to display to the fUser + */ + public UserValidationDialog(Shell parentShell, String location, String defaultName, String message) { + super(parentShell); + this.defaultUsername = defaultName; + this.domain = location; + this.message = message; + } + + /** + * @see Window#configureShell + */ + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText(Messages.getString("UserValidationDialog.required")); //$NON-NLS-1$ + // set F1 help + // WorkbenchHelp.setHelp(newShell, IHelpContextIds.USER_VALIDATION_DIALOG); + } + + /** + * @see Window#create + */ + public void create() { + super.create(); + // add some default values + usernameField.setText(defaultUsername); + + if (isUsernameMutable) { + // give focus to username field + usernameField.selectAll(); + usernameField.setFocus(); + } else { + usernameField.setEditable(false); + passwordField.setFocus(); + } + } + + /** + * @see Dialog#createDialogArea + */ + protected Control createDialogArea(Composite parent) { + Composite top = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + + top.setLayout(layout); + top.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + Composite imageComposite = new Composite(top, SWT.NONE); + layout = new GridLayout(); + imageComposite.setLayout(layout); + imageComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL)); + + Composite main = new Composite(top, SWT.NONE); + layout = new GridLayout(); + layout.numColumns = 3; + main.setLayout(layout); + main.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + Label imageLabel = new Label(imageComposite, SWT.NONE); + keyLockImage = TeamImages.getImageDescriptor(ITeamUIImages.IMG_KEY_LOCK).createImage(); + imageLabel.setImage(keyLockImage); + GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); + imageLabel.setLayoutData(data); + + if (message != null) { + Label messageLabel = new Label(main, SWT.WRAP); + messageLabel.setText(message); + data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); + data.horizontalSpan = 3; + data.widthHint = 300; + messageLabel.setLayoutData(data); + } + if (domain != null) { + Label d = new Label(main, SWT.WRAP); + d.setText(Messages.getString("UserValidationDialog.5")); //$NON-NLS-1$ + data = new GridData(); + d.setLayoutData(data); + Label label = new Label(main, SWT.WRAP); + if (isUsernameMutable) { + label.setText(Messages.bind("UserValidationDialog.labelUser", domain)); //$NON-NLS-1$ + } else { + label.setText(Messages.bind("UserValidationDialog.labelPassword", new Object[] { defaultUsername, domain })); //$NON-NLS-1$ + } + data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); + data.horizontalSpan = 2; + data.widthHint = 300; + label.setLayoutData(data); + } + createUsernameFields(main); + createPasswordFields(main); + + if (domain != null && showAllowCachingButton) { + allowCachingButton = new Button(main, SWT.CHECK); + allowCachingButton.setText(Messages.getString("UserValidationDialog.6")); //$NON-NLS-1$ + data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); + data.horizontalSpan = 3; + allowCachingButton.setLayoutData(data); + allowCachingButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + allowCaching = allowCachingButton.getSelection(); + } + }); + Composite warningComposite = new Composite(main, SWT.NONE); + layout = new GridLayout(); + layout.numColumns = 2; + layout.marginHeight = 0; + layout.marginHeight = 0; + warningComposite.setLayout(layout); + data = new GridData(GridData.FILL_HORIZONTAL); + data.horizontalSpan = 3; + warningComposite.setLayoutData(data); + Label warningLabel = new Label(warningComposite, SWT.NONE); + warningLabel.setImage(getImage(DLG_IMG_MESSAGE_WARNING)); + warningLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_BEGINNING)); + Label warningText = new Label(warningComposite, SWT.WRAP); + warningText.setText(Messages.getString("UserValidationDialog.7")); //$NON-NLS-1$ + data = new GridData(GridData.FILL_HORIZONTAL); + data.widthHint = 300; + warningText.setLayoutData(data); + } + + Dialog.applyDialogFont(parent); + + return main; + } + + /** + * Create a spacer. + */ + protected void createSpacer(Composite top, int columnSpan, int vertSpan) { + Label l = new Label(top, SWT.NONE); + GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); + data.horizontalSpan = columnSpan; + data.verticalSpan = vertSpan; + l.setLayoutData(data); + } + + /** + * Creates the three widgets that represent the fPassword entry area. + * + * @param parent + * the parent of the widgets + */ + protected void createPasswordFields(Composite parent) { + new Label(parent, SWT.NONE).setText(Messages.getString("UserValidationDialog.password")); //$NON-NLS-1$ + + passwordField = new Text(parent, SWT.BORDER | SWT.PASSWORD); + GridData data = new GridData(GridData.FILL_HORIZONTAL); + data.horizontalSpan = 2; + data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH); + passwordField.setLayoutData(data); + } + + /** + * Creates the three widgets that represent the fUser name entry area. + * + * @param parent + * the parent of the widgets + */ + protected void createUsernameFields(Composite parent) { + new Label(parent, SWT.NONE).setText(Messages.getString("UserValidationDialog.fUser")); //$NON-NLS-1$ + + usernameField = new Text(parent, SWT.BORDER); + GridData data = new GridData(GridData.FILL_HORIZONTAL); + data.horizontalSpan = 2; + data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH); + usernameField.setLayoutData(data); + } + + /** + * Returns the fPassword entered by the fUser, or null if the fUser canceled. + * + * @return the entered fPassword + */ + public String getPassword() { + return password; + } + + /** + * Returns the username entered by the fUser, or null if the fUser canceled. + * + * @return the entered username + */ + public String getUsername() { + return username; + } + + /** + * Returns true if the save fPassword checkbox was selected. + * + * @return true if the save fPassword checkbox was selected and false otherwise. + */ + public boolean getAllowCaching() { + return allowCaching; + } + + /** + * Notifies that the ok button of this dialog has been pressed. + *

+ * The default implementation of this framework method sets this dialog's return code to Window.OK and closes the + * dialog. Subclasses may override. + *

+ */ + protected void okPressed() { + password = passwordField.getText(); + username = usernameField.getText(); + + super.okPressed(); + } + + /** + * Sets whether or not the username field should be mutable. This method must be called before create(), otherwise it will be + * ignored. + * + * @param value + * whether the username is mutable + */ + public void setUsernameMutable(boolean value) { + isUsernameMutable = value; + } + + public void setShowAllowCachingButton(boolean value) { + showAllowCachingButton = value; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.dialogs.Dialog#close() + */ + public boolean close() { + if (keyLockImage != null) { + keyLockImage.dispose(); + } + return super.close(); + } +} \ No newline at end of file diff --git a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/ui/internal/ConfigurationComposite.java b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/ui/internal/ConfigurationComposite.java index cffe190..f09d804 100644 --- a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/ui/internal/ConfigurationComposite.java +++ b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/ui/internal/ConfigurationComposite.java @@ -89,8 +89,8 @@ public class ConfigurationComposite extends Composite { TableLayout tableLayout = new TableLayout(); TableColumn statusColumn = new TableColumn(table, SWT.NONE); - statusColumn.setText(WikiEditorPlugin.getResource("%columnStatus")); - ColumnWeightData colData = new ColumnWeightData(6, 30, true); + statusColumn.setText(WikiEditorPlugin.getResource("%columnName")); + ColumnWeightData colData = new ColumnWeightData(5, 30, true); tableLayout.addColumnData(colData); TableColumn typeColumn = new TableColumn(table, SWT.NONE); @@ -99,13 +99,13 @@ public class ConfigurationComposite extends Composite { tableLayout.addColumnData(colData); TableColumn urlColumn = new TableColumn(table, SWT.NONE); - urlColumn.setText(WikiEditorPlugin.getResource("%columnURL")); - colData = new ColumnWeightData(12, 150, true); + urlColumn.setText(WikiEditorPlugin.getResource("%columnUser")); + colData = new ColumnWeightData(5, 30, true); tableLayout.addColumnData(colData); - + TableColumn localColumn = new TableColumn(table, SWT.NONE); - localColumn.setText(WikiEditorPlugin.getResource("%columnUser")); - colData = new ColumnWeightData(5, 50, true); + localColumn.setText(WikiEditorPlugin.getResource("%columnURL")); + colData = new ColumnWeightData(5, 150, true); tableLayout.addColumnData(colData); table.setLayout(tableLayout); diff --git a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/ui/internal/ConfigurationContentProvider.java b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/ui/internal/ConfigurationContentProvider.java index dae90f1..158e508 100644 --- a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/ui/internal/ConfigurationContentProvider.java +++ b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/ui/internal/ConfigurationContentProvider.java @@ -49,8 +49,8 @@ public class ConfigurationContentProvider implements IStructuredContentProvider List list = new ArrayList(); Iterator iterator = WikiEditorPlugin.getConfigurations().iterator(); while (iterator.hasNext()) { - IConfiguration monitor = (IConfiguration) iterator.next(); - list.add(monitor); + IConfiguration configuration = (IConfiguration) iterator.next(); + list.add(configuration); } return list.toArray(); } diff --git a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/ui/internal/ConfigurationDialog.java b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/ui/internal/ConfigurationDialog.java index 04ef13e..150e4fc 100644 --- a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/ui/internal/ConfigurationDialog.java +++ b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/ui/internal/ConfigurationDialog.java @@ -12,6 +12,7 @@ package net.sourceforge.phpeclipse.wiki.ui.internal; import net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin; import net.sourceforge.phpeclipse.wiki.internal.IConfigurationWorkingCopy; +import net.sourceforge.phpeclipse.wiki.preferences.Messages; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; @@ -84,6 +85,22 @@ public class ConfigurationDialog extends Dialog { return label; } + protected Text createPassword(Composite comp, String txt, final StringModifyListener listener) { + final Text text = new Text(comp, SWT.BORDER | SWT.PASSWORD); + if (txt != null) + text.setText(txt); + GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING); + data.widthHint = 150; + text.setLayoutData(data); + if (listener != null) + text.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + listener.valueChanged(text.getText()); + } + }); + return text; + } + protected Text createText(Composite comp, String txt, final StringModifyListener listener) { final Text text = new Text(comp, SWT.BORDER); if (txt != null) @@ -137,24 +154,26 @@ public class ConfigurationDialog extends Dialog { // WorkbenchHelp.setHelp(composite, ContextIds.PREF_DIALOG); + createLabel(composite, WikiEditorPlugin.getResource("%name")); + fUserName = createText(composite, fConfiguration.getName() + "", new StringModifyListener() { + public void valueChanged(String name) { + fConfiguration.setName(name); + validateFields(); + } + }); + Group group = new Group(composite, SWT.NONE); GridLayout layout = new GridLayout(2, false); group.setLayout(layout); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 2; + group.setLayoutData(data); - group.setText(WikiEditorPlugin.getResource("%remoteGroup")); + group.setText(WikiEditorPlugin.getResource("%configGroup")); - createLabel(group, WikiEditorPlugin.getResource("%url")); - fUrl = createText(group, fConfiguration.getURL(), new StringModifyListener() { - public void valueChanged(String s) { - fConfiguration.setURL(s); - validateFields(); - } - }); - createLabel(composite, WikiEditorPlugin.getResource("%user")); - fUserName = createText(composite, fConfiguration.getUser() + "", new StringModifyListener() { + createLabel(group, WikiEditorPlugin.getResource("%user")); + fUserName = createText(group, fConfiguration.getUser() + "", new StringModifyListener() { public void valueChanged(String s) { fConfiguration.setUser(s); validateFields(); @@ -162,13 +181,22 @@ public class ConfigurationDialog extends Dialog { }); createLabel(group, WikiEditorPlugin.getResource("%password")); - fPassword = createText(group, fConfiguration.getPassword() + "", new StringModifyListener() { + fPassword = createPassword(group, fConfiguration.getPassword() + "", new StringModifyListener() { public void valueChanged(String s) { fConfiguration.setPassword(s); validateFields(); } }); + createLabel(group, WikiEditorPlugin.getResource("%url")); + fUrl = createText(group, fConfiguration.getURL(), new StringModifyListener() { + public void valueChanged(String s) { + fConfiguration.setURL(s); + validateFields(); + } + }); + + createLabel(group, WikiEditorPlugin.getResource("%parseType")); createTypeCombo(group, WikiEditorPlugin.getTypes(), fConfiguration.getType(), new TypeModifyListener() { public void valueChanged(String fType) { diff --git a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/ui/internal/ConfigurationTableLabelProvider.java b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/ui/internal/ConfigurationTableLabelProvider.java index 84154c0..d002a58 100644 --- a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/ui/internal/ConfigurationTableLabelProvider.java +++ b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/ui/internal/ConfigurationTableLabelProvider.java @@ -4,7 +4,7 @@ * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html - * +  * * Contributors: * IBM - Initial API and implementation **********************************************************************/ @@ -16,112 +16,101 @@ import net.sourceforge.phpeclipse.wiki.internal.IConfiguration; import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.swt.graphics.Image; + /** * Configuration table label provider. */ public class ConfigurationTableLabelProvider implements ITableLabelProvider { - /** - * ConfigurationTableLabelProvider constructor comment. - */ - public ConfigurationTableLabelProvider() { - super(); - } + /** + * ConfigurationTableLabelProvider constructor comment. + */ + public ConfigurationTableLabelProvider() { + super(); + } + + /** + * Adds a listener to this label provider. Has no effect if an identical listener is already registered. + *

+ * Label provider listeners are informed about state changes that affect the rendering of the viewer that uses this label + * provider. + *

+ * + * @param listener + * a label provider listener + */ + public void addListener(ILabelProviderListener listener) { + } - /** - * Adds a listener to this label provider. - * Has no effect if an identical listener is already registered. - *

- * Label provider listeners are informed about state changes - * that affect the rendering of the viewer that uses this label provider. - *

- * - * @param listener a label provider listener - */ - public void addListener(ILabelProviderListener listener) { } + /** + * Disposes of this label provider. When a label provider is attached to a viewer, the viewer will automatically call this method + * when the viewer is being closed. When label providers are used outside of the context of a viewer, it is the client's + * responsibility to ensure that this method is called when the provider is no longer needed. + */ + public void dispose() { + } - /** - * Disposes of this label provider. When a label provider is - * attached to a viewer, the viewer will automatically call - * this method when the viewer is being closed. When label providers - * are used outside of the context of a viewer, it is the client's - * responsibility to ensure that this method is called when the - * provider is no longer needed. - */ - public void dispose() { } + /** + * Returns the label image for the given column of the given element. + * + * @param element + * the object representing the entire row, or null indicating that no input object is set in the viewer + * @param columnIndex + * the zero-based index of the column in which the label appears + */ + public Image getColumnImage(Object element, int columnIndex) { + return null; + } - /** - * Returns the label image for the given column of the given element. - * - * @param element the object representing the entire row, or - * null indicating that no input object is set - * in the viewer - * @param columnIndex the zero-based index of the column in which - * the label appears - */ - public Image getColumnImage(Object element, int columnIndex) { - if (columnIndex == 0) { - IConfiguration monitor = (IConfiguration) element; - if (monitor.isActive()) - return WikiEditorPlugin.getDefault().getImage(WikiEditorPlugin.IMG_MONITOR_ON); - else - return WikiEditorPlugin.getDefault().getImage(WikiEditorPlugin.IMG_MONITOR_OFF); - } - return null; - } + /** + * Returns the label text for the given column of the given element. + * + * @param element + * the object representing the entire row, or null indicating that no input object is set in the viewer + * @param columnIndex + * the zero-based index of the column in which the label appears + */ + public String getColumnText(Object element, int columnIndex) { + IConfiguration monitor = (IConfiguration) element; + if (columnIndex == 0) { + return monitor.getName(); + } else if (columnIndex == 1) + return monitor.getType(); + else if (columnIndex == 2) + return monitor.getUser(); + else if (columnIndex == 3) + return monitor.getURL(); + else + return "X"; + } - /** - * Returns the label text for the given column of the given element. - * - * @param element the object representing the entire row, or - * null indicating that no input object is set - * in the viewer - * @param columnIndex the zero-based index of the column in which the label appears - */ - public String getColumnText(Object element, int columnIndex) { - IConfiguration monitor = (IConfiguration) element; - if (columnIndex == 0) { - if (monitor.isActive()) - return WikiEditorPlugin.getResource("%started"); - else - return WikiEditorPlugin.getResource("%stopped"); - } else if (columnIndex == 1) - return monitor.getURL() + ":" + monitor.getPassword(); - else if (columnIndex == 2) - return monitor.getType(); - else if (columnIndex == 3) - return monitor.getUser(); - else - return "X"; - } - - protected String notNull(String s) { - if (s != null) - return s; - else - return ""; - } + protected String notNull(String s) { + if (s != null) + return s; + else + return ""; + } - /** - * Returns whether the label would be affected - * by a change to the given property of the given element. - * This can be used to optimize a non-structural viewer update. - * If the property mentioned in the update does not affect the label, - * then the viewer need not update the label. - * - * @param element the element - * @param property the property - * @return true if the label would be affected, - * and false if it would be unaffected - */ - public boolean isLabelProperty(Object element, String property) { - return false; - } + /** + * Returns whether the label would be affected by a change to the given property of the given element. This can be used to + * optimize a non-structural viewer update. If the property mentioned in the update does not affect the label, then the viewer + * need not update the label. + * + * @param element + * the element + * @param property + * the property + * @return true if the label would be affected, and false if it would be unaffected + */ + public boolean isLabelProperty(Object element, String property) { + return false; + } - /** - * Removes a listener to this label provider. - * Has no affect if an identical listener is not registered. - * - * @param listener a label provider listener - */ - public void removeListener(ILabelProviderListener listener) { } + /** + * Removes a listener to this label provider. Has no affect if an identical listener is not registered. + * + * @param listener + * a label provider listener + */ + public void removeListener(ILabelProviderListener listener) { + } } \ No newline at end of file -- 1.7.1