protected int runEclipse(String message, File location, String[] args, File extensions) {
   File root = new File(Activator.getBundleContext().getProperty("java.home"));
   root = new File(root, "bin");
   File exe = new File(root, "javaw.exe");
   if (!exe.exists()) exe = new File(root, "java");
   assertTrue("Java executable not found in: " + exe.getAbsolutePath(), exe.exists());
   List<String> command = new ArrayList<String>();
   Collections.addAll(
       command,
       new String[] {
         (new File(location == null ? output : location, getExeFolder() + "eclipse"))
             .getAbsolutePath(),
         "--launcher.suppressErrors",
         "-nosplash",
         "-vm",
         exe.getAbsolutePath()
       });
   Collections.addAll(command, args);
   Collections.addAll(command, new String[] {"-vmArgs", "-Dosgi.checkConfiguration=true"});
   // command-line if you want to run and allow a remote debugger to connect
   if (debug)
     Collections.addAll(
         command,
         new String[] {
           "-Xdebug", "-Xnoagent", "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8787"
         });
   int result = run(message, command.toArray(new String[command.size()]));
   // 13 means that we wrote something out in the log file.
   // so try and parse it and fail via that message if we can.
   if (result == 13) parseExitdata(message);
   return result;
 }
  /**
   * Returns paths constructed by rewriting pathInfo using rules from the hosted site's mappings.
   * Paths are ordered from most to least specific match.
   *
   * @param site The hosted site.
   * @param pathInfo Path to be rewritten.
   * @param queryString
   * @return The rewritten path. May be either:
   *     <ul>
   *       <li>A path to a file in the Orion workspace, eg. <code>/ProjectA/foo/bar.txt</code>
   *       <li>An absolute URL pointing to another site, eg. <code>http://foo.com/bar.txt</code>
   *     </ul>
   *
   * @return The rewritten paths.
   * @throws URISyntaxException
   */
  private URI[] getMapped(IHostedSite site, IPath pathInfo, String queryString)
      throws URISyntaxException {
    final Map<String, List<String>> map = site.getMappings();
    final IPath originalPath = pathInfo;
    IPath path = originalPath.removeTrailingSeparator();

    List<URI> uris = new ArrayList<URI>();
    String rest = null;
    final int count = path.segmentCount();
    for (int i = 0; i <= count; i++) {
      List<String> base = map.get(path.toString());
      if (base != null) {
        rest = originalPath.removeFirstSegments(count - i).toString();
        for (int j = 0; j < base.size(); j++) {
          URI uri =
              rest.equals("") ? new URI(base.get(j)) : URIUtil.append(new URI(base.get(j)), rest);
          uris.add(
              new URI(
                  uri.getScheme(),
                  uri.getUserInfo(),
                  uri.getHost(),
                  uri.getPort(),
                  uri.getPath(),
                  queryString,
                  uri.getFragment()));
        }
      }
      path = path.removeLastSegments(1);
    }
    if (uris.size() == 0)
      // No mapping for /
      return null;
    else return uris.toArray(new URI[uris.size()]);
  }
 /*
  * Run the reconciler to discover changes in the drop-ins folder and update the system state.
  */
 public void reconcile(String message, boolean clean) {
   List<String> args = new ArrayList<String>();
   args.add("-application");
   args.add("org.eclipse.equinox.p2.reconciler.application");
   if (clean) args.add("-clean");
   runEclipse(message, args.toArray(new String[args.size()]));
 }
예제 #4
0
 /**
  * Method filterResources filters the given resources using the given working set.
  *
  * @param current
  * @param resources
  * @return ICVSRemoteResource[]
  */
 public ICVSRemoteResource[] filterResources(
     IWorkingSet workingSet, ICVSRemoteResource[] resources) {
   if (workingSet == null) return resources;
   // get the projects associated with the working set
   IAdaptable[] adaptables = workingSet.getElements();
   Set projects = new HashSet();
   for (int i = 0; i < adaptables.length; i++) {
     IAdaptable adaptable = adaptables[i];
     Object adapted = adaptable.getAdapter(IResource.class);
     if (adapted != null) {
       // Can this code be generalized?
       IProject project = ((IResource) adapted).getProject();
       projects.add(project);
     }
   }
   List result = new ArrayList();
   for (int i = 0; i < resources.length; i++) {
     ICVSRemoteResource resource = resources[i];
     for (Iterator iter = projects.iterator(); iter.hasNext(); ) {
       IProject project = (IProject) iter.next();
       if (project.getName().equals(resource.getName())) {
         result.add(resource);
         break;
       }
     }
   }
   return (ICVSRemoteResource[]) result.toArray(new ICVSRemoteResource[result.size()]);
 }
예제 #5
0
 @Override
 public void fireModelChanged(IModelChangedEvent event) {
   IModelChangedListener[] list = fListeners.toArray(new IModelChangedListener[fListeners.size()]);
   for (int i = 0; i < list.length; i++) {
     IModelChangedListener listener = list[i];
     listener.modelChanged(event);
   }
 }
예제 #6
0
 /**
  * Method getRepositoryRoots.
  *
  * @param iCVSRepositoryLocations
  * @return RepositoryRoot[]
  */
 private RepositoryRoot[] getRepositoryRoots(ICVSRepositoryLocation[] locations) {
   List roots = new ArrayList();
   for (int i = 0; i < locations.length; i++) {
     ICVSRepositoryLocation location = locations[i];
     RepositoryRoot root = getRepositoryRootFor(location);
     if (root != null) roots.add(root);
   }
   return (RepositoryRoot[]) roots.toArray(new RepositoryRoot[roots.size()]);
 }
 public IStatus asStatus() {
   if (errors.isEmpty()) {
     List result = new ArrayList();
     accumulateStatus(
         (IResource[]) addedRoots.toArray(new IResource[addedRoots.size()]), result, ADDED);
     accumulateStatus(
         (IResource[]) removedRoots.toArray(new IResource[removedRoots.size()]), result, REMOVED);
     accumulateStatus(
         (IResource[]) movedRoots.toArray(new IResource[movedRoots.size()]), result, MOVED);
     accumulateStatus(
         (IResource[]) copiedRoots.toArray(new IResource[copiedRoots.size()]), result, COPIED);
     accumulateStatus(
         (IResource[]) changedRoots.toArray(new IResource[changedRoots.size()]), result, CHANGED);
     accumulateStatus(
         (IResource[]) closedProjects.toArray(new IResource[closedProjects.size()]),
         result,
         CLOSED);
     if (!result.isEmpty()) {
       if (result.size() == 1) return (IStatus) result.get(0);
       return new MultiStatus(
           "org.eclipse.core.tests.resources",
           0,
           (IStatus[]) result.toArray(new IStatus[result.size()]),
           "Changes were validated",
           null);
     }
     return Status.OK_STATUS;
   } else if (errors.size() == 1) {
     return (IStatus) errors.get(0);
   }
   return new MultiStatus(
       "org.eclipse.core.tests.resources",
       0,
       (IStatus[]) errors.toArray(new IStatus[errors.size()]),
       "Errors occurred",
       null);
 }
예제 #8
0
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.jface.wizard.IWizard#getPages()
  */
 public IWizardPage[] getPages() {
   return (IWizardPage[]) pages.toArray(new IWizardPage[pages.size()]);
 }