/**
   * 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()]);
  }
  /**
   * Tests identification of source bundles in a 3.0.2 install.
   *
   * @throws Exception
   */
  public void testClassicSourcePlugins() throws Exception {
    // extract the 3.0.2 skeleton
    IPath location = extractClassicPlugins();

    // the new way
    ITargetDefinition definition = getNewTarget();
    ITargetLocation container = getTargetService().newDirectoryLocation(location.toOSString());
    definition.setTargetLocations(new ITargetLocation[] {container});

    definition.resolve(null);
    TargetBundle[] bundles = definition.getBundles();
    List source = new ArrayList();
    for (int i = 0; i < bundles.length; i++) {
      TargetBundle sb = bundles[i];
      if (sb.isSourceBundle()) {
        source.add(sb);
      }
    }

    assertEquals("Wrong number of source bundles", 4, source.size());
    Set names = new HashSet();
    for (int i = 0; i < source.size(); i++) {
      names.add(((TargetBundle) source.get(i)).getBundleInfo().getSymbolicName());
    }
    String[] expected =
        new String[] {
          "org.eclipse.platform.source",
          "org.eclipse.jdt.source",
          "org.eclipse.pde.source",
          "org.eclipse.platform.source.win32.win32.x86"
        };
    for (int i = 0; i < expected.length; i++) {
      assertTrue("Missing source for " + expected[i], names.contains(expected[i]));
    }
  }
Exemplo n.º 3
0
 @Override
 protected IStatus performJob() {
   try {
     // list all tags
     File gitDir = GitUtils.getGitDir(path);
     Repository db = new FileRepository(gitDir);
     Git git = new Git(db);
     List<Ref> refs = git.tagList().call();
     JSONObject result = new JSONObject();
     List<Tag> tags = new ArrayList<Tag>();
     for (Ref ref : refs) {
       Tag tag = new Tag(cloneLocation, db, ref);
       tags.add(tag);
     }
     Collections.sort(tags, Tag.COMPARATOR);
     JSONArray children = new JSONArray();
     int firstTag = pageSize > 0 ? pageSize * (pageNo - 1) : 0;
     int lastTag = pageSize > 0 ? firstTag + pageSize - 1 : tags.size() - 1;
     lastTag = lastTag > tags.size() - 1 ? tags.size() - 1 : lastTag;
     if (pageNo > 1 && baseLocation != null) {
       String prev = baseLocation + "?page=" + (pageNo - 1) + "&pageSize=" + pageSize;
       if (commitsSize > 0) {
         prev += "&" + GitConstants.KEY_TAG_COMMITS + "=" + commitsSize;
       }
       result.put(ProtocolConstants.KEY_PREVIOUS_LOCATION, prev);
     }
     if (lastTag < tags.size() - 1) {
       String next = baseLocation + "?page=" + (pageNo + 1) + "&pageSize=" + pageSize;
       if (commitsSize > 0) {
         next += "&" + GitConstants.KEY_TAG_COMMITS + "=" + commitsSize;
       }
       result.put(ProtocolConstants.KEY_NEXT_LOCATION, next);
     }
     for (int i = firstTag; i <= lastTag; i++) {
       Tag tag = tags.get(i);
       if (this.commitsSize == 0) {
         children.put(tag.toJSON());
       } else {
         // add info about commits if requested
         LogCommand lc = git.log();
         String toCommitName = tag.getRevCommitName();
         ObjectId toCommitId = db.resolve(toCommitName);
         Ref toCommitRef = db.getRef(toCommitName);
         toCommitId = getCommitObjectId(db, toCommitId);
         lc.add(toCommitId);
         lc.setMaxCount(this.commitsSize);
         Iterable<RevCommit> commits = lc.call();
         Log log = new Log(cloneLocation, db, commits, null, null, toCommitRef);
         children.put(tag.toJSON(log.toJSON(1, commitsSize)));
       }
     }
     result.put(ProtocolConstants.KEY_CHILDREN, children);
     result.put(ProtocolConstants.KEY_TYPE, Tag.TYPE);
     return new ServerStatus(Status.OK_STATUS, HttpServletResponse.SC_OK, result);
   } catch (Exception e) {
     String msg = NLS.bind("An error occured when listing tags for {0}", path);
     return new Status(IStatus.ERROR, GitActivator.PI_GIT, msg, e);
   }
 }
Exemplo n.º 4
0
  /**
   * Ausfuehrung der Evaluierung. Jeder Ausdruck wird ueber die Verbindung ausgewertet und das
   * Ergebnis der Evaluierung wird dem {@link IBackgroundEvaluationListener} mitgeteilt.
   *
   * @param monitor - der ProgressMonitor
   * @see IBackgroundEvaluationListener
   * @sse {@link AbstractJob#run0(IProgressMonitor)}
   */
  @Override
  @SuppressWarnings("NP") // Rueckgabe von non-null Wert wird über Methoden-Contract geregelt
  protected IStatus run0(final IProgressMonitor monitor) throws Exception {
    monitor.subTask("Waiting for connection");
    acquireLock();

    ensureConnected(fConnection);
    callPrepare(fForms.size() > 1);

    monitor.beginTask(fJobName, (fForms.size() + 1) * 1000);

    if (monitor.isCanceled()) {
      return Status.CANCEL_STATUS;
    }

    for (int i = 0, n = fForms.size(); i < n; i++) {

      PackageBoundForm form = fForms.get(i);
      monitor.subTask("Starting evaluation " + i + "/" + fForms.size());
      IEvaluation eval = fConnection.getEvaluation();

      eval.evalStart(form.getPackage(), form.getForm());

      // Output Lesen
      readAllOutput(monitor);

      monitor.subTask("Reading result");
      IResult evalResult = eval.evalResult();

      boolean more = i != n - 1;
      IRestartSelection selection = callFormEvaluated(evalResult, more);

      monitor.worked(1000);

      if (evalResult.getTyp() == TResult.SUCCESS) { // Ergebnis ok
        continue; // alles ok mit ergebnis, mit naechstem weitermachen wenn vorhanden
      } else if (evalResult.getTyp()
          == TResult.READ_ERROR) { // Read error, es darf kein abort gesendet werden
        break;
      } else if (selection != null && selection.isAborted()) {
        abort(); // Ein Fehler, kann nur EVAL_ERROR sein, wurde abgebrochen
        break;
      } else { // EVAL_ERROR und es wurde ein Restart gewaehlt, bzw. war verfuegbar
        boolean abort = restart(monitor, selection, more); // eintritt rekursiver restart
        if (abort) { // restart abgebrochen
          abort(); // abort senden
          break; // und (bulk-)eval komplette beenden
        }
        continue; // restart war erfolgreich -> weiter mit naechstem im bulk
      }
    }

    return new Status(IStatus.OK, LispPluginActivator.ID, IStatus.OK, "Evaluation succeeded", null);
  }
 /*
  * 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()]));
 }
 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;
 }
Exemplo n.º 7
0
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.jface.wizard.IWizard#canFinish()
  */
 public boolean canFinish() {
   // Default implementation is to check if all pages are complete.
   for (int i = 0; i < pages.size(); i++) {
     if (!((IWizardPage) pages.get(i)).isPageComplete()) return false;
   }
   return true;
 }
  /**
   * Tests a JDT source feature bundle container contains the appropriate bundles
   *
   * @throws Exception
   */
  public void testSourceFeatureBundleContainer() throws Exception {
    // extract the feature
    IPath location = extractModifiedFeatures();

    ITargetDefinition definition = getNewTarget();
    ITargetLocation container =
        getTargetService()
            .newFeatureLocation(location.toOSString(), "org.eclipse.jdt.source", null);
    container.resolve(definition, null);
    TargetBundle[] bundles = container.getBundles();

    List expected = new ArrayList();
    expected.add("org.eclipse.jdt.source");
    expected.add("org.eclipse.jdt.launching.source");
    // There are two versions of junit available, each with source
    expected.add("org.junit.source");
    expected.add("org.junit.source");
    if (Platform.getOS().equals(Platform.OS_MACOSX)) {
      expected.add("org.eclipse.jdt.launching.macosx.source");
    }

    assertEquals("Wrong number of bundles", expected.size(), bundles.length);
    for (int i = 0; i < bundles.length; i++) {
      if (bundles[i].getBundleInfo().getSymbolicName().equals("org.eclipse.jdt.doc.isv")) {
        assertFalse("Should not be a source bundle", bundles[i].isSourceBundle());
      } else {
        assertTrue(expected.remove(bundles[i].getBundleInfo().getSymbolicName()));
        assertTrue("Should be a source bundle", bundles[i].isSourceBundle());
      }
    }
    assertTrue("Wrong bundles in JDT feature", expected.isEmpty());
  }
 @Override
 public IStatus getResolutionResult() {
   if (currentRemedy != null) return super.getResolutionResult();
   return remedies.size() > 0
       ? Status.OK_STATUS
       : new Status(IStatus.ERROR, Activator.ID, Messages.RemediationOperation_NoRemedyFound);
 }
Exemplo n.º 10
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()]);
 }
Exemplo n.º 11
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.eclipse.jface.wizard.IWizard#getNextPage(org.eclipse.jface.wizard
   * .IWizardPage)
   */
  public IWizardPage getNextPage(IWizardPage page) {
    int index = pages.indexOf(page);
    if (index == pages.size() - 1 || index == -1)
      // last page or page not found
      return null;

    return (IWizardPage) pages.get(index + 1);
  }
Exemplo n.º 12
0
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.jface.wizard.IWizard#getPage(java.lang.String)
  */
 public IWizardPage getPage(String name) {
   for (int i = 0; i < pages.size(); i++) {
     IWizardPage page = (IWizardPage) pages.get(i);
     String pageName = page.getName();
     if (pageName.equals(name)) return page;
   }
   return null;
 }
Exemplo n.º 13
0
 /*
  * (non-Javadoc)
  *
  * @see
  * org.eclipse.jface.wizard.IWizard#createPageControls(org.eclipse.swt.widgets
  * .Composite)
  */
 public void createPageControls(Composite pageContainer) {
   this.pageContainerHook = pageContainer;
   // the default behavior is to create all the pages controls
   for (int i = 0; i < pages.size(); i++) {
     IWizardPage page = (IWizardPage) pages.get(i);
     page.createControl(pageContainer);
   }
 }
Exemplo n.º 14
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);
   }
 }
Exemplo n.º 15
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()]);
 }
Exemplo n.º 16
0
  private void removeBuildPath(IResource resource, IProject project) {

    IScriptProject projrct = DLTKCore.create(project);
    IPath filePath = resource.getFullPath();

    oldBuildEntries = Arrays.asList(projrct.readRawBuildpath());

    newBuildEntries = new ArrayList<IBuildpathEntry>();

    newBuildEntries.addAll(oldBuildEntries);

    for (int i = 0; i < oldBuildEntries.size(); i++) {
      IBuildpathEntry fEntryToChange = oldBuildEntries.get(i);
      IPath entryPath = fEntryToChange.getPath();

      int mattchedPath = entryPath.matchingFirstSegments(filePath);

      if (mattchedPath == filePath.segmentCount()) {
        newBuildEntries.remove(fEntryToChange);
      } else {
        IBuildpathEntry newEntry =
            RefactoringUtility.createNewBuildpathEntry(
                fEntryToChange, fEntryToChange.getPath(), filePath, ""); // $NON-NLS-1$
        newBuildEntries.remove(fEntryToChange);
        newBuildEntries.add(newEntry);
      }
    }

    oldIncludePath = new ArrayList<IBuildpathEntry>();

    newIncludePathEntries = new ArrayList<IBuildpathEntry>();
    List<IncludePath> includePathEntries =
        Arrays.asList(IncludePathManager.getInstance().getIncludePaths(project));

    for (IncludePath entry : includePathEntries) {
      Object includePathEntry = entry.getEntry();
      IResource includeResource = null;
      if (!(includePathEntry instanceof IBuildpathEntry)) {
        includeResource = (IResource) includePathEntry;
        IPath entryPath = includeResource.getFullPath();

        IBuildpathEntry oldEntry =
            RefactoringUtility.createNewBuildpathEntry(IBuildpathEntry.BPE_SOURCE, entryPath);
        oldIncludePath.add((IBuildpathEntry) oldEntry);

        if (filePath.isPrefixOf(entryPath) || entryPath.equals(filePath)) {
        } else {
          IBuildpathEntry newEntry =
              RefactoringUtility.createNewBuildpathEntry(IBuildpathEntry.BPE_SOURCE, entryPath);
          newIncludePathEntries.add(newEntry);
        }
      } else {
        newIncludePathEntries.add((IBuildpathEntry) includePathEntry);
        oldIncludePath.add((IBuildpathEntry) includePathEntry);
      }
    }
  }
Exemplo n.º 17
0
 /**
  * Erstellt einen neuen Evaluierungsjob. Der Job kann mit {@link Job#schedule()} zur Abarbeitung
  * an den Job-Manager uebergeben werden.
  *
  * @param connection - Die Verbindung an dem der Job die Evaluierung vornimmt
  * @param forms - Eine Liste von Ausdruecken die evaluiert werden soll
  * @param listener - Der Listener der die Durchfuehrung der Abarbeitung des Jobs ueberwacht.
  * @throws NullPointerException - wenn connection, forms oder listener <code>null</code>
  * @throws IllegalArgumentException - wenn Liste der Ausdruecke leer
  */
 public EvaluationJob(
     final IConnection connection,
     final List<PackageBoundForm> forms,
     final IBackgroundEvaluationListener listener) {
   super(connection, listener, JOB_NAME);
   if (forms.size() < 1) {
     throw new IllegalArgumentException("at least one form must be supplied");
   }
   init(forms);
 }
Exemplo n.º 18
0
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.jface.wizard.IWizard#dispose()
   */
  public void dispose() {
    // notify pages
    for (int i = 0; i < pages.size(); i++) {
      ((IWizardPage) pages.get(i)).dispose();
    }

    // dispose of image
    if (defaultImage != null) {
      defaultImage.dispose();
      defaultImage = null;
    }
  }
Exemplo n.º 19
0
 @Override
 public void transferListenersTo(
     IModelChangeProviderExtension target, IModelChangedListenerFilter filter) {
   ArrayList<IModelChangedListener> removed = new ArrayList<>();
   for (int i = 0; i < fListeners.size(); i++) {
     IModelChangedListener listener = fListeners.get(i);
     if (filter == null || filter.accept(listener)) {
       target.addModelChangedListener(listener);
       removed.add(listener);
     }
   }
   fListeners.removeAll(removed);
 }
  /**
   * Tests a JDT feature bundle container contains the appropriate bundles for a specific OS.
   *
   * @throws Exception
   */
  public void testMacOSFeatureBundleContainer() throws Exception {
    // extract the feature
    IPath location = extractModifiedFeatures();

    ITargetDefinition definition = getNewTarget();
    definition.setOS(Platform.OS_MACOSX);
    ITargetLocation container =
        getTargetService().newFeatureLocation(location.toOSString(), "org.eclipse.jdt", null);
    container.resolve(definition, null);
    TargetBundle[] bundles = container.getBundles();

    List expected = new ArrayList();
    expected.add("org.eclipse.jdt");
    expected.add("org.eclipse.jdt.launching");
    // 2 versions of JUnit
    expected.add("org.junit");
    expected.add("org.junit");
    expected.add("org.junit4");
    expected.add("org.eclipse.jdt.launching.macosx");

    assertEquals("Wrong number of bundles in JDT feature", expected.size(), bundles.length);
    for (int i = 0; i < bundles.length; i++) {
      String symbolicName = bundles[i].getBundleInfo().getSymbolicName();
      expected.remove(symbolicName);
      if (symbolicName.equals("org.eclipse.jdt.launching.macosx")) {
        // the bundle should be missing unless on Mac
        IStatus status = bundles[i].getStatus();
        if (Platform.getOS().equals(Platform.OS_MACOSX)) {
          assertTrue("Mac bundle should be present", status.isOK());
        } else {
          assertFalse("Mac bundle should be missing", status.isOK());
          assertEquals(
              "Mac bundle should be mssing",
              TargetBundle.STATUS_PLUGIN_DOES_NOT_EXIST,
              status.getCode());
        }
      }
    }
    Iterator iterator = expected.iterator();
    while (iterator.hasNext()) {
      String name = (String) iterator.next();
      System.err.println("Missing: " + name);
    }
    assertTrue("Wrong bundles in JDT feature", expected.isEmpty());

    // should be no source bundles
    for (int i = 0; i < bundles.length; i++) {
      TargetBundle bundle = bundles[i];
      assertFalse("Should be no source bundles", bundle.isSourceBundle());
    }
  }
 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);
 }
  /**
   * Tests setting the target platform to the stored JDT feature test data
   *
   * @throws Exception
   */
  public void testSetTargetPlatformToJdtFeature() throws Exception {
    try {
      // extract the feature
      IPath location = extractModifiedFeatures();
      // org.eclipse.jdt_3.6.0.v20100105-0800-7z8VFR9FMTb52_pOyKHhoek1

      ITargetDefinition target = getNewTarget();
      ITargetLocation container =
          getTargetService()
              .newFeatureLocation(
                  location.toOSString(),
                  "org.eclipse.jdt",
                  "3.6.0.v20100105-0800-7z8VFR9FMTb52_pOyKHhoek1");

      target.setTargetLocations(new ITargetLocation[] {container});

      setTargetPlatform(target);

      List expected = new ArrayList();
      expected.add("org.eclipse.jdt");
      expected.add("org.eclipse.jdt.launching");
      // 2 versions of JUnit
      expected.add("org.junit");
      expected.add("org.junit");
      expected.add("org.junit4");
      if (Platform.getOS().equals(Platform.OS_MACOSX)) {
        expected.add("org.eclipse.jdt.launching.macosx");
      }

      // current platform
      IPluginModelBase[] models = TargetPlatformHelper.getPDEState().getTargetModels();

      assertEquals("Wrong number of bundles in JDT feature", expected.size(), models.length);
      for (int i = 0; i < models.length; i++) {
        expected.remove(models[i].getPluginBase().getId());
        assertTrue(models[i].isEnabled());
      }
      Iterator iterator = expected.iterator();
      while (iterator.hasNext()) {
        String name = (String) iterator.next();
        System.err.println("Missing: " + name);
      }
      assertTrue("Wrong bundles in target platform", expected.isEmpty());
    } finally {
      resetTargetPlatform();
    }
  }
Exemplo n.º 23
0
 /**
  * Verifies if the given element matches one of the selection requirements. Element must at least
  * pass the type test, and optionally wildcard name match.
  */
 private boolean verifyElement(IAdaptable element) {
   if (classes.isEmpty()) {
     return true;
   }
   for (int i = 0; i < classes.size(); i++) {
     SelectionClass sc = (SelectionClass) classes.get(i);
     if (verifyClass(element, sc.className) == false) {
       continue;
     }
     if (sc.nameFilter == null) {
       return true;
     }
     IWorkbenchAdapter de = (IWorkbenchAdapter) Util.getAdapter(element, IWorkbenchAdapter.class);
     if ((de != null) && verifyNameMatch(de.getLabel(element), sc.nameFilter)) {
       return true;
     }
   }
   return false;
 }
  /**
   * 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());
      }
    }
  }
  /**
   * Tests that a target definition based on the default target platform restricted to a subset of
   * bundles contains the right set.
   *
   * @throws Exception
   */
  public void testRestrictedDefaultTargetPlatform() throws Exception {
    ITargetDefinition definition = getNewTarget();
    ITargetLocation container =
        getTargetService().newProfileLocation(TargetPlatform.getDefaultLocation(), null);
    NameVersionDescriptor[] restrictions =
        new NameVersionDescriptor[] {
          new NameVersionDescriptor("org.eclipse.jdt.launching", null),
          new NameVersionDescriptor("org.eclipse.jdt.debug", null)
        };
    definition.setTargetLocations(new ITargetLocation[] {container});
    definition.setIncluded(restrictions);
    List infos = getAllBundleInfos(definition);

    assertEquals("Wrong number of bundles", 2, infos.size());
    Set set = collectAllSymbolicNames(infos);
    for (int i = 0; i < restrictions.length; i++) {
      NameVersionDescriptor info = restrictions[i];
      set.remove(info.getId());
    }
    assertEquals("Wrong bundles", 0, set.size());
  }
Exemplo n.º 26
0
  /**
   * Returns true if given text selection matches the conditions specified in the registry for this
   * action.
   */
  private boolean isEnabledFor(ISelection sel, int count) {
    if (verifySelectionCount(count) == false) {
      return false;
    }

    // Compare selection to enablement expression.
    if (enablementExpression != null) {
      return enablementExpression.isEnabledFor(sel);
    }

    // Compare selection to class requirements.
    if (classes.isEmpty()) {
      return true;
    }
    for (int i = 0; i < classes.size(); i++) {
      SelectionClass sc = (SelectionClass) classes.get(i);
      if (verifyClass(sel, sc.className)) {
        return true;
      }
    }
    return false;
  }
  /**
   * Tests that a target definition based on the JDT feature restricted to a subset of bundles
   * contains the right set.
   *
   * @throws Exception
   */
  public void testRestrictedFeatureBundleContainer() throws Exception {
    // extract the feature
    IPath location = extractModifiedFeatures();

    ITargetDefinition definition = getNewTarget();
    ITargetLocation container =
        getTargetService().newFeatureLocation(location.toOSString(), "org.eclipse.jdt", null);
    NameVersionDescriptor[] restrictions =
        new NameVersionDescriptor[] {
          new NameVersionDescriptor("org.eclipse.jdt", null),
          new NameVersionDescriptor("org.junit", "3.8.2.v20090203-1005")
        };
    definition.setTargetLocations(new ITargetLocation[] {container});
    definition.setIncluded(restrictions);
    List infos = getAllBundleInfos(definition);

    assertEquals("Wrong number of bundles", 2, infos.size());
    Set set = collectAllSymbolicNames(infos);
    for (int i = 0; i < restrictions.length; i++) {
      NameVersionDescriptor info = restrictions[i];
      set.remove(info.getId());
    }
    assertEquals("Wrong bundles", 0, set.size());
  }
Exemplo n.º 28
0
  private void mainPerform(
      MultiStatus status, EngineSession session, Operand[] operands, SubMonitor subMonitor) {
    IProfile profile = session.getProfile();
    subMonitor.beginTask(null, operands.length);
    for (int i = 0; i < operands.length; i++) {
      subMonitor.setWorkRemaining(operands.length - i);
      if (subMonitor.isCanceled()) throw new OperationCanceledException();
      Operand operand = operands[i];
      if (!isApplicable(operand)) continue;

      session.recordOperandStart(operand);
      List<ProvisioningAction> actions = getActions(operand);
      operandParameters = new HashMap<String, Object>(phaseParameters);
      operandParameters.put(PARM_OPERAND, operand);
      mergeStatus(status, initializeOperand(profile, operand, operandParameters, subMonitor));
      if (status.matches(IStatus.ERROR | IStatus.CANCEL)) {
        operandParameters = null;
        return;
      }

      Touchpoint operandTouchpoint = (Touchpoint) operandParameters.get(PARM_TOUCHPOINT);
      if (operandTouchpoint != null) {
        mergeStatus(
            status,
            initializeTouchpointParameters(profile, operand, operandTouchpoint, subMonitor));
        if (status.matches(IStatus.ERROR | IStatus.CANCEL)) return;

        operandParameters = touchpointToTouchpointOperandParameters.get(operandTouchpoint);
      }

      operandParameters = Collections.unmodifiableMap(operandParameters);
      if (actions != null) {
        for (int j = 0; j < actions.size(); j++) {
          ProvisioningAction action = actions.get(j);
          Map<String, Object> parameters = operandParameters;
          Touchpoint touchpoint = action.getTouchpoint();
          if (touchpoint != null) {
            mergeStatus(
                status, initializeTouchpointParameters(profile, operand, touchpoint, subMonitor));
            if (status.matches(IStatus.ERROR | IStatus.CANCEL)) return;

            parameters = touchpointToTouchpointOperandParameters.get(touchpoint);
          }
          IStatus actionStatus = null;
          try {
            session.recordActionExecute(action, parameters);
            actionStatus = action.execute(parameters);
          } catch (RuntimeException e) {
            if (!forced) throw e;
            // "action.execute" calls user code and might throw an unchecked exception
            // we catch the error here to gather information on where the problem occurred.
            actionStatus =
                new Status(
                    IStatus.ERROR,
                    EngineActivator.ID,
                    NLS.bind(Messages.forced_action_execute_error, action.getClass().getName()),
                    e);
          } catch (LinkageError e) {
            if (!forced) throw e;
            // Catch linkage errors as these are generally recoverable but let other Errors
            // propagate (see bug 222001)
            actionStatus =
                new Status(
                    IStatus.ERROR,
                    EngineActivator.ID,
                    NLS.bind(Messages.forced_action_execute_error, action.getClass().getName()),
                    e);
          }
          if (forced && actionStatus != null && actionStatus.matches(IStatus.ERROR)) {
            MultiStatus result =
                new MultiStatus(EngineActivator.ID, IStatus.ERROR, getProblemMessage(), null);
            result.add(
                new Status(
                    IStatus.ERROR,
                    EngineActivator.ID,
                    session.getContextString(this, operand, action),
                    null));
            LogHelper.log(result);
            actionStatus = Status.OK_STATUS;
          }
          mergeStatus(status, actionStatus);
          if (status.matches(IStatus.ERROR | IStatus.CANCEL)) return;
        }
      }
      mergeStatus(
          status, touchpointCompleteOperand(profile, operand, operandParameters, subMonitor));
      mergeStatus(status, completeOperand(profile, operand, operandParameters, subMonitor));
      if (status.matches(IStatus.ERROR | IStatus.CANCEL)) return;
      operandParameters = null;
      session.recordOperandEnd(operand);
      subMonitor.worked(1);
    }
  }
Exemplo n.º 29
0
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.jface.wizard.IWizard#needsPreviousAndNextButtons()
  */
 public boolean needsPreviousAndNextButtons() {
   return forcePreviousAndNextButtons || pages.size() > 1;
 }
Exemplo n.º 30
0
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.jface.wizard.IWizard#getStartingPage()
   */
  public IWizardPage getStartingPage() {
    if (pages.size() == 0) return null;

    return (IWizardPage) pages.get(0);
  }