/** * 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()]); }
/* * (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; }
/* * (non-Javadoc) * * @see * org.eclipse.jface.wizard.IWizard#getPreviousPage(org.eclipse.jface.wizard * .IWizardPage) */ public IWizardPage getPreviousPage(IWizardPage page) { int index = pages.indexOf(page); if (index == 0 || index == -1) // first page or page not found return null; return (IWizardPage) pages.get(index - 1); }
/** * 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])); } }
@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); } }
/* * (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; }
/* * (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); } }
/* * (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); }
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); } } }
/** * 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); }
/* * (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; } }
@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); }
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); }
/** * 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; }
/** * 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; }
protected void switchWizardFragment(WizardFragment newFragment) { List<WizardFragment> list = getAllWizardFragments(); int oldIndex = list.indexOf(currentFragment); int newIndex = list.indexOf(newFragment); if (oldIndex == newIndex) return; if (currentFragment != null) currentFragment.exit(); if (oldIndex < newIndex) oldIndex++; else oldIndex--; while (oldIndex != newIndex) { WizardFragment fragment = (WizardFragment) list.get(oldIndex); fragment.enter(); fragment.exit(); if (oldIndex < newIndex) oldIndex++; else oldIndex--; } currentFragment = newFragment; currentFragment.enter(); }
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); } }
/* * (non-Javadoc) * * @see org.eclipse.jface.wizard.IWizard#getStartingPage() */ public IWizardPage getStartingPage() { if (pages.size() == 0) return null; return (IWizardPage) pages.get(0); }