/********************************************************************** * Copyright (c) 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * 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 **********************************************************************/ 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_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 = ""; } } }