コード例 #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
 private org.eclipse.equinox.internal.simpleconfigurator.utils.BundleInfo[] convertBundleInfos(
     BundleInfo[] configuration, URI installArea) {
   // convert to SimpleConfigurator BundleInfo Type
   org.eclipse.equinox.internal.simpleconfigurator.utils.BundleInfo[] simpleInfos =
       new org.eclipse.equinox.internal.simpleconfigurator.utils.BundleInfo[configuration.length];
   for (int i = 0; i < configuration.length; i++) {
     BundleInfo bundleInfo = configuration[i];
     URI location = bundleInfo.getLocation();
     if (bundleInfo.getSymbolicName() == null
         || bundleInfo.getVersion() == null
         || location == null)
       throw new IllegalArgumentException(
           "Cannot persist bundleinfo: " + bundleInfo.toString()); // $NON-NLS-1$
     // only need to make a new BundleInfo if we are changing it.
     if (installArea != null) location = URIUtil.makeRelative(location, installArea);
     simpleInfos[i] =
         new org.eclipse.equinox.internal.simpleconfigurator.utils.BundleInfo(
             bundleInfo.getSymbolicName(),
             bundleInfo.getVersion(),
             location,
             bundleInfo.getStartLevel(),
             bundleInfo.isMarkedAsStarted());
     simpleInfos[i].setBaseLocation(bundleInfo.getBaseLocation());
   }
   return simpleInfos;
 }
コード例 #3
0
  protected void handleAdd() {
    ElementListSelectionDialog dialog =
        new ElementListSelectionDialog(getShell(), new StyledBundleLabelProvider(false, false));

    try {
      dialog.setElements(getValidBundles());
    } catch (CoreException e) {
      dialog.setMessage(e.getMessage());
    }

    dialog.setTitle(PDEUIMessages.PluginSelectionDialog_title);
    dialog.setMessage(PDEUIMessages.PluginSelectionDialog_message);
    dialog.setMultipleSelection(true);
    if (dialog.open() == Window.OK) {

      Object[] models = dialog.getResult();
      ArrayList<NameVersionDescriptor> pluginsToAdd = new ArrayList<NameVersionDescriptor>();
      for (int i = 0; i < models.length; i++) {
        BundleInfo desc = ((BundleInfo) models[i]);
        pluginsToAdd.add(new NameVersionDescriptor(desc.getSymbolicName(), null));
      }
      Set<NameVersionDescriptor> allDependencies = new HashSet<NameVersionDescriptor>();
      allDependencies.addAll(pluginsToAdd);
      NameVersionDescriptor[] currentBundles = getTargetDefinition().getImplicitDependencies();
      if (currentBundles != null) {
        allDependencies.addAll(Arrays.asList(currentBundles));
      }
      getTargetDefinition()
          .setImplicitDependencies(
              allDependencies.toArray(new NameVersionDescriptor[allDependencies.size()]));
      fElementViewer.refresh();
      updateImpButtons();
    }
  }
コード例 #4
0
  /**
   * Tests that a target definition based on the default target platform restricted to a subset of
   * bundle versions contains the right set.
   *
   * @throws Exception
   */
  public void testVersionRestrictedDefaultTargetPlatform() throws Exception {
    ITargetDefinition definition = getNewTarget();
    ITargetLocation container =
        getTargetService().newProfileLocation(TargetPlatform.getDefaultLocation(), null);
    definition.setTargetLocations(new ITargetLocation[] {container});
    List infos = getAllBundleInfos(definition);
    // find right versions
    String v1 = null;
    String v2 = null;
    Iterator iterator = infos.iterator();
    while (iterator.hasNext() && (v2 == null || v1 == null)) {
      BundleInfo info = (BundleInfo) iterator.next();
      if (info.getSymbolicName().equals("org.eclipse.jdt.launching")) {
        v1 = info.getVersion();
      } else if (info.getSymbolicName().equals("org.eclipse.jdt.debug")) {
        v2 = info.getVersion();
      }
    }
    assertNotNull(v1);
    assertFalse(v1.equals(BundleInfo.EMPTY_VERSION));
    assertNotNull(v2);
    assertFalse(v2.equals(BundleInfo.EMPTY_VERSION));

    NameVersionDescriptor[] restrictions =
        new NameVersionDescriptor[] {
          new NameVersionDescriptor("org.eclipse.jdt.launching", v1),
          new NameVersionDescriptor("org.eclipse.jdt.debug", v2)
        };
    definition.setIncluded(restrictions);
    infos = getAllBundleInfos(definition);

    assertEquals("Wrong number of bundles", 2, infos.size());
    iterator = infos.iterator();
    while (iterator.hasNext()) {
      BundleInfo info = (BundleInfo) iterator.next();
      if (info.getSymbolicName().equals("org.eclipse.jdt.launching")) {
        assertEquals(v1, info.getVersion());
      } else if (info.getSymbolicName().equals("org.eclipse.jdt.debug")) {
        assertEquals(v2, info.getVersion());
      }
    }
  }
コード例 #5
0
 /*
  * Return a boolean value indicating whether or not a bundle with the given id
  * is listed in the bundles.info file. If the version is non-null, check to ensure the
  * version is the expected one. If the location is non-null then do a String#contains check.
  */
 public boolean isInBundlesInfo(File bundlesInfo, String bundleId, String version, String location)
     throws IOException {
   BundleInfo[] infos = loadBundlesInfo(bundlesInfo);
   for (int i = 0; infos != null && i < infos.length; i++) {
     BundleInfo info = infos[i];
     if (!bundleId.equals(info.getSymbolicName())) continue;
     if (version != null && !version.equals(info.getVersion())) continue;
     if (location == null) return true;
     return info.getLocation().toString().contains(location);
   }
   return false;
 }