KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > runtime > preferences > ConfigurationScope


1 /*******************************************************************************
2  * Copyright (c) 2004, 2006 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.core.runtime.preferences;
12
13 import java.net.URL JavaDoc;
14 import org.eclipse.core.internal.preferences.AbstractScope;
15 import org.eclipse.core.internal.preferences.PreferencesOSGiUtils;
16 import org.eclipse.core.runtime.IPath;
17 import org.eclipse.core.runtime.Path;
18 import org.eclipse.osgi.service.datalocation.Location;
19
20 /**
21  * Object representing the configuration scope in the Eclipse preferences
22  * hierarchy. Can be used as a context for searching for preference
23  * values (in the IPreferencesService APIs) or for determining the
24  * correct preference node to set values in the store.
25  * <p>
26  * Configuration preferences are stored on a per configuration basis in the
27  * platform's configuration area. (The configuration area typically
28  * contains the list of plug-ins available for use, various settings
29  * (those shared across different instances of the same configuration)
30  * and any other such data needed by plug-ins.)
31  * </p>
32  * <p>
33  * The path for preferences defined in the configuration scope hierarchy
34  * is as follows: <code>/configuration/&lt;qualifier&gt;</code>
35  * </p>
36  * <p>
37  * This class is not intended to be subclassed. This class may be instantiated.
38  * </p>
39  * @see Location#CONFIGURATION_FILTER
40  * @since 3.0
41  */

42 public final class ConfigurationScope extends AbstractScope implements IScopeContext {
43
44     /**
45      * String constant (value of <code>"configuration"</code>) used for the
46      * scope name for the configuration preference scope.
47      */

48     public static final String JavaDoc SCOPE = "configuration"; //$NON-NLS-1$
49

50     /**
51      * Create and return a new configuration scope instance.
52      */

53     public ConfigurationScope() {
54         super();
55     }
56
57     /*
58      * @see org.eclipse.core.runtime.preferences.IScopeContext#getName()
59      */

60     public String JavaDoc getName() {
61         return SCOPE;
62     }
63
64     /* (non-Javadoc)
65      * @see org.eclipse.core.runtime.preferences.IScopeContext#getNode(java.lang.String)
66      */

67     public IEclipsePreferences getNode(String JavaDoc qualifier) {
68         return super.getNode(qualifier);
69     }
70
71     /*
72      * @see org.eclipse.core.runtime.preferences.IScopeContext#getLocation()
73      */

74     public IPath getLocation() {
75         IPath result = null;
76         Location location = PreferencesOSGiUtils.getDefault().getConfigurationLocation();
77         if (!location.isReadOnly()) {
78             URL JavaDoc url = location.getURL();
79             if (url != null) {
80                 result = new Path(url.getFile());
81                 if (result.isEmpty())
82                     result = null;
83             }
84         }
85         return result;
86     }
87 }
88
Popular Tags