Ejemplo 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;
  }
  private void extensionsToString(IExtension[] extensions) {
    extensionIDs = new ArrayList(extensions.length);
    for (int i = 0; i < extensions.length; i++) {
      IExtension extension = extensions[i];
      extensionIDs.add(extension.getUniqueIdentifier());

      // test navigation: to extension point
      String ownerId = extension.getExtensionPointUniqueIdentifier();
      if (extPointId != null) assertTrue(extPointId.equals(ownerId));
      // test navigation: all children
      assertTrue(validContents(extension.getConfigurationElements()));
    }
  }
  /**
   * Create a new instance of <code>LightweightActionDescriptor</code>.
   *
   * @param actionElement the configuration element
   */
  public LightweightActionDescriptor(IConfigurationElement actionElement) {
    super();

    this.id = actionElement.getAttribute(IWorkbenchRegistryConstants.ATT_ID);
    this.label = actionElement.getAttribute(IWorkbenchRegistryConstants.ATT_LABEL);
    this.description = actionElement.getAttribute(IWorkbenchRegistryConstants.TAG_DESCRIPTION);

    String iconName = actionElement.getAttribute(IWorkbenchRegistryConstants.ATT_ICON);
    if (iconName != null) {
      IExtension extension = actionElement.getDeclaringExtension();
      this.image = AbstractUIPlugin.imageDescriptorFromPlugin(extension.getNamespace(), iconName);
    }
  }
  public IdentityRepository[] getPluggedInIdentityRepositries() {

    IExtension[] extensions =
        Platform.getExtensionRegistry()
            .getExtensionPoint(JSchCorePlugin.ID, JSchCorePlugin.PT_IDENTITYREPOSITORY)
            .getExtensions();

    if (extensions.length == 0) return new IdentityRepository[0];

    ArrayList tmp = new ArrayList();
    for (int i = 0; i < extensions.length; i++) {
      IExtension extension = extensions[i];
      IConfigurationElement[] configs = extension.getConfigurationElements();
      if (configs.length == 0) {
        JSchCorePlugin.log(
            IStatus.ERROR,
            NLS.bind(
                "IdentityRepository {0} is missing required fields",
                (new Object[] {extension.getUniqueIdentifier()})),
            null); //$NON-NLS-1$
        continue;
      }
      try {
        IConfigurationElement config = configs[0];
        AbstractIdentityRepositoryFactory iirf =
            (AbstractIdentityRepositoryFactory)
                config.createExecutableExtension("run"); // $NON-NLS-1$
        tmp.add(iirf.create());
      } catch (CoreException ex) {
        JSchCorePlugin.log(
            IStatus.ERROR,
            NLS.bind(
                "Unable to instantiate identity repository {0}",
                (new Object[] {extension.getUniqueIdentifier()})),
            ex); //$NON-NLS-1$
      }
    }

    IdentityRepository[] repositories = new IdentityRepository[tmp.size()];
    for (int i = 0; i < tmp.size(); i++) {
      repositories[i] = (IdentityRepository) tmp.get(i);
    }
    return repositories;
  }
 /** Initialize this nature descriptor based on the provided extension point. */
 protected void readExtension(IExtension natureExtension) throws CoreException {
   // read the extension
   id = natureExtension.getUniqueIdentifier();
   if (id == null) {
     fail(Messages.natures_missingIdentifier);
   }
   label = natureExtension.getLabel();
   IConfigurationElement[] elements = natureExtension.getConfigurationElements();
   int count = elements.length;
   ArrayList requiredList = new ArrayList(count);
   ArrayList setList = new ArrayList(count);
   ArrayList builderList = new ArrayList(count);
   ArrayList contentTypeList = new ArrayList(count);
   for (int i = 0; i < count; i++) {
     IConfigurationElement element = elements[i];
     String name = element.getName();
     if (name.equalsIgnoreCase("requires-nature")) { // $NON-NLS-1$
       String attribute = element.getAttribute("id"); // $NON-NLS-1$
       if (attribute == null) fail();
       requiredList.add(attribute);
     } else if (name.equalsIgnoreCase("one-of-nature")) { // $NON-NLS-1$
       String attribute = element.getAttribute("id"); // $NON-NLS-1$
       if (attribute == null) fail();
       setList.add(attribute);
     } else if (name.equalsIgnoreCase("builder")) { // $NON-NLS-1$
       String attribute = element.getAttribute("id"); // $NON-NLS-1$
       if (attribute == null) fail();
       builderList.add(attribute);
     } else if (name.equalsIgnoreCase("content-type")) { // $NON-NLS-1$
       String attribute = element.getAttribute("id"); // $NON-NLS-1$
       if (attribute == null) fail();
       contentTypeList.add(attribute);
     } else if (name.equalsIgnoreCase("options")) { // $NON-NLS-1$
       String attribute = element.getAttribute("allowLinking"); // $NON-NLS-1$
       // when in doubt (missing attribute, wrong value) default to allow linking
       allowLinking = !Boolean.FALSE.toString().equalsIgnoreCase(attribute);
     }
   }
   requiredNatures = (String[]) requiredList.toArray(new String[requiredList.size()]);
   natureSets = (String[]) setList.toArray(new String[setList.size()]);
   builderIds = (String[]) builderList.toArray(new String[builderList.size()]);
   contentTypeIds = (String[]) contentTypeList.toArray(new String[contentTypeList.size()]);
 }