Пример #1
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);
      }
    }
  }
Пример #2
0
  /** 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() + "'");
      }
    }
  }
 private PreferenceNodeElement[] getElements() {
   final IConfigurationElement[] extensions =
       registry.getConfigurationElementsFor(PREF_EXTENSION_POINT);
   final PreferenceNodeElement[] elements = new PreferenceNodeElement[extensions.length];
   final int length = extensions.length;
   for (int i = 0; i < length; i++) {
     final PreferenceNodeElement nodeElement = new PreferenceNodeElement();
     nodeElement.name = extensions[i].getAttribute(PREF_PAGE_ATTR_NAME);
     nodeElement.className = extensions[i].getAttribute(PREF_PAGE_ATTR_CLASS);
     nodeElement.bundleID = extensions[i].getContributor().getName();
     nodeElement.id = extensions[i].getAttribute(PREF_PAGE_ATTR_ID);
     nodeElement.category = extensions[i].getAttribute(PREF_PAGE_ATTR_CATEGORY);
     if (nodeElement.id != null
         && nodeElement.name != null
         && nodeElement.className != null
         && nodeElement.bundleID != null) {
       elements[i] = nodeElement;
     } else {
       logger.warn(
           MessageFormat.format(
               "Couldn''t load the preferences extension for the page {0}, of the plugin {1}.",
               nodeElement.name, nodeElement.bundleID));
     }
   }
   Arrays.sort(elements);
   return elements;
 }
Пример #4
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);
  }
Пример #5
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);
    }
  }
  /** 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);
    }
  }
  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;
  }
 /*
  * 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;
 }
Пример #9
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();
    }
  }
Пример #10
0
 private void loadNavigatorItems(IExtensionRegistry reg) throws CoreException {
   for (IConfigurationElement ice : reg.getConfigurationElementsFor(PLUGIN_ID, "navigatorItems")) {
     if ("node".equals(ice.getName())) {
       NavigatorItemContrib nic = new NavigatorItemContrib(ice);
       NAVIGATOR_ITEMS.add(nic);
     }
   }
 }
Пример #11
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 -<-");
 }
Пример #12
0
 public void loadInitialPerspective(IExtensionRegistry registry) {
   for (IConfigurationElement ice :
       registry.getConfigurationElementsFor(PLUGIN_ID, "initialPerspective")) {
     if ("perspective".equals(ice.getName())) {
       INITIAL_PERSPECTIVE = ice.getAttribute("id");
     }
   }
   if (INITIAL_PERSPECTIVE == null) INITIAL_PERSPECTIVE = Perspective.ID;
 }
  /** @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;
  }
Пример #14
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;
 }
 /**
  * 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;
 }
Пример #16
0
  /**
   * Creates a new configuration parser that parses all configuration files located in the
   * configuration folder (defined in the plug-in preferences).
   *
   * @throws CoreException
   * @see FileLocator
   */
  public ConfigurationParser() throws CoreException {
    configurations = new LinkedHashMap<String, Configuration>();

    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IConfigurationElement[] elements =
        registry.getConfigurationElementsFor(PLUGIN_ID + ".definition");
    for (IConfigurationElement element : elements) {
      Configuration configuration = parseConfiguration(element);
      configurations.put(configuration.getName(), configuration);
    }
  }
  private void loadRegisters() {

    IExtensionRegistry reg = Platform.getExtensionRegistry();
    IConfigurationElement[] extensions = reg.getConfigurationElementsFor(EXTENSION_POINT);

    PhaseMethodRegistryExtension registry;
    for (IConfigurationElement extension : extensions) {
      registry = new PhaseMethodRegistryExtension(extension);
      _registers.put(registry.getAttribute(EPhaseMethodElements.id), registry);
    }
  }
Пример #18
0
  private void loadRegistersNewDomainDialog(IExtensionRegistry reg) {

    IConfigurationElement[] extensions =
        reg.getConfigurationElementsFor(NEW_DOMAIN_DIALOG_EXTENSION_POINT);

    NewDomainDialogRegistryExtension registry;
    for (IConfigurationElement extension : extensions) {
      registry = new NewDomainDialogRegistryExtension(extension);
      _newDomainDialogRegisters.put(registry.getElement(ENewDomainDialogElements.id), registry);
    }
  }
Пример #19
0
  private void loadRegisters() {
    IExtensionRegistry reg = Platform.getExtensionRegistry();
    IConfigurationElement[] extensions = reg.getConfigurationElementsFor(EXTENSION_POINT);

    DomainUIRegistryExtension registry;
    for (IConfigurationElement extension : extensions) {
      registry = new DomainUIRegistryExtension(extension);
      _registers.put(registry.getElement(EDomainUIElements.domain), registry);
    }

    loadRegistersNewDomainDialog(reg);
    loadRegistersModifyDomainDialog(reg);
  }
Пример #20
0
 private IBranchNameProvider getBranchNameProvider() {
   IExtensionRegistry registry = Platform.getExtensionRegistry();
   IConfigurationElement[] config = registry.getConfigurationElementsFor(BRANCH_NAME_PROVIDER_ID);
   if (config.length > 0) {
     Object provider;
     try {
       provider = config[0].createExecutableExtension("class"); // $NON-NLS-1$
       if (provider instanceof IBranchNameProvider) return (IBranchNameProvider) provider;
     } catch (Throwable e) {
       Activator.logError(UIText.CreateBranchPage_CreateBranchNameProviderFailed, e);
     }
   }
   return null;
 }
Пример #21
0
 public static void loadProviders() {
   IExtensionRegistry registry = Platform.getExtensionRegistry();
   IConfigurationElement[] configurations =
       registry.getConfigurationElementsFor(Activator.PLUGIN_ID, Activator.EXTENSION_LOGIN_ID);
   for (IConfigurationElement configuration : configurations) {
     try {
       LoginProvider provider = (LoginProvider) configuration.createExecutableExtension("class");
       PROVIDERS.add(provider);
     } catch (Exception e) {
       LOGGER.error("解析LoginProvider失败", e);
       throw new RuntimeException(e);
     }
   }
 }
 private ICommitMessageProvider getCommitMessageProvider() throws CoreException {
   IExtensionRegistry registry = Platform.getExtensionRegistry();
   IConfigurationElement[] config =
       registry.getConfigurationElementsFor(COMMIT_MESSAGE_PROVIDER_ID);
   if (config.length > 0) {
     Object provider;
     provider = config[0].createExecutableExtension("class"); // $NON-NLS-1$
     if (provider instanceof ICommitMessageProvider) {
       return (ICommitMessageProvider) provider;
     } else {
       Activator.logError(UIText.CommitDialog_WrongTypeOfCommitMessageProvider, null);
     }
   }
   return null;
 }
 /**
  * If the extension registry for PlanFactory has an element the action of which is the given ID
  * string, return the PlanFactory; otherwise return null string,
  *
  * @param id the required value of the element's "action" attribute
  * @return the PlanFactory instance if found; otherwise null
  */
 public IPlanFactory getAction(String id) {
   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")))
       try {
         return (IPlanFactory) element.createExecutableExtension("class");
       } catch (CoreException e) {
         LogUtil.error("Unable to instantiate action:", e);
       }
   }
   return null;
 }
 /**
  * Return a list of all the values of the "action" attribute for the elements in the extension
  * registry for PlanFactory.
  *
  * @return a list of all the values of the "action" attribute for the elements in the extension
  *     registry for PlanFactory
  */
 public List<String> getAvailable() {
   IExtensionRegistry registry = Platform.getExtensionRegistry();
   List<String> result = new ArrayList<String>();
   synchronized (this) {
     IConfigurationElement[] elements =
         registry.getConfigurationElementsFor("gov.nasa.ensemble.core.model.plan.PlanFactory");
     for (int i = 0; i < elements.length; i++) {
       IConfigurationElement element = elements[i];
       String key = element.getAttribute("action");
       if (key != null) {
         result.add(key);
       }
     }
   }
   return result;
 }
Пример #25
0
 public void loadBootJobs(IExtensionRegistry reg) {
   for (IConfigurationElement ice : reg.getConfigurationElementsFor(PLUGIN_ID, "bootTask")) {
     if ("onBoot".equals(ice.getName())) {
       try {
         BOOT_JOBS.add(
             Pair.valueOf(
                 ice.getAttribute("taskName"),
                 (IRunnableWithProgress) ice.createExecutableExtension("taskAction")));
       } catch (InvalidRegistryObjectException e) {
         logger.log(Level.SEVERE, e.getMessage(), e);
       } catch (CoreException e) {
         logger.log(Level.SEVERE, e.getMessage(), e);
       }
     }
   }
 }
  private List<Action> readToolbarActions(EObject modelElement, final EditingDomain editingDomain) {
    final List<Action> actions = new ArrayList<Action>();
    final IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
    if (extensionRegistry == null) {
      return actions;
    }
    if (!VView.class.isInstance(modelElement)) {
      return actions;
    }
    final VView view = (VView) modelElement;

    final IConfigurationElement[] controls =
        extensionRegistry.getConfigurationElementsFor(
            "org.eclipse.emf.ecp.view.treemasterdetail.ui.swt.masterDetailActions"); //$NON-NLS-1$
    for (final IConfigurationElement e : controls) {
      try {
        final String location = e.getAttribute("location"); // $NON-NLS-1$
        if (!location.equals("toolbar")) { // $NON-NLS-1$
          continue;
        }

        final String label = e.getAttribute("label"); // $NON-NLS-1$
        final String imagePath = e.getAttribute("imagePath"); // $NON-NLS-1$
        final MasterDetailAction command =
            (MasterDetailAction) e.createExecutableExtension("command"); // $NON-NLS-1$
        final Action newAction =
            new Action() {
              @Override
              public void run() {
                super.run();
                command.execute(view);
              }
            };

        newAction.setImageDescriptor(
            ImageDescriptor.createFromURL(
                FrameworkUtil.getBundle(command.getClass()).getResource(imagePath)));
        newAction.setText(label);
        actions.add(newAction);
      } catch (final CoreException e1) {
        e1.printStackTrace();
      }
    }
    return actions;
  }
  /** Tests that the services extension point for {@link BindingSourceProvider} is correct. */
  @Test
  public void testServicesExtension() {
    boolean found = false;
    final Map<String, Object> currentState = myProvider.getCurrentState();
    final List<String> providedSourceNames = Arrays.asList(myProvider.getProvidedSourceNames());

    final IExtensionRegistry registry = Platform.getExtensionRegistry();
    for (final IConfigurationElement ce :
        registry.getConfigurationElementsFor("org.eclipse.ui.services")) {
      if (!ce.getContributor().getName().equals(Activator.ID)) {
        continue;
      }
      assertEquals("sourceProvider", ce.getName());
      if (!ce.getAttribute("provider").equals(BindingSourceProvider.class.getName())) {
        continue;
      }

      /*
       * Only one declaration
       */
      assertTrue(!found);
      found = true;

      final IConfigurationElement[] children = ce.getChildren("variable");
      final List<String> childrenVariables = new ArrayList<String>();
      for (final IConfigurationElement cce : children) {
        final String name = cce.getAttribute("name");
        assertFalse(name + " listed twice", childrenVariables.contains(name));
        childrenVariables.add(name);
        assertTrue(name + " not in current state", currentState.containsKey(name));
        if (name.equals(Constants.SOURCES_THE_MANAGER)) {
          assertEquals(name + " priority", "workbench", cce.getAttribute("priorityLevel"));
        } else {
          assertEquals(name + " priority", "activeSite", cce.getAttribute("priorityLevel"));
        }
      }
      for (final String name : childrenVariables) {
        assertTrue(name + " not in provider names", providedSourceNames.contains(name));
      }
      assertEquals(providedSourceNames.size(), children.length);
    }

    assertTrue(found);
  }
  private synchronized void ensureSortersRead() {
    if (fSorters != null) {
      return;
    }

    Map<String, ProposalSorterHandle> sorters = new LinkedHashMap<String, ProposalSorterHandle>();
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    List<IConfigurationElement> elements =
        new ArrayList<IConfigurationElement>(
            Arrays.asList(
                registry.getConfigurationElementsFor(
                    DartToolsPlugin.getPluginId(), EXTENSION_POINT)));

    for (Iterator<IConfigurationElement> iter = elements.iterator(); iter.hasNext(); ) {
      IConfigurationElement element = iter.next();

      try {

        ProposalSorterHandle handle = new ProposalSorterHandle(element);
        final String id = handle.getId();
        sorters.put(id, handle);
        if (DEFAULT_ID.equals(id)) {
          fDefaultSorter = handle;
        }

      } catch (InvalidRegistryObjectException x) {
        /*
         * Element is not valid any longer as the contributing plug-in was unloaded or for some
         * other reason. Do not include the extension in the list and inform the user about it.
         */
        Object[] args = {element.toString()};
        String message =
            Messages.format(
                DartTextMessages.CompletionProposalComputerRegistry_invalid_message, args);
        IStatus status =
            new Status(IStatus.WARNING, DartToolsPlugin.getPluginId(), IStatus.OK, message, x);
        informUser(status);
      }
    }

    fSorters = sorters;
  }
  private void load() throws Exception {
    IExtensionRegistry extRegistry = Platform.getExtensionRegistry();
    IConfigurationElement[] extensions = extRegistry.getConfigurationElementsFor(EXT_POINT_ID);
    for (IConfigurationElement element : extensions) {
      if (!FACTORY_ID.equals(element.getName())) continue;

      IExecutionAdminFactory factory =
          (IExecutionAdminFactory) element.createExecutableExtension(CLASS_ATTRIBUTE_ID);

      IConfigurationElement[] versions = element.getChildren(VERSION_ELEMENT_ID);
      for (IConfigurationElement version : versions) {
        String major = version.getAttribute(MAJOR_ATTRIBUTE_ID);
        String minor = version.getAttribute(MINOR_ATTRIBUTE_ID);
        String micro = version.getAttribute(MICRO_ATTRIBUTE_ID);

        ITeiidServerVersion serverVersion = new TeiidServerVersion(major, minor, micro);
        factories.put(serverVersion, factory);
      }
    }
  }
Пример #30
0
  /**
   * Returns all templates for a specified category.
   *
   * @param categoryId
   * @return
   */
  public ITemplate[] getTemplates(String categoryId) {
    List<ITemplate> ret = new ArrayList<ITemplate>();
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IConfigurationElement[] elements =
        registry.getConfigurationElementsFor(EXTENSIONPOINT_RECORD_TEMPLATES);

    for (int i = 0; i < elements.length; i++) {
      try {
        if (elements[i].getName().equals("template")
            && categoryId.equalsIgnoreCase(elements[i].getAttribute("category"))) {
          Template template = new Template();
          template.init(elements[i]);
          ret.add(template);
        }
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    }

    return ret.toArray(new ITemplate[ret.size()]);
  }