KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > update > internal > model > ConfiguredSiteModel


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.update.internal.model;
12 import org.eclipse.core.runtime.*;
13 import org.eclipse.update.core.model.*;
14 import org.eclipse.update.internal.core.*;
15
16 /**
17  *
18  */

19 public class ConfiguredSiteModel extends ModelObject {
20     private String JavaDoc[] previousPluginPath;
21
22     private SiteModel site;
23     private String JavaDoc platformURLString;
24     private ConfigurationPolicyModel policy;
25     private InstallConfigurationModel installConfiguration;
26     private boolean installable = false;
27
28     /**
29      * Constructor
30      */

31     public ConfiguredSiteModel() {
32         super();
33     }
34
35     /**
36      * returns the site
37      * @return The ISite
38      * @since 2.0
39      */

40     public SiteModel getSiteModel() {
41         return site;
42     }
43
44     /**
45      * Sets the site.
46      * @param site The site to set
47      */

48     public void setSiteModel(SiteModel site) {
49         assertIsWriteable();
50         this.site = site;
51     }
52
53     /**
54      * returns the policy
55      */

56     public ConfigurationPolicyModel getConfigurationPolicyModel() {
57         return policy;
58     }
59
60     /**
61      *
62      * @since 2.0
63      */

64     public void setConfigurationPolicyModel(ConfigurationPolicyModel policy) {
65         assertIsWriteable();
66         this.policy = policy;
67         policy.setConfiguredSiteModel(this);
68     }
69
70     /**
71      * @since
72      */

73     public boolean isUpdatable() {
74         return installable;
75     }
76
77     /**
78      * @since 2.0
79      */

80     public void setUpdatable(boolean installable) {
81         assertIsWriteable();
82         this.installable = installable;
83     }
84
85     /**
86      * Gets the installConfiguration.
87      * @return Returns a InstallConfigurationModel
88      */

89     public InstallConfigurationModel getInstallConfigurationModel() {
90         return installConfiguration;
91     }
92
93     /**
94      * Sets the installConfiguration.
95      * @param installConfiguration The installConfiguration to set
96      */

97     public void setInstallConfigurationModel(InstallConfigurationModel installConfiguration) {
98         assertIsWriteable();
99         this.installConfiguration = installConfiguration;
100     }
101
102     /**
103      * Gets the platformURLString.
104      * @return Returns a String
105      */

106     public String JavaDoc getPlatformURLString() {
107         return platformURLString;
108     }
109
110     /**
111      * Sets the platformURLString.
112      * @param platformURLString The platformURLString to set
113      */

114     public void setPlatformURLString(String JavaDoc platformURLString) {
115         this.platformURLString = platformURLString;
116     }
117
118     
119         /**
120      * Gets the previousPluginPath. The list of plugins the platform had.
121      * @return Returns a String[]
122      */

123     public String JavaDoc[] getPreviousPluginPath() {
124         if (previousPluginPath == null)
125             previousPluginPath = new String JavaDoc[0];
126         return previousPluginPath;
127     }
128
129     /**
130      * Sets the previousPluginPath.
131      * @param previousPluginPath The previousPluginPath to set
132      */

133     public void setPreviousPluginPath(String JavaDoc[] previousPluginPath) {
134         this.previousPluginPath = new String JavaDoc[previousPluginPath.length];
135         System.arraycopy(previousPluginPath, 0, this.previousPluginPath, 0, previousPluginPath.length);
136     }
137
138     /*
139      * creates a Status
140      */

141     protected IStatus createStatus(int statusType, String JavaDoc msg, Exception JavaDoc e){
142         if (statusType!=IStatus.OK) statusType = IStatus.ERROR;
143         return createStatus(statusType,IStatus.OK, msg.toString(), e);
144     }
145
146     /*
147      * creates a Status
148      */

149     protected IStatus createStatus(int statusSeverity, int statusCode, String JavaDoc msg, Exception JavaDoc e){
150         String JavaDoc id = UpdateCore.getPlugin().getBundle().getSymbolicName();
151     
152         StringBuffer JavaDoc completeString = new StringBuffer JavaDoc(""); //$NON-NLS-1$
153
if (msg!=null)
154             completeString.append(msg);
155         if (e!=null){
156             completeString.append("\r\n["); //$NON-NLS-1$
157
completeString.append(e.toString());
158             completeString.append("]\r\n"); //$NON-NLS-1$
159
}
160         return new Status(statusSeverity, id, statusCode, completeString.toString(), e);
161     }
162     
163     /**
164      * @see org.eclipse.update.configuration.IConfiguredSite#isEnabled()
165      */

166     public boolean isEnabled() {
167         return getConfigurationPolicyModel().isEnabled();
168     }
169
170     /**
171      * @see org.eclipse.update.configuration.IConfiguredSite#setEnabled(boolean)
172      */

173     public void setEnabled(boolean value) {
174         getConfigurationPolicyModel().setEnabled(value);
175     }
176     
177 }
178
Popular Tags