/**
   * 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;
  }
Esempio n. 2
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);
         }
       }
     }
   }
 }
 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. 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);
          }
        }
      }
    }
  }
Esempio n. 5
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);
         }
       }
     }
   }
 }
  @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);
    }
  }
  /** 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());
          }
        }
      }
    }
  }
  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();
  }
 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;
 }
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);
           }
         }
       }
     }
   }
 }
 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);
 }
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;
          }
        }
      }
    }
  }
 /** @return true if some extensions were found */
 protected boolean configure(String extensionPointId) {
   IExtensionPoint extPoint = registry.getExtensionPoint(extensionPointId);
   if (extPoint == null) {
     return false;
   }
   IExtension[] extensions = extPoint.getExtensions();
   if (extensions.length == 0) {
     return false;
   }
   Map<String, Map<String, ICSSPropertyHandler>> handlersMap =
       new HashMap<String, Map<String, ICSSPropertyHandler>>();
   for (IExtension e : extensions) {
     for (IConfigurationElement ce : e.getConfigurationElements()) {
       if (ce.getName().equals(ATTR_HANDLER)) {
         // a single handler may implement a number of properties
         String name = ce.getAttribute(ATTR_COMPOSITE);
         String adapter = ce.getAttribute(ATTR_ADAPTER);
         // if (className.equals(adapter)) {
         IConfigurationElement[] children = ce.getChildren();
         String[] names = new String[children.length];
         String[] deprecated = new String[children.length];
         for (int i = 0; i < children.length; i++) {
           if (children[i].getName().equals(ATTR_PROPERTY_NAME)) {
             names[i] = children[i].getAttribute(ATTR_NAME);
             deprecated[i] = children[i].getAttribute(ATTR_DEPRECATED);
             if (deprecated[i] != null) {
               hasDeprecatedProperties = true;
             }
           }
         }
         try {
           Map<String, ICSSPropertyHandler> adaptersMap = handlersMap.get(adapter);
           if (adaptersMap == null) {
             handlersMap.put(adapter, adaptersMap = new HashMap<String, ICSSPropertyHandler>());
           }
           if (!adaptersMap.containsKey(name)) {
             Object t = ce.createExecutableExtension(ATTR_HANDLER);
             if (t instanceof ICSSPropertyHandler) {
               for (int i = 0; i < names.length; i++) {
                 adaptersMap.put(
                     names[i],
                     deprecated[i] == null
                         ? (ICSSPropertyHandler) t
                         : new DeprecatedPropertyHandlerWrapper(
                             (ICSSPropertyHandler) t, deprecated[i]));
               }
             } else {
               logError("invalid property handler for " + name);
             }
           }
         } catch (CoreException e1) {
           logError("invalid property handler for " + name + ": " + e1);
         }
       }
     }
   }
   propertyHandlerMap.putAll(handlersMap);
   return true;
 }
 /**
  * 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;
 }
 /** Start the registry reading process using the supplied plugin ID and extension point. */
 protected void readRegistry(IExtensionRegistry registry, String pluginId, String extensionPoint) {
   IExtensionPoint point = registry.getExtensionPoint(pluginId, extensionPoint);
   if (point != null) {
     IExtension[] extensions = point.getExtensions();
     extensions = orderExtensions(extensions);
     for (int i = 0; i < extensions.length; i++) readExtension(extensions[i]);
   }
 }
    public static void initExtensions() {
      if (!extensionsRead) {
        IExtensionRegistry registry = Platform.getExtensionRegistry();

        IExtensionPoint extensionPoint =
            registry.getExtensionPoint(BridgesExtensionPointReader.EXTENSION_ID_CONTEXT);
        IExtension[] extensions = extensionPoint.getExtensions();
        for (IExtension extension : extensions) {
          IConfigurationElement[] elements = extension.getConfigurationElements();
          for (IConfigurationElement element : elements) {
            if (element.getName().compareTo(BridgesExtensionPointReader.ELEMENT_STRUCTURE_BRIDGE)
                == 0) {
              readBridge(element);
            }
          }
        }

        // internal bridges
        extensionPoint =
            registry.getExtensionPoint(BridgesExtensionPointReader.EXTENSION_ID_INTERNAL_CONTEXT);
        extensions = extensionPoint.getExtensions();
        for (IExtension extension : extensions) {
          IConfigurationElement[] elements = extension.getConfigurationElements();
          for (IConfigurationElement element : elements) {
            if (element.getName().compareTo(BridgesExtensionPointReader.ELEMENT_SHADOW) == 0) {
              readInternalBridge(element);
            }
          }
        }

        extensionPoint =
            registry.getExtensionPoint(BridgesExtensionPointReader.EXTENSION_ID_RELATION_PROVIDERS);
        extensions = extensionPoint.getExtensions();
        for (IExtension extension : extensions) {
          IConfigurationElement[] elements = extension.getConfigurationElements();
          for (IConfigurationElement element : elements) {
            if (element.getName().compareTo(BridgesExtensionPointReader.ELEMENT_RELATION_PROVIDER)
                == 0) {
              readRelationProvider(element);
            }
          }
        }
        extensionsRead = true;
      }
    }
Esempio n. 17
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;
 }
  /** read from plugin registry and parse it. */
  public void readRegistry(String extensionPointId) {
    IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
    IExtensionPoint point = extensionRegistry.getExtensionPoint(PLUGIN_ID, extensionPointId);

    if (point != null) {
      IConfigurationElement[] elements = point.getConfigurationElements();
      for (int i = 0; i < elements.length; i++) {
        readElement(elements[i]);
      }
    }
  }
  /**
   * Though this listener reacts to the extension point changes, there could have been contributions
   * before it's been registered. This will parse these initial contributions.
   */
  public void parseInitialContributions() {
    final IExtensionRegistry registry = Platform.getExtensionRegistry();

    final IExtensionPoint extensionPoint =
        registry.getExtensionPoint(VIEW_LABELPROVIDER_EXTENSION_POINT);
    if (extensionPoint != null) {
      for (IExtension extension : extensionPoint.getExtensions()) {
        parseExtension(extension);
      }
    }
  }
  /** 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;
  }
Esempio n. 21
0
 private static String[] readGlobalLoadingPluginNames() {
   IExtensionRegistry reg = Platform.getExtensionRegistry();
   IExtensionPoint exPoint =
       reg.getExtensionPoint(PLUGIN_ID, "globalPluginResourceLoad"); // $NON-NLS-1$
   IExtension[] extensions = exPoint.getExtensions();
   String[] names = new String[extensions.length];
   if (extensions.length > 0) {
     for (int i = 0; i < extensions.length; i++)
       names[i] = extensions[i].getContributor().getName();
   }
   return names;
 }
 public static void runStartupExtensions() {
   IExtensionRegistry registry = Platform.getExtensionRegistry();
   IExtensionPoint extensionPoint = registry.getExtensionPoint(EXTENSION_ID_STARTUP);
   IExtension[] extensions = extensionPoint.getExtensions();
   for (IExtension extension : extensions) {
     IConfigurationElement[] elements = extension.getConfigurationElements();
     for (IConfigurationElement element : elements) {
       if (element.getName().compareTo(ELEMENT_STARTUP) == 0) {
         runStartupExtension(element);
       }
     }
   }
 }
Esempio n. 23
0
  private void loadDriverExtensions() {
    if (driverExtensions != null)
      // Already loaded
      return;

    // First time: load all driverinfo extensions
    driverExtensions = new HashMap();
    IExtensionRegistry extReg = Platform.getExtensionRegistry();

    /*
     * getConfigurationElementsFor is not working for server Platform.
     * I have to work around this by walking the extension list
    IConfigurationElement[] configElems =
    	extReg.getConfigurationElementsFor( OdaJdbcDriver.Constants.DRIVER_INFO_EXTENSION );
    */
    IExtensionPoint extPoint =
        extReg.getExtensionPoint(OdaJdbcDriver.Constants.DRIVER_INFO_EXTENSION);

    if (extPoint == null) return;

    IExtension[] exts = extPoint.getExtensions();
    if (exts == null) return;

    for (int e = 0; e < exts.length; e++) {
      IConfigurationElement[] configElems = exts[e].getConfigurationElements();
      if (configElems == null) continue;

      for (int i = 0; i < configElems.length; i++) {
        if (configElems[i].getName().equals(OdaJdbcDriver.Constants.DRIVER_INFO_ELEM_JDBCDRIVER)) {
          String driverClass =
              configElems[i].getAttribute(OdaJdbcDriver.Constants.DRIVER_INFO_ATTR_DRIVERCLASS);
          String connectionFactory =
              configElems[i].getAttribute(OdaJdbcDriver.Constants.DRIVER_INFO_ATTR_CONNFACTORY);
          logger.info(
              "Found JDBC driverinfo extension: driverClass="
                  + driverClass
                  + ", connectionFactory="
                  + connectionFactory);
          if (driverClass != null
              && driverClass.length() > 0
              && connectionFactory != null
              && connectionFactory.length() > 0) {
            // This driver class has its own connection factory; cache it
            // Note that the instantiation of the connection factory can wait
            // until we actually need it
            driverExtensions.put(driverClass, configElems[i]);
          }
        }
      }
    }
  }
  /**
   * Gets the templates description.
   *
   * @return the templates description
   */
  private ModelTemplateDescription[] getTemplatesDescription() {
    if (myTemplateDescriptions == null) {
      List<ModelTemplateDescription> templates = new ArrayList<ModelTemplateDescription>();

      IExtensionRegistry registry = Platform.getExtensionRegistry();
      IExtension[] extensions = registry.getExtensionPoint(EXTENSION_POINT_ID).getExtensions();

      for (IExtension extension : extensions) {
        templates.addAll(processExtension(extension));
      }
      myTemplateDescriptions = templates.toArray(new ModelTemplateDescription[templates.size()]);
    }
    return myTemplateDescriptions;
  }
 static Class<?> getJDClassFileEditorClass() throws ClassNotFoundException {
   IExtensionRegistry registry = Platform.getExtensionRegistry();
   IExtensionPoint point = registry.getExtensionPoint("org.eclipse.ui.editors");
   if (point == null) return null;
   IExtension[] extensions = point.getExtensions();
   for (int i = 0; i < extensions.length; i++) {
     IConfigurationElement[] elements = extensions[i].getConfigurationElements();
     for (int j = 0; j < elements.length; j++) {
       String id = elements[j].getAttribute("id");
       if (id.indexOf("jd.ide.eclipse.editors.JDClassFileEditor") == 0)
         return Class.forName(elements[j].getAttribute("class"));
     }
   }
   return null;
 }
Esempio n. 26
0
 /**
  * Parse the viewer extensions and return the descriptor of the tree viewer.
  *
  * @return The viewer descriptor.
  */
 public ViewerDescriptor parseViewer() {
   Assert.isNotNull(viewerId);
   IExtensionRegistry registry = Platform.getExtensionRegistry();
   IExtensionPoint extensionPoint = registry.getExtensionPoint(EXTENSION_POINT_ID);
   IConfigurationElement[] configurations = extensionPoint.getConfigurationElements();
   for (IConfigurationElement configuration : configurations) {
     String name = configuration.getName();
     if ("viewer".equals(name)) { // $NON-NLS-1$
       String id = configuration.getAttribute("id"); // $NON-NLS-1$
       if (viewerId.equals(id)) {
         return createViewerDescriptor(configuration);
       }
     }
   }
   return null;
 }
  public CodeGeneratorPortTemplatesRegistry() {
    final IExtensionRegistry reg = Platform.getExtensionRegistry();
    final IExtensionPoint ep =
        reg.getExtensionPoint(
            RedhawkCodegenActivator.PLUGIN_ID, CodeGeneratorPortTemplatesRegistry.EP_ID);

    this.tracker = new ExtensionTracker(reg);

    if (ep != null) {
      final IFilter filter = ExtensionTracker.createExtensionPointFilter(ep);
      this.tracker.registerHandler(this, filter);
      final IExtension[] extensions = ep.getExtensions();
      for (final IExtension extension : extensions) {
        addExtension(this.tracker, extension);
      }
    }
  }
  public void registerConnectors(
      TaskRepositoryManager repositoryManager, TaskListExternalizer taskListExternalizer) {
    IExtensionRegistry registry = Platform.getExtensionRegistry();

    // NOTE: has to be read first, consider improving
    RepositoryConnectorExtensionReader reader =
        new RepositoryConnectorExtensionReader(taskListExternalizer, repositoryManager);
    // load core extension point
    reader.loadConnectorsFromRepositoriesExtension();
    // load legacy ui extension point
    reader.loadConnectors(registry.getExtensionPoint(EXTENSION_REPOSITORIES));
    // load connectors contributed at runtime
    reader.loadConnectorsFromContributors();
    reader.registerConnectors();
    descriptors.addAll(reader.getDescriptors());
    blackList.merge(reader.getBlackList());
  }
Esempio n. 29
0
  private Collection<IConfigurationElement> getExtensionInfo(String extPoint, String type) {
    Collection<IConfigurationElement> rtn = new ArrayList<IConfigurationElement>();
    IExtensionRegistry registry = Platform.getExtensionRegistry();

    // possible if running w/o eclipse launched fully
    if (registry == null) return rtn;

    IExtensionPoint exp = registry.getExtensionPoint("org.jactr.tools.shell.commands");

    if (exp == null) return rtn;

    for (IExtension extension : exp.getExtensions())
      for (IConfigurationElement config : extension.getConfigurationElements())
        if (config.getName().equals(type)) rtn.add(config);

    return rtn;
  }
  private static List<String> getBinaryPaths() {
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IExtensionPoint point = registry.getExtensionPoint(PLUGIN_ID, TOOLBUS_BINARY_PROVIDER);

    IExtension extensions[] = point.getExtensions();
    int nrOfExtensions = extensions.length;
    List<String> searchPaths = new ArrayList<String>(nrOfExtensions);
    for (int i = nrOfExtensions - 1; i >= 0; i--) {
      IConfigurationElement[] binaryProviderElements = extensions[i].getConfigurationElements();
      IConfigurationElement ce = binaryProviderElements[0];
      String path = ce.getAttribute("path");

      Bundle bundle = Platform.getBundle(ce.getContributor().getName());

      searchPaths.add(getFile(bundle, path));
    }

    return searchPaths;
  }