Lines 12-22
Link Here
|
12 |
|
12 |
|
13 |
package org.eclipse.emf.validation.internal; |
13 |
package org.eclipse.emf.validation.internal; |
14 |
|
14 |
|
|
|
15 |
import java.net.URL; |
15 |
import java.util.Collection; |
16 |
import java.util.Collection; |
16 |
import java.util.HashMap; |
17 |
import java.util.HashMap; |
17 |
import java.util.Iterator; |
18 |
import java.util.Iterator; |
18 |
import java.util.Map; |
19 |
import java.util.Map; |
19 |
|
20 |
|
|
|
21 |
import org.eclipse.core.runtime.CoreException; |
20 |
import org.eclipse.core.runtime.IConfigurationElement; |
22 |
import org.eclipse.core.runtime.IConfigurationElement; |
21 |
import org.eclipse.core.runtime.IStatus; |
23 |
import org.eclipse.core.runtime.IStatus; |
22 |
import org.eclipse.core.runtime.Platform; |
24 |
import org.eclipse.core.runtime.Platform; |
Lines 25-32
Link Here
|
25 |
import org.eclipse.emf.common.util.ResourceLocator; |
27 |
import org.eclipse.emf.common.util.ResourceLocator; |
26 |
import org.eclipse.emf.validation.internal.l10n.ValidationMessages; |
28 |
import org.eclipse.emf.validation.internal.l10n.ValidationMessages; |
27 |
import org.eclipse.emf.validation.internal.service.ClientContextManager; |
29 |
import org.eclipse.emf.validation.internal.service.ClientContextManager; |
|
|
30 |
import org.eclipse.emf.validation.internal.util.XmlConstraintFactory; |
31 |
import org.eclipse.emf.validation.model.CategoryManager; |
32 |
import org.eclipse.emf.validation.service.ConstraintFactory; |
28 |
import org.eclipse.emf.validation.service.EventTypeService; |
33 |
import org.eclipse.emf.validation.service.EventTypeService; |
29 |
import org.eclipse.emf.validation.service.ModelValidationService; |
34 |
import org.eclipse.emf.validation.service.ModelValidationService; |
|
|
35 |
import org.eclipse.emf.validation.util.XmlConfig; |
30 |
import org.eclipse.osgi.util.NLS; |
36 |
import org.eclipse.osgi.util.NLS; |
31 |
import org.osgi.framework.BundleContext; |
37 |
import org.osgi.framework.BundleContext; |
32 |
|
38 |
|
Lines 172-178
Link Here
|
172 |
new EMFModelValidationPlugin(); |
178 |
new EMFModelValidationPlugin(); |
173 |
|
179 |
|
174 |
private static Implementation plugin; |
180 |
private static Implementation plugin; |
175 |
|
181 |
|
|
|
182 |
/** |
183 |
* Flag to track standalone configuration, that should happen once |
184 |
* to prevent multiple registration of constraint providers, parsers, |
185 |
* etc. |
186 |
*/ |
187 |
private boolean alreadyConfigured = false; |
188 |
|
176 |
/** |
189 |
/** |
177 |
* Initializes me. |
190 |
* Initializes me. |
178 |
*/ |
191 |
*/ |
Lines 185-190
Link Here
|
185 |
return plugin; |
198 |
return plugin; |
186 |
} |
199 |
} |
187 |
|
200 |
|
|
|
201 |
/** |
202 |
* Configures parsers, constraint providers, categories and constraint bindings |
203 |
* from the given XML document <code>urls</code> in standalone mode (no Eclipse). |
204 |
* <p> |
205 |
* At a minimum one URL should refer to the <code>org.eclipse.emf.validation</code> plugin descriptor. For example: |
206 |
* <pre>jar:file:///c:/mydir/lib/org.eclipse.emf.validation_1.1.0.v200705301635.jar!/plugin.xml</pre> |
207 |
* and another URL should refer to the user contributed constraint providers. For example: |
208 |
* <pre>file:///c:/mydir/plugin.xml</pre> |
209 |
* To enable support for OCL constraints, add a URL to the <code>org.eclipse.emf.validation.ocl</code> plugin descriptor. For example: |
210 |
* <pre>jar:file:///c:/mydir/lib/org.eclipse.emf.validation.ocl_1.1.0.v200705301635.jar!/plugin.xml</pre> |
211 |
* |
212 |
* @param urls the locations of the XML documents to use for standalone initialization. |
213 |
* @throws CoreException on any problem parsing an XML file |
214 |
*/ |
215 |
public void configureStandalone(URL[] urls) throws CoreException { |
216 |
assert urls != null; |
217 |
if (!EMFPlugin.IS_ECLIPSE_RUNNING && !alreadyConfigured) { |
218 |
alreadyConfigured = true; |
219 |
for (int i=0; i < urls.length; i++) { |
220 |
IConfigurationElement element = XmlConfig.load(urls[i]); |
221 |
// Configure any defined parsers |
222 |
IConfigurationElement[] parsers = |
223 |
XmlConfig.findExtensionPoint(getPluginId() + "." + XmlConstraintFactory.CONSTRAINT_PARSERS_EXT_P_NAME, element); |
224 |
if (parsers != null) { |
225 |
((XmlConstraintFactory)ConstraintFactory.getInstance()).configureParsers(parsers); |
226 |
} |
227 |
// Configure any defined constraint providers and categories |
228 |
IConfigurationElement[] providers = |
229 |
XmlConfig.findExtensionPoint(getPluginId() + "." + CONSTRAINT_PROVIDERS_EXT_P_NAME, element); |
230 |
if (providers != null) { |
231 |
ModelValidationService.getInstance().configureProviders(providers); |
232 |
CategoryManager.getInstance().configureCategories(providers); |
233 |
} |
234 |
// Configure any defined constraint bindings |
235 |
IConfigurationElement[] bindings = |
236 |
XmlConfig.findExtensionPoint(getPluginId() + "." + CONSTRAINT_BINDINGS_EXT_P_NAME, element); |
237 |
if (bindings != null) { |
238 |
ClientContextManager.getInstance().configureConstraintBindings(bindings); |
239 |
} |
240 |
} |
241 |
} |
242 |
} |
243 |
|
188 |
/** |
244 |
/** |
189 |
* Obtains the Eclipse plug-in that I implement. |
245 |
* Obtains the Eclipse plug-in that I implement. |
190 |
* |
246 |
* |
Lines 200-206
Link Here
|
200 |
* @return my plug-in unique ID |
256 |
* @return my plug-in unique ID |
201 |
*/ |
257 |
*/ |
202 |
public static String getPluginId() { |
258 |
public static String getPluginId() { |
203 |
return getPlugin().getBundle().getSymbolicName(); |
259 |
if (!EMFPlugin.IS_ECLIPSE_RUNNING) { |
|
|
260 |
return "org.eclipse.emf.validation"; |
261 |
} |
262 |
else { |
263 |
return getPlugin().getBundle().getSymbolicName(); |
264 |
} |
204 |
} |
265 |
} |
205 |
|
266 |
|
206 |
/** |
267 |
/** |
Lines 298-304
Link Here
|
298 |
* |
359 |
* |
299 |
*/ |
360 |
*/ |
300 |
protected static boolean shouldTrace() { |
361 |
protected static boolean shouldTrace() { |
301 |
return plugin.isDebugging(); |
362 |
return (!EMFPlugin.IS_ECLIPSE_RUNNING)?false:plugin.isDebugging(); |
302 |
} |
363 |
} |
303 |
|
364 |
|
304 |
/** |
365 |
/** |