Esempio n. 1
0
  public ProcessingStep create(
      IProvisioningAgent agent, IProcessingStepDescriptor descriptor, IArtifactDescriptor context) {
    IExtensionRegistry registry = RegistryFactory.getRegistry();
    IExtension extension =
        registry.getExtension(PROCESSING_STEPS_EXTENSION_ID, descriptor.getProcessorId());
    Exception error;
    if (extension != null) {
      IConfigurationElement[] config = extension.getConfigurationElements();
      try {
        Object object = config[0].createExecutableExtension("class"); // $NON-NLS-1$
        ProcessingStep step = (ProcessingStep) object;
        step.initialize(agent, descriptor, context);
        return step;
      } catch (Exception e) {
        error = e;
      }
    } else
      error =
          new ProcessingStepHandlerException(
              NLS.bind(
                  Messages.cannot_get_extension,
                  PROCESSING_STEPS_EXTENSION_ID,
                  descriptor.getProcessorId()));

    int severity = descriptor.isRequired() ? IStatus.ERROR : IStatus.INFO;
    ProcessingStep result = new EmptyProcessingStep();
    result.setStatus(
        new Status(
            severity,
            Activator.ID,
            Messages.cannot_instantiate_step + descriptor.getProcessorId(),
            error));
    return result;
  }
  /**
   * Dump the whole extension registry up to the specified nesting depth.
   *
   * @param extensionPointPrefix considering only extension points that have this prefix or null for
   *     all
   * @param depth nesting depth
   */
  public static void dumpRegistry(final String extensionPointPrefix, final int depth) {
    final IExtensionRegistry extensionRegistry = RegistryFactory.getRegistry();
    if (extensionRegistry == null) {
      System.out.println("No extension registry available."); // $NON-NLS-1$
      return;
    }
    final Object strategy = ReflectionUtils.getHidden(extensionRegistry, "strategy"); // $NON-NLS-1$
    final StringBuilder bob = new StringBuilder("<< Registry"); // $NON-NLS-1$
    if (extensionPointPrefix != null) {
      bob.append(" for prefix ").append(extensionPointPrefix); // $NON-NLS-1$
    }
    bob.append(" with strategy ")
        .append(strategy.getClass().getSimpleName())
        .append(":"); // $NON-NLS-1$ //$NON-NLS-2$
    System.out.println(bob);

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

    Arrays.sort(
        extensionPoints,
        new Comparator<IExtensionPoint>() {
          public int compare(final IExtensionPoint ep1, final IExtensionPoint ep2) {
            return ep1.getUniqueIdentifier().compareTo(ep2.getUniqueIdentifier());
          }
        });
    for (final IExtensionPoint extensionPoint : extensionPoints) {
      if (extensionPointPrefix != null
          && !extensionPoint.getUniqueIdentifier().startsWith(extensionPointPrefix)) {
        continue;
      }
      System.out.println(extensionPoint.getUniqueIdentifier() + ":"); // $NON-NLS-1$
      dumpExtensions(extensionPoint.getExtensions(), depth);
    }
    System.out.println(">>"); // $NON-NLS-1$
  }
Esempio n. 3
0
  /*
   * (non-Javadoc)
   * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
   */
  public void start(BundleContext context) throws Exception {
    super.start(context);
    plugin = this;

    IExtensionRegistry reg = RegistryFactory.getRegistry();
    loadNavigatorItems(reg);
    loadInitialPerspective(reg);
    loadBootJobs(reg);
    runBootJobs();
  }
Esempio n. 4
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;
 }
 /** 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);
   }
 }
  /* (non-Javadoc)
   * Method declared on IWorkbenchPart.
   */
  public void dispose() {
    // run super.
    super.dispose();

    // remove ourselves as a selection and registry listener
    getSite().getPage().removePostSelectionListener(this);
    RegistryFactory.getRegistry().removeListener(this);

    currentPart = null;
    currentSelection = null;
    pinPropertySheetAction = null;
  }
Esempio n. 7
0
 private Dispatcher() {
   IConfigurationElement[] config =
       RegistryFactory.getRegistry().getConfigurationElementsFor(DISPATCH_FILTER_ID);
   for (IConfigurationElement element : config) {
     try {
       boolean isFilter = "filter".equals(element.getName()); // $NON-NLS-1$
       if (isFilter) {
         DispatchFilter filter = new DispatchFilter(element);
         filters.putSingle(filter.getPriority(), filter);
       }
     } catch (Exception e) {
       logger.error("Error processing dispatch filter", e); // $NON-NLS-1$
     }
   }
 }
 /**
  * Get the whole extension registry as a set of paths.
  *
  * @param extensionPointPrefix considering only extension points that have this prefix or null for
  *     all
  * @return
  */
 public static Set<String> getRegistryPaths(final String extensionPointPrefix) {
   final Set<String> result = new HashSet<String>();
   final IExtensionRegistry extensionRegistry = RegistryFactory.getRegistry();
   if (extensionRegistry
       != null) { // is null when running without the workbench (plain junit test)
     final IExtensionPoint[] extensionPoints = extensionRegistry.getExtensionPoints();
     for (final IExtensionPoint extensionPoint : extensionPoints) {
       if (extensionPointPrefix != null
           && !extensionPoint.getUniqueIdentifier().startsWith(extensionPointPrefix)) {
         continue;
       }
       final String path = extensionPoint.getUniqueIdentifier() + ": "; // $NON-NLS-1$
       getExtensionsPaths(result, path, extensionPoint.getExtensions());
     }
   }
   return result;
 }
 private HashSet getIgnoredViews() {
   if (ignoredViews == null) {
     ignoredViews = new HashSet();
     IExtensionRegistry registry = RegistryFactory.getRegistry();
     IExtensionPoint ep = registry.getExtensionPoint(EXT_POINT);
     if (ep != null) {
       IExtension[] extensions = ep.getExtensions();
       for (int i = 0; i < extensions.length; i++) {
         IConfigurationElement[] elements = extensions[i].getConfigurationElements();
         for (int j = 0; j < elements.length; j++) {
           if ("excludeSources".equalsIgnoreCase(elements[j].getName())) { // $NON-NLS-1$
             String id = elements[j].getAttribute("id"); // $NON-NLS-1$
             if (id != null) ignoredViews.add(id);
           }
         }
       }
     }
   }
   return ignoredViews;
 }
    /** @return an instance of (any random) implementation of {@link JavaScriptFormatter} or null */
    public static JavaScriptFormatter getInstance() {
      IExtensionPoint extensionPoint =
          RegistryFactory.getRegistry().getExtensionPoint(EXTENSION_POINT_ID);
      IExtension[] extensions = extensionPoint.getExtensions();

      for (IExtension extension : extensions) {
        for (IConfigurationElement element : extension.getConfigurationElements()) {
          if (!ELEMENT_NAME.equals(element.getName())) {
            continue;
          }
          Object obj;
          try {
            obj = element.createExecutableExtension(CLASS_PROPERTY);
          } catch (CoreException e) {
            throw new RuntimeException(e);
          }
          return (JavaScriptFormatter) obj;
        }
      }
      return null;
    }
  // TODO This should go into a different bundle
  public static IEclipseContext createDefaultHeadlessContext() {
    IEclipseContext serviceContext = E4Workbench.getServiceContext();

    IExtensionRegistry registry = RegistryFactory.getRegistry();
    ExceptionHandler exceptionHandler = new ExceptionHandler();
    ReflectionContributionFactory contributionFactory = new ReflectionContributionFactory(registry);
    serviceContext.set(IContributionFactory.class, contributionFactory);
    serviceContext.set(IExceptionHandler.class, exceptionHandler);
    serviceContext.set(IExtensionRegistry.class, registry);

    serviceContext.set(
        Adapter.class, ContextInjectionFactory.make(EclipseAdapter.class, serviceContext));

    // No default log provider available
    if (serviceContext.get(ILoggerProvider.class) == null) {
      serviceContext.set(
          ILoggerProvider.class,
          ContextInjectionFactory.make(DefaultLoggerProvider.class, serviceContext));
    }

    return serviceContext;
  }
  public void initialize() {

    //
    if (_isInitalized) {
      return;
    }

    // set initialized
    _isInitalized = true;

    //
    _extensionInstances = new LinkedList<T>();
    _extensionBundleNamespaces = new LinkedList<String>();

    // get the extension registry
    IExtensionRegistry registry = RegistryFactory.getRegistry();

    // get the extension points
    IExtensionPoint extensionPoint = registry.getExtensionPoint(_extensionPointId);

    // get the extension tracker
    _tracker = new ExtensionTracker(registry);

    //
    for (IExtension extension : extensionPoint.getExtensions()) {

      //
      _extensionBundleNamespaces.add(extension.getContributor().getName());

      //
      addExtension(_tracker, extension);
    }

    // register IExtensionChangeHandler
    _tracker.registerHandler(this, ExtensionTracker.createExtensionPointFilter(extensionPoint));
  }
 /** Creates a property sheet view. */
 public PropertySheet() {
   super();
   pinPropertySheetAction = new PinPropertySheetAction();
   RegistryFactory.getRegistry().addListener(this, EXT_POINT);
 }