initial contribution
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.wiki / src / net / sourceforge / phpeclipse / wiki / internal / Configuration.java
1 /**********************************************************************
2  * Copyright (c) 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  *    IBM - Initial API and implementation
10  **********************************************************************/
11 package net.sourceforge.phpeclipse.wiki.internal;
12
13 import net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin;
14
15
16 /**
17  * 
18  */
19 public class Configuration implements IConfiguration {
20         private static final String MEMENTO_ID = "id";
21         private static final String MEMENTO_USER = "user";
22         private static final String MEMENTO_URL = "url";
23         private static final String MEMENTO_PASSWORD = "password";
24         private static final String MEMENTO_TYPE_ID = "type-id";
25
26         protected String id;
27         protected String fUrl;
28         protected String fPassword;
29         protected String fUser;
30         protected String fType;
31         
32         public Configuration() {
33           this( WikiEditorPlugin.HTTP_QUERY );  // default type
34         }
35         
36         public Configuration(String type) {
37           this.fType = type;
38         }
39         
40         /* (non-Javadoc)
41          * @see org.eclipse.monitor.internal.IConfiguration#getId()
42          */
43         public String getId() {
44                 return id;
45         }
46
47         public String getURL() {
48                 return fUrl;
49         }
50
51         /* (non-Javadoc)
52          * @see org.eclipse.monitor.internal.IConfiguration#getRemotePort()
53          */
54         public String getPassword() {
55                 return fPassword;
56         }
57
58         /* (non-Javadoc)
59          * @see org.eclipse.monitor.internal.IConfiguration#getLocalPort()
60          */
61         public String getUser() {
62                 return fUser;
63         }
64
65         /**
66          */
67         public String getType() {
68                 return fType;
69         }
70
71         /* (non-Javadoc)
72          * @see org.eclipse.monitor.internal.IConfiguration#isRunning()
73          */
74         public boolean isActive() {
75                 return ConfigurationManager.getInstance().isActive(this);
76         }
77         
78         public void delete() {
79                 ConfigurationManager.getInstance().removeConfiguration(this);
80         }
81
82         public boolean isWorkingCopy() {
83                 return false;
84         }
85         
86         public IConfigurationWorkingCopy getWorkingCopy() {
87                 return new ConfigurationWorkingCopy(this);
88         }
89         
90         protected void setInternal(IConfiguration monitor) {
91                 id = monitor.getId();
92                 fUrl = monitor.getURL();
93                 fPassword = monitor.getPassword();
94                 fUser = monitor.getUser();
95                 fType = monitor.getType();
96         }
97         
98         protected void save(IMemento memento) {
99                 memento.putString(MEMENTO_ID, id);
100                 memento.putString(MEMENTO_TYPE_ID, fType);
101                 memento.putString(MEMENTO_USER, fUser);
102                 memento.putString(MEMENTO_URL, fUrl);
103                 memento.putString(MEMENTO_PASSWORD, fPassword);
104         }
105
106         protected void load(IMemento memento) {
107                 id = memento.getString(MEMENTO_ID);
108                 fType = memento.getString(MEMENTO_TYPE_ID);
109                 fUser = memento.getString(MEMENTO_USER);
110                 fUrl = memento.getString(MEMENTO_URL);
111                 fPassword = memento.getString(MEMENTO_PASSWORD);
112         }
113 }