Search in sources :

Example 16 with INodeAdapterFactory

use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory in project webtools.sourceediting by eclipse.

the class TagModelLoader method getAdapterFactories.

public List getAdapterFactories() {
    List factories = super.getAdapterFactories();
    /*
		 * Replace the default JSP model query by using our own factory
		 */
    Iterator i = factories.iterator();
    while (i.hasNext()) {
        if (((INodeAdapterFactory) i.next()).isFactoryForType(ModelQueryAdapter.class)) {
            i.remove();
        }
    }
    factories.add(new ModelQueryAdapterFactoryForTag());
    return factories;
}
Also used : ModelQueryAdapterFactoryForTag(org.eclipse.jst.jsp.core.internal.modelquery.ModelQueryAdapterFactoryForTag) Iterator(java.util.Iterator) List(java.util.List) INodeAdapterFactory(org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory)

Example 17 with INodeAdapterFactory

use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory in project webtools.sourceediting by eclipse.

the class ModelManagerPluginRegistryReader method loadFactoryFromConfigurationElement.

protected INodeAdapterFactory loadFactoryFromConfigurationElement(IConfigurationElement element, Object requesterType) {
    INodeAdapterFactory factory = null;
    if (element.getName().equals(TAG_NAME)) {
        String contentType = element.getAttribute(ATTR_CONTENTTYPE);
        if (!contentType.equals(requesterType))
            return null;
        String className = element.getAttribute(ATTR_CLASS);
        String adapterKeyClass = element.getAttribute(ATTR_ADAPTERKEY);
        String registerAdapters = element.getAttribute(ATTR_REGISTERADAPTER);
        // for adapter factories
        if (className != null) {
            String name = element.getDeclaringExtension().getNamespace();
            Bundle bundle = null;
            try {
                bundle = Platform.getBundle(name);
            } catch (Exception e) {
                // if an error occurs here, its probably that the plugin
                // could not be found/loaded
                // $NON-NLS-1$
                Logger.logException("Could not find bundle: " + name, e);
            }
            if (bundle != null) {
                boolean useExtendedConstructor = false;
                boolean doRegisterAdapters = false;
                Object adapterKey = null;
                if (registerAdapters != null && registerAdapters.length() > 0 && Boolean.valueOf(registerAdapters).booleanValue()) {
                    doRegisterAdapters = true;
                }
                if (adapterKeyClass != null) {
                    try {
                        Class aClass = null;
                        // Class.forName(adapterKeyClass);
                        if (bundle.getState() != Bundle.UNINSTALLED) {
                            aClass = bundle.loadClass(adapterKeyClass);
                        } else {
                            aClass = Class.forName(adapterKeyClass);
                        }
                        if (aClass != null) {
                            useExtendedConstructor = true;
                            adapterKey = aClass;
                        } else {
                            adapterKey = adapterKeyClass;
                        }
                    } catch (Exception anyErrors) {
                        adapterKey = adapterKeyClass;
                    }
                }
                try {
                    Class theClass = null;
                    // Class.forName(className);
                    if (bundle.getState() != Bundle.UNINSTALLED) {
                        theClass = bundle.loadClass(className);
                    } else {
                        theClass = Class.forName(className);
                    }
                    if (useExtendedConstructor) {
                        java.lang.reflect.Constructor[] ctors = theClass.getConstructors();
                        for (int i = 0; i < ctors.length; i++) {
                            Class[] paramTypes = ctors[i].getParameterTypes();
                            if (ctors[i].isAccessible() && paramTypes.length == 2 && paramTypes[0].equals(Object.class) && paramTypes[1].equals(boolean.class)) {
                                try {
                                    factory = (INodeAdapterFactory) ctors[i].newInstance(new Object[] { adapterKey, new Boolean(doRegisterAdapters) });
                                } catch (IllegalAccessException e) {
                                    // log for now, unless we find reason
                                    // not to
                                    Logger.log(Logger.INFO, e.getMessage());
                                } catch (IllegalArgumentException e) {
                                    // log for now, unless we find reason
                                    // not to
                                    Logger.log(Logger.INFO, e.getMessage());
                                } catch (InstantiationException e) {
                                    // log for now, unless we find reason
                                    // not to
                                    Logger.log(Logger.INFO, e.getMessage());
                                } catch (InvocationTargetException e) {
                                    // log for now, unless we find reason
                                    // not to
                                    Logger.log(Logger.INFO, e.getMessage());
                                } catch (ExceptionInInitializerError e) {
                                    // log or now, unless we find reason
                                    // not to
                                    Logger.log(Logger.INFO, e.getMessage());
                                }
                            }
                        }
                    }
                    if (factory == null) {
                        factory = (INodeAdapterFactory) element.createExecutableExtension(ATTR_CLASS);
                    }
                } catch (ClassNotFoundException e) {
                    // log or now, unless we find reason not to
                    Logger.log(Logger.INFO, e.getMessage());
                } catch (CoreException e) {
                    // log or now, unless we find reason not to
                    Logger.log(Logger.INFO, e.getMessage());
                }
            }
        }
    }
    return factory;
}
Also used : Bundle(org.osgi.framework.Bundle) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) InvocationTargetException(java.lang.reflect.InvocationTargetException) INodeAdapterFactory(org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory) CoreException(org.eclipse.core.runtime.CoreException)

Example 18 with INodeAdapterFactory

use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory in project webtools.sourceediting by eclipse.

the class ModelManagerPluginRegistryReader method loadRegistry.

protected List loadRegistry(Object contentType) {
    List factoryList = new Vector();
    IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
    IExtensionPoint point = extensionRegistry.getExtensionPoint(SSECorePlugin.ID, EXTENSION_POINT_ID);
    if (point != null) {
        IConfigurationElement[] elements = point.getConfigurationElements();
        for (int i = 0; i < elements.length; i++) {
            INodeAdapterFactory factory = loadFactoryFromConfigurationElement(elements[i], contentType);
            if (factory != null)
                factoryList.add(factory);
        }
    }
    return factoryList;
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) List(java.util.List) Vector(java.util.Vector) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry) INodeAdapterFactory(org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory)

Example 19 with INodeAdapterFactory

use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory in project webtools.sourceediting by eclipse.

the class AdapterFactoryProviderForJSON method addContentBasedFactories.

protected void addContentBasedFactories(IStructuredModel structuredModel) {
    FactoryRegistry factoryRegistry = structuredModel.getFactoryRegistry();
    // $NON-NLS-1$
    Assert.isNotNull(factoryRegistry, "Program Error: client caller must ensure model has factory registry");
    INodeAdapterFactory factory = null;
    factory = factoryRegistry.getFactoryFor(IJFaceNodeAdapter.class);
    if (factory == null) {
        factory = new JFaceNodeAdapterFactory();
        factoryRegistry.addFactory(factory);
    }
// cs... added for inferred grammar support
// 
// if (structuredModel != null) {
// ModelQuery modelQuery = ModelQueryUtil.getModelQuery(structuredModel);
// if (modelQuery != null) {
// CMDocumentManager documentManager = modelQuery.getCMDocumentManager();
// if (documentManager != null) {
// IPreferenceStore store = XMLUIPlugin.getDefault().getPreferenceStore();
// boolean useInferredGrammar = (store != null) ? store.getBoolean(XMLUIPreferenceNames.USE_INFERRED_GRAMMAR) : true;
// 
// documentManager.setPropertyEnabled(CMDocumentManager.PROPERTY_ASYNC_LOAD, true);
// documentManager.setPropertyEnabled(CMDocumentManager.PROPERTY_AUTO_LOAD, false);
// documentManager.setPropertyEnabled(CMDocumentManager.PROPERTY_USE_CACHED_RESOLVED_URI, true);
// DOMObserver domObserver = new DOMObserver(structuredModel);
// domObserver.setGrammarInferenceEnabled(useInferredGrammar);
// domObserver.init();
// }
// }
// }
}
Also used : FactoryRegistry(org.eclipse.wst.sse.core.internal.model.FactoryRegistry) JFaceNodeAdapterFactory(org.eclipse.wst.json.ui.internal.contentoutline.JFaceNodeAdapterFactory) IJFaceNodeAdapter(org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter) INodeAdapterFactory(org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory)

Example 20 with INodeAdapterFactory

use of org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory in project webtools.sourceediting by eclipse.

the class AdapterFactoryProviderCSS method addContentBasedFactories.

protected void addContentBasedFactories(IStructuredModel structuredModel) {
    FactoryRegistry factoryRegistry = structuredModel.getFactoryRegistry();
    // $NON-NLS-1$
    Assert.isNotNull(factoryRegistry, "Program Error: client caller must ensure model has factory registry");
    INodeAdapterFactory factory = null;
    factory = factoryRegistry.getFactoryFor(IJFaceNodeAdapter.class);
    if (factory == null) {
        factory = new JFaceNodeAdapterFactoryCSS(IJFaceNodeAdapter.class, true);
        factoryRegistry.addFactory(factory);
    }
}
Also used : JFaceNodeAdapterFactoryCSS(org.eclipse.wst.css.ui.internal.contentoutline.JFaceNodeAdapterFactoryCSS) FactoryRegistry(org.eclipse.wst.sse.core.internal.model.FactoryRegistry) IJFaceNodeAdapter(org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter) INodeAdapterFactory(org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory)

Aggregations

INodeAdapterFactory (org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory)35 List (java.util.List)9 Iterator (java.util.Iterator)8 ArrayList (java.util.ArrayList)7 FactoryRegistry (org.eclipse.wst.sse.core.internal.model.FactoryRegistry)7 IJFaceNodeAdapter (org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter)7 ValidationAdapter (org.eclipse.wst.sse.core.internal.validate.ValidationAdapter)4 PropagatingAdapterFactoryImpl (org.eclipse.wst.xml.core.internal.propagate.PropagatingAdapterFactoryImpl)4 IDOMDocument (org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)4 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)3 Vector (java.util.Vector)2 ITextFileBuffer (org.eclipse.core.filebuffers.ITextFileBuffer)2 IFile (org.eclipse.core.resources.IFile)2 CoreException (org.eclipse.core.runtime.CoreException)2 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)2 IExtensionRegistry (org.eclipse.core.runtime.IExtensionRegistry)2 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)2 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)2 IStyleSelectorAdapter (org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSelectorAdapter)2 IStyleSheetAdapter (org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetAdapter)2