Java Code Examples for org.eclipse.core.runtime.IConfigurationElement

The following are top voted examples for showing how to use org.eclipse.core.runtime.IConfigurationElement. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: n4js   File: TesterRegistry.java   View source code 6 votes vote down vote up
/**
 * Reads information from extensions defined in plugin.xml files.
 */
private void initialize() {
	if (isInitialized)
		throw new IllegalStateException("may invoke method initialize() only once");
	isInitialized = true;

	final IExtensionRegistry registry = RegistryFactory.getRegistry();
	if (registry != null) {
		final IConfigurationElement[] configElems = registry
				.getConfigurationElementsFor(TESTERS_EXTENSION_POINT_ID);

		for (IConfigurationElement elem : configElems) {
			try {
				final EclipseTesterDescriptor descriptor = new EclipseTesterDescriptor(elem);
				injector.injectMembers(descriptor);
				register(descriptor);
			} catch (Exception ex) {
				log.error("Error while reading extensions for extension point " + TESTERS_EXTENSION_POINT_ID, ex);
			}
		}
	}
}
 
Example 2
Project: n4js   File: RunnerRegistry.java   View source code 6 votes vote down vote up
/**
 * Reads information from extensions defined in plugin.xml files.
 */
private void initialize() {
	if (isInitialized)
		throw new IllegalStateException("may invoke method initialize() only once");
	isInitialized = true;

	final IExtensionRegistry registry = RegistryFactory.getRegistry();
	if (registry != null) {
		final IConfigurationElement[] configElems = registry
				.getConfigurationElementsFor(RUNNERS_EXTENSION_POINT_ID);

		for (IConfigurationElement elem : configElems) {
			try {
				final EclipseRunnerDescriptor descriptor = new EclipseRunnerDescriptor(elem);
				injector.injectMembers(descriptor);
				register(descriptor);
			} catch (Exception ex) {
				log.error("Error while reading extensions for extension point " + RUNNERS_EXTENSION_POINT_ID, ex);
			}
		}
	}
}
 
Example 3
Project: n4js   File: WorkingSetManagerBrokerImpl.java   View source code 6 votes vote down vote up
private Supplier<Map<String, WorkingSetManager>> initContributions() {

		return memoize(() -> {

			if (!isRunning()) {
				return emptyMap();
			}

			final Builder<String, WorkingSetManager> builder = ImmutableMap.builder();
			final IConfigurationElement[] elements = getExtensionRegistry()
					.getConfigurationElementsFor(EXTENSION_POINT_ID);
			for (final IConfigurationElement element : elements) {
				try {
					final WorkingSetManager manager = (WorkingSetManager) element
							.createExecutableExtension(CLASS_ATTRIBUTE);
					injector.injectMembers(manager);
					builder.put(manager.getId(), manager);
				} catch (final CoreException e) {
					LOGGER.error("Error while trying to instantiate working set manager.", e);
				}
			}

			return builder.build();
		});
	}
 
Example 4
Project: n4js   File: DelegatingQuickfixProvider.java   View source code 6 votes vote down vote up
private static Builder<DefaultQuickfixProvider> collectRegisteredProviders() {
	final Builder<DefaultQuickfixProvider> builder = ImmutableList.<DefaultQuickfixProvider> builder();
	if (Platform.isRunning()) {
		final IConfigurationElement[] elements = getQuickfixSupplierElements();
		for (final IConfigurationElement element : elements) {
			try {
				final Object extension = element.createExecutableExtension(CLAZZ_PROPERTY_NAME);
				if (extension instanceof QuickfixProviderSupplier) {
					builder.add(((QuickfixProviderSupplier) extension).get());
				}
			} catch (final CoreException e) {
				LOGGER.error("Error while instantiating quickfix provider supplier instance.", e);
			}
		}
	}
	return builder;
}
 
Example 5
Project: AgentWorkbench   File: EvaluateContributionsHandler.java   View source code 6 votes vote down vote up
/**
 * Execute.
 * @param registry the registry
 */
@Execute
   public void execute() {
       
   	System.out.println("Start evaluating available extensions");
   	IConfigurationElement[] config = this.getExtensionRegistry().getConfigurationElementsFor(PLUGIN_ID);
   	
       try {
       	
           for (IConfigurationElement e : config) {
               System.out.println("Evaluating extension " + e.getName());
               final Object object = e.createExecutableExtension("class");
               if (object instanceof PlugIn) {
                   executeExtension(object);
               }
           }
       } catch (CoreException ex) {
           System.err.println(ex.getMessage());
       }
   }
 
Example 6
Project: gemoc-studio-modeldebugging   File: Activator.java   View source code 6 votes vote down vote up
/**
 * Retrieve all the locators registered with the extension point, and additionally store them in a cache.
 * 
 * @return All locators registered with the extension point.
 */
public List<ILocator> retrieveLocators() {
	if (locators == null) {
		IExtensionRegistry reg = Platform.getExtensionRegistry();
		IExtensionPoint ep = reg.getExtensionPoint("org.eclipse.gemoc.dsl.debug.locator");
		IExtension[] extensions = ep.getExtensions();
		ArrayList<ILocator> contributors = new ArrayList<ILocator>();
		for (int i = 0; i < extensions.length; i++) {
			IExtension ext = extensions[i];
			IConfigurationElement[] ce = ext.getConfigurationElements();
			for (int j = 0; j < ce.length; j++) {
				ILocator locator;
				try {
					locator = (ILocator)ce[j].createExecutableExtension("class");
					contributors.add(locator);
				} catch (CoreException e) {
					e.printStackTrace();
				}
			}
		}
		locators = contributors;
	}
	return locators;
}
 
Example 7
Project: gemoc-studio-modeldebugging   File: MelangeHelper.java   View source code 6 votes vote down vote up
/**
 * Return a bundle with a .melange declaring 'language'
 */
public static Bundle getMelangeBundle(String languageName){
	
	IConfigurationElement[] melangeLanguages = Platform
			.getExtensionRegistry().getConfigurationElementsFor(
					"fr.inria.diverse.melange.language");
	String melangeBundleName = "";
	
	for (IConfigurationElement lang : melangeLanguages) {
		if(lang.getAttribute("id").equals(languageName)){
			melangeBundleName = lang.getContributor().getName();
			return Platform.getBundle(melangeBundleName);
		}
	}
	
	return null;
}
 
Example 8
Project: gemoc-studio-modeldebugging   File: MelangeHelper.java   View source code 6 votes vote down vote up
/**
 * Return all ModelTypes matching 'language'
 */
public static List<String> getModelTypes(String language){
	List<String> modelTypeNames = new ArrayList<String>();
	IConfigurationElement[] melangeLanguages = Platform
			.getExtensionRegistry().getConfigurationElementsFor(
					"fr.inria.diverse.melange.language");
	for (IConfigurationElement lang : melangeLanguages) {
		if (lang.getAttribute("id").equals(language)) {
			IConfigurationElement[] adapters = lang
					.getChildren("adapter");
			for (IConfigurationElement adapter : adapters) {
				modelTypeNames.add(adapter
						.getAttribute("modeltypeId"));
			}
		}
	}
	return modelTypeNames;
}
 
Example 9
Project: gemoc-studio-modeldebugging   File: ExtensionPoint.java   View source code 6 votes vote down vote up
protected Collection<T> internal_getSpecifications()
{
	IConfigurationElement[] confElements = getExtensions(getExtensionPointName());
	ArrayList<T> specs = new ArrayList<T>();
	for (int i = 0; i < confElements.length; i++) 
	{						
		try 
		{
			T s = createInstance();
			s.setSpecification(confElements[i]);
			specs.add(s);
		} 
		catch (InstantiationException | IllegalAccessException e) 
		{
			// silent catch
			e.printStackTrace();
			//throw new ExtensionPointException(e.getMessage(), e);
		} 
	}	
	return specs;
}
 
Example 10
Project: neoscada   File: ValidationRunner.java   View source code 6 votes vote down vote up
private boolean isTargetMatch ( final Class<? extends EObject> clazz, final IConfigurationElement ele )
{
    if ( isTargetClass ( ele.getAttribute ( "filterClass" ), ele.getContributor (), clazz ) )
    {
        return true;
    }

    for ( final IConfigurationElement child : ele.getChildren ( "filterClass" ) )
    {
        if ( isTargetClass ( child.getAttribute ( "class" ), ele.getContributor (), clazz ) )
        {
            return true;
        }
    }

    return false;
}
 
Example 11
Project: neoscada   File: ConnectionCreatorHelper.java   View source code 6 votes vote down vote up
public static ConnectionService createConnection ( final ConnectionInformation info, final Integer autoReconnectDelay, final boolean lazyActivation )
{
    if ( info == null )
    {
        return null;
    }

    for ( final IConfigurationElement ele : Platform.getExtensionRegistry ().getConfigurationElementsFor ( Activator.EXTP_CONNECTON_CREATOR ) )
    {
        final String interfaceName = ele.getAttribute ( "interface" );
        final String driverName = ele.getAttribute ( "driver" );
        if ( interfaceName == null || driverName == null )
        {
            continue;
        }
        if ( interfaceName.equals ( info.getInterface () ) && driverName.equals ( info.getDriver () ) )
        {
            final ConnectionService service = createConnection ( info, ele, autoReconnectDelay, lazyActivation );
            if ( service != null )
            {
                return service;
            }
        }
    }
    return null;
}
 
Example 12
Project: OCCI-Studio   File: OcciRegistry.java   View source code 6 votes vote down vote up
/**
 * Initializes the extensions map.
 * 
 * @throws CoreException
 *             if the registry cannot be initialized
 */
public void initialize() {
  try {
	if (Platform.isRunning()) {
		registry.clear();
		final IExtension[] extensions = Platform.getExtensionRegistry()
				.getExtensionPoint(OCCIE_EXTENSION_POINT).getExtensions();
		for (int i = 0; i < extensions.length; i++) {
			final IConfigurationElement[] configElements = extensions[i]
					.getConfigurationElements();
			for (int j = 0; j < configElements.length; j++) {
				String scheme = configElements[j].getAttribute("scheme"); //$NON-NLS-1$
				String uri = "platform:/plugin/" + extensions[i].getContributor().getName() + "/" + configElements[j].getAttribute("file"); //$NON-NLS-1$
				registerExtension(scheme, uri);
			}
		}
	}
  } catch(NoClassDefFoundError ncdfe) {
	  LOGGER.info("  Running out of an Eclipse Platform...");
  }
}
 
Example 13
Project: neoscada   File: Helper.java   View source code 6 votes vote down vote up
public static KeyProviderFactory findFactory ( final String id )
{
    for ( final IConfigurationElement ele : Platform.getExtensionRegistry ().getConfigurationElementsFor ( EXTP_KEY_PROVIDER_FACTORY ) )
    {
        if ( !ELE_FACTORY.equals ( ele.getName () ) )
        {
            continue;
        }

        try
        {
            return (KeyProviderFactory)ele.createExecutableExtension ( ATTR_CLASS );
        }
        catch ( final CoreException e )
        {
            StatusManager.getManager ().handle ( e, Activator.PLUGIN_ID );
        }
    }

    return null;
}
 
Example 14
Project: neoscada   File: Helper.java   View source code 6 votes vote down vote up
public static Collection<KeyProviderFactory> createFactories ()
{
    final Collection<KeyProviderFactory> result = new LinkedList<KeyProviderFactory> ();

    for ( final IConfigurationElement ele : Platform.getExtensionRegistry ().getConfigurationElementsFor ( EXTP_KEY_PROVIDER_FACTORY ) )
    {
        if ( !ELE_FACTORY.equals ( ele.getName () ) )
        {
            continue;
        }

        try
        {
            result.add ( (KeyProviderFactory)ele.createExecutableExtension ( ATTR_CLASS ) );
        }
        catch ( final CoreException e )
        {
            StatusManager.getManager ().handle ( e, Activator.PLUGIN_ID );
        }
    }

    return result;
}
 
Example 15
Project: neoscada   File: Activator.java   View source code 6 votes vote down vote up
public static List<ExtensionDescriptor> getExtensionDescriptors ()
{
    final List<ExtensionDescriptor> result = new LinkedList<ExtensionDescriptor> ();

    for ( final IConfigurationElement element : Platform.getExtensionRegistry ().getConfigurationElementsFor ( EXTP_VIEWER ) )
    {
        if ( !"viewerExtension".equals ( element.getName () ) )
        {
            continue;
        }

        result.add ( new ExtensionDescriptor ( element ) );
    }

    return result;
}
 
Example 16
Project: neoscada   File: Activator.java   View source code 6 votes vote down vote up
protected static List<ViewInstanceDescriptor> loadDescriptors ()
{
    final List<ViewInstanceDescriptor> result = new LinkedList<ViewInstanceDescriptor> ();
    for ( final IConfigurationElement element : Platform.getExtensionRegistry ().getConfigurationElementsFor ( EXTP_VIEW ) )
    {
        if ( !ELE_VIEW_INSTANCE.equals ( element.getName () ) )
        {
            continue;
        }

        final ViewInstanceDescriptor descriptor = convert ( element );
        if ( descriptor != null )
        {
            result.add ( descriptor );
        }
    }
    return result;
}
 
Example 17
Project: neoscada   File: PreferenceSelectorStyleGenerator.java   View source code 6 votes vote down vote up
private StyleGenerator create ( final IConfigurationElement ele )
{
    if ( ele == null )
    {
        return null;
    }

    try
    {
        final Object o = ele.createExecutableExtension ( Messages.PreferenceSelectorStyleGenerator_2 );
        if ( o instanceof StyleGenerator )
        {
            return (StyleGenerator)o;
        }
        logger.warn ( "Class referenced in 'generatorClass' did not implement {}", StyleGenerator.class ); //$NON-NLS-1$
        return null;
    }
    catch ( final CoreException e )
    {
        StatusManager.getManager ().handle ( e, Activator.PLUGIN_ID );
        return null;
    }
}
 
Example 18
Project: neoscada   File: StyleGeneratorInformation.java   View source code 6 votes vote down vote up
public static List<StyleGeneratorInformation> list ()
{
    final List<StyleGeneratorInformation> result = new LinkedList<StyleGeneratorInformation> ();

    for ( final IConfigurationElement ele : Platform.getExtensionRegistry ().getConfigurationElementsFor ( EXTP_STYLE_GENERATOR ) )
    {
        if ( !ELE_STYLE_GENERATOR.equals ( ele.getName () ) )
        {
            continue;
        }

        final String id = ele.getAttribute ( "id" ); //$NON-NLS-1$
        final String name = ele.getAttribute ( "name" ); //$NON-NLS-1$
        final String description = getText ( ele.getChildren ( "description" ) ); //$NON-NLS-1$

        result.add ( new StyleGeneratorInformation ( id, name, description ) );
    }

    return result;
}
 
Example 19
Project: neoscada   File: EventHistorySearchDialog.java   View source code 6 votes vote down vote up
protected List<FilterTab> getFilterTabs ()
{
    final List<FilterTab> result = new LinkedList<FilterTab> ();

    result.add ( new QueryByExampleTab () );
    result.add ( new FreeFormTab () );

    for ( final IConfigurationElement ele : Platform.getExtensionRegistry ().getConfigurationElementsFor ( EXTP_FILTER_TAB ) )
    {
        if ( !"filterTab".equals ( ele.getName () ) )
        {
            continue;
        }

        try
        {
            result.add ( (FilterTab)ele.createExecutableExtension ( "class" ) );
        }
        catch ( final CoreException e )
        {
            StatusManager.getManager ().handle ( e.getStatus () );
        }
    }

    return result;
}
 
Example 20
Project: neoscada   File: ConfigurationHelper.java   View source code 6 votes vote down vote up
public static List<MonitorViewConfiguration> loadAllMonitorConfigurations ()
{
    final List<MonitorViewConfiguration> result = new ArrayList<MonitorViewConfiguration> ();

    for ( final IConfigurationElement ele : Platform.getExtensionRegistry ().getConfigurationElementsFor ( EXTP_CFG_ID ) )
    {
        if ( !"monitorView".equals ( ele.getName () ) ) //$NON-NLS-1$
        {
            continue;
        }

        final MonitorViewConfiguration cfg = convertMonitor ( ele );
        if ( cfg != null )
        {
            result.add ( cfg );
        }
    }

    return result;
}
 
Example 21
Project: neoscada   File: ConfigurationHelper.java   View source code 6 votes vote down vote up
private static MonitorViewConfiguration convertMonitor ( final IConfigurationElement ele )
{
    try
    {
        final String id = ele.getAttribute ( "id" ); //$NON-NLS-1$
        final String monitorQueryId = ele.getAttribute ( "monitorQueryId" ); //$NON-NLS-1$
        final String connectionString = ele.getAttribute ( "connectionString" ); //$NON-NLS-1$
        final ConnectionType connectionType = ConnectionType.valueOf ( ele.getAttribute ( "connectionType" ) ); //$NON-NLS-1$
        final String label = ele.getAttribute ( "label" ); //$NON-NLS-1$
        final List<ColumnProperties> columns = parseColumnSettings ( ele.getAttribute ( "columns" ) ); //$NON-NLS-1$

        return new MonitorViewConfiguration ( id, monitorQueryId, connectionString, connectionType, label, columns );
    }
    catch ( final Exception e )
    {
        logger.warn ( "Failed to convert monitor configuration: {}", ele ); //$NON-NLS-1$
        return null;
    }
}
 
Example 22
Project: neoscada   File: ConfigurationHelper.java   View source code 6 votes vote down vote up
public static List<EventPoolViewConfiguration> loadAllEventPoolConfigurations ()
{
    final List<EventPoolViewConfiguration> result = new ArrayList<EventPoolViewConfiguration> ();

    for ( final IConfigurationElement ele : Platform.getExtensionRegistry ().getConfigurationElementsFor ( EXTP_CFG_ID ) )
    {
        if ( !"eventPoolView".equals ( ele.getName () ) ) //$NON-NLS-1$
        {
            continue;
        }

        final EventPoolViewConfiguration cfg = convertEventPool ( ele );
        if ( cfg != null )
        {
            result.add ( cfg );
        }
    }

    return result;
}
 
Example 23
Project: neoscada   File: ConfigurationHelper.java   View source code 6 votes vote down vote up
public static List<EventHistoryViewConfiguration> loadAllEventHistoryConfigurations ()
{
    final List<EventHistoryViewConfiguration> result = new ArrayList<EventHistoryViewConfiguration> ();

    for ( final IConfigurationElement ele : Platform.getExtensionRegistry ().getConfigurationElementsFor ( EXTP_CFG_ID ) )
    {
        if ( !"eventHistoryView".equals ( ele.getName () ) ) //$NON-NLS-1$
        {
            continue;
        }

        final EventHistoryViewConfiguration cfg = convertEventHistory ( ele );
        if ( cfg != null )
        {
            result.add ( cfg );
        }
    }

    return result;
}
 
Example 24
Project: neoscada   File: ConfigurationHelper.java   View source code 6 votes vote down vote up
private static EventHistoryViewConfiguration convertEventHistory ( final IConfigurationElement ele )
{
    try
    {
        final String id = ele.getAttribute ( "id" ); //$NON-NLS-1$
        final String connectionString = ele.getAttribute ( "connectionString" ); //$NON-NLS-1$
        final ConnectionType connectionType = ConnectionType.valueOf ( ele.getAttribute ( "connectionType" ) ); //$NON-NLS-1$
        final String label = ele.getAttribute ( "label" ); //$NON-NLS-1$

        final List<ColumnLabelProviderInformation> columnInformation = new LinkedList<ColumnLabelProviderInformation> ();
        fillColumnInformation ( columnInformation, ele );

        return new EventHistoryViewConfiguration ( id, connectionString, connectionType, label, columnInformation );
    }
    catch ( final Exception e )
    {
        logger.warn ( "Failed to convert event history configuration: {}", ele ); //$NON-NLS-1$
        return null;
    }
}
 
Example 25
Project: neoscada   File: ConfigurationHelper.java   View source code 6 votes vote down vote up
public static AlarmNotifierConfiguration findAlarmNotifierConfiguration ()
{
    for ( final IConfigurationElement ele : Platform.getExtensionRegistry ().getConfigurationElementsFor ( EXTP_CFG_ID ) )
    {
        if ( !"alarmNotifier".equals ( ele.getName () ) ) //$NON-NLS-1$
        {
            continue;
        }

        final AlarmNotifierConfiguration cfg = convertAlarmNotifier ( ele );
        if ( cfg != null )
        {
            return cfg;
        }
    }
    return null;
}
 
Example 26
Project: neoscada   File: ConfigurationHelper.java   View source code 6 votes vote down vote up
private static AlarmNotifierConfiguration convertAlarmNotifier ( final IConfigurationElement ele )
{
    try
    {
        final String connectionId = ele.getAttribute ( "connectionId" ); //$NON-NLS-1$
        final String prefix = ele.getAttribute ( "prefix" ) == null ? "ae.server.info" : ele.getAttribute ( "prefix" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ $NON-NLS-2$
        final URL soundFile = Platform.getBundle ( ele.getContributor ().getName () ).getEntry ( ele.getAttribute ( "soundFile" ) ); //$NON-NLS-1$
        final ParameterizedCommand ackAlarmsAvailableCommand = convertCommand ( ele.getChildren ( "ackAlarmsAvailableCommand" )[0] ); //$NON-NLS-1$
        final ParameterizedCommand alarmsAvailableCommand = convertCommand ( ele.getChildren ( "alarmsAvailableCommand" )[0] ); //$NON-NLS-1$
        return new AlarmNotifierConfiguration ( connectionId, prefix, soundFile, ackAlarmsAvailableCommand, alarmsAvailableCommand );
    }
    catch ( final Exception e )
    {
        logger.warn ( "Failed to convert alarm notifier configuration: {}", ele ); //$NON-NLS-1$
        return null;
    }
}
 
Example 27
Project: neoscada   File: AbstractItemExtension.java   View source code 6 votes vote down vote up
@Override
public void setInitializationData ( final IConfigurationElement config, final String propertyName, final Object data ) throws CoreException
{

    if ( data instanceof String )
    {
        final String str = (String)data;
        if ( str.contains ( "#" ) )
        {
            final String[] tok = str.split ( "\\#", 2 );
            this.connectionId = tok[0];
            this.itemId = tok[1];
        }
    }
    if ( data instanceof Hashtable<?, ?> )
    {
        final Hashtable<?, ?> props = (Hashtable<?, ?>)data;

        this.connectionId = "" + props.get ( "connectionId" );
        this.itemId = "" + props.get ( "itemId" );
    }

}
 
Example 28
Project: neoscada   File: ImageExtension.java   View source code 6 votes vote down vote up
@Override
public void setInitializationData ( final IConfigurationElement config, final String propertyName, final Object data ) throws CoreException
{
    try
    {
        if ( data instanceof String )
        {
            this.imageUrl = new URL ( (String)data );
        }
        if ( data instanceof Hashtable<?, ?> )
        {
            this.imageUrl = new URL ( (String) ( (Hashtable<?, ?>)data ).get ( "url" ) );
        }
    }
    catch ( final Exception e )
    {
        logger.warn ( "Failed to parse URL", e );
    }
}
 
Example 29
Project: neoscada   File: ConfigurationFormInformation.java   View source code 6 votes vote down vote up
public Set<String> getFactoryIds ()
{
    final Set<String> result = new HashSet<String> ();

    // by attribute
    final String factoryId = this.configuration.getAttribute ( "factoryId" );
    if ( factoryId != null && !factoryId.isEmpty () )
    {
        result.add ( factoryId );
    }

    // by child element
    for ( final IConfigurationElement ele : this.configuration.getChildren ( "factory" ) )
    {
        if ( ele.getValue () != null && !ele.getValue ().isEmpty () )
        {
            result.add ( ele.getValue () );
        }
    }

    return result;
}
 
Example 30
Project: neoscada   File: Activator.java   View source code 6 votes vote down vote up
public static List<ConfigurationFormInformation> findMatching ( final String factoryId )
{
    final List<ConfigurationFormInformation> result = new LinkedList<ConfigurationFormInformation> ();

    for ( final IConfigurationElement ele : Platform.getExtensionRegistry ().getConfigurationElementsFor ( EXTP_FORM ) )
    {
        if ( !"form".equals ( ele.getName () ) )
        {
            continue;
        }
        final ConfigurationFormInformation info = new ConfigurationFormInformation ( ele );
        if ( info.getFactoryIds () == null )
        {
            continue;
        }

        if ( info.getFactoryIds ().contains ( "*" ) || info.getFactoryIds ().contains ( factoryId ) )
        {
            result.add ( info );
        }
    }

    return result;
}
 
Example 31
Project: neoscada   File: Activator.java   View source code 6 votes vote down vote up
private void fillFactories ( final Collection<LoginFactory> factories, final IConfigurationElement ele )
{
    for ( final IConfigurationElement child : ele.getChildren ( "factory" ) ) //$NON-NLS-1$
    {
        try
        {
            final LoginFactory factory = (LoginFactory)child.createExecutableExtension ( "class" );//$NON-NLS-1$
            if ( factory != null )
            {
                factories.add ( factory );
            }
        }
        catch ( final Exception e )
        {
            getLog ().log ( new Status ( IStatus.WARNING, PLUGIN_ID, Messages.Activator_ErrorParse, e ) );
        }
    }
}
 
Example 32
Project: neoscada   File: DetailViewManager.java   View source code 6 votes vote down vote up
public static DetailView openView ( final String id, final Map<String, String> properties ) throws CoreException
{
    logger.info ( "Searching view: {}", id ); //$NON-NLS-1$

    for ( final IConfigurationElement ele : Platform.getExtensionRegistry ().getConfigurationElementsFor ( EXTP_DETAIL_VIEW ) )
    {
        final String cfgId = ele.getAttribute ( "id" ); //$NON-NLS-1$

        logger.debug ( "Checking: {}", cfgId ); //$NON-NLS-1$

        if ( cfgId != null && cfgId.equals ( id ) )
        {
            return createDetailView ( id, ele, properties );
        }
    }
    return null;
}
 
Example 33
Project: neoscada   File: WorldRunner.java   View source code 6 votes vote down vote up
private boolean isMatch ( final BundleContext ctx, final IConfigurationElement ele, final Object element )
{
    if ( isMatch ( Factories.loadClass ( ctx, ele, ATTR_FOR_CLASS ), element ) )
    {
        return true;
    }

    for ( final IConfigurationElement child : ele.getChildren ( ELE_FOR_CLASS ) )
    {
        if ( isMatch ( Factories.loadClass ( ctx, child, ATTR_CLASS ), element ) )
        {
            return true;
        }
    }
    return false;
}
 
Example 34
Project: neoscada   File: Activator.java   View source code 6 votes vote down vote up
public static Collection<OscarProcessor> createProcessors ()
{
    final Collection<OscarProcessor> result = new LinkedList<> ();
    for ( final IConfigurationElement ele : Platform.getExtensionRegistry ().getConfigurationElementsFor ( EXTP_GENERATOR ) )
    {
        if ( !ele.getName ().equals ( ELE_OSCAR_PROCESSOR ) )
        {
            continue;
        }
        try
        {
            result.add ( (OscarProcessor)ele.createExecutableExtension ( "class" ) );
        }
        catch ( final CoreException e )
        {
            logger.warn ( "Failed to create oscar processor", e );
            getDefault ().getLog ().log ( e.getStatus () );
            throw new IllegalStateException ( "Failed to create OSCAR processor", e );
        }
    }
    return result;
}
 
Example 35
Project: neoscada   File: ForwardingDanglingReferenceResolver.java   View source code 6 votes vote down vote up
private void buildCache ()
{
    for ( final IConfigurationElement ele : Platform.getExtensionRegistry ().getConfigurationElementsFor ( EXPT_DANGLING_RESOLVER ) )
    {
        if ( !ele.getName ().equals ( ELE_RESOLVER ) )
        {
            continue;
        }
        try
        {
            final DanglingReferenceResolver resolver = (DanglingReferenceResolver)ele.createExecutableExtension ( ATTR_CLASS );
            logger.debug ( "Adding resolver: {}", resolver ); //$NON-NLS-1$
            this.cache.add ( resolver );
        }
        catch ( final Exception e )
        {
            Activator.getDefault ().getLog ().log ( new Status ( IStatus.ERROR, Activator.PLUGIN_ID, "Failed to create resolver instance", e ) );
        }
    }
}
 
Example 36
Project: scanning   File: PointGeneratorService.java   View source code 6 votes vote down vote up
private static void readExtensions(Map<Class<? extends IScanPathModel>, Class<? extends IPointGenerator<?>>> gens,
		                           Map<String,   GeneratorInfo> tids) throws CoreException {

	if (Platform.getExtensionRegistry()!=null) {
		final IConfigurationElement[] eles = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.scanning.api.generator");
		for (IConfigurationElement e : eles) {
			final IPointGenerator<?>    generator = (IPointGenerator<?>)e.createExecutableExtension("class");
			final IScanPathModel     model = (IScanPathModel)e.createExecutableExtension("model");

			final Class<? extends IScanPathModel> modelClass = model.getClass();
			@SuppressWarnings("unchecked")
			final Class<? extends IPointGenerator<?>> generatorClass = (Class<? extends IPointGenerator<?>>) generator.getClass();
			gens.put(modelClass, generatorClass);

			final GeneratorInfo info = new GeneratorInfo();
			info.setModelClass(model.getClass());
			info.setGeneratorClass(generator.getClass());
			info.setLabel(e.getAttribute("label"));
			info.setDescription(e.getAttribute("description"));

			String id = e.getAttribute("id");
			tids.put(id, info);
		}
	}
}
 
Example 37
Project: scanning   File: StatusQueueView.java   View source code 6 votes vote down vote up
private List<IResultHandler> getResultsHandlers() {
	if (resultsHandlers == null) {
		final IConfigurationElement[] configElements = Platform.getExtensionRegistry()
				.getConfigurationElementsFor(RESULTS_HANDLER_EXTENSION_POINT_ID);
		final List<IResultHandler> handlers = new ArrayList<>(configElements.length + 1);
		for (IConfigurationElement configElement : configElements) {
			try {
				final IResultHandler handler = (IResultHandler) configElement.createExecutableExtension("class");
				handler.init(service, createConsumerConfiguration());
				handlers.add(handler);
			} catch (Exception e) {
				ErrorDialog.openError(getSite().getShell(), "Internal Error",
						"Could not create results handler for class " + configElement.getAttribute("class") +
						".\n\nPlease contact your support representative.",
						new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage()));
			}
		}
		handlers.add(new DefaultResultsHandler());
		resultsHandlers = handlers;
	}
	return resultsHandlers;
}
 
Example 38
Project: codelens-eclipse   File: CodeLensControllerRegistry.java   View source code 6 votes vote down vote up
/**
 * Load the SourceMap language supports.
 */
private synchronized void loadFactories() {
	if (loaded) {
		return;
	}

	try {
		IExtensionRegistry registry = Platform.getExtensionRegistry();
		if (registry == null) {
			return;
		}
		IConfigurationElement[] cf = registry.getConfigurationElementsFor(CodeLensEditorPlugin.PLUGIN_ID,
				EXTENSION_CODELENS_CONTROLLER_FACTORIES);
		loadCodeLensProvidersFromExtension(cf);
	} finally {
		loaded = true;
	}
}
 
Example 39
Project: gemoc-studio   File: MessagingSystemManager.java   View source code 6 votes vote down vote up
/**
 * 
 * @return a new MessagingSystem that is supposed to be the best implementation for the current platform
 * @param baseMessageGroup id for the messaging system, if two instances of MessagingSystem use the same id, the platform may decide to group the messages in a single console
 * @param userFriendlyName, name for the console, if several instances use the same  baseMessageGroup, it will use one of the userFriendlyName (the first that is created) 
 */
public MessagingSystem createBestPlatformMessagingSystem(String baseMessageGroup, String userFriendlyName ){
	MessagingSystem result = null;
	IConfigurationElement[] confElements = Platform.getExtensionRegistry()
			.getConfigurationElementsFor(MESSAGINGSYSTEM_EXTENSION_POINT_NAME);
	for (int i = 0; i < confElements.length; i++) {
		// get first working contribution
		// TODO find some criterion or properties allowing to have better selection in case of multiple definitions
		//String name = confElements[i].getAttribute(MESSAGINGSYSTEM_EXTENSION_POINT_CONTRIB_NAME_ATT);
		try {
			result = (MessagingSystem) confElements[i].createExecutableExtension(MESSAGINGSYSTEM_EXTENSION_POINT_CONTRIB_MESSAGINGSYSTEM_ATT);
			result.initialize(baseMessageGroup, userFriendlyName);
			if(result != null)	break;
		} catch (Throwable e) {;
		}
	}
	if (result == null){
		// still not created, either due to exception or to missing extension contributor
		// fallback to default constructor
		result = new StdioSimpleMessagingSystem();
	}
	
	return result;
}
 
Example 40
Project: gemoc-studio   File: AbstractNewProjectWizardWithTemplates.java   View source code 6 votes vote down vote up
protected WizardElement createWizardElement(IConfigurationElement config) {
	String name = config.getAttribute(WizardElement.ATT_NAME);
	String id = config.getAttribute(WizardElement.ATT_ID);
	String className = config.getAttribute(WizardElement.ATT_CLASS);
	if (name == null || id == null || className == null)
		return null;
	WizardElement element = new WizardElement(config);
	element.id = id;
	String imageName = config.getAttribute(WizardElement.ATT_ICON);
	if (imageName != null) {
		String pluginID = config.getNamespaceIdentifier();
		Image image = PDEPlugin.getDefault().getLabelProvider().getImageFromPlugin(pluginID, imageName);
		element.setImage(image);
	}
	return element;
}