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 static void initializeClientContextIDs() {
    registeredClientContextIds = new java.util.HashSet<String>();

    IExtensionPoint extPoint =
        Platform.getExtensionRegistry().getExtensionPoint(EP_UI_REGISTERED_CLIENT_CONTEXTS);

    for (IExtension extension : extPoint.getExtensions()) {
      for (IConfigurationElement next : extension.getConfigurationElements()) {

        registeredClientContextIds.add(next.getAttribute(A_ID));
      }
    }

    IExtensionTracker extTracker = ValidationUIPlugin.getExtensionTracker();

    if (extTracker != null) {
      IExtensionChangeHandler extensionHandler =
          new IExtensionChangeHandler() {

            public void addExtension(IExtensionTracker tracker, IExtension extension) {

              addClientContextIDs(extension.getConfigurationElements());
            }

            public void removeExtension(IExtension extension, Object[] objects) {
              // client-context IDs cannot be undefined
            }
          };

      extTracker.registerHandler(
          extensionHandler, ExtensionTracker.createExtensionPointFilter(extPoint));
    }
  }
 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;
 }
Пример #4
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);
         }
       }
     }
   }
 }
  /** Initializes TestRun Listener extensions */
  private void loadTestRunListeners() {
    fLegacyTestRunListeners = new ArrayList();
    IExtensionPoint extensionPoint =
        Platform.getExtensionRegistry().getExtensionPoint(ID_EXTENSION_POINT_TESTRUN_LISTENERS);
    if (extensionPoint == null) {
      return;
    }
    IConfigurationElement[] configs = extensionPoint.getConfigurationElements();
    MultiStatus status =
        new MultiStatus(
            PLUGIN_ID,
            IStatus.OK,
            "Could not load some testRunner extension points",
            null); //$NON-NLS-1$

    for (int i = 0; i < configs.length; i++) {
      try {
        Object testRunListener = configs[i].createExecutableExtension("class"); // $NON-NLS-1$
        if (testRunListener instanceof ITestRunListener) {
          fLegacyTestRunListeners.add(testRunListener);
        }
      } catch (CoreException e) {
        status.add(e.getStatus());
      }
    }
    if (!status.isOK()) {
      PHPUnitPlugin.getDefault().getLog().log(status);
    }
  }
Пример #6
0
  private synchronized void ensurePagesRegistered() {
    if (fPageDescriptors != null) {
      return;
    }

    ArrayList<CleanUpTabPageDescriptor> result = new ArrayList<CleanUpTabPageDescriptor>();

    IExtensionPoint point =
        Platform.getExtensionRegistry().getExtensionPoint(DartUI.ID_PLUGIN, EXTENSION_POINT_NAME);
    IConfigurationElement[] elements = point.getConfigurationElements();
    for (int i = 0; i < elements.length; i++) {
      IConfigurationElement element = elements[i];

      if (TABPAGE_CONFIGURATION_ELEMENT_NAME.equals(element.getName())) {
        result.add(new CleanUpTabPageDescriptor(element));
      }
    }

    fPageDescriptors = result.toArray(new CleanUpTabPageDescriptor[result.size()]);
    Arrays.sort(
        fPageDescriptors,
        new Comparator<CleanUpTabPageDescriptor>() {
          @Override
          public int compare(CleanUpTabPageDescriptor o1, CleanUpTabPageDescriptor o2) {
            String name1 = o1.getName();
            String name2 = o2.getName();
            return Collator.getInstance()
                .compare(
                    name1.replaceAll("&", ""),
                    name2.replaceAll(
                        "&", "")); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
          }
        });
  }
Пример #7
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);
          }
        }
      }
    }
  }
  private static void loadCheatSheetExtensions() {
    IExtensionPoint extensionPoint =
        Platform.getExtensionRegistry().getExtensionPoint(CHEAT_SHEET_PLUGIN_ID, EXT_PT);

    if (extensionPoint != null) {
      IExtension[] extensions = extensionPoint.getExtensions();

      if (extensions.length != 0) {
        List temp = new ArrayList();

        for (int i = 0; i < extensions.length; ++i) {
          IConfigurationElement[] elements = extensions[i].getConfigurationElements();

          // only care about cheatsheet configuration elements. don't care about category elements.
          for (int j = 0; j < elements.length; ++j) {
            if (elements[j].getName().equals(CHEATSHEET_ELEMENT)) {
              temp.add(elements[j]);
            }
          }
        }

        if (!temp.isEmpty()) {
          temp.toArray(cheatsheets = new IConfigurationElement[temp.size()]);
        } else {
          cheatsheets = new IConfigurationElement[0];
        }
      }
    }

    if (cheatsheets == null) {
      cheatsheets = new IConfigurationElement[0];
    }
  }
Пример #9
0
 /** @param viewer */
 private void addDndSupport(GraphicalViewer viewer, String type) {
   IExtensionPoint point =
       Platform.getExtensionRegistry().getExtensionPoint(UMLPlugin.PLUGIN_ID, "dnd");
   IExtension[] extensions = point.getExtensions();
   for (int i = 0; i < extensions.length; i++) {
     IExtension extension = extensions[i];
     IConfigurationElement[] elements = extension.getConfigurationElements();
     for (int j = 0; j < elements.length; j++) {
       IConfigurationElement element = elements[j];
       try {
         Object object = element.createExecutableExtension("class");
         if (object instanceof UMLDropTargetListenerFactory) {
           UMLDropTargetListenerFactory factory = (UMLDropTargetListenerFactory) object;
           if (factory.accept(type)) {
             TransferDropTargetListener targetListener = factory.getDropTargetListener(viewer);
             viewer.addDropTargetListener(targetListener);
           }
         }
       } catch (CoreException e) {
         e.printStackTrace();
       } finally {
       }
     }
   }
 }
 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);
 }
Пример #11
0
  /**
   * 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;
  }
Пример #12
0
 public AbstractSourceProvider[] getSourceProviders() {
   ArrayList providers = new ArrayList();
   IExtensionPoint ep = getExtensionPoint();
   IConfigurationElement[] elements = ep.getConfigurationElements();
   for (int i = 0; i < elements.length; i++) {
     if (elements[i].getName().equals(IWorkbenchRegistryConstants.TAG_SOURCE_PROVIDER)) {
       try {
         Object sourceProvider =
             elements[i].createExecutableExtension(IWorkbenchRegistryConstants.ATTR_PROVIDER);
         if (!(sourceProvider instanceof AbstractSourceProvider)) {
           String attributeName =
               elements[i].getAttribute(IWorkbenchRegistryConstants.ATTR_PROVIDER);
           final String message =
               "Source Provider '"
                   + //$NON-NLS-1$
                   attributeName
                   + "' should extend AbstractSourceProvider"; //$NON-NLS-1$
           final IStatus status = new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, message);
           WorkbenchPlugin.log(status);
           continue;
         }
         providers.add(sourceProvider);
         processVariables(elements[i].getChildren(IWorkbenchRegistryConstants.TAG_VARIABLE));
       } catch (CoreException e) {
         StatusManager.getManager().handle(e.getStatus());
       }
     }
   }
   return (AbstractSourceProvider[])
       providers.toArray(new AbstractSourceProvider[providers.size()]);
 }
Пример #13
0
 /**
  * Returns the {@link INamespaceLabelProvider} for the given {@link ISourceModelElement}'s
  * namespace.
  */
 public static INamespaceLabelProvider getLabelProvider(ISourceModelElement element) {
   IExtensionPoint point =
       Platform.getExtensionRegistry().getExtensionPoint(NAMESPACES_EXTENSION_POINT);
   if (point != null) {
     String namespaceURI = getNameSpaceURI(element);
     for (IExtension extension : point.getExtensions()) {
       for (IConfigurationElement config : extension.getConfigurationElements()) {
         if (namespaceURI.equals(config.getAttribute("uri"))) {
           if (config.getAttribute("labelProvider") != null) {
             try {
               Object provider = config.createExecutableExtension("labelProvider");
               if (provider instanceof INamespaceLabelProvider) {
                 return (INamespaceLabelProvider) provider;
               }
             } catch (CoreException e) {
               BeansUIPlugin.log(e);
             }
           }
           return null;
         }
       }
     }
   }
   return null;
 }
Пример #14
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);
           }
         }
       }
     }
   }
 }
Пример #15
0
 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;
 }
 static {
   IExtensionPoint extensionPoint =
       Platform.getExtensionRegistry().getExtensionPoint(TYPE_EVALUATORS);
   IExtension[] ext = extensionPoint.getExtensions();
   // ArrayList resolvers = new ArrayList();
   for (int a = 0; a < ext.length; a++) {
     IConfigurationElement[] elements = ext[a].getConfigurationElements();
     IConfigurationElement myElement = elements[0];
     try {
       String nature = myElement.getAttribute(NATURE);
       List list = (List) evaluatorsByNatures.get(nature);
       if (list == null) {
         list = new ArrayList();
         evaluatorsByNatures.put(nature, list);
       }
       // ITypeInferencer resolver = (ITypeInferencer) myElement
       // .createExecutableExtension("evaluator");
       // resolvers.add(resolver);
       // list.add(resolver);
       list.add(myElement);
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
 }
  @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);
    }
  }
  public static List<ContextComputationStrategy> readContextComputationStrategies() {
    List<ContextComputationStrategy> strategies = new ArrayList<ContextComputationStrategy>();

    IExtensionPoint extensionPoint =
        Platform.getExtensionRegistry().getExtensionPoint(STRATEGIES_EXTENSION_POINT_ID);
    IExtension[] extensions = extensionPoint.getExtensions();
    for (IExtension extension : extensions) {
      IConfigurationElement[] configurationElements = extension.getConfigurationElements();
      for (IConfigurationElement element : configurationElements) {
        if (element.getName().equals(CONTEXT_COMPUTATION_STRATEGY)) {
          try {
            ContextComputationStrategy strategy =
                (ContextComputationStrategy) element.createExecutableExtension(ATTRIBUTE_CLASS);
            strategies.add(strategy);
          } catch (Throwable t) {
            StatusHandler.log(
                new Status(
                    IStatus.ERROR,
                    ContextCorePlugin.ID_PLUGIN,
                    NLS.bind(
                        "Cannot instantiate {0} from bundle {1}: {2}", //$NON-NLS-1$
                        new Object[] {
                          element.getAttribute(ATTRIBUTE_CLASS),
                          extension.getContributor().getName(),
                          t.getMessage()
                        }),
                    t));
          }
        }
      }
    }
    return strategies;
  }
  /** 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 static IContainerDescriptor[] getDescriptors() {
    ArrayList<IContainerDescriptor> containers = new ArrayList<IContainerDescriptor>();

    IExtensionPoint extensionPoint =
        Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID, ATT_EXTENSION);
    if (extensionPoint != null) {
      IContainerDescriptor defaultPage = null;
      String defaultPageName = CPathContainerDefaultPage.class.getName();

      IConfigurationElement[] elements = extensionPoint.getConfigurationElements();
      for (IConfigurationElement element : elements) {
        try {
          CPathContainerDescriptor curr = new CPathContainerDescriptor(element);
          if (defaultPageName.equals(curr.getPageClass())) {
            defaultPage = curr;
          } else {
            containers.add(curr);
          }
        } catch (CoreException e) {
          CUIPlugin.log(e);
        }
      }
      if (defaultPageName != null && containers.isEmpty()) {
        // default page only added if no other extensions found
        containers.add(defaultPage);
      }
    }
    return containers.toArray(new CPathContainerDescriptor[containers.size()]);
  }
Пример #21
0
  /**
   * 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$
  }
Пример #22
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;
          }
        }
      }
    }
  }
Пример #23
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);
         }
       }
     }
   }
 }
 /** @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;
 }
Пример #26
0
 /** 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]);
   }
 }
 private void printExtensionPoints(String pointId) {
   System.out.println("Point [" + pointId + "] search results:");
   IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(pointId);
   if (point != null) {
     for (IExtension ex : point.getExtensions()) {
       System.out.println("   " + ex.getNamespaceIdentifier() + "/" + ex.getUniqueIdentifier());
     }
   }
 }
Пример #28
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;
 }
Пример #29
0
 /** Populates the language catalog from the extension registry. */
 private void initLanguages() {
   IExtensionPoint point =
       RegistryFactory.getRegistry().getExtensionPoint(FrontEnd.PLUGIN_ID, "frontEndLanguage");
   IConfigurationElement[] elements = point.getConfigurationElements();
   languages = new HashMap<String, FrontEndLanguage>();
   for (int i = 0; i < elements.length; i++) {
     FrontEndLanguage current = FrontEndLanguage.build(elements[i]);
     languages.put(current.fileExtension, current);
   }
 }
  /** 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;
  }