initial contribution
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.wiki / src / net / sourceforge / phpeclipse / wiki / internal / Configuration.java
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
new file mode 100644 (file)
index 0000000..0b2c404
--- /dev/null
@@ -0,0 +1,113 @@
+/**********************************************************************
+ * 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_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);
+       }
+}
\ No newline at end of file