KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > core > plugin > PluginRegistry


1 /*******************************************************************************
2  * Copyright (c) 2007 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.pde.core.plugin;
12
13 import org.eclipse.core.resources.IProject;
14 import org.eclipse.osgi.service.resolver.BundleDescription;
15 import org.eclipse.pde.internal.core.PDECore;
16
17 /**
18  * The central access point for models representing plug-ins found in the workspace
19  * and in the targret platform.
20  * <p>
21  * This class provides static methods only; it is not intended to be
22  * instantiated or subclassed by clients.
23  * </p>
24  *
25  * @since 3.3
26  */

27 public class PluginRegistry {
28     
29     /**
30      * Returns a model entry containing all workspace and target plug-ins by the given ID
31      *
32      * @param id the plug-in ID
33      *
34      * @return a model entry containing all workspace and target plug-ins by the given ID
35      */

36     public static ModelEntry findEntry(String JavaDoc id) {
37         return PDECore.getDefault().getModelManager().findEntry(id);
38     }
39     
40     /**
41      * Returns the plug-in model for the best match plug-in with the given ID.
42      * A null value is returned if no such bundle is found in the workspace or target platform.
43      * <p>
44      * A workspace plug-in is always preferably returned over a target plug-in.
45      * A plug-in that is checked/enabled on the Target Platform preference page is always
46      * preferably returned over a target plug-in that is unchecked/disabled.
47      * </p>
48      * <p>
49      * In the case of a tie among workspace plug-ins or among target plug-ins,
50      * the plug-in with the highest version is returned.
51      * </p>
52      * <p>
53      * In the case of a tie among more than one suitable plug-in that have the same version,
54      * one of those plug-ins is randomly returned.
55      * </p>
56      *
57      * @param id the plug-in ID
58      * @return the plug-in model for the best match plug-in with the given ID
59      */

60     public static IPluginModelBase findModel(String JavaDoc id) {
61         return PDECore.getDefault().getModelManager().findModel(id);
62     }
63         
64     /**
65      * Returns the plug-in model corresponding to the given project, or <code>null</code>
66      * if the project does not represent a plug-in project or if it contains a manifest file
67      * that is malformed or missing vital information.
68      *
69      * @param project the project
70      * @return a plug-in model corresponding to the project or <code>null</code> if the project
71      * is not a plug-in project
72      */

73     public static IPluginModelBase findModel(IProject project) {
74         return PDECore.getDefault().getModelManager().findModel(project);
75     }
76     
77     /**
78      * Returns a plug-in model associated with the given bundle description
79      *
80      * @param desc the bundle description
81      *
82      * @return a plug-in model associated with the given bundle description or <code>null</code>
83      * if none exists
84      */

85     public static IPluginModelBase findModel(BundleDescription desc) {
86         return PDECore.getDefault().getModelManager().findModel(desc);
87     }
88     
89     /**
90      * Returns all plug-ins and fragments in the workspace as well as all plug-ins and fragments that are
91      * checked on the Target Platform preference page.
92      * <p>
93      * If a workspace plug-in/fragment has the same ID as a target plug-in/fragment, the target counterpart
94      * is skipped and not included.
95      * </p>
96      * <p>
97      * Equivalent to <code>getActiveModels(true)</code>
98      * </p>
99      *
100      * @return all plug-ins and fragments in the workspace as well as all plug-ins and fragments that are
101      * checked on the Target Platform preference page.
102      */

103     public static IPluginModelBase[] getActiveModels() {
104         return getActiveModels(true);
105     }
106
107     /**
108      * Returns all plug-ins and (possibly) fragments in the workspace as well as all plug-ins and (possibly)
109      * fragments that are checked on the Target Platform preference page.
110      * <p>
111      * If a workspace plug-in/fragment has the same ID as a target plug-in, the target counterpart
112      * is skipped and not included.
113      * </p>
114      * <p>
115      * The returned result includes fragments only if <code>includeFragments</code>
116      * is set to true
117      * </p>
118      * @param includeFragments a boolean indicating if fragments are desired in the returned
119      * result
120      * @return all plug-ins and (possibly) fragments in the workspace as well as all plug-ins and
121      * (possibly) fragments that are checked on the Target Platform preference page.
122      */

123     public static IPluginModelBase[] getActiveModels(boolean includeFragments) {
124         return PDECore.getDefault().getModelManager().getActiveModels(includeFragments);
125     }
126
127     /**
128      * Returns all plug-ins and fragments in the workspace as well as all target plug-ins and fragments, regardless
129      * whether or not they are checked or not on the Target Platform preference page.
130      * <p>
131      * If a workspace plug-in/fragment has the same ID as a target plug-in, the target counterpart
132      * is skipped and not included.
133      * </p>
134      * <p>
135      * Equivalent to <code>getAllModels(true)</code>
136      * </p>
137      *
138      * @return all plug-ins and fragments in the workspace as well as all target plug-ins and fragments, regardless
139      * whether or not they are checked on the Target Platform preference page.
140      */

141     public static IPluginModelBase[] getAllModels() {
142         return getAllModels(true);
143     }
144     
145     /**
146      * Returns all plug-ins and (possibly) fragments in the workspace as well as all plug-ins
147      * and (possibly) fragments, regardless whether or not they are
148      * checked on the Target Platform preference page.
149      * <p>
150      * If a workspace plug-in/fragment has the same ID as a target plug-in/fragment, the target counterpart
151      * is skipped and not included.
152      * </p>
153      * <p>
154      * The returned result includes fragments only if <code>includeFragments</code>
155      * is set to true
156      * </p>
157      * @param includeFragments a boolean indicating if fragments are desired in the returned
158      * result
159      * @return ll plug-ins and (possibly) fragments in the workspace as well as all plug-ins
160      * and (possibly) fragments, regardless whether or not they are
161      * checked on the Target Platform preference page.
162      */

163     public static IPluginModelBase[] getAllModels(boolean includeFragments) {
164         return PDECore.getDefault().getModelManager().getAllModels(includeFragments);
165     }
166     
167     /**
168      * Returns all plug-in models in the workspace
169      *
170      * @return all plug-in models in the workspace
171      */

172     public static IPluginModelBase[] getWorkspaceModels() {
173         return PDECore.getDefault().getModelManager().getWorkspaceModels();
174     }
175     
176     /**
177      * Return the model manager that keeps track of plug-ins in the target platform
178      *
179      * @return the model manager that keeps track of plug-ins in the target platform
180      */

181     public static IPluginModelBase[] getExternalModels() {
182         return PDECore.getDefault().getModelManager().getExternalModels();
183     }
184
185 }
186
Popular Tags