View | Details | Raw Unified | Return to bug 167972 | Differences between
and this patch

Collapse All | Expand All

(-)META-INF/MANIFEST.MF (-1 / +1 lines)
Lines 23-28 Link Here
23
 g.eclipse.emf.validation.marker,org.eclipse.emf.validation.model,org.
23
 g.eclipse.emf.validation.marker,org.eclipse.emf.validation.model,org.
24
 eclipse.emf.validation.preferences,org.eclipse.emf.validation.service
24
 eclipse.emf.validation.preferences,org.eclipse.emf.validation.service
25
 ,org.eclipse.emf.validation.util,org.eclipse.emf.validation.xml
25
 ,org.eclipse.emf.validation.util,org.eclipse.emf.validation.xml
26
Bundle-Version: 1.1.0.v200705301635
26
Bundle-Version: 1.1.0.v200705301635a
27
Eclipse-LazyStart: true
27
Eclipse-LazyStart: true
28
28
(-)src/org/eclipse/emf/validation/model/CategoryManager.java (-9 / +28 lines)
Lines 18-23 Link Here
18
18
19
import org.eclipse.core.runtime.IConfigurationElement;
19
import org.eclipse.core.runtime.IConfigurationElement;
20
import org.eclipse.core.runtime.Platform;
20
import org.eclipse.core.runtime.Platform;
21
import org.eclipse.emf.common.EMFPlugin;
21
import org.eclipse.emf.validation.internal.EMFModelValidationDebugOptions;
22
import org.eclipse.emf.validation.internal.EMFModelValidationDebugOptions;
22
import org.eclipse.emf.validation.internal.EMFModelValidationPlugin;
23
import org.eclipse.emf.validation.internal.EMFModelValidationPlugin;
23
import org.eclipse.emf.validation.internal.l10n.ValidationMessages;
24
import org.eclipse.emf.validation.internal.l10n.ValidationMessages;
Lines 229-248 Link Here
229
	 * point.
230
	 * point.
230
	 */
231
	 */
231
	private void loadCategories() {
232
	private void loadCategories() {
232
		IConfigurationElement[] elements = Platform.getExtensionRegistry().getExtensionPoint(
233
		IConfigurationElement[] elements = new IConfigurationElement[0];
234
        if (EMFPlugin.IS_ECLIPSE_RUNNING) {
235
            elements = Platform.getExtensionRegistry().getExtensionPoint(
233
				EMFModelValidationPlugin.getPluginId(),
236
				EMFModelValidationPlugin.getPluginId(),
234
				EMFModelValidationPlugin.CONSTRAINT_PROVIDERS_EXT_P_NAME)
237
				EMFModelValidationPlugin.CONSTRAINT_PROVIDERS_EXT_P_NAME)
235
					.getConfigurationElements();
238
					.getConfigurationElements();
236
		
239
        }
237
		for (int i = 0; i < elements.length; i++) {
240
		configureCategories(elements);
238
			IConfigurationElement next = elements[i];
239
			
240
			if (next.getName().equals(XmlConfig.E_CATEGORY)) {
241
				loadCategories(globalCategory, next);
242
			}
243
		}
244
	}
241
	}
245
	
242
	
243
    /**
244
     * <p>
245
     * Configures my categories from the Eclipse configuration
246
     * <code>elements</code>
247
     * </p>
248
     * <p>
249
     * <b>NOTE</b> that this method should only be called by the EMF Model
250
     * Validation Plug-in, not by any client code!
251
     * </p>
252
     * 
253
     * @param elements 
254
     */
255
    public void configureCategories(IConfigurationElement[] elements) {
256
        for (int i = 0; i < elements.length; i++) {
257
            IConfigurationElement next = elements[i];
258
            
259
            if (next.getName().equals(XmlConfig.E_CATEGORY)) {
260
                loadCategories(globalCategory, next);
261
            }
262
        }        
263
    }
264
	
246
	/**
265
	/**
247
	 * Loads subcategories of the specified <code>parent</code> category.
266
	 * Loads subcategories of the specified <code>parent</code> category.
248
	 * @param parent
267
	 * @param parent
(-)src/org/eclipse/emf/validation/preferences/EMFModelValidationPreferences.java (-1 / +2 lines)
Lines 14-19 Link Here
14
14
15
import org.eclipse.core.runtime.Preferences;
15
import org.eclipse.core.runtime.Preferences;
16
16
17
import org.eclipse.emf.common.EMFPlugin;
17
import org.eclipse.emf.validation.internal.EMFModelValidationPlugin;
18
import org.eclipse.emf.validation.internal.EMFModelValidationPlugin;
18
import org.eclipse.emf.validation.service.ConstraintRegistry;
19
import org.eclipse.emf.validation.service.ConstraintRegistry;
19
import org.eclipse.emf.validation.service.IConstraintDescriptor;
20
import org.eclipse.emf.validation.service.IConstraintDescriptor;
Lines 27-33 Link Here
27
	static final String CONSTRAINT_DISABLED_PREFIX = "con.disabled/"; //$NON-NLS-1$
28
	static final String CONSTRAINT_DISABLED_PREFIX = "con.disabled/"; //$NON-NLS-1$
28
	
29
	
29
	private static final Preferences prefs =
30
	private static final Preferences prefs =
30
		EMFModelValidationPlugin.getPlugin().getPluginPreferences();
31
		(!EMFPlugin.IS_ECLIPSE_RUNNING)?new Preferences():EMFModelValidationPlugin.getPlugin().getPluginPreferences();
31
	
32
	
32
	/**
33
	/**
33
	 * Not instantiable, as all features are static.
34
	 * Not instantiable, as all features are static.
(-)src/org/eclipse/emf/validation/internal/service/TraversalStrategyManager.java (-3 / +5 lines)
Lines 18-23 Link Here
18
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.IConfigurationElement;
19
import org.eclipse.core.runtime.IConfigurationElement;
20
import org.eclipse.core.runtime.Platform;
20
import org.eclipse.core.runtime.Platform;
21
import org.eclipse.emf.common.EMFPlugin;
21
import org.eclipse.emf.ecore.EClass;
22
import org.eclipse.emf.ecore.EClass;
22
import org.eclipse.emf.ecore.EClassifier;
23
import org.eclipse.emf.ecore.EClassifier;
23
import org.eclipse.emf.ecore.EObject;
24
import org.eclipse.emf.ecore.EObject;
Lines 95-105 Link Here
95
	 * required by a validation operation.
96
	 * required by a validation operation.
96
	 */
97
	 */
97
	private void initStrategies() {
98
	private void initStrategies() {
98
		IConfigurationElement[] strats =
99
		IConfigurationElement[] strats = new IConfigurationElement[0];
99
			Platform.getExtensionRegistry().getConfigurationElementsFor(
100
		if (EMFPlugin.IS_ECLIPSE_RUNNING) {
101
			strats = Platform.getExtensionRegistry().getConfigurationElementsFor(
100
				EMFModelValidationPlugin.getPluginId(),
102
				EMFModelValidationPlugin.getPluginId(),
101
				TRAVERSAL_EXT_P_NAME);
103
				TRAVERSAL_EXT_P_NAME);
102
		
104
		}
103
		for (int i = 0; i < strats.length; i++) {
105
		for (int i = 0; i < strats.length; i++) {
104
			IConfigurationElement config = strats[i];
106
			IConfigurationElement config = strats[i];
105
			
107
			
(-)src/org/eclipse/emf/validation/internal/EMFModelValidationPlugin.java (-3 / +64 lines)
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
    	/**
(-)src/org/eclipse/emf/validation/internal/util/ConstraintsContentHandler.java (+5 lines)
Lines 31-36 Link Here
31
import org.xml.sax.SAXParseException;
31
import org.xml.sax.SAXParseException;
32
import org.xml.sax.helpers.DefaultHandler;
32
import org.xml.sax.helpers.DefaultHandler;
33
33
34
import org.eclipse.emf.common.EMFPlugin;
34
import org.eclipse.emf.validation.internal.EMFModelValidationPlugin;
35
import org.eclipse.emf.validation.internal.EMFModelValidationPlugin;
35
import org.eclipse.emf.validation.internal.EMFModelValidationStatusCodes;
36
import org.eclipse.emf.validation.internal.EMFModelValidationStatusCodes;
36
37
Lines 524-529 Link Here
524
		if ((s == null) || !s.startsWith("%")) { //$NON-NLS-1$
525
		if ((s == null) || !s.startsWith("%")) { //$NON-NLS-1$
525
			return s;
526
			return s;
526
		} else if (resourceBundle == null) {
527
		} else if (resourceBundle == null) {
528
			// FIXME Localize in standalone mode           
529
            if (!EMFPlugin.IS_ECLIPSE_RUNNING) {                
530
                return s;               
531
            }            
527
			return Platform.getResourceString(
532
			return Platform.getResourceString(
528
					Platform.getBundle(extension.getNamespaceIdentifier()),
533
					Platform.getBundle(extension.getNamespaceIdentifier()),
529
					s);
534
					s);
(-)src/org/eclipse/emf/validation/internal/util/Log.java (-3 / +23 lines)
Lines 17-22 Link Here
17
import org.eclipse.core.runtime.IStatus;
17
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.core.runtime.Status;
18
import org.eclipse.core.runtime.Status;
19
19
20
import org.eclipse.emf.common.EMFPlugin;
20
import org.eclipse.emf.validation.internal.EMFModelValidationPlugin;
21
import org.eclipse.emf.validation.internal.EMFModelValidationPlugin;
21
22
22
/**
23
/**
Lines 142-149 Link Here
142
		
143
		
143
		Status s = new Status(severity, EMFModelValidationPlugin.getPluginId(),
144
		Status s = new Status(severity, EMFModelValidationPlugin.getPluginId(),
144
			code, message, throwable);
145
			code, message, throwable);
145
146
		if (!EMFPlugin.IS_ECLIPSE_RUNNING) {
146
		EMFModelValidationPlugin.getPlugin().log(s);
147
			if (s.isOK()) {
148
				System.out.println(s);
149
			}
150
			else {
151
				System.err.println(s);
152
			}			
153
		}
154
		else {
155
			EMFModelValidationPlugin.getPlugin().log(s);
156
		}
147
	}
157
	}
148
158
149
	/**
159
	/**
Lines 155-161 Link Here
155
	 * @param status The status object on which to base the log.
165
	 * @param status The status object on which to base the log.
156
	 */
166
	 */
157
	public static void log(IStatus status) {
167
	public static void log(IStatus status) {
158
		EMFModelValidationPlugin.getPlugin().log(status);
168
		if (!EMFPlugin.IS_ECLIPSE_RUNNING) {
169
			if (status.isOK()) {
170
				System.out.println(status);
171
			}
172
			else {
173
				System.err.println(status);
174
			}						
175
		}
176
		else {
177
			EMFModelValidationPlugin.getPlugin().log(status);
178
		}
159
	}
179
	}
160
180
161
	/**
181
	/**
(-)src/org/eclipse/emf/validation/internal/util/XmlConfigurationElement.java (-11 / +18 lines)
Lines 92-112 Link Here
92
	 */
92
	 */
93
	public Object createExecutableExtension(String propertyName)
93
	public Object createExecutableExtension(String propertyName)
94
			throws CoreException {
94
			throws CoreException {
95
		
95
		Object result = null;
96
		String message = EMFModelValidationPlugin.getMessage(
96
	    String className = getAttribute(propertyName);
97
        try {
98
            Class clazz = this.getClass().getClassLoader().loadClass(className);
99
            result = clazz.newInstance();
100
        }
101
        catch (Exception ex) {
102
			String message = EMFModelValidationPlugin.getMessage(
97
				EMFModelValidationStatusCodes.XML_CREATE_EXTENSION_MSG,
103
				EMFModelValidationStatusCodes.XML_CREATE_EXTENSION_MSG,
98
				new Object[] {getName()});
104
				new Object[] {getName()});
99
		
105
		
100
		CoreException ce = new CoreException(
106
			CoreException ce = new CoreException(
101
				new Status(
107
				new Status(
102
						IStatus.ERROR,
108
					IStatus.ERROR,
103
						EMFModelValidationPlugin.getPluginId(),
109
					EMFModelValidationPlugin.getPluginId(),
104
						EMFModelValidationStatusCodes.ERROR_PARSING_XML,
110
					EMFModelValidationStatusCodes.ERROR_PARSING_XML,
105
						message,
111
					message,
106
						null));
112
					ex));		
107
		
113
			Trace.throwing(getClass(), "createExecutableExtension", ce); //$NON-NLS-1$
108
		Trace.throwing(getClass(), "createExecutableExtension", ce); //$NON-NLS-1$
114
			throw ce;        
109
		throw ce;
115
        }
116
        return result;
110
	}
117
	}
111
118
112
	// implements the interface method
119
	// implements the interface method
(-)src/org/eclipse/emf/validation/internal/util/JavaConstraintParser.java (-2 / +7 lines)
Lines 155-162 Link Here
155
		Bundle bundle = Platform.getBundle(bundleName);
155
		Bundle bundle = Platform.getBundle(bundleName);
156
		
156
		
157
		try {
157
		try {
158
			Class resultType = bundle.loadClass(className);
158
			Class resultType = null;
159
159
			if (bundle == null) {
160
				resultType = this.getClass().getClassLoader().loadClass(className);
161
			}
162
			else {
163
				resultType = bundle.loadClass(className);
164
			}
160
			if (AbstractModelConstraint.class.isAssignableFrom(resultType)) {
165
			if (AbstractModelConstraint.class.isAssignableFrom(resultType)) {
161
				// instantiate the class extending AbstractModelConstraint
166
				// instantiate the class extending AbstractModelConstraint
162
				result = new ConstraintAdapter(
167
				result = new ConstraintAdapter(
(-)src/org/eclipse/emf/validation/internal/util/XmlConstraintFactory.java (-5 / +12 lines)
Lines 43-49 Link Here
43
	/**
43
	/**
44
	 * Extension point name for the model providers extension point.
44
	 * Extension point name for the model providers extension point.
45
	 */
45
	 */
46
	private static final String CONSTRAINT_PARSERS_EXT_P_NAME =
46
	public static final String CONSTRAINT_PARSERS_EXT_P_NAME =
47
			"constraintParsers"; //$NON-NLS-1$
47
			"constraintParsers"; //$NON-NLS-1$
48
48
49
	/** Mapping of language names to parser implementations. */
49
	/** Mapping of language names to parser implementations. */
Lines 145-151 Link Here
145
			return new DisabledConstraint(descriptor, e);
145
			return new DisabledConstraint(descriptor, e);
146
		}
146
		}
147
	}
147
	}
148
148
	
149
	public void configureParsers(IConfigurationElement[] elements) {
150
        for (int i = 0; i < elements.length; i++) {
151
            registerParser(elements[i]);
152
        }
153
    }
154
	
149
	/**
155
	/**
150
	 * Registers a parser implementation against the language that it provides.
156
	 * Registers a parser implementation against the language that it provides.
151
	 * 
157
	 * 
Lines 202-212 Link Here
202
	 * extension point.
208
	 * extension point.
203
	 */
209
	 */
204
	private void initializeParsers() {
210
	private void initializeParsers() {
205
		IConfigurationElement[] configs = 
211
		IConfigurationElement[] configs = new IConfigurationElement[0];
206
			Platform.getExtensionRegistry().getConfigurationElementsFor(
212
		if (Platform.getExtensionRegistry() != null) {
213
			configs = Platform.getExtensionRegistry().getConfigurationElementsFor(
207
				EMFModelValidationPlugin.getPluginId(),
214
				EMFModelValidationPlugin.getPluginId(),
208
				CONSTRAINT_PARSERS_EXT_P_NAME);
215
				CONSTRAINT_PARSERS_EXT_P_NAME);
209
216
		}
210
		for (int i = 0; i < configs.length; i++) {
217
		for (int i = 0; i < configs.length; i++) {
211
			IConfigurationElement config = configs[i];
218
			IConfigurationElement config = configs[i];
212
219
(-)src/org/eclipse/emf/validation/util/XmlConfig.java (+182 lines)
Lines 20-26 Link Here
20
20
21
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.runtime.IConfigurationElement;
22
import org.eclipse.core.runtime.IConfigurationElement;
23
import org.eclipse.core.runtime.IContributor;
24
import org.eclipse.core.runtime.IExtension;
25
import org.eclipse.core.runtime.IPluginDescriptor;
23
import org.eclipse.core.runtime.IStatus;
26
import org.eclipse.core.runtime.IStatus;
27
import org.eclipse.core.runtime.InvalidRegistryObjectException;
24
import org.eclipse.core.runtime.Platform;
28
import org.eclipse.core.runtime.Platform;
25
import org.eclipse.core.runtime.Status;
29
import org.eclipse.core.runtime.Status;
26
import org.eclipse.emf.validation.internal.EMFModelValidationDebugOptions;
30
import org.eclipse.emf.validation.internal.EMFModelValidationDebugOptions;
Lines 349-354 Link Here
349
				element.getDeclaringExtension().getNamespaceIdentifier()).getEntry("/"); //$NON-NLS-1$
353
				element.getDeclaringExtension().getNamespaceIdentifier()).getEntry("/"); //$NON-NLS-1$
350
		}
354
		}
351
	}
355
	}
356
    
357
    /**
358
     * Loads a configuration element from the specified <code>url</code>
359
     * 
360
     * @param url the location of the XML document
361
     * @return the configuration element representing the XML document
362
     * @throws CoreException on any problem parsing an XML file
363
     * @see #load(IConfigurationElement, URL)
364
     */
365
    public static IConfigurationElement load(URL url) 
366
        throws CoreException {
367
            return load(new DummyConfigurationElement(), url);
368
    }
352
369
353
	/**
370
	/**
354
	 * Loads a <tt>&lt;constraints&gt;</tt> element from the specified
371
	 * Loads a <tt>&lt;constraints&gt;</tt> element from the specified
Lines 417-422 Link Here
417
	}
434
	}
418
    
435
    
419
    /**
436
    /**
437
     * Returns the children of the configuration element that matches the given
438
     * <code>extensionPoint</code>, searches recursively the given parent element. 
439
     *  
440
     * @param extensionPoint The name of the extension point to match
441
     * @param parent The top level configuration element to search 
442
     * @return the matching configuration element children or null if not found
443
     */
444
    public static IConfigurationElement[] findExtensionPoint(String extensionPoint, IConfigurationElement parent) {
445
        if (parent.getAttribute("point") != null && parent.getAttribute("point").equals(extensionPoint)) {
446
            return parent.getChildren();
447
        }
448
        else {
449
            // Recurse
450
            IConfigurationElement[] children = parent.getChildren();
451
            if (children != null) {
452
            	for (int i = 0; i < children.length; i++) {
453
                    IConfigurationElement[] result = findExtensionPoint(extensionPoint, children[i]);
454
                    if (result != null) {
455
                        return result;
456
                    }
457
                } 
458
            }
459
        }
460
        return null;
461
    }
462
463
    /**
420
     * Obtains an array including all of the <tt>event</tt> and <tt>customEvent</tt>
464
     * Obtains an array including all of the <tt>event</tt> and <tt>customEvent</tt>
421
     * children of the specified <tt>config</tt>uration element.
465
     * children of the specified <tt>config</tt>uration element.
422
     * 
466
     * 
Lines 438-441 Link Here
438
482
439
        return result;
483
        return result;
440
    }
484
    }
485
    
486
    
487
    // Inner classes
488
489
    /**
490
     * A mock configuration element used to supply a valid extension namespace identifier  
491
     * <p>
492
     * This class is not intended to be used outside of the validation framework.
493
     * </p>
494
     * @see XmlConfig#load(URL)
495
     */
496
    private static class DummyConfigurationElement implements IConfigurationElement {
497
        
498
        IExtension dummyExtension = new DummyExtension("org.eclipse.emf.validation.internal");
499
        
500
        public IExtension getDeclaringExtension() throws InvalidRegistryObjectException {
501
            return dummyExtension;
502
        }
503
        
504
        // Unused Methods
505
        
506
        public Object createExecutableExtension(String propertyName) throws CoreException {
507
            return null;
508
        }
509
510
        public String getAttribute(String name) throws InvalidRegistryObjectException {
511
            return null;
512
        }
513
514
        public String getAttributeAsIs(String name) throws InvalidRegistryObjectException {
515
            return null;
516
        }
517
518
        public String[] getAttributeNames() throws InvalidRegistryObjectException {
519
            return null;
520
        }
521
522
        public IConfigurationElement[] getChildren() throws InvalidRegistryObjectException {
523
            return null;
524
        }
525
526
        public IConfigurationElement[] getChildren(String name) throws InvalidRegistryObjectException {
527
            return null;
528
        }
529
530
        public IContributor getContributor() throws InvalidRegistryObjectException {
531
            return null;
532
        }
533
534
        public String getName() throws InvalidRegistryObjectException {
535
            return null;
536
        }
537
538
        public String getNamespace() throws InvalidRegistryObjectException {
539
            return null;
540
        }
541
542
        public String getNamespaceIdentifier() throws InvalidRegistryObjectException {
543
            return null;
544
        }
545
546
        public Object getParent() throws InvalidRegistryObjectException {
547
            return null;
548
        }
549
550
        public String getValue() throws InvalidRegistryObjectException {
551
            return null;
552
        }
553
554
        public String getValueAsIs() throws InvalidRegistryObjectException {
555
            return null;
556
        }
557
558
        public boolean isValid() {
559
            return false;
560
        }
561
        
562
    }
563
    
564
    /**
565
     * A mock extension used to supply a valid namespace identifier  
566
     * <p>
567
     * This class is not intended to be used outside of the validation framework.
568
     * </p>
569
     * @see XmlConfig#load(URL)
570
     */
571
    private static class DummyExtension implements IExtension {
572
        
573
        String namespaceIndentifier = null;
574
        
575
        public DummyExtension(String namespaceIdentifier) {
576
            this.namespaceIndentifier = namespaceIdentifier;
577
        }
578
579
        public String getNamespaceIdentifier() throws InvalidRegistryObjectException {
580
            return namespaceIndentifier;
581
        }
582
        
583
        // Unused Methods 
584
        
585
        public IConfigurationElement[] getConfigurationElements() throws InvalidRegistryObjectException {
586
            return null;
587
        }
588
589
        public IContributor getContributor() throws InvalidRegistryObjectException {
590
            return null;
591
        }
592
593
        public IPluginDescriptor getDeclaringPluginDescriptor() throws InvalidRegistryObjectException {
594
            return null;
595
        }
596
597
        public String getExtensionPointUniqueIdentifier() throws InvalidRegistryObjectException {
598
            return null;
599
        }
600
601
        public String getLabel() throws InvalidRegistryObjectException {
602
            return null;
603
        }
604
605
        public String getNamespace() throws InvalidRegistryObjectException {
606
            return null;
607
        }
608
609
        public String getSimpleIdentifier() throws InvalidRegistryObjectException {
610
            return null;
611
        }
612
613
        public String getUniqueIdentifier() throws InvalidRegistryObjectException {
614
            return null;
615
        }
616
617
        public boolean isValid() {
618
            return false;
619
        }
620
        
621
    }   
622
    
441
}
623
}

Return to bug 167972