Java Code Examples for org.eclipse.core.runtime.IConfigurationElement#createExecutableExtension()

The following examples show how to use org.eclipse.core.runtime.IConfigurationElement#createExecutableExtension() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConfigurationWizard.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void addPages() {
    final IConfigurationElement[] elems = BonitaStudioExtensionRegistryManager.getInstance()
            .getConfigurationElements(CONFIGURATION_WIZARD_PAGE_ID);
    final List<IConfigurationElement> elements = sortByPriority(elems);
    for (final IConfigurationElement e : elements) {
        try {
            final IProcessConfigurationWizardPage page = (IProcessConfigurationWizardPage) e
                    .createExecutableExtension(CLASS_ATTRIBUTE);
            addPage(page);
        } catch (final Exception e1) {
            BonitaStudioLog.error(e1);
        }
    }
    addPage(new JavaDependenciesConfigurationWizardPage());
    addPage(new RunConfigurationWizardPage());
}
 
Example 2
Source File: BarExporter.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected BARResourcesProvider getBARApplicationResourcesProvider() {
    BARResourcesProvider result = null;
    int maxPriority = -1;
    final IConfigurationElement[] extensions = BonitaStudioExtensionRegistryManager.getInstance()
            .getConfigurationElements(
                    BAR_APPLICATION_RESOURCE_PROVIDERS_EXTENSION_POINT);
    for (final IConfigurationElement extension : extensions) {

        try {
            final int p = Integer.parseInt(extension.getAttribute("priority"));
            if (p >= maxPriority) {

                result = (BARResourcesProvider) extension.createExecutableExtension("providerClass");
                maxPriority = p;
            }
        } catch (final Exception ex) {
            BonitaStudioLog.error(ex);
        }
    }
    return result;
}
 
Example 3
Source File: SVNUIPlugin.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public static ISVNRepositorySourceProvider[] getRepositorySourceProviders() throws Exception {
	if (repositorySourceProviders == null) {
		List<ISVNRepositorySourceProvider> repositorySourceProviderList = new ArrayList<ISVNRepositorySourceProvider>();
		IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
		IConfigurationElement[] configurationElements = extensionRegistry.getConfigurationElementsFor(REPOSITORY_SOURCE_PROVIDERS);
		for (int i = 0; i < configurationElements.length; i++) {
			IConfigurationElement configurationElement = configurationElements[i];
			ISVNRepositorySourceProvider repositorySourceProvider = (ISVNRepositorySourceProvider)configurationElement.createExecutableExtension("class"); //$NON-NLS-1$
			repositorySourceProvider.setId(configurationElement.getAttribute("id")); //$NON-NLS-1$
			repositorySourceProviderList.add(repositorySourceProvider);
		}
		repositorySourceProviders = new ISVNRepositorySourceProvider[repositorySourceProviderList.size()];
		repositorySourceProviderList.toArray(repositorySourceProviders);
		Arrays.sort(repositorySourceProviders, new Comparator<ISVNRepositorySourceProvider>() {
			public int compare(ISVNRepositorySourceProvider o1, ISVNRepositorySourceProvider o2) {
				return o1.getName().compareTo(o2.getName());
			}		
		});
	}
	return repositorySourceProviders;
}
 
Example 4
Source File: ObservableListContentProviderWithProposalListeners.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected void initProposalListeners(final EObject context) {
    proposalListeners.clear();
    final IConfigurationElement[] configurationElements = BonitaStudioExtensionRegistryManager.getInstance()
            .getConfigurationElements(PROPOSAL_LISTENER_EXTENSION_ID);
    // Filters duplicates
    for (final IConfigurationElement configElement : configurationElements) {
        final String type = configElement.getAttribute("type");
        if (type.equals(ExpressionConstants.VARIABLE_TYPE)) {
            IDataProposalListener extension;
            try {
                extension = (IDataProposalListener) configElement.createExecutableExtension("providerClass");
                if (extension.isRelevant(context, null) && !proposalListeners.contains(extension)) {
                    extension.setMultipleData(isMultipleData());
                    proposalListeners.add(extension);
                }
            } catch (final CoreException e) {
                BonitaStudioLog.error(e);
            }

        }
    }
}
 
Example 5
Source File: AbstractSliceSystem.java    From dawnsci with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 
 * @param e
 * @return
 */
private ISlicingTool createSliceTool(IConfigurationElement e) {
   	
	ISlicingTool tool = null;
   	try {
   		tool  = (ISlicingTool)e.createExecutableExtension("class");
   	} catch (Throwable ne) {
   		logger.error("Cannot create tool page "+e.getAttribute("class"), ne);
   		return null;
   	}
   	tool.setToolId(e.getAttribute("id"));	       	
   	tool.setSlicingSystem(this);
   	
   	// TODO Provide the tool with a reference to the part with the
   	// slice will end up being showed in?
   	
   	return tool;
}
 
Example 6
Source File: TmMatcher.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 加哉记忆库匹配实现 ;
 */
private void runExtension() {
	IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(
			TMMATCH_EXTENSION_ID);
	try {
		for (IConfigurationElement e : config) {
			final Object o = e.createExecutableExtension("class");
			if (o instanceof ITmMatch) {
				ISafeRunnable runnable = new ISafeRunnable() {

					public void handleException(Throwable exception) {
						logger.error(Messages.getString("match.TmMatcher.logger1"), exception);
					}

					public void run() throws Exception {
						tmTranslation = (ITmMatch) o;
					}
				};
				SafeRunner.run(runnable);
			}
		}
	} catch (CoreException ex) {
		logger.error(Messages.getString("match.TmMatcher.logger1"), ex);
	}
}
 
Example 7
Source File: CodeGenerators.java    From JReFrameworker with MIT License 6 votes vote down vote up
/**
 * Registers the contributed plugin code generator definitions
 */
public static void loadCodeGeneratorContributions() {
	IExtensionRegistry registry = Platform.getExtensionRegistry();
	IConfigurationElement[] config = registry.getConfigurationElementsFor(Activator.PLUGIN_CODE_GENERATOR_EXTENSION_ID);
	try {
		for (IConfigurationElement element : config) {
			final Object o = element.createExecutableExtension("class");
			if (o instanceof CodeGenerator) {
				CodeGenerator codeGenerator = (CodeGenerator) o;
				registerCodeGenerator(codeGenerator);
			}
		}
	} catch (CoreException e) {
		Log.error("Error loading code generators.", e);
	}
}
 
Example 8
Source File: NewProjectWizardTemplateSelectionPage.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private AbstractProjectTemplate[] loadTemplatesFromExtensionPoint() {
	List<AbstractProjectTemplate> result = new ArrayList<>();
	for (IConfigurationElement element : Platform.getExtensionRegistry()
			.getConfigurationElementsFor(PROJECT_TEMPLATE_PROVIDER_EXTENSION_POINT_ID)) {
		if (PROJECT_TEMPLATE_PROVIDER_ID.equals(element.getName())
				&& grammarName.equals(element.getAttribute(PROJECT_TEMPLATE_PROVIDER_GRAMMAR_NAME_ATTRIBUTE))) {
			try {
				IProjectTemplateProvider provider = (IProjectTemplateProvider) element
						.createExecutableExtension(PROJECT_TEMPLATE_PROVIDER_GRAMMAR_CLASS_ATTRIBUTE);
				result.addAll(Arrays.asList(provider.getProjectTemplates()));
			} catch (CoreException e) {
				logger.error("Can not instantiate '" + element.getAttribute(PROJECT_TEMPLATE_PROVIDER_GRAMMAR_CLASS_ATTRIBUTE) + "'", //$NON-NLS-1$ //$NON-NLS-2$
						e);
			}
		}
	}
	return result.toArray(new AbstractProjectTemplate[0]);
}
 
Example 9
Source File: OnDemandAnalysisManager.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Private constructor, should only be called via {@link #getInstance()}.
 */
private OnDemandAnalysisManager() {
    fAnalysisWrappers = new HashSet<>();
    IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_POINT_ID);

    for (IConfigurationElement element : configElements) {
        if (ELEM_NAME_ANALYSIS.equals(element.getName())) {
            try {
                Object extension = element.createExecutableExtension(ATTR_CLASS);
                if (extension != null) {
                    fAnalysisWrappers.add(new OndemandAnalysisWrapper((IOnDemandAnalysis) extension));
                }
            } catch (CoreException | ClassCastException e) {
                Activator.logError("Exception while loading extension point", e); //$NON-NLS-1$
            }
        }
    }
}
 
Example 10
Source File: Fall.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Retrieve the ooutputter for this case's billing system
 * 
 * @return the IRnOutputter that will be used or null if none was found
 */
public IRnOutputter getOutputter(){
	String outputterName = getOutputterName();
	if (outputterName.length() > 0) {
		List<IConfigurationElement> list =
			Extensions.getExtensions(ExtensionPointConstantsData.RECHNUNGS_MANAGER); //$NON-NLS-1$
		for (IConfigurationElement ic : list) {
			if (ic.getAttribute("name").equals(outputterName)) { //$NON-NLS-1$
				try {
					IRnOutputter ret = (IRnOutputter) ic.createExecutableExtension("outputter"); //$NON-NLS-1$
					return ret;
				} catch (CoreException e) {
					ExHandler.handle(e);
				}
			}
		}
	}
	return null;
}
 
Example 11
Source File: ScriptLanguageService.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public Set<IScriptLanguageProvider> getScriptLanguageProviders() {
	if(scriptProviders == null){
		scriptProviders = new HashSet<IScriptLanguageProvider>() ;
		IConfigurationElement[] elements = BonitaStudioExtensionRegistryManager.getInstance().getConfigurationElements(SCRIPT_LANGUAGE_EXTENSION_ID) ;
		for(IConfigurationElement element : elements){
			try {
				IScriptLanguageProvider provider = (IScriptLanguageProvider) element.createExecutableExtension(PROVIDER_CLASS_ATTRIBUTE) ;
				scriptProviders.add(provider) ;
			}catch (Exception e) {
				BonitaStudioLog.error(e) ;
			}
		}
	}
	return scriptProviders;
}
 
Example 12
Source File: CodeDetailView.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private void addPagesFor(String point){
	List<IConfigurationElement> list = Extensions.getExtensions(point);
	for (IConfigurationElement ce : list) {
		try {
			if ("Artikel".equals(ce.getName())) { //$NON-NLS-1$
				continue;
			}
			IDetailDisplay detailDisplay =
				(IDetailDisplay) ce.createExecutableExtension(ExtensionPointConstantsUi.VERRECHNUNGSCODE_CDD);
			CodeSelectorFactory codeSelector =
				(CodeSelectorFactory) ce.createExecutableExtension(ExtensionPointConstantsUi.VERRECHNUNGSCODE_CSF);
			String a = ce.getAttribute(ExtensionPointConstantsUi.VERRECHNUNGSCODE_IMPC);
			ImporterPage ip = null;
			if (a != null) {
				ip = (ImporterPage) ce.createExecutableExtension(ExtensionPointConstantsUi.VERRECHNUNGSCODE_IMPC);
				if (ip != null) {
					importers.put(detailDisplay.getTitle(), ip);
				}
			}
			MasterDetailsPage page = new MasterDetailsPage(ctab, codeSelector, detailDisplay);
			CTabItem ct = new CTabItem(ctab, SWT.NONE);
			ct.setText(detailDisplay.getTitle());
			ct.setControl(page);
			ct.setData(detailDisplay);
			
			CoreUiUtil.injectServicesWithContext(codeSelector);
			CoreUiUtil.injectServicesWithContext(detailDisplay);
		} catch (Exception ex) {
			LoggerFactory.getLogger(getClass()).error("Error creating pages", ex);
			ElexisStatus status =
				new ElexisStatus(ElexisStatus.WARNING, Hub.PLUGIN_ID, ElexisStatus.CODE_NONE,
					"Fehler beim Initialisieren von " + ce.getName(), ex,
					ElexisStatus.LOG_WARNINGS);
			StatusManager.getManager().handle(status, StatusManager.SHOW);
		}
	}
}
 
Example 13
Source File: ProjectSettingHandler.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 加载扩展向导页 ;
 */
private void runWizardPageExtension() {
	IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(
			"net.heartsome.cat.ts.ui.extensionpoint.projectsetting");
	try {
		// 修改术语库重复
		extensionPages.clear();
		for (IConfigurationElement e : config) {
			final Object o = e.createExecutableExtension("class");
			if (o instanceof AbstractProjectSettingPage) {
				ISafeRunnable runnable = new ISafeRunnable() {

					public void handleException(Throwable exception) {
						logger.error(Messages.getString("handlers.ProjectSettingHandler.logger1"), exception);
					}

					public void run() throws Exception {
						extensionPages.add((AbstractProjectSettingPage) o);
					}
				};
				SafeRunner.run(runnable);
			}
		}
	} catch (CoreException ex) {
		logger.error(Messages.getString("handlers.ProjectSettingHandler.logger1"), ex);
	}
}
 
Example 14
Source File: PlottingFactory.java    From dawnsci with Eclipse Public License 1.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private static final <T> IPlottingSystem<T> createPlottingSystem(final String plottingSystemId) throws CoreException {
	
       IConfigurationElement[] systems = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.dawnsci.plotting.api.plottingClass");
       for (IConfigurationElement ia : systems) {
		if (ia.getAttribute("id").equals(plottingSystemId)) return (IPlottingSystem<T>)ia.createExecutableExtension("class");
	}
	
       return null;
}
 
Example 15
Source File: Repository.java    From textuml with Eclipse Public License 1.0 5 votes vote down vote up
private void initWeaver() {
    String weaverName = getProperties().getProperty(WEAVER);
    IExtensionPoint point = RegistryFactory.getRegistry().getExtensionPoint(MDDCore.PLUGIN_ID, "modelWeaver");
    IConfigurationElement[] elements = point.getConfigurationElements();
    for (IConfigurationElement current : elements)
        if (weaverName.equals(current.getAttribute("name"))) {
            try {
                weaver = (IModelWeaver) current.createExecutableExtension("class");
            } catch (CoreException e) {
                LogUtils.logError(MDDCore.PLUGIN_ID, "Could not instantiate weaver: " + weaverName, e);
            }
            return;
        }
}
 
Example 16
Source File: WorldRunner.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
private NodeElementProcessor createProcessor ( final EObject element, final World world, final ApplicationNode applicationNode ) throws CoreException
{
    final EAnnotation an = element.eClass ().getEAnnotation ( "http://eclipse.org/SCADA/Configuration/World" );

    if ( an != null && Boolean.parseBoolean ( an.getDetails ().get ( "ignore" ) ) )
    {
        return new NodeElementProcessor () {

            @Override
            public void process ( final String phase, final IFolder baseDir, final IProgressMonitor monitor, final Map<String, String> properties ) throws Exception
            {
                // no-op
            }
        };
    }

    for ( final IConfigurationElement ele : Platform.getExtensionRegistry ().getConfigurationElementsFor ( Activator.EXTP_GENERATOR ) )
    {
        if ( !ele.getName ().equals ( ELE_NODE_ELEMENT_PROCESSOR ) )
        {
            continue;
        }
        if ( isMatch ( Activator.getDefault ().getBundle ().getBundleContext (), ele, element ) )
        {
            final NodeElementProcessorFactory factory = (NodeElementProcessorFactory)ele.createExecutableExtension ( "factoryClass" );
            return factory.createProcessor ( element, world, applicationNode );
        }
    }

    throw new IllegalStateException ( String.format ( "No processor found for element: %s", element ) );
}
 
Example 17
Source File: SVNProviderPlugin.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public static IMessageHandler[] getMessageHandlers() throws Exception {
	if (messageHandlers == null) {
		ArrayList<IMessageHandler> messageHandlerList = new ArrayList<IMessageHandler>();
		IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
		IConfigurationElement[] configurationElements = extensionRegistry.getConfigurationElementsFor(MESSAGE_HANDLERS);
		for (int i = 0; i < configurationElements.length; i++) {
			IConfigurationElement configurationElement = configurationElements[i];
			IMessageHandler messageHandler = (IMessageHandler)configurationElement.createExecutableExtension("class"); //$NON-NLS-1$
			messageHandlerList.add(messageHandler);
		}
		messageHandlers = new IMessageHandler[messageHandlerList.size()];
		messageHandlerList.toArray(messageHandlers);	
	}
	return messageHandlers;
}
 
Example 18
Source File: EvaluateExtentionHandler.java    From developer-studio with Apache License 2.0 5 votes vote down vote up
public void execute(IExtensionRegistry registry) {
	IConfigurationElement[] config = registry.getConfigurationElementsFor(ExtentionPoint_ID);
	try {
		for (IConfigurationElement e : config) {
			final Object o = e.createExecutableExtension("class");
			if (o instanceof IResourceManager) {
				executeExtension(o);
			}
		}
	} catch (CoreException ex) {
		log.error("Error while finding " + ExtentionPoint_ID, ex);
	}
}
 
Example 19
Source File: ValidationRunner.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
protected boolean runElement ( final EObject element, final DiagnosticChain diagnostics, final Map<Object, Object> context )
{
    if ( element == null )
    {
        return true;
    }

    if ( isCached ( element, context ) )
    {
        return true;
    }

    final String packageUri = element.eClass ().getEPackage ().getNsURI ();
    if ( packageUri == null )
    {
        return false;
    }

    boolean result = true;

    for ( final IConfigurationElement ele : Platform.getExtensionRegistry ().getConfigurationElementsFor ( "org.eclipse.scada.utils.ecore.validation.handler" ) )
    {
        if ( !ele.getName ().equals ( "validationContext" ) )
        {
            continue;
        }

        final String uri = ele.getAttribute ( "packageUri" );
        if ( !packageUri.equals ( uri ) )
        {
            continue;
        }

        final String contextId = ele.getAttribute ( "contextId" );

        for ( final IConfigurationElement child : ele.getChildren ( "validator" ) )
        {
            if ( !child.getName ().equals ( "validator" ) )
            {
                continue;
            }

            if ( !isTargetMatch ( element.getClass (), child ) )
            {
                continue;
            }

            try
            {
                final Object o = child.createExecutableExtension ( "class" );
                if ( o instanceof Validator )
                {
                    final Validator v = (Validator)o;
                    final ValidationContextImpl validationContext = new ValidationContextImpl ( contextId, element );
                    v.validate ( validationContext );
                    if ( !validationContext.apply ( diagnostics ) )
                    {
                        result = false;
                    }
                }
            }
            catch ( final CoreException e )
            {
                ValidationPlugin.getDefault ().getLog ().log ( e.getStatus () );
                throw new IllegalStateException ( e );
            }
        }
    }

    return result;
}
 
Example 20
Source File: GeneratorLocator.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
public Map<Class<?>, Set<GeneratorFactory>> getFactories ()
{
    if ( this.cache == null )
    {
        logger.info ( "Rebuild factory cache" );

        this.cache = new HashMap<> ();
        for ( final IConfigurationElement ele : Platform.getExtensionRegistry ().getConfigurationElementsFor ( EXTP_GENERATOR_FACTORY ) )
        {
            if ( !ELE_FACTORY.equals ( ele.getName () ) )
            {
                continue;
            }

            logger.debug ( "Checking factory - factory: {}", ele.getAttribute ( ATTR_CLASS ) );

            GeneratorFactory factory;
            try
            {
                factory = (GeneratorFactory)ele.createExecutableExtension ( ATTR_CLASS );
            }
            catch ( final CoreException e )
            {
                this.log.log ( e.getStatus () );
                logger.warn ( "Failed to create factory", e );
                continue;
            }

            for ( final IConfigurationElement child : ele.getChildren ( ELE_GENERATE_FOR ) )
            {
                logger.debug ( "Checking for -> {}", child.getAttribute ( ATTR_CLASS ) );

                final Class<?> sourceClass = makeSourceClass ( child );
                if ( sourceClass != null )
                {
                    addCacheEntry ( sourceClass, factory );
                }
            }
        }
    }
    return this.cache;
}