コード例 #1
0
  /**
   * Gets a list of all the bundles that can be added as implicit dependencies
   *
   * @return list of possible dependencies
   */
  protected BundleInfo[] getValidBundles() throws CoreException {
    NameVersionDescriptor[] current = getTargetDefinition().getImplicitDependencies();
    Set<String> currentBundles = new HashSet<String>();
    if (current != null) {
      for (int i = 0; i < current.length; i++) {
        if (!currentBundles.contains(current[i].getId())) {
          currentBundles.add(current[i].getId());
        }
      }
    }

    List<BundleInfo> targetBundles = new ArrayList<BundleInfo>();
    TargetBundle[] allTargetBundles = getTargetDefinition().getAllBundles();
    if (allTargetBundles == null || allTargetBundles.length == 0) {
      throw new CoreException(
          new Status(
              IStatus.WARNING,
              PDEPlugin.getPluginId(),
              PDEUIMessages.ImplicitDependenciesSection_0));
    }
    for (int i = 0; i < allTargetBundles.length; i++) {
      BundleInfo bundleInfo = allTargetBundles[i].getBundleInfo();
      if (!currentBundles.contains(bundleInfo.getSymbolicName())) {
        currentBundles.add(bundleInfo.getSymbolicName()); // to avoid duplicate entries
        targetBundles.add(bundleInfo);
      }
    }

    return targetBundles.toArray(new BundleInfo[targetBundles.size()]);
  }
コード例 #2
0
    public IStatus validate(String text) {
      String id = PDEPlugin.getPluginId();
      if (text.length() == 0)
        return new Status(
            IStatus.ERROR, id, IStatus.ERROR, PDEUIMessages.AddLibraryDialog_emptyLibraries, null);

      if (text.indexOf(' ') != -1)
        return new Status(
            IStatus.ERROR, id, IStatus.ERROR, PDEUIMessages.AddLibraryDialog_nospaces, null);

      if (libraries == null || libraries.length == 0)
        return new Status(IStatus.OK, id, IStatus.OK, "", null); // $NON-NLS-1$

      if (librarySet.contains(new Path(ClasspathUtilCore.expandLibraryName(text))))
        return new Status(
            IStatus.ERROR,
            id,
            IStatus.ERROR,
            PDEUIMessages.ManifestEditor_RuntimeLibraryDialog_validationError,
            null);
      return new Status(IStatus.OK, id, IStatus.OK, "", null); // $NON-NLS-1$
    }
  /**
   * Creates a WizardElement representing the template extension to be used by this wizard.
   *
   * @return element representing the template or <code>null</code> if the extension could not be
   *     loaded
   */
  private WizardElement getTemplateWizard() {
    String templateID = getTemplateID();
    if (templateID == null) {
      return null;
    }

    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IExtensionPoint point = registry.getExtensionPoint(PDEPlugin.getPluginId(), PLUGIN_POINT);
    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++) {
        if (elements[j].getName().equals(TAG_WIZARD)) {
          if (templateID.equals(elements[j].getAttribute(WizardElement.ATT_ID))) {
            return WizardElement.create(elements[j]);
          }
        }
      }
    }
    return null;
  }