Search in sources :

Example 1 with IChildDescriptorProvider

use of org.obeonetwork.dsl.environment.edit.specific.extensions.IChildDescriptorProvider in project InformationSystem by ObeoNetwork.

the class FilterContainerItemProvider method addExternalChildDescriptors.

/**
 * This adds to the collection of {@link org.eclipse.emf.edit.command.CommandParameter}s
 * describing all of the children that can be created under this object.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated NOT
 */
@SuppressWarnings({ "unchecked", "deprecation" })
protected void addExternalChildDescriptors(Collection newChildDescriptors, Object object) {
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IExtensionPoint extensionPoint = registry.getExtensionPoint(CHILD_DESCRIPTOR_EXTENSION_ID);
    if (extensionPoint == null || extensionPoint.getExtensions().length == 0) {
        EcorePlugin.INSTANCE.log("Extension point '" + CHILD_DESCRIPTOR_EXTENSION_ID + "' not found");
    } else {
        Bundle theBundle = null;
        IExtension[] extensions = extensionPoint.getExtensions();
        for (int i = 0; i < extensions.length; i++) {
            IExtension extension = extensions[i];
            IConfigurationElement[] members = extension.getConfigurationElements();
            for (int j = 0; j < members.length; j++) {
                IConfigurationElement member = members[j];
                String conditionClass = member.getAttribute("implementation");
                theBundle = Platform.getBundle(member.getNamespace());
                if (conditionClass != null) {
                    try {
                        Class c = theBundle.loadClass(conditionClass);
                        Object instance = c.newInstance();
                        if (instance instanceof IChildDescriptorProvider) {
                            IChildDescriptorProvider childDescriptorProvider = (IChildDescriptorProvider) instance;
                            CommandParameter parameter = childDescriptorProvider.getEntityFilter(object);
                            if (parameter != null) {
                                newChildDescriptors.add(parameter);
                            }
                        }
                    } catch (ClassNotFoundException e) {
                        EcorePlugin.INSTANCE.log(e);
                    } catch (InstantiationException e) {
                        EcorePlugin.INSTANCE.log(e);
                    } catch (IllegalAccessException e) {
                        EcorePlugin.INSTANCE.log(e);
                    }
                }
            }
        }
    }
}
Also used : CommandParameter(org.eclipse.emf.edit.command.CommandParameter) Bundle(org.osgi.framework.Bundle) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IChildDescriptorProvider(org.obeonetwork.dsl.environment.edit.specific.extensions.IChildDescriptorProvider) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IExtension(org.eclipse.core.runtime.IExtension) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Aggregations

IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 IExtension (org.eclipse.core.runtime.IExtension)1 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)1 IExtensionRegistry (org.eclipse.core.runtime.IExtensionRegistry)1 CommandParameter (org.eclipse.emf.edit.command.CommandParameter)1 IChildDescriptorProvider (org.obeonetwork.dsl.environment.edit.specific.extensions.IChildDescriptorProvider)1 Bundle (org.osgi.framework.Bundle)1