/** readElement() */ protected void readElement(IConfigurationElement element) { if (element.getName().equals(tagName)) { String namespace = element.getAttribute(ATT_NAME_SPACE); if (namespace != null) { Bundle bundle = Platform.getBundle(element.getDeclaringExtension().getContributor().getName()); if (attributeNames.length == 1) { String className = element.getAttribute(attributeNames[0]); if (className != null) { nsKeyedExtensionRegistry.put(namespace, className, bundle); } } else { HashMap map = new HashMap(); for (int i = 0; i < attributeNames.length; i++) { String attributeName = attributeNames[i]; String className = element.getAttribute(attributeName); if (className != null && className.length() > 0) { map.put(attributeName, className); } } nsKeyedExtensionRegistry.put(namespace, map, bundle); } } } }
private static void getConfigurationElementsPaths( final Set<String> result, final String path, final IConfigurationElement[] elements) { if (elements.length == 0) { if (!result.add(path)) { System.err.println( "Error while collecting registry paths. Adding " + path + " twice."); //$NON-NLS-1$ //$NON-NLS-2$ // Commented, because that pollutes the log! // for (final String str : result) { // if (path.equals(str)) { // System.err.println(str); // } else { // System.out.println(str); // } // } } return; } for (final IConfigurationElement element : elements) { final String subPath = path + "<" + element.getName() + " " + getAttributes(element) + "/>"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ getConfigurationElementsPaths(result, subPath, element.getChildren()); } }
private void initGlobaleGuiceInjector() { List<Module> moduleList = new ArrayList<Module>(); IExtensionRegistry reg = Platform.getExtensionRegistry(); IConfigurationElement[] extensions = reg.getConfigurationElementsFor(ISharedModuleProvider.EXTENSION_POINT_ID); for (int i = 0; i < extensions.length; i++) { IConfigurationElement element = extensions[i]; if (element.getAttribute("class") != null) { try { ISharedModuleProvider provider = (ISharedModuleProvider) element.createExecutableExtension("class"); moduleList.add(provider.get()); } catch (Exception e) { e.printStackTrace(); } } } Injector injector = Guice.createInjector(moduleList); try { Field field = GuiceContext.class.getDeclaredField("globalSharedInjector"); field.setAccessible(true); field.set(GuiceContext.class, injector); } catch (Exception e) { e.printStackTrace(); } }
@Override public IToolBehaviorProvider[] getAvailableToolBehaviorProviders() { if (toolBehaviorProviders == null) { DefaultBPMN2Editor editor = (DefaultBPMN2Editor) getDiagramEditor(); TargetRuntime rt = editor.getTargetRuntime(); IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(Activator.UI_EXTENSION_ID); Bpmn2ToolBehaviorProvider provider = null; try { for (IConfigurationElement e : config) { if (e.getName().equals("toolProvider")) { // $NON-NLS-1$ String id = e.getAttribute("id"); // $NON-NLS-1$ String runtimeId = e.getAttribute("runtimeId"); // $NON-NLS-1$ if (rt != null && rt.getId().equals(runtimeId)) { String className = e.getAttribute("class"); // $NON-NLS-1$ ClassLoader cl = rt.getRuntimeExtension().getClass().getClassLoader(); Constructor ctor = null; Class providerClass = Class.forName(className, true, cl); ctor = providerClass.getConstructor(IDiagramTypeProvider.class); provider = (Bpmn2ToolBehaviorProvider) ctor.newInstance(this); break; } } } } catch (Exception ex) { Activator.logError(ex); } if (provider == null) provider = new Bpmn2ToolBehaviorProvider(this); toolBehaviorProviders = new IToolBehaviorProvider[] {provider}; } return toolBehaviorProviders; }
protected List<IScmAccessValidator> getAllValidators() { List<IScmAccessValidator> validators = new ArrayList<IScmAccessValidator>(); IConfigurationElement[] configurationElements = Platform.getExtensionRegistry() .getConfigurationElementsFor(IScmAccessValidator.EXTENSION_POINT_ID); for (IConfigurationElement v : configurationElements) { if (!"validator".equals(v.getName())) { continue; } try { Object extension = v.createExecutableExtension("class"); log.debug("Found SCM validator: {}", extension.getClass().getCanonicalName()); if (!(extension instanceof IScmAccessValidator)) { throw new IllegalArgumentException( extension.getClass().getCanonicalName() + " does not implement the IScmAccessValidator interface"); } validators.add((IScmAccessValidator) extension); } catch (CoreException e) { log.error("Failed to instantiate SCM access validator, will be ignored", e); } } return validators; }
/** * Returns the set of modes specified in the configuration data, or <code>null</code> if none * (i.e. default tab group) * * @return the set of modes specified in the configuration data, or <code>null</code> */ protected List<Set<String>> getModes() { if (fModes == null) { fModes = new ArrayList<Set<String>>(); fPerspectives = new Hashtable<Set<String>, String>(); IConfigurationElement[] modes = fConfig.getChildren(IConfigurationElementConstants.LAUNCH_MODE); if (modes.length > 0) { IConfigurationElement element = null; String perspective = null, mode = null; Set<String> mset = null; for (int i = 0; i < modes.length; i++) { element = modes[i]; mode = element.getAttribute(IConfigurationElementConstants.MODE); mset = new HashSet<String>(); mset.add(mode); fModes.add(mset); perspective = element.getAttribute(IConfigurationElementConstants.PERSPECTIVE); if (perspective != null) { fPerspectives.put(mset, perspective); } } } } return fModes; }
/* (non-Javadoc) * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object) */ @Override public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException { id = config.getAttribute("id"); factoryName = config.getAttribute("name"); name = config.getAttribute("name"); }
/** Read command descriptors from extension points. */ private void initializeCreationCommandDescriptors() { creationCommandDescriptors = new HashMap<Object, CreationCommandDescriptor>(); // Reading data from plugins IConfigurationElement[] configElements = Platform.getExtensionRegistry() .getConfigurationElementsFor(extensionPointNamespace, EDITOR_EXTENSION_ID); CreationCommandExtensionFactory extensionReader = new CreationCommandExtensionFactory(); for (IConfigurationElement ele : configElements) { CreationCommandDescriptor desc; try { if (CreationCommandExtensionFactory.CREATION_COMMAND_EXTENSIONPOINT.equals(ele.getName())) { desc = extensionReader.createCreationCommand(ele); creationCommandDescriptors.put(desc.commandId, desc); } } catch (ExtensionException e) { Activator.getDefault() .getLog() .log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, e.getMessage(), e)); PapyrusTrace.error( IDebugChannel.PAPYRUS_EXTENSIONPOINT_LOADING, this, "Initialization creation command problem " + e); } } PapyrusTrace.trace( IDebugChannel.PAPYRUS_EXTENSIONPOINT_LOADING, this, "" + creationCommandDescriptors.size() + " creationCommands loaded"); }
public static List<ContextComputationStrategy> readContextComputationStrategies() { List<ContextComputationStrategy> strategies = new ArrayList<ContextComputationStrategy>(); IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(STRATEGIES_EXTENSION_POINT_ID); IExtension[] extensions = extensionPoint.getExtensions(); for (IExtension extension : extensions) { IConfigurationElement[] configurationElements = extension.getConfigurationElements(); for (IConfigurationElement element : configurationElements) { if (element.getName().equals(CONTEXT_COMPUTATION_STRATEGY)) { try { ContextComputationStrategy strategy = (ContextComputationStrategy) element.createExecutableExtension(ATTRIBUTE_CLASS); strategies.add(strategy); } catch (Throwable t) { StatusHandler.log( new Status( IStatus.ERROR, ContextCorePlugin.ID_PLUGIN, NLS.bind( "Cannot instantiate {0} from bundle {1}: {2}", //$NON-NLS-1$ new Object[] { element.getAttribute(ATTRIBUTE_CLASS), extension.getContributor().getName(), t.getMessage() }), t)); } } } } return strategies; }
/* * Internal hook for unit testing. */ public AbstractCriteriaDefinitionProvider[] getCriteriaDefinitionProviders() { if (null == criteriaDefinitionProviders) { List<AbstractCriteriaDefinitionProvider> providers = new ArrayList<>(); IExtensionRegistry registry = Platform.getExtensionRegistry(); IConfigurationElement[] elements = registry.getConfigurationElementsFor(EXTENSION_POINT_ID_CRITERIA_DEFINITION); for (int i = 0; i < elements.length; ++i) { IConfigurationElement elem = elements[i]; if (elem.getName().equals(ELEMENT_NAME_CRITERIA_DEFINITION_PROVIDER)) { try { AbstractCriteriaDefinitionProvider provider = (AbstractCriteriaDefinitionProvider) elem.createExecutableExtension(ATTRIBUTE_NAME_CLASS); providers.add(provider); } catch (CoreException e) { // log and skip String msg = "Error instantiating help keyword index provider class \"" + elem.getAttribute(ATTRIBUTE_NAME_CLASS) + '"'; //$NON-NLS-1$ HelpPlugin.logError(msg, e); } } } criteriaDefinitionProviders = providers.toArray(new AbstractCriteriaDefinitionProvider[providers.size()]); } return criteriaDefinitionProviders; }
private ToolbarDockableRegistry() { super(); IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); if (extensionRegistry == null) { return; } IConfigurationElement[] extensions = extensionRegistry.getConfigurationElementsFor(EXTENSION_POINT_ID); for (IConfigurationElement element : extensions) { String groupId = element.getAttribute(ATT_GROUP_ID); if (groupId == null || groupId.trim().length() == 0) { groupId = GLOBAL_GROUP_ID; } List<Dockable> compos = toolbarDockables.get(groupId); if (compos == null) { compos = new ArrayList<Dockable>(); } try { JComponent compo = (JComponent) element.createExecutableExtension(ATT_CLASS); Dockable dockable = new ButtonDockable(element.getAttribute(ATT_ID), compo); createDockableDragger(dockable); compos.add(dockable); } catch (Exception e) { e.printStackTrace(); } toolbarDockables.put(groupId, compos); } }
/** Reads all relevant extensions. */ private void extensionReader() { final IExtensionRegistry registry = Platform.getExtensionRegistry(); for (final IConfigurationElement ce : registry.getConfigurationElementsFor(InternalConstants.SCRIPT_ENGINES_EXTENSION_POINT)) { final String elementName = ce.getName(); if (elementName.equals(InternalConstants.ENGINE_TAG)) { final String language = ce.getAttribute(InternalConstants.LANGUAGE_TAG); if (language == null || language.length() == 0) { LogUtils.error( ce, InternalConstants.LANGUAGE_TAG + " must be specified. Ignored"); // $NON-NLS-1$ continue; } if (getEngines().get(language) != null) { LogUtils.error(ce, "Duplicate declaration of language '" + language + "'. Ignored."); continue; } final IScriptEngineDescriptor engine = IScriptEngineFactory.eINSTANCE.createScriptEngineDescriptor(); engine.init(language, ce); getEngines().put(language, engine); } else { LogUtils.error(ce, "Unknown tag: '" + ce.getName() + "'"); } } }
/** * Creates an extension. If the extension plugin has not been loaded, a busy cursor will be * activated during the duration of the load. * * @param element the config element defining the extension * @param classAttribute the name of the attribute carrying the class * @return the extension object */ public static Object createExtension( final IConfigurationElement element, final String classAttribute) throws CoreException { // If plugin has been loaded, create extension. // Otherwise, show busy cursor then create extension. String id = element.getContributor().getName(); Bundle bundle = Platform.getBundle(id); if (bundle.getState() == org.osgi.framework.Bundle.ACTIVE) { return element.createExecutableExtension(classAttribute); } final Object[] ret = new Object[1]; final CoreException[] exc = new CoreException[1]; BusyIndicator.showWhile( null, new Runnable() { @Override public void run() { try { ret[0] = element.createExecutableExtension(classAttribute); } catch (CoreException e) { exc[0] = e; } } }); if (exc[0] != null) throw exc[0]; return ret[0]; }
private boolean hasWizard() { DataSetTypeElement dTypeElement = (DataSetTypeElement) getSelectedDataSet(); if (dTypeElement == null) { return false; } if (dTypeElement instanceof OdaDataSetTypeElement) { // Get the currently selected Data Set type and invoke its wizard // class IConfigurationElement element = ((OdaDataSetTypeElement) dTypeElement).getIConfigurationElement(); if (element != null) { AbstractDataSetWizard newWizard = (AbstractDataSetWizard) htDataSetWizards.get(element.getAttribute("id")); // $NON-NLS-1$ if (newWizard != null) { return true; } // Get the new wizard from this element IConfigurationElement[] v3elements = element.getChildren("dataSetWizard"); // $NON-NLS-1$ IConfigurationElement[] v2elements = element.getChildren("newDataSetWizard"); // $NON-NLS-1$ if (v3elements.length > 0 || v2elements.length > 0) { return true; } } } else if (isScriptDataSet(dTypeElement.getDataSetTypeName())) { return true; } else return helper.hasWizard(getSelectedDataSource()); return false; }
/** * Returns the {@link INamespaceLabelProvider} for the given {@link ISourceModelElement}'s * namespace. */ public static INamespaceLabelProvider getLabelProvider(ISourceModelElement element) { IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(NAMESPACES_EXTENSION_POINT); if (point != null) { String namespaceURI = getNameSpaceURI(element); for (IExtension extension : point.getExtensions()) { for (IConfigurationElement config : extension.getConfigurationElements()) { if (namespaceURI.equals(config.getAttribute("uri"))) { if (config.getAttribute("labelProvider") != null) { try { Object provider = config.createExecutableExtension("labelProvider"); if (provider instanceof INamespaceLabelProvider) { return (INamespaceLabelProvider) provider; } } catch (CoreException e) { BeansUIPlugin.log(e); } } return null; } } } } return null; }
@Override protected void okPressed() { Iterator settingsIterator = selectedSettings.iterator(); MultiStatus result = new MultiStatus( PlatformUI.PLUGIN_ID, IStatus.OK, IDEWorkbenchMessages.ChooseWorkspaceWithSettingsDialog_ProblemsTransferTitle, null); IPath path = new Path(getWorkspaceLocation()); String[] selectionIDs = new String[selectedSettings.size()]; int index = 0; while (settingsIterator.hasNext()) { IConfigurationElement elem = (IConfigurationElement) settingsIterator.next(); result.add(transferSettings(elem, path)); selectionIDs[index] = elem.getAttribute(ATT_ID); } if (result.getSeverity() != IStatus.OK) { ErrorDialog.openError( getShell(), IDEWorkbenchMessages.ChooseWorkspaceWithSettingsDialog_TransferFailedMessage, IDEWorkbenchMessages.ChooseWorkspaceWithSettingsDialog_SaveSettingsFailed, result); return; } saveSettings(selectionIDs); super.okPressed(); }
/** * Returns this tab group's description in the given mode set. * * @param modes the set of modes * @return a description of the Launch Mode if available. If not available, attempts to return a * description of the Launch Configuration. If no appropriate description is found an empty * string is returned. */ public String getDescription(Set<String> modes) { String description = null; if (fDescriptions == null) { fDescriptions = new HashMap<Set<String>, String>(); IConfigurationElement[] children = fConfig.getChildren(IConfigurationElementConstants.LAUNCH_MODE); IConfigurationElement child = null; String mode = null; HashSet<String> set = null; for (int i = 0; i < children.length; i++) { child = children[i]; mode = child.getAttribute(IConfigurationElementConstants.MODE); if (mode != null) { set = new HashSet<String>(); set.add(mode); } description = child.getAttribute(IConfigurationElementConstants.DESCRIPTION); if (description != null) { fDescriptions.put(set, description); } } } description = fDescriptions.get(modes); if (description == null) { description = fConfig.getAttribute(IConfigurationElementConstants.DESCRIPTION); } return (description == null ? IInternalDebugCoreConstants.EMPTY_STRING : description); }
private List<Dependency> parseDependencies(IConfigurationElement element) { IConfigurationElement[] dependencyElements = element.getChildren("dependency"); // $NON-NLS-1$ if (dependencyElements == null) { return Collections.emptyList(); } List<Dependency> dependencies = new ArrayList<Dependency>(dependencyElements.length); for (IConfigurationElement dependencyElement : dependencyElements) { String artifactId = parseArtifactId(dependencyElement); String groupId = parseGroupId(dependencyElement); String scope = parseScope(dependencyElement); if (artifactId == null || artifactId.length() == 0 || groupId == null || groupId.length() == 0) { Activator.getDefault() .getLog() .log( new Status( Status.ERROR, Activator.PLUGIN_ID, Messages.SwitchYardComponentExtensionManager_InvalidDependencyStatus + element.getContributor().getName())); continue; } dependencies.add(M2EUtils.createSwitchYardDependency(groupId, artifactId, scope)); } return dependencies; }
/** * Runs an artifact analysis for the given file by searching the given extension point for an * {@link IArtifactAnalysis} that matches its language ID. * * <p>This is a utility method generally invoked from {@link #doArtifactAnalysis(ITranslationUnit, * List)}. * * <p>It is assumed that only one extension will be contributed per language ID. If multiple * extensions are found, it is unspecified which one will be run. * * @param extensionPointID * @param tu * @param includes * @param allowPrefixOnlyMatch * @return {@link ScanReturn} * @since 6.0 */ protected ScanReturn runArtifactAnalysisFromExtensionPoint( String extensionPointID, final ITranslationUnit tu, final List<String> includes, final boolean allowPrefixOnlyMatch) { try { final String languageID = tu.getLanguage().getId(); for (IConfigurationElement config : Platform.getExtensionRegistry().getConfigurationElementsFor(extensionPointID)) { try { if (languageID.equals(config.getAttribute("languageID"))) { IArtifactAnalysis artifactAnalysis = (IArtifactAnalysis) config.createExecutableExtension("class"); // $NON-NLS-1$ return artifactAnalysis.runArtifactAnalysis( languageID, tu, includes, allowPrefixOnlyMatch); } } catch (CoreException e) { CommonPlugin.log(e.getClass().getSimpleName() + ": " + e.getMessage()); } } } catch (CoreException e) { e.printStackTrace(); CommonPlugin.log( IStatus.ERROR, "RunAnalyseMPICommandHandler: Error setting up analysis for project " + tu.getCProject() + " error=" + e.getMessage()); // $NON-NLS-1$ //$NON-NLS-2$ } return new ScanReturn(); }
private static void loadSetupLibraries( final String id, final Map<String, String> filter, final IConfigurationElement[] configurationElements, final RSetup setup) throws Exception { for (int i = 0; i < configurationElements.length; i++) { final IConfigurationElement element = configurationElements[i]; if (element.getName().equals(LIBRARY_ELEMENT_NAME) && id.equals(element.getAttribute(SETUP_ID_ATTRIBUTE_NAME))) { final String path = getLocation(element, filter); if (path == null) { continue; } final String groupId = element.getAttribute(GROUP_ATTRIBUTE_NAME); if (groupId == null || groupId.length() == 0 || groupId.equals("R_LIBS")) { // $NON-NLS-1$ setup.getRLibs().add(path); } else if (groupId.equals("R_LIBS_SITE")) { // $NON-NLS-1$ setup.getRLibsSite().add(path); } else if (groupId.equals("R_LIBS_USER")) { // $NON-NLS-1$ setup.getRLibsUser().add(path); } else { log( IStatus.WARNING, "Invalid R setup element: " + "Unknown library group '" + groupId + "', the library is ignored", element); } } } }
public void setClient(WebView view) { this.view = view; this.engine = view.getEngine(); JSObject window = (JSObject) engine.executeScript("window"); window.setMember("ide", this); Collection<IEclipseToBrowserFunction> onLoadFunctions = new ArrayList<IEclipseToBrowserFunction>(); IConfigurationElement[] extensions = BrowserExtensions.getExtensions( BrowserExtensions.EXTENSION_ID_ECLIPSE_TO_BROWSER, null, view.getEngine().locationProperty().get()); for (IConfigurationElement element : extensions) { try { String onLoad = element.getAttribute(BrowserExtensions.ELEMENT_ONLOAD); if (onLoad != null && onLoad.equals("true")) { onLoadFunctions.add( (IEclipseToBrowserFunction) WorkbenchPlugin.createExtension(element, BrowserExtensions.ELEMENT_CLASS)); } } catch (CoreException ex) { StatusManager.getManager() .handle( new Status( IStatus.ERROR, IdeUiPlugin.PLUGIN_ID, "Could not instantiate browser element provider extension.", ex)); return; } } callOnBrowser(onLoadFunctions); }
private static RSetup loadSetup( final String id, final Map<String, String> filter, final IConfigurationElement[] configurationElements) { try { for (int i = 0; i < configurationElements.length; i++) { final IConfigurationElement element = configurationElements[i]; if (element.getName().equals(SETUP_ELEMENT_NAME) && id.equals(element.getAttribute(ID_ATTRIBUTE_NAME))) { final RSetup setup = new RSetup(id); if (filter != null && filter.containsKey("$os$")) { // $NON-NLS-1$ setup.setOS(filter.get("$os$"), filter.get("$arch$")); // $NON-NLS-1$ //$NON-NLS-2$ } else { setup.setOS(Platform.getOS(), Platform.getOSArch()); } setup.setName(element.getAttribute(NAME_ATTRIBUTE_NAME)); loadSetupBase(id, filter, configurationElements, setup); if (setup.getRHome() == null) { log( IStatus.WARNING, "Incomplete R setup: Missing R home for setup '" + id + "', the setup is ignored.", element); return null; } loadSetupLibraries(id, filter, configurationElements, setup); return setup; } } } catch (final Exception e) { LOGGER.log( new Status(IStatus.ERROR, PLUGIN_ID, "Error in R setup: Failed to load setup.", e)); } return null; }
@Override public void addExtension(IExtensionTracker tracker, IExtension extension) { IConfigurationElement[] elements = extension.getConfigurationElements(); for (int i = 0; i < elements.length; i++) { IConfigurationElement element = elements[i]; if (element.getName().equals(tag)) { String id = element.getAttribute(IWorkbenchRegistryConstants.ATT_ID); String file = element.getAttribute(IWorkbenchRegistryConstants.ATT_ICON); if (file == null || id == null) { Persistence.log( element, Persistence.ACTIVITY_IMAGE_BINDING_DESC, "definition must contain icon and ID"); //$NON-NLS-1$ continue; // ignore - malformed } if (registry.getDescriptor(id) == null) { // first come, first serve ImageDescriptor descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(element.getNamespace(), file); if (descriptor != null) { registry.put(id, descriptor); tracker.registerObject(extension, id, IExtensionTracker.REF_WEAK); } } } } }
/** 加载记忆库匹配实现 ; */ private void runExtension() { IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(TMIMPORTER_EXTENSION_ID); try { for (IConfigurationElement e : config) { final Object o = e.createExecutableExtension("class"); if (o instanceof ITmImporter) { ISafeRunnable runnable = new ISafeRunnable() { public void handleException(Throwable exception) { logger.error(Messages.getString("importer.TmImporter.logger1"), exception); } public void run() throws Exception { tmImporter = (ITmImporter) o; } }; SafeRunner.run(runnable); } } } catch (CoreException ex) { logger.error(Messages.getString("importer.TmImporter.logger1"), ex); } }
/** @param viewer */ private void addDndSupport(GraphicalViewer viewer, String type) { IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(UMLPlugin.PLUGIN_ID, "dnd"); IExtension[] extensions = point.getExtensions(); for (int i = 0; i < extensions.length; i++) { IExtension extension = extensions[i]; IConfigurationElement[] elements = extension.getConfigurationElements(); for (int j = 0; j < elements.length; j++) { IConfigurationElement element = elements[j]; try { Object object = element.createExecutableExtension("class"); if (object instanceof UMLDropTargetListenerFactory) { UMLDropTargetListenerFactory factory = (UMLDropTargetListenerFactory) object; if (factory.accept(type)) { TransferDropTargetListener targetListener = factory.getDropTargetListener(viewer); viewer.addDropTargetListener(targetListener); } } } catch (CoreException e) { e.printStackTrace(); } finally { } } } }
private IEvaluatedType evaluateType(AbstractTypeGoal goal, int time, List list) { Set typeSet = new HashSet(); for (Iterator iterator = list.iterator(); iterator.hasNext(); ) { IConfigurationElement element = (IConfigurationElement) iterator.next(); ITypeInferencer ti; try { ti = (ITypeInferencer) element.createExecutableExtension("evaluator"); // $NON-NLS-1$ } catch (CoreException e) { e.printStackTrace(); continue; } // ITypeInferencer ti = (ITypeInferencer) // iterator.next(); IEvaluatedType type = ti.evaluateType(goal, time); if (type != null && !(type instanceof UnknownType)) { if (type instanceof AmbiguousType) { flattenTypes((AmbiguousType) type, typeSet); } else { typeSet.add(type); } } } if ((typeSet.size() > 1) && (goal.getContext() instanceof BasicContext)) { reduceTypes((BasicContext) goal.getContext(), typeSet); } if (typeSet.size() == 1) { return (IEvaluatedType) typeSet.iterator().next(); } else if (typeSet.size() > 1) { return new AmbiguousType( (IEvaluatedType[]) typeSet.toArray(new IEvaluatedType[typeSet.size()])); } else { return null; } }
EngineExtensionManager() { IExtensionRegistry registry = Platform.getExtensionRegistry(); IExtensionPoint extensionPoint = registry.getExtensionPoint("org.eclipse.birt.core.FactoryService"); IExtension[] extensions = extensionPoint.getExtensions(); for (IExtension extension : extensions) { IConfigurationElement[] elements = extension.getConfigurationElements(); for (IConfigurationElement element : elements) { String type = element.getAttribute("type"); if ("org.eclipse.birt.report.engine.extension".equals(type)) { try { Object factoryObject = element.createExecutableExtension("class"); if (factoryObject instanceof IReportEngineExtensionFactory) { IReportEngineExtensionFactory factory = (IReportEngineExtensionFactory) factoryObject; IReportEngineExtension engineExtension = factory.createExtension(ReportEngine.this); exts.put(engineExtension.getExtensionName(), engineExtension); } } catch (CoreException ex) { logger.log(Level.WARNING, "can not load the engine extension factory", ex); } } } } }
static { IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(TYPE_EVALUATORS); IExtension[] ext = extensionPoint.getExtensions(); // ArrayList resolvers = new ArrayList(); for (int a = 0; a < ext.length; a++) { IConfigurationElement[] elements = ext[a].getConfigurationElements(); IConfigurationElement myElement = elements[0]; try { String nature = myElement.getAttribute(NATURE); List list = (List) evaluatorsByNatures.get(nature); if (list == null) { list = new ArrayList(); evaluatorsByNatures.put(nature, list); } // ITypeInferencer resolver = (ITypeInferencer) myElement // .createExecutableExtension("evaluator"); // resolvers.add(resolver); // list.add(resolver); list.add(myElement); } catch (Exception e) { e.printStackTrace(); } } }
private static void initializeClientContextIDs() { registeredClientContextIds = new java.util.HashSet<String>(); IExtensionPoint extPoint = Platform.getExtensionRegistry().getExtensionPoint(EP_UI_REGISTERED_CLIENT_CONTEXTS); for (IExtension extension : extPoint.getExtensions()) { for (IConfigurationElement next : extension.getConfigurationElements()) { registeredClientContextIds.add(next.getAttribute(A_ID)); } } IExtensionTracker extTracker = ValidationUIPlugin.getExtensionTracker(); if (extTracker != null) { IExtensionChangeHandler extensionHandler = new IExtensionChangeHandler() { public void addExtension(IExtensionTracker tracker, IExtension extension) { addClientContextIDs(extension.getConfigurationElements()); } public void removeExtension(IExtension extension, Object[] objects) { // client-context IDs cannot be undefined } }; extTracker.registerHandler( extensionHandler, ExtensionTracker.createExtensionPointFilter(extPoint)); } }
@Override protected List<Object> getKeys() { List<Object> keys = new ArrayList<Object>(); List<IConfigurationElement> proxyElements = ToolchainExtensions.getInstance().findExplorerProxyNodes(element); List<IConfigurationElement> children = new ArrayList<IConfigurationElement>(); Collections.addAll(children, element.getChildren()); for (IConfigurationElement proxy : proxyElements) { Collections.addAll(children, proxy.getChildren()); } for (IConfigurationElement el : children) { if (ToolchainExtensions.NODE_EXTENSION_NAME.equals(el.getName())) { keys.add(new Key(el, null)); } if (ToolchainExtensions.NODE_RESOURCE_EXTENSION_NAME.equals(el.getName())) { keys.add(new Key(el, null)); } if (ToolchainExtensions.NODE_DYNAMIC_EXTENSION_NAME.equals(el.getName())) { try { IExplorerContentRetriever contentRetriever = contentRetrievers.get(el); if (contentRetriever == null) { contentRetriever = (IExplorerContentRetriever) el.createExecutableExtension("class"); contentRetriever.initialize(el.getAttribute("id"), getNode().getContext()); contentRetriever.addPropertyChangeListener(contentRetrieverListener); contentRetrievers.put(el, contentRetriever); } if (contentRetriever != null) { List<Object> contentList = contentRetriever.getChildren(); if (contentList.isEmpty()) { String emptyNodeID = el.getAttribute("empty"); if (emptyNodeID != null && !emptyNodeID.isEmpty()) { keys.add(new Key(el, null)); } } else { for (Object content : contentList) { keys.add(new Key(el, content)); } } } } catch (CoreException e) { e.printStackTrace(); } } } return keys; }