Java Code Examples for org.eclipse.xtext.resource.FileExtensionProvider#getFileExtensions()

The following examples show how to use org.eclipse.xtext.resource.FileExtensionProvider#getFileExtensions() . 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: RegistryProvider.java    From openhab-core with Eclipse Public License 2.0 6 votes vote down vote up
private void register(IResourceServiceProvider.Registry registry, Injector injector) {
    IResourceServiceProvider resourceServiceProvider = injector.getInstance(IResourceServiceProvider.class);
    FileExtensionProvider extensionProvider = injector.getInstance(FileExtensionProvider.class);
    for (String ext : extensionProvider.getFileExtensions()) {
        if (registry.getExtensionToFactoryMap().containsKey(ext)) {
            if (extensionProvider.getPrimaryFileExtension() == ext) {
                registry.getExtensionToFactoryMap().put(ext, resourceServiceProvider);
            }
        } else {
            registry.getExtensionToFactoryMap().put(ext, resourceServiceProvider);
        }

        IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
        Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(ext, resourceFactory);
    }
}
 
Example 2
Source File: RegistryProvider.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
private void register(IResourceServiceProvider.Registry registry, Injector injector) {
    IResourceServiceProvider resourceServiceProvider = injector.getInstance(IResourceServiceProvider.class);
    FileExtensionProvider extensionProvider = injector.getInstance(FileExtensionProvider.class);
    for (String ext : extensionProvider.getFileExtensions()) {
        if (registry.getExtensionToFactoryMap().containsKey(ext)) {
            if (extensionProvider.getPrimaryFileExtension() == ext) {
                registry.getExtensionToFactoryMap().put(ext, resourceServiceProvider);
            }
        } else {
            registry.getExtensionToFactoryMap().put(ext, resourceServiceProvider);
        }

        IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
        Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(ext, resourceFactory);
    }
}
 
Example 3
Source File: WrappingInjectorProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private void registerFactory(Injector injector) {
	IResourceFactory factory = injector.getInstance(IResourceFactory.class);
	IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
	FileExtensionProvider fileExtensionProvider = injector.getInstance(FileExtensionProvider.class);
	for(String ext: fileExtensionProvider.getFileExtensions()) {
		Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(ext, factory);
		IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put(ext, serviceProvider);
	}
}
 
Example 4
Source File: JavaProjectPreferencesInitializer.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@SuppressWarnings("restriction")
@Inject
public void addOwnFileExtensionsToJavaBuildResourceCopyFilter(FileExtensionProvider extensionProvider) {
	@SuppressWarnings("deprecation")
	IScopeContext defaultScope = new DefaultScope();

	// The class org.eclipse.jdt.internal.launching.LaunchingPreferenceInitializer has this very nasty habit 
	// of replacing all RESOURCE_COPY_FILTERs with its own filter. Calling getNode(LaunchingPlugin.ID_PLUGIN) 
	// causes LaunchingPreferenceInitializer to be executed that afterwards we can append our filters safely.    
	// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=395366
	defaultScope.getNode(org.eclipse.jdt.internal.launching.LaunchingPlugin.ID_PLUGIN);

	IEclipsePreferences dnode = defaultScope.getNode(JavaCore.PLUGIN_ID);
	if (dnode == null)
		return;
	Set<String> filters = Sets.newLinkedHashSet();
	for (String filter : dnode.get(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, "").split(",")) {
		String trimmed = filter.trim();
		if (!"".equals(trimmed))
			filters.add(trimmed);
	}
	for (String ext : extensionProvider.getFileExtensions())
		filters.add("*." + ext);
	dnode.put(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, Joiner.on(", ").join(filters));
	try {
		dnode.flush();
	} catch (BackingStoreException e) {
		log.error("Error saving preferences", e);
	}
}
 
Example 5
Source File: WrappingInjectorProvider.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
private void registerFactory(Injector injector) {
	IResourceFactory factory = injector.getInstance(IResourceFactory.class);
	IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
	FileExtensionProvider fileExtensionProvider = injector.getInstance(FileExtensionProvider.class);
	for(String ext: fileExtensionProvider.getFileExtensions()) {
		Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(ext, factory);
		IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put(ext, serviceProvider);
	}
}