コード例 #1
0
  ISourceContainer[] getSourceContainers(String location, String id) throws CoreException {

    ISourceContainer[] containers = (ISourceContainer[]) fSourceContainerMap.get(location);
    if (containers != null) {
      return containers;
    }

    ArrayList result = new ArrayList();
    ModelEntry entry = MonitorRegistry.findEntry(id);

    boolean match = false;

    IMonitorModelBase[] models = entry.getWorkspaceModels();
    for (int i = 0; i < models.length; i++) {
      if (isPerfectMatch(models[i], new Path(location))) {
        IResource resource = models[i].getUnderlyingResource();
        // if the plug-in matches a workspace model,
        // add the project and any libraries not coming via a container
        // to the list of source containers, in that order
        if (resource != null) {
          addProjectSourceContainers(resource.getProject(), result);
        }
        match = true;
        break;
      }
    }

    if (!match) {
      File file = new File(location);
      if (file.isFile()) {
        // in case of linked plug-in projects that map to an external JARd plug-in,
        // use source container that maps to the library in the linked project.
        ISourceContainer container = getArchiveSourceContainer(location);
        if (container != null) {
          containers = new ISourceContainer[] {container};
          fSourceContainerMap.put(location, containers);
          return containers;
        }
      }

      models = entry.getExternalModels();
      for (int i = 0; i < models.length; i++) {
        if (isPerfectMatch(models[i], new Path(location))) {
          // try all source zips found in the source code locations
          IClasspathEntry[] entries = MDEClasspathContainer.getExternalEntries(models[i]);
          for (int j = 0; j < entries.length; j++) {
            IRuntimeClasspathEntry rte = convertClasspathEntry(entries[j]);
            if (rte != null) result.add(rte);
          }
          break;
        }
      }
    }

    IRuntimeClasspathEntry[] entries =
        (IRuntimeClasspathEntry[]) result.toArray(new IRuntimeClasspathEntry[result.size()]);
    containers = JavaRuntime.getSourceContainers(entries);
    fSourceContainerMap.put(location, containers);
    return containers;
  }
コード例 #2
0
 public static String[] getFeaturePaths() {
   IFeatureModel[] models = MDECore.getDefault().getFeatureModelManager().getModels();
   ArrayList list = new ArrayList();
   for (int i = 0; i < models.length; i++) {
     String location = models[i].getInstallLocation();
     if (location != null)
       list.add(location + IPath.SEPARATOR + ICoreConstants.FEATURE_FILENAME_DESCRIPTOR);
   }
   return (String[]) list.toArray(new String[list.size()]);
 }
コード例 #3
0
  private void addProjectSourceContainers(IProject project, ArrayList result) throws CoreException {
    if (project == null || !project.hasNature(JavaCore.NATURE_ID)) return;

    IJavaProject jProject = JavaCore.create(project);
    result.add(JavaRuntime.newProjectRuntimeClasspathEntry(jProject));

    IClasspathEntry[] entries = jProject.getRawClasspath();
    for (int i = 0; i < entries.length; i++) {
      IClasspathEntry entry = entries[i];
      if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
        IRuntimeClasspathEntry rte = convertClasspathEntry(entry);
        if (rte != null) result.add(rte);
      }
    }
  }
コード例 #4
0
  public static Dictionary[] getPlatformProperties(String[] profiles, MinimalState state) {
    if (profiles == null || profiles.length == 0)
      return new Dictionary[] {getTargetEnvironment(state)};

    // add java profiles for those EE's that have a .profile file in the current system bundle
    ArrayList result = new ArrayList(profiles.length);
    for (int i = 0; i < profiles.length; i++) {
      IExecutionEnvironment environment =
          JavaRuntime.getExecutionEnvironmentsManager().getEnvironment(profiles[i]);
      if (environment != null) {
        Properties profileProps = environment.getProfileProperties();
        if (profileProps != null) {
          Dictionary props = TargetPlatformHelper.getTargetEnvironment(state);
          String systemPackages = profileProps.getProperty(Constants.FRAMEWORK_SYSTEMPACKAGES);
          if (systemPackages != null) props.put(Constants.FRAMEWORK_SYSTEMPACKAGES, systemPackages);
          String ee = profileProps.getProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT);
          if (ee != null) props.put(Constants.FRAMEWORK_EXECUTIONENVIRONMENT, ee);
          result.add(props);
        }
      }
    }
    if (result.size() > 0) return (Dictionary[]) result.toArray(new Dictionary[result.size()]);
    return new Dictionary[] {TargetPlatformHelper.getTargetEnvironment(state)};
  }
コード例 #5
0
  /*
   * (non-Javadoc)
   * @see org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration#getProgramArguments(org.eclipse.debug.core.ILaunchConfiguration)
   */
  public String[] getProgramArguments(ILaunchConfiguration configuration) throws CoreException {
    ArrayList programArgs = new ArrayList();

    programArgs.add("-dev"); // $NON-NLS-1$
    programArgs.add(
        ClasspathHelper.getDevEntriesProperties(
            getConfigDir(configuration).toString() + "/dev.properties",
            fAllBundles)); //$NON-NLS-1$

    saveConfigurationFile(configuration);
    programArgs.add("-configuration"); // $NON-NLS-1$
    programArgs.add(
        "file:"
            + new Path(getConfigDir(configuration).getPath())
                .addTrailingSeparator()
                .toString()); //$NON-NLS-1$

    String[] args = super.getProgramArguments(configuration);
    for (int i = 0; i < args.length; i++) {
      programArgs.add(args[i]);
    }
    return (String[]) programArgs.toArray(new String[programArgs.size()]);
  }
コード例 #6
0
  private boolean resourceExists(String location) {
    String bundleJar = null;
    IPath path = new Path(location);
    if ("platform:".equals(path.getDevice()) && path.segmentCount() > 2) { // $NON-NLS-1$
      if ("plugin".equals(path.segment(0))) { // $NON-NLS-1$
        String id = path.segment(1);
        IMonitorModelBase model = MonitorRegistry.findModel(id);
        if (model != null && model.isEnabled()) {
          path = path.setDevice(null).removeFirstSegments(2);
          String bundleLocation = model.getInstallLocation();
          if (bundleLocation.endsWith(".jar")) { // $NON-NLS-1$
            bundleJar = bundleLocation;
          } else {
            path = new Path(model.getInstallLocation()).append(path);
          }
          location = path.toString();
        }
      }
    } else if (path.getDevice() == null
        && path.segmentCount() > 3
        && "platform:".equals(path.segment(0))) { // $NON-NLS-1$
      if ("plugin".equals(path.segment(1))) { // $NON-NLS-1$
        String id = path.segment(2);
        IMonitorModelBase model = MonitorRegistry.findModel(id);
        if (model != null && model.isEnabled()) {
          path = path.removeFirstSegments(3);
          String bundleLocation = model.getInstallLocation();
          if (bundleLocation.endsWith(".jar")) { // $NON-NLS-1$
            bundleJar = bundleLocation;
          } else {
            path = new Path(model.getInstallLocation()).append(path);
          }
          location = path.toString();
        }
      }
    }

    ArrayList paths = new ArrayList();
    if (location.indexOf("$nl$") != -1) { // $NON-NLS-1$
      StringTokenizer tokenizer = new StringTokenizer(TargetPlatform.getNL(), "_"); // $NON-NLS-1$
      String language = tokenizer.hasMoreTokens() ? tokenizer.nextToken() : null;
      String country = tokenizer.hasMoreTokens() ? tokenizer.nextToken() : null;
      if (language != null && country != null)
        paths.add(
            location.replaceAll(
                "\\$nl\\$",
                "nl"
                    + IPath.SEPARATOR
                    + language
                    + IPath.SEPARATOR
                    + country)); //$NON-NLS-1$ //$NON-NLS-2$
      if (language != null)
        paths.add(
            location.replaceAll(
                "\\$nl\\$", "nl" + IPath.SEPARATOR + language)); // $NON-NLS-1$ //$NON-NLS-2$
      paths.add(location.replaceAll("\\$nl\\$", "")); // $NON-NLS-1$ //$NON-NLS-2$
    } else {
      paths.add(location);
    }

    for (int i = 0; i < paths.size(); i++) {
      if (bundleJar == null) {
        IPath currPath = new Path(paths.get(i).toString());
        if (currPath.isAbsolute() && currPath.toFile().exists()) return true;
        if (PDEProject.getBundleRoot(fFile.getProject()).findMember(currPath) != null) return true;
        if (fBuildModel != null
            && fBuildModel.getEntry("source." + paths.get(i)) != null) // $NON-NLS-1$
        return true;
      } else {
        if (CoreUtility.jarContainsResource(new File(bundleJar), paths.get(i).toString(), false))
          return true;
      }
    }

    return false;
  }