X-Git-Url: http://secure.phpeclipse.com 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..85fd155 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,160 @@ 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); - } +public class Configuration implements IConfiguration, Comparable { + 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 = ""; + } + } + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + public String toString() { + StringBuffer buffer = new StringBuffer(); + buffer.append(fName); + buffer.append(" - "); + buffer.append(fUser); + buffer.append(" - "); + buffer.append(fUrl); + buffer.append(" - "); + buffer.append(fType); + return buffer.toString(); + } + + /* (non-Javadoc) + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ + public int compareTo(Object o) { + if (o instanceof IConfiguration) { + return fName.compareTo(((IConfiguration)o).getName()); + } + return 1; + } } \ No newline at end of file