コード例 #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$
    }