|
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-31
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.ModelValidationService; |
33 |
import org.eclipse.emf.validation.service.ModelValidationService; |
|
|
34 |
import org.eclipse.emf.validation.util.XmlConfig; |
| 29 |
import org.eclipse.osgi.util.NLS; |
35 |
import org.eclipse.osgi.util.NLS; |
| 30 |
import org.osgi.framework.BundleContext; |
36 |
import org.osgi.framework.BundleContext; |
| 31 |
|
37 |
|
|
Lines 164-170
Link Here
|
| 164 |
new EMFModelValidationPlugin(); |
170 |
new EMFModelValidationPlugin(); |
| 165 |
|
171 |
|
| 166 |
private static Implementation plugin; |
172 |
private static Implementation plugin; |
| 167 |
|
173 |
|
|
|
174 |
/** |
| 175 |
* Flag to track standalone configuration, that should happen once |
| 176 |
* to prevent multiple registration of constraint providers, parsers, |
| 177 |
* etc. |
| 178 |
*/ |
| 179 |
private boolean alreadyConfigured = false; |
| 180 |
|
| 168 |
/** |
181 |
/** |
| 169 |
* Initializes me. |
182 |
* Initializes me. |
| 170 |
*/ |
183 |
*/ |
|
Lines 177-182
Link Here
|
| 177 |
return plugin; |
190 |
return plugin; |
| 178 |
} |
191 |
} |
| 179 |
|
192 |
|
|
|
193 |
/** |
| 194 |
* Configures parsers, constraint providers, categories and constraint bindings |
| 195 |
* from the given XML document <code>urls</code> in standalone mode (no Eclipse). |
| 196 |
* <p> |
| 197 |
* At a minimum one URL should refer to the <code>org.eclipse.emf.validation</code> plugin descriptor. For example: |
| 198 |
* <pre>jar:file:///c:/mydir/lib/org.eclipse.emf.validation_1.0.1.v200609250852.jar!/plugin.xml</pre> |
| 199 |
* and another URL should refer to the user contributed constraint providers. For example: |
| 200 |
* <pre>file:///c:/mydir/plugin.xml</pre> |
| 201 |
* To enable support for OCL constraints, add a URL to the <code>org.eclipse.emf.validation.ocl</code> plugin descriptor. For example: |
| 202 |
* <pre>jar:file:///c:/mydir/lib/org.eclipse.emf.validation.ocl_1.0.1.v200609250852.jar!/plugin.xml</pre> |
| 203 |
* |
| 204 |
* @param urls the locations of the XML documents to use for standalone initialization. |
| 205 |
* @throws CoreException on any problem parsing an XML file |
| 206 |
*/ |
| 207 |
public void configureStandalone(URL[] urls) throws CoreException { |
| 208 |
assert urls != null; |
| 209 |
if (!EMFPlugin.IS_ECLIPSE_RUNNING && !alreadyConfigured) { |
| 210 |
alreadyConfigured = true; |
| 211 |
for (int i=0; i < urls.length; i++) { |
| 212 |
IConfigurationElement element = XmlConfig.load(urls[i]); |
| 213 |
// Configure any defined parsers |
| 214 |
IConfigurationElement[] parsers = |
| 215 |
XmlConfig.findExtensionPoint(getPluginId() + "." + XmlConstraintFactory.CONSTRAINT_PARSERS_EXT_P_NAME, element); |
| 216 |
if (parsers != null) { |
| 217 |
((XmlConstraintFactory)ConstraintFactory.getInstance()).configureParsers(parsers); |
| 218 |
} |
| 219 |
// Configure any defined constraint providers and categories |
| 220 |
IConfigurationElement[] providers = |
| 221 |
XmlConfig.findExtensionPoint(getPluginId() + "." + CONSTRAINT_PROVIDERS_EXT_P_NAME, element); |
| 222 |
if (providers != null) { |
| 223 |
ModelValidationService.getInstance().configureProviders(providers); |
| 224 |
CategoryManager.getInstance().configureCategories(providers); |
| 225 |
} |
| 226 |
// Configure any defined constraint bindings |
| 227 |
IConfigurationElement[] bindings = |
| 228 |
XmlConfig.findExtensionPoint(getPluginId() + "." + CONSTRAINT_BINDINGS_EXT_P_NAME, element); |
| 229 |
if (bindings != null) { |
| 230 |
ClientContextManager.getInstance().configureConstraintBindings(bindings); |
| 231 |
} |
| 232 |
} |
| 233 |
} |
| 234 |
} |
| 235 |
|
| 180 |
/** |
236 |
/** |
| 181 |
* Obtains the Eclipse plug-in that I implement. |
237 |
* Obtains the Eclipse plug-in that I implement. |
| 182 |
* |
238 |
* |
|
Lines 192-200
Link Here
|
| 192 |
* @return my plug-in unique ID |
248 |
* @return my plug-in unique ID |
| 193 |
*/ |
249 |
*/ |
| 194 |
public static String getPluginId() { |
250 |
public static String getPluginId() { |
| 195 |
return getPlugin().getBundle().getSymbolicName(); |
251 |
if (!EMFPlugin.IS_ECLIPSE_RUNNING) { |
|
|
252 |
return "org.eclipse.emf.validation"; |
| 253 |
} |
| 254 |
else { |
| 255 |
return getPlugin().getBundle().getSymbolicName(); |
| 256 |
} |
| 196 |
} |
257 |
} |
| 197 |
|
258 |
|
| 198 |
/** |
259 |
/** |
| 199 |
* The definition of the Eclipse plug-in flavour of this EMF plug-in. |
260 |
* The definition of the Eclipse plug-in flavour of this EMF plug-in. |
| 200 |
* |
261 |
* |
|
Lines 274-280
Link Here
|
| 274 |
* |
335 |
* |
| 275 |
*/ |
336 |
*/ |
| 276 |
protected static boolean shouldTrace() { |
337 |
protected static boolean shouldTrace() { |
| 277 |
return plugin.isDebugging(); |
338 |
return (!EMFPlugin.IS_ECLIPSE_RUNNING)?false:plugin.isDebugging(); |
| 278 |
} |
339 |
} |
| 279 |
|
340 |
|
| 280 |
/** |
341 |
/** |