public void testExtensionContributionExpression() throws Exception {
    IAction a =
        new Action() {
          @Override
          public void run() {
            System.out.println("Hello action");
          }
        };
    final MenuManager manager = new MenuManager();
    final ActionContributionItem aci = new ActionContributionItem(a);

    IExtensionRegistry reg = Platform.getExtensionRegistry();
    IExtensionPoint menusExtension = reg.getExtensionPoint("org.eclipse.ui.menus");
    IExtension extension = menusExtension.getExtension(EXTENSION_ID);

    IConfigurationElement[] mas = extension.getConfigurationElements();
    final Expression activeContextExpr[] = new Expression[1];
    for (IConfigurationElement ma : mas) {
      IConfigurationElement[] items = ma.getChildren();
      for (IConfigurationElement item : items) {
        String id = item.getAttribute("id");
        if (id != null && id.equals("org.eclipse.ui.tests.menus.itemX1")) {
          IConfigurationElement visibleWhenElement = item.getChildren("visibleWhen")[0];
          activeContextExpr[0] =
              ExpressionConverter.getDefault().perform(visibleWhenElement.getChildren()[0]);
        }
      }
    }
    assertNotNull("Failed to find expression", activeContextExpr[0]);
    AbstractContributionFactory factory =
        new AbstractContributionFactory(LOCATION, TestPlugin.PLUGIN_ID) {
          @Override
          public void createContributionItems(
              IServiceLocator menuService, IContributionRoot additions) {
            additions.addContributionItem(aci, activeContextExpr[0]);
          }
        };

    menuService.addContributionFactory(factory);
    menuService.populateContributionManager(manager, LOCATION);

    assertFalse("starting state", aci.isVisible());

    activeContext = contextService.activateContext(MenuContributionHarness.CONTEXT_TEST1_ID);
    final Menu menu = manager.createContextMenu(window.getShell());
    menu.notifyListeners(SWT.Show, new Event());
    assertTrue("active context", aci.isVisible());
    menu.notifyListeners(SWT.Hide, new Event());

    contextService.deactivateContext(activeContext);
    activeContext = null;

    menu.notifyListeners(SWT.Show, new Event());
    assertFalse("after deactivation", aci.isVisible());
    menu.notifyListeners(SWT.Hide, new Event());

    menuService.releaseContributions(manager);
    menuService.removeContributionFactory(factory);
    manager.dispose();
  }
Esempio n. 2
0
  private void loadExtensions() throws CoreException {
    // load the command handlers
    IExtensionRegistry reg = getExtensionRegistry();
    if (reg != null) {
      IConfigurationElement[] elements =
          reg.getConfigurationElementsFor("org.eclipse.ecf.provider.irc.bot.commandHandler");
      for (int i = 0; i < elements.length; i++) {
        String id = elements[i].getAttribute("botId");
        String expression = elements[i].getAttribute("expression");
        ICommandHandler handler = (ICommandHandler) elements[i].createExecutableExtension("class");
        List c = (List) commands.get(id);
        if (c == null) {
          c = new ArrayList();
          c.add(new CommandEntry(expression, handler));
          commands.put(id, c);
        } else {
          c.add(new CommandEntry(expression, handler));
          commands.put(id, c);
        }
      }

      // load the bots
      elements = reg.getConfigurationElementsFor("org.eclipse.ecf.provider.irc.bot.ircbot");
      for (int i = 0; i < elements.length; i++) {
        String id = elements[i].getAttribute("id");
        String name = elements[i].getAttribute("name");
        String server = elements[i].getAttribute("server");
        String channel = elements[i].getAttribute("channel");
        List c = (List) commands.get(id);
        if (c == null) c = new ArrayList();
        IBotEntry bot = new BotEntry(id, name, server, channel, c);
        bots.put(id, bot);
      }
    }
  }
  private void doActivateOSGi() throws CoreException {
    org.eclipse.core.runtime.IExtensionRegistry extensionRegistry =
        org.eclipse.core.runtime.Platform.getExtensionRegistry();
    if (extensionRegistry == null) {
      return;
    }

    org.eclipse.core.runtime.IConfigurationElement[] elements =
        extensionRegistry.getConfigurationElementsFor(NAMESPACE, EXT_POINT);
    for (org.eclipse.core.runtime.IConfigurationElement element : elements) {
      IElementProcessor processor =
          (IElementProcessor) element.createExecutableExtension(ATTR_CLASS);
      processors.add(processor);
    }

    org.eclipse.core.runtime.IRegistryChangeListener listener =
        new org.eclipse.core.runtime.IRegistryChangeListener() {
          public void registryChanged(org.eclipse.core.runtime.IRegistryChangeEvent event) {
            org.eclipse.core.runtime.IExtensionDelta[] deltas =
                event.getExtensionDeltas(NAMESPACE, EXT_POINT);
            for (org.eclipse.core.runtime.IExtensionDelta delta : deltas) {
              // TODO Handle ExtensionDelta
              OM.LOG.warn("ExtensionDelta not handled: " + delta); // $NON-NLS-1$
            }
          }
        };

    extensionRegistry.addRegistryChangeListener(listener, NAMESPACE);
    extensionRegistryListener = listener;
  }
Esempio n. 4
0
  /** see if any extra right click handlers are defined */
  private static void loadLoaderExtensions() {
    IExtensionRegistry registry = Platform.getExtensionRegistry();

    if (registry != null) {
      final IExtensionPoint point = registry.getExtensionPoint(PLUGIN_ID, EXTENSION_POINT_ID);

      final IExtension[] extensions = point.getExtensions();
      for (int i = 0; i < extensions.length; i++) {
        final IExtension iExtension = extensions[i];
        final IConfigurationElement[] confE = iExtension.getConfigurationElements();
        for (int j = 0; j < confE.length; j++) {
          final IConfigurationElement iConfigurationElement = confE[j];
          RightClickContextItemGenerator newInstance;
          try {
            newInstance =
                (RightClickContextItemGenerator)
                    iConfigurationElement.createExecutableExtension("class");
            addRightClickGenerator(newInstance);
          } catch (final CoreException e) {
            CorePlugin.logError(
                Status.ERROR, "Trouble whilst loading right-click handler extensions", e);
          }
        }
      }
    }
  }
  /** Reads all relevant extensions. */
  private void extensionReader() {
    final IExtensionRegistry registry = Platform.getExtensionRegistry();

    for (final IConfigurationElement ce :
        registry.getConfigurationElementsFor(InternalConstants.SCRIPT_ENGINES_EXTENSION_POINT)) {
      final String elementName = ce.getName();
      if (elementName.equals(InternalConstants.ENGINE_TAG)) {
        final String language = ce.getAttribute(InternalConstants.LANGUAGE_TAG);
        if (language == null || language.length() == 0) {
          LogUtils.error(
              ce, InternalConstants.LANGUAGE_TAG + " must be specified. Ignored"); // $NON-NLS-1$
          continue;
        }

        if (getEngines().get(language) != null) {
          LogUtils.error(ce, "Duplicate declaration of language '" + language + "'. Ignored.");
          continue;
        }

        final IScriptEngineDescriptor engine =
            IScriptEngineFactory.eINSTANCE.createScriptEngineDescriptor();
        engine.init(language, ce);
        getEngines().put(language, engine);
      } else {
        LogUtils.error(ce, "Unknown tag: '" + ce.getName() + "'");
      }
    }
  }
  /** Called by IncQueryBasePlugin. */
  public static void initRegistry() {
    getContributedWellbehavingDerivedFeatures().clear();
    getContributedWellbehavingDerivedClasses().clear();
    getContributedWellbehavingDerivedPackages().clear();

    IExtensionRegistry reg = Platform.getExtensionRegistry();
    IExtensionPoint poi;

    poi = reg.getExtensionPoint(IncQueryBasePlugin.WELLBEHAVING_DERIVED_FEATURE_EXTENSION_POINT_ID);
    if (poi != null) {
      IExtension[] exts = poi.getExtensions();

      for (IExtension ext : exts) {

        IConfigurationElement[] els = ext.getConfigurationElements();
        for (IConfigurationElement el : els) {
          if (el.getName().equals("wellbehaving-derived-feature")) {
            processWellbehavingExtension(el);
          } else {
            throw new UnsupportedOperationException(
                "Unknown configuration element "
                    + el.getName()
                    + " in plugin.xml of "
                    + el.getDeclaringExtension().getUniqueIdentifier());
          }
        }
      }
    }
  }
Esempio n. 7
0
  public ProcessingStep create(
      IProvisioningAgent agent, IProcessingStepDescriptor descriptor, IArtifactDescriptor context) {
    IExtensionRegistry registry = RegistryFactory.getRegistry();
    IExtension extension =
        registry.getExtension(PROCESSING_STEPS_EXTENSION_ID, descriptor.getProcessorId());
    Exception error;
    if (extension != null) {
      IConfigurationElement[] config = extension.getConfigurationElements();
      try {
        Object object = config[0].createExecutableExtension("class"); // $NON-NLS-1$
        ProcessingStep step = (ProcessingStep) object;
        step.initialize(agent, descriptor, context);
        return step;
      } catch (Exception e) {
        error = e;
      }
    } else
      error =
          new ProcessingStepHandlerException(
              NLS.bind(
                  Messages.cannot_get_extension,
                  PROCESSING_STEPS_EXTENSION_ID,
                  descriptor.getProcessorId()));

    int severity = descriptor.isRequired() ? IStatus.ERROR : IStatus.INFO;
    ProcessingStep result = new EmptyProcessingStep();
    result.setStatus(
        new Status(
            severity,
            Activator.ID,
            Messages.cannot_instantiate_step + descriptor.getProcessorId(),
            error));
    return result;
  }
Esempio n. 8
0
 void processingExtensionPointByHand() {
   String xpid = "net.refractions.udig.project.ui.tool";
   IExtensionRegistry registry = Platform.getExtensionRegistry();
   IExtensionPoint extensionPoint = registry.getExtensionPoint(xpid);
   if (extensionPoint == null) {
     throw new NullPointerException("Could not find extensionPoint:" + xpid);
   }
   for (IExtension extension : extensionPoint.getExtensions()) {
     for (IConfigurationElement element : extension.getConfigurationElements()) {
       String name = element.getName();
       System.out.println(name);
       if ("modalTool".equals(name)) {
         try {
           ModalTool tool = (ModalTool) element.createExecutableExtension("class");
           System.out.println(tool);
         } catch (CoreException e) {
           // Perhaps an error in the constructor?
           String message = "Could not create Modal tool " + element.getAttribute("class");
           Status status =
               new Status(IStatus.ERROR, extension.getContributor().getName(), message, e);
           Activator.getDefault().getLog().log(status);
         }
       }
     }
   }
 }
Esempio n. 9
0
  public void testPropertyChange() throws Exception {
    IWorkbenchWindow window = openTestWindow();
    IEvaluationService service = (IEvaluationService) window.getService(IEvaluationService.class);
    assertNotNull(service);
    MyEval listener = new MyEval();
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IConfigurationElement element = null;
    IConfigurationElement[] elements =
        registry.getConfigurationElementsFor("org.eclipse.core.expressions.definitions");
    for (int i = 0; i < elements.length && element == null; i++) {
      if (elements[i].getAttribute("id").equals("org.eclipse.ui.tests.defWithPropertyTester")) {
        element = elements[i];
      }
    }

    assertNotNull(element);
    Expression expr = ExpressionConverter.getDefault().perform(element.getChildren()[0]);
    service.addEvaluationListener(expr, listener, IEvaluationService.RESULT);
    assertFalse(listener.currentValue);
    assertEquals(1, listener.count);

    StaticVarPropertyTester.result = true;
    assertFalse(listener.currentValue);
    assertEquals(1, listener.count);

    service.requestEvaluation("org.eclipse.ui.tests.class.method");
    assertTrue(listener.currentValue);
    assertEquals(2, listener.count);

    service.requestEvaluation("org.eclipse.ui.tests.class.method");
    assertTrue(listener.currentValue);
    assertEquals(2, listener.count);
  }
Esempio n. 10
0
 private synchronized void load() {
   if (commandFilters != null) return;
   commandFilters = new HashMap<String, Set<Pattern>>();
   IExtensionRegistry registry = Platform.getExtensionRegistry();
   IExtensionPoint point = registry.getExtensionPoint("ca.uvic.chisel.logging.eclipse.loggers");
   IConfigurationElement[] elements = point.getConfigurationElements();
   for (IConfigurationElement loggerElement : elements) {
     String categoryID = loggerElement.getAttribute("categoryID");
     if (categoryID != null) {
       for (IConfigurationElement workbenchElement : loggerElement.getChildren("workbench")) {
         for (IConfigurationElement logElement : workbenchElement.getChildren("command")) {
           // get the filters for the command
           String filter = logElement.getAttribute("commandFilter");
           if (filter != null) {
             // create a pattern for the filter
             filter = filter.replace(".", "\\.");
             filter = filter.replace("*", ".*");
             Pattern pattern = Pattern.compile(filter);
             Set<Pattern> filters = commandFilters.get(categoryID);
             if (filters == null) {
               filters = new HashSet<Pattern>();
               commandFilters.put(categoryID, filters);
             }
             filters.add(pattern);
           }
         }
       }
     }
   }
 }
  /** Loads the built-in check configurations defined in plugin.xml or custom fragments. */
  private static void loadBuiltinConfigurations() {

    IExtensionRegistry pluginRegistry = Platform.getExtensionRegistry();

    IConfigurationElement[] elements =
        pluginRegistry.getConfigurationElementsFor(CONFIGS_EXTENSION_POINT);

    for (int i = 0; i < elements.length; i++) {
      String name = elements[i].getAttribute(XMLTags.NAME_TAG);
      String description = elements[i].getAttribute(XMLTags.DESCRIPTION_TAG);
      String location = elements[i].getAttribute(XMLTags.LOCATION_TAG);

      IConfigurationType configType = ConfigurationTypes.getByInternalName("builtin");

      Map<String, String> additionalData = new HashMap<String, String>();
      additionalData.put(
          BuiltInConfigurationType.CONTRIBUTOR_KEY, elements[i].getContributor().getName());

      List<ResolvableProperty> props = new ArrayList<ResolvableProperty>();
      IConfigurationElement[] propEls = elements[i].getChildren(XMLTags.PROPERTY_TAG);
      for (IConfigurationElement propEl : propEls) {
        props.add(
            new ResolvableProperty(
                propEl.getAttribute(XMLTags.NAME_TAG), propEl.getAttribute(XMLTags.VALUE_TAG)));
      }

      ICheckConfiguration checkConfig =
          new CheckConfiguration(
              name, location, description, configType, true, props, additionalData);
      sConfigurations.add(checkConfig);
    }
  }
Esempio n. 12
0
  /** Loads the extension for the source code view. */
  public void loadExtensions() {
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IExtensionPoint point = registry.getExtensionPoint(EXTENSION_POINT_ID);
    if (point == null) {
      return;
    }

    IExtension[] extensions = point.getExtensions();
    if (extensions.length > 0) {
      IExtension ex = extensions[0];
      IConfigurationElement[] elems = ex.getConfigurationElements();
      for (IConfigurationElement h : elems) {
        Object obj = null;
        if (h.getName().compareTo("sourcecodeview") == 0) {

          try {
            obj = h.createExecutableExtension("class");
          } catch (CoreException e) {
            e.printStackTrace();
          }
          if (obj instanceof SourceCodeView) {
            sourceCodeView = (SourceCodeView) obj;
          }
        }
      }
    }
  }
 public static List<ICheckNodesService> getCheckNodesService() {
   if (checkNodeServices == null) {
     checkNodeServices = new ArrayList<ICheckNodesService>();
     IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
     IExtensionPoint extensionPoint =
         extensionRegistry.getExtensionPoint(
             "org.talend.designer.core.check_nodes"); //$NON-NLS-1$
     if (extensionPoint != null) {
       IExtension[] extensions = extensionPoint.getExtensions();
       for (IExtension extension : extensions) {
         IConfigurationElement[] configurationElements = extension.getConfigurationElements();
         for (IConfigurationElement configurationElement : configurationElements) {
           try {
             Object service =
                 configurationElement.createExecutableExtension("class"); // $NON-NLS-1$
             if (service instanceof ICheckNodesService) {
               checkNodeServices.add((ICheckNodesService) service);
             }
           } catch (CoreException e) {
             ExceptionHandler.process(e);
           }
         }
       }
     }
   }
   return checkNodeServices;
 }
Esempio n. 14
0
  private ToolbarDockableRegistry() {
    super();

    IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
    if (extensionRegistry == null) {
      return;
    }
    IConfigurationElement[] extensions =
        extensionRegistry.getConfigurationElementsFor(EXTENSION_POINT_ID);
    for (IConfigurationElement element : extensions) {
      String groupId = element.getAttribute(ATT_GROUP_ID);
      if (groupId == null || groupId.trim().length() == 0) {
        groupId = GLOBAL_GROUP_ID;
      }
      List<Dockable> compos = toolbarDockables.get(groupId);
      if (compos == null) {
        compos = new ArrayList<Dockable>();
      }

      try {
        JComponent compo = (JComponent) element.createExecutableExtension(ATT_CLASS);
        Dockable dockable = new ButtonDockable(element.getAttribute(ATT_ID), compo);
        createDockableDragger(dockable);
        compos.add(dockable);
      } catch (Exception e) {
        e.printStackTrace();
      }
      toolbarDockables.put(groupId, compos);
    }
  }
  /**
   * Dump the whole extension registry up to the specified nesting depth.
   *
   * @param extensionPointPrefix considering only extension points that have this prefix or null for
   *     all
   * @param depth nesting depth
   */
  public static void dumpRegistry(final String extensionPointPrefix, final int depth) {
    final IExtensionRegistry extensionRegistry = RegistryFactory.getRegistry();
    if (extensionRegistry == null) {
      System.out.println("No extension registry available."); // $NON-NLS-1$
      return;
    }
    final Object strategy = ReflectionUtils.getHidden(extensionRegistry, "strategy"); // $NON-NLS-1$
    final StringBuilder bob = new StringBuilder("<< Registry"); // $NON-NLS-1$
    if (extensionPointPrefix != null) {
      bob.append(" for prefix ").append(extensionPointPrefix); // $NON-NLS-1$
    }
    bob.append(" with strategy ")
        .append(strategy.getClass().getSimpleName())
        .append(":"); // $NON-NLS-1$ //$NON-NLS-2$
    System.out.println(bob);

    final IExtensionPoint[] extensionPoints = extensionRegistry.getExtensionPoints();

    Arrays.sort(
        extensionPoints,
        new Comparator<IExtensionPoint>() {
          public int compare(final IExtensionPoint ep1, final IExtensionPoint ep2) {
            return ep1.getUniqueIdentifier().compareTo(ep2.getUniqueIdentifier());
          }
        });
    for (final IExtensionPoint extensionPoint : extensionPoints) {
      if (extensionPointPrefix != null
          && !extensionPoint.getUniqueIdentifier().startsWith(extensionPointPrefix)) {
        continue;
      }
      System.out.println(extensionPoint.getUniqueIdentifier() + ":"); // $NON-NLS-1$
      dumpExtensions(extensionPoint.getExtensions(), depth);
    }
    System.out.println(">>"); // $NON-NLS-1$
  }
Esempio n. 16
0
  private void initGlobaleGuiceInjector() {
    List<Module> moduleList = new ArrayList<Module>();
    IExtensionRegistry reg = Platform.getExtensionRegistry();
    IConfigurationElement[] extensions =
        reg.getConfigurationElementsFor(ISharedModuleProvider.EXTENSION_POINT_ID);
    for (int i = 0; i < extensions.length; i++) {
      IConfigurationElement element = extensions[i];
      if (element.getAttribute("class") != null) {
        try {
          ISharedModuleProvider provider =
              (ISharedModuleProvider) element.createExecutableExtension("class");
          moduleList.add(provider.get());
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }

    Injector injector = Guice.createInjector(moduleList);
    try {
      Field field = GuiceContext.class.getDeclaredField("globalSharedInjector");
      field.setAccessible(true);
      field.set(GuiceContext.class, injector);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  /**
   * Get a list of plot views from extension register
   *
   * @return list of views
   */
  public static List<String> getRegisteredViews() {
    List<String> plotViews = new LinkedList<String>();

    IExtensionRegistry registry = Platform.getExtensionRegistry();

    // Add the default point first, this is where the double click action will go
    IExtensionPoint point =
        registry.getExtensionPoint("uk.ac.diamond.scisoft.analysis.rcp.ExplorerViewDefault");
    IExtension[] extensions = point.getExtensions();
    for (int i = 0; i < extensions.length; i++) {
      IConfigurationElement[] elements = extensions[i].getConfigurationElements();
      for (int i1 = 0; i1 < elements.length; i1++) {
        if (elements[i1].getName().equals("ViewDefaultRegister")) {
          if (!plotViews.contains(elements[i1].getAttribute("ViewName")))
            plotViews.add(elements[i1].getAttribute("ViewName"));
        }
      }
    }

    // now add all the other contributions to the list
    point = registry.getExtensionPoint("uk.ac.diamond.scisoft.analysis.rcp.ExplorerViewRegister");
    extensions = point.getExtensions();
    for (int i = 0; i < extensions.length; i++) {
      IConfigurationElement[] elements = extensions[i].getConfigurationElements();
      for (int i1 = 0; i1 < elements.length; i1++) {
        if (elements[i1].getName().equals("ViewRegister")) {
          if (!plotViews.contains(elements[i1].getAttribute("ViewName")))
            plotViews.add(elements[i1].getAttribute("ViewName"));
        }
      }
    }
    return plotViews;
  }
  @Override
  protected void findModelTypes() {
    modelTypes = new ArrayList<ModelTypeExtension>();
    IExtensionRegistry registry = Platform.getExtensionRegistry();

    IExtensionPoint extensionPoint =
        registry.getExtensionPoint("org.eclipse.epsilon.common.dt.modelType");
    IConfigurationElement[] configurationElements = extensionPoint.getConfigurationElements();

    try {
      for (int i = 0; i < configurationElements.length; i++) {
        IConfigurationElement configurationElement = configurationElements[i];
        // Intercept the EMF model as we want to provide our reduced dialog
        String type = configurationElement.getAttribute("type");
        ModelTypeExtension modelType = new ModelTypeExtension();
        modelType.setClazz(configurationElement.getAttribute("class"));
        modelType.setType(type);
        modelType.setLabel(configurationElement.getAttribute("label"));
        modelType.setStable(Boolean.parseBoolean(configurationElement.getAttribute("stable")));

        String contributingPlugin =
            configurationElement.getDeclaringExtension().getNamespaceIdentifier();
        Image image =
            AbstractUIPlugin.imageDescriptorFromPlugin(
                    contributingPlugin, configurationElement.getAttribute("icon"))
                .createImage();
        modelType.setImage(image);
        modelType.setConfigurationElement(configurationElement);
        modelTypes.add(modelType);
      }
    } catch (Exception ex) {
      LogUtil.log(ex);
    }
  }
 private List<OpenWizardDescr> loadDataProviders() {
   List<OpenWizardDescr> res = new LinkedList<>();
   IExtensionRegistry registry = Platform.getExtensionRegistry();
   if (registry == null) {
     return res;
   }
   IExtensionPoint point = registry.getExtensionPoint(OPENWIZARD_EXTENSION_POINT);
   if (point == null) {
     return res;
   }
   for (IExtension extension : point.getExtensions()) {
     if (null != extension) {
       for (IConfigurationElement element : extension.getConfigurationElements()) {
         if (null != element) {
           try {
             res.add(createDescr(element));
           } catch (CoreException e) {
             // just ignore
           }
         }
       }
     }
   }
   return res;
 }
 private static QvtTransformationInterpreterFactory getInterpreterFactory() throws MdaException {
   if (implFactory != null) {
     return implFactory;
   }
   IExtensionRegistry pluginRegistry = Platform.getExtensionRegistry();
   IExtensionPoint extensionPoint =
       pluginRegistry.getExtensionPoint(
           QvtTransformationInterpreterFactory.Descriptor.FACTORY_POINT_ID);
   if (extensionPoint != null) {
     IExtension[] allExtensions = extensionPoint.getExtensions();
     // take only first suitable factory
     for (IExtension ext : allExtensions) {
       IConfigurationElement[] elements = ext.getConfigurationElements();
       Object factoryObj = null;
       try {
         factoryObj =
             elements[0].createExecutableExtension(
                 QvtTransformationInterpreterFactory.Descriptor.CLASS_ATTR);
       } catch (CoreException e) {
         throw new MdaException(e);
       }
       return implFactory = (QvtTransformationInterpreterFactory) factoryObj;
     }
   }
   throw new MdaException(Messages.NoQvtImplementorFactoryRegistered);
 }
 /*
  * Internal hook for unit testing.
  */
 public AbstractCriteriaDefinitionProvider[] getCriteriaDefinitionProviders() {
   if (null == criteriaDefinitionProviders) {
     List<AbstractCriteriaDefinitionProvider> providers = new ArrayList<>();
     IExtensionRegistry registry = Platform.getExtensionRegistry();
     IConfigurationElement[] elements =
         registry.getConfigurationElementsFor(EXTENSION_POINT_ID_CRITERIA_DEFINITION);
     for (int i = 0; i < elements.length; ++i) {
       IConfigurationElement elem = elements[i];
       if (elem.getName().equals(ELEMENT_NAME_CRITERIA_DEFINITION_PROVIDER)) {
         try {
           AbstractCriteriaDefinitionProvider provider =
               (AbstractCriteriaDefinitionProvider)
                   elem.createExecutableExtension(ATTRIBUTE_NAME_CLASS);
           providers.add(provider);
         } catch (CoreException e) {
           // log and skip
           String msg =
               "Error instantiating help keyword index provider class \""
                   + elem.getAttribute(ATTRIBUTE_NAME_CLASS)
                   + '"'; //$NON-NLS-1$
           HelpPlugin.logError(msg, e);
         }
       }
     }
     criteriaDefinitionProviders =
         providers.toArray(new AbstractCriteriaDefinitionProvider[providers.size()]);
   }
   return criteriaDefinitionProviders;
 }
Esempio n. 22
0
 EngineExtensionManager() {
   IExtensionRegistry registry = Platform.getExtensionRegistry();
   IExtensionPoint extensionPoint =
       registry.getExtensionPoint("org.eclipse.birt.core.FactoryService");
   IExtension[] extensions = extensionPoint.getExtensions();
   for (IExtension extension : extensions) {
     IConfigurationElement[] elements = extension.getConfigurationElements();
     for (IConfigurationElement element : elements) {
       String type = element.getAttribute("type");
       if ("org.eclipse.birt.report.engine.extension".equals(type)) {
         try {
           Object factoryObject = element.createExecutableExtension("class");
           if (factoryObject instanceof IReportEngineExtensionFactory) {
             IReportEngineExtensionFactory factory =
                 (IReportEngineExtensionFactory) factoryObject;
             IReportEngineExtension engineExtension = factory.createExtension(ReportEngine.this);
             exts.put(engineExtension.getExtensionName(), engineExtension);
           }
         } catch (CoreException ex) {
           logger.log(Level.WARNING, "can not load the engine extension factory", ex);
         }
       }
     }
   }
 }
Esempio n. 23
0
 /** Load the generator images. */
 private static void loadGeneratorImages() {
   Trace.trace(Trace.CONFIG, "->- Loading .generatorImages extension point ->-");
   IExtensionRegistry registry = Platform.getExtensionRegistry();
   loadGeneratorImages(
       registry.getConfigurationElementsFor(JM2TUI.PLUGIN_ID, JM2TUI.EXTENSION_GENERATOR_IMAGES));
   JM2TUI.addRegistryListener();
   Trace.trace(Trace.CONFIG, "-<- Done loading .generatorImages extension point -<-");
 }
 /**
  * Given extension point id, retrieves all extender classes that use this extension point.
  *
  * @param extensionPointID Identifier of the extension point that is given.
  * @return Extender classes that use the extension point represented by the id.
  */
 private IConfigurationElement[] getConfigurationElements(String extensionPointID) {
   IExtensionRegistry registry = Platform.getExtensionRegistry();
   IExtensionPoint contentTypesXP = registry.getExtensionPoint(extensionPointID);
   if (contentTypesXP == null) return new IConfigurationElement[0];
   logger.fine("contentTypes XP = " + contentTypesXP);
   IConfigurationElement[] allContentTypeCEs = contentTypesXP.getConfigurationElements();
   return allContentTypeCEs;
 }
  /** @return the list of {@code CloneSourceProvider} read from the extension point registry */
  public static List<CloneSourceProvider> getCloneSourceProvider() {
    List<CloneSourceProvider> cloneSourceProvider = new ArrayList<>();

    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IConfigurationElement[] config = registry.getConfigurationElementsFor(CLONE_SOURCE_PROVIDER_ID);
    if (config.length > 0) addCloneSourceProvider(cloneSourceProvider, config, 0);

    return cloneSourceProvider;
  }
Esempio n. 26
0
 /**
  * Check to see that we have processors for all the steps in the given descriptor
  *
  * @param descriptor the descriptor to check
  * @return whether or not processors for all the descriptor's steps are installed
  */
 public static boolean canProcess(IArtifactDescriptor descriptor) {
   IExtensionRegistry registry = RegistryFactory.getRegistry();
   IExtensionPoint point = registry.getExtensionPoint(PROCESSING_STEPS_EXTENSION_ID);
   if (point == null) return false;
   IProcessingStepDescriptor[] steps = descriptor.getProcessingSteps();
   for (int i = 0; i < steps.length; i++) {
     if (point.getExtension(steps[i].getProcessorId()) == null) return false;
   }
   return true;
 }
 /**
  * If the extension registry for PlanFactory has an element the action of which is the given ID
  * string, return the value of the attribute with the given key string.
  *
  * @param id the required value of the element's "action attribute
  * @param key the key of the attribute to return
  * @return the value of the attribute with the given key; if not found, null
  */
 public String getActionProperty(String id, String key) {
   IExtensionRegistry registry = Platform.getExtensionRegistry();
   IConfigurationElement[] elements =
       registry.getConfigurationElementsFor("gov.nasa.ensemble.core.model.plan.PlanFactory");
   for (int i = 0; i < elements.length; i++) {
     IConfigurationElement element = elements[i];
     if (id.equals(element.getAttribute("action"))) return element.getAttribute(key);
   }
   return null;
 }
Esempio n. 28
0
 /**
  * Returns all contributed Erlang element filters.
  *
  * @return all contributed Erlang element filters
  */
 public static Collection<FilterDescriptor> getFilterDescriptors() {
   if (fgFilterDescriptors == null) {
     final IExtensionRegistry registry = Platform.getExtensionRegistry();
     final IConfigurationElement[] elements =
         registry.getConfigurationElementsFor(ErlideUIPlugin.PLUGIN_ID, EXTENSION_POINT_NAME);
     final String extensionPointID = ErlideUIPlugin.PLUGIN_ID + "." + EXTENSION_POINT_NAME;
     fgFilterDescriptors = createFilterDescriptors(elements, extensionPointID);
   }
   return fgFilterDescriptors;
 }
  private void doDeactivateOSGi() {
    org.eclipse.core.runtime.IExtensionRegistry extensionRegistry =
        org.eclipse.core.runtime.Platform.getExtensionRegistry();
    if (extensionRegistry == null) {
      return;
    }

    extensionRegistry.removeRegistryChangeListener(
        (org.eclipse.core.runtime.IRegistryChangeListener) extensionRegistryListener);
  }
  /** key is the plugin id, value is the plugin library path */
  public static synchronized SortedMap<String, String> getContributedDetectors() {
    if (contributedDetectors != null) {
      return contributedDetectors;
    }
    TreeMap<String, String> set = new TreeMap<String, String>();

    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IExtensionPoint point = registry.getExtensionPoint(EXTENSION_POINT_ID);
    if (point == null) {
      return set;
    }
    IExtension[] extensions = point.getExtensions();
    for (IExtension extension : extensions) {
      IConfigurationElement[] elements = extension.getConfigurationElements();
      for (IConfigurationElement configElt : elements) {
        String libPathAsString;
        String pluginId;
        IContributor contributor = null;
        try {
          contributor = configElt.getContributor();
          if (contributor == null) {
            throw new IllegalArgumentException("Null contributor");
          }
          pluginId = configElt.getAttribute(PLUGIN_ID);
          if (pluginId == null) {
            throw new IllegalArgumentException("Missing '" + PLUGIN_ID + "'");
          }
          libPathAsString = configElt.getAttribute(LIBRARY_PATH);
          if (libPathAsString == null) {
            throw new IllegalArgumentException("Missing '" + LIBRARY_PATH + "'");
          }
          libPathAsString = resolveRelativePath(contributor, libPathAsString);
          if (libPathAsString == null) {
            throw new IllegalArgumentException("Failed to resolve library path for: " + pluginId);
          }
          if (set.containsKey(pluginId)) {
            throw new IllegalArgumentException("Duplicated '" + pluginId + "' contribution.");
          }
          set.put(pluginId, libPathAsString);
        } catch (Throwable e) {
          String cName = contributor != null ? contributor.getName() : "unknown contributor";
          String message =
              "Failed to read contribution for '"
                  + EXTENSION_POINT_ID
                  + "' extension point from "
                  + cName;
          FindbugsPlugin.getDefault().logException(e, message);
          continue;
        }
      }
    }
    contributedDetectors = set;
    return contributedDetectors;
  }