List of usage examples for org.eclipse.jdt.core JavaCore getClasspathVariableNames
public static String[] getClasspathVariableNames()
From source file:com.ibm.research.tours.content.url.delegates.ClassFileURLTourElementDelegate.java
License:Open Source License
private void init() { IPackageFragmentRoot root = null;/*from w ww. j a va 2s .c o m*/ root = JavaModelUtil.getPackageFragmentRoot(fFile); String[] entries = JavaCore.getClasspathVariableNames(); ArrayList elements = new ArrayList(entries.length); for (int i = 0; i < entries.length; i++) { String name = entries[i]; IPath entryPath = JavaCore.getClasspathVariable(name); IPath fullPath = root.getPath(); if (entryPath != null) { if (entryPath.isPrefixOf(fullPath)) { int matchingSegments = fullPath.matchingFirstSegments(entryPath); int numSegments = fullPath.segmentCount(); String[] segments = fullPath.segments(); String path = name + Path.SEPARATOR; for (int j = matchingSegments; j < numSegments; j++) { path = path + segments[j]; if (j != numSegments - 1) path = path + Path.SEPARATOR; } break; } } } }
From source file:com.liferay.ide.server.remote.ModuleTraverser.java
License:Open Source License
private static IPath getResolvedPathForArchiveComponent(URI uri) { String resourceType = uri.segment(1); URI contenturi = ModuleURIUtil.trimToRelativePath(uri, 2); String contentName = contenturi.toString(); if (resourceType.equals("lib")) { //$NON-NLS-1$ // module:/classpath/lib/D:/foo/foo.jar return Path.fromOSString(contentName); } else if (resourceType.equals("var")) { //$NON-NLS-1$ // module:/classpath/var/<CLASSPATHVAR>/foo.jar String classpathVar = contenturi.segment(0); URI remainingPathuri = ModuleURIUtil.trimToRelativePath(contenturi, 1); String remainingPath = remainingPathuri.toString(); String[] classpathvars = JavaCore.getClasspathVariableNames(); boolean found = false; for (int i = 0; i < classpathvars.length; i++) { if (classpathVar.equals(classpathvars[i])) { found = true;/*from w ww. j a va2 s .c o m*/ break; } } if (found) { IPath path = JavaCore.getClasspathVariable(classpathVar); if (path != null) { URI finaluri = URI.createURI(path.toOSString() + IPath.SEPARATOR + remainingPath); return Path.fromOSString(finaluri.toString()); } } // Trace.trace(Trace.WARNING, // NLS.bind("Tomcat publishing could not resolve dependency URI \"{0}\". A value for classpath variable {1} was not found.", uri, classpathVar)); //$NON-NLS-1$ } return null; }
From source file:org.eclim.plugin.jdt.command.classpath.ClasspathVariablesCommand.java
License:Open Source License
/** * {@inheritDoc}/*from w w w . j ava 2s .c om*/ */ public Object execute(CommandLine commandLine) throws Exception { ArrayList<ClasspathVariable> results = new ArrayList<ClasspathVariable>(); String[] names = JavaCore.getClasspathVariableNames(); for (int ii = 0; ii < names.length; ii++) { IPath path = JavaCore.getClasspathVariable(names[ii]); if (path != null) { ClasspathVariable variable = new ClasspathVariable(); variable.setName(names[ii]); variable.setPath(path.toOSString()); results.add(variable); } } Collections.sort(results); return results; }
From source file:org.eclim.plugin.jdt.project.JavaProjectManager.java
License:Open Source License
/** * Determines if the supplied path starts with a variable name. * * @param path The path to test./* w w w .ja va 2s. co m*/ * @return True if the path starts with a variable name, false otherwise. */ protected boolean startsWithVariable(String path) { String[] variables = JavaCore.getClasspathVariableNames(); for (int ii = 0; ii < variables.length; ii++) { if (path.startsWith(variables[ii])) { return true; } } return false; }
From source file:org.eclipse.edt.ide.ui.internal.property.pages.VariableBlock.java
License:Open Source License
public boolean performOk() { ArrayList removedVariables = new ArrayList(); ArrayList changedVariables = new ArrayList(); removedVariables.addAll(Arrays.asList(JavaCore.getClasspathVariableNames())); // remove all unchanged List changedElements = fVariablesList.getElements(); for (int i = changedElements.size() - 1; i >= 0; i--) { CPVariableElement curr = (CPVariableElement) changedElements.get(i); if (curr.isReadOnly()) { changedElements.remove(curr); } else {/*from w w w . jav a 2 s .c om*/ IPath path = curr.getPath(); IPath prevPath = JavaCore.getClasspathVariable(curr.getName()); if (prevPath != null && prevPath.equals(path)) { changedElements.remove(curr); } else { changedVariables.add(curr.getName()); } } removedVariables.remove(curr.getName()); } int steps = changedElements.size() + removedVariables.size(); if (steps > 0) { boolean needsBuild = false; if (fAskToBuild && doesChangeRequireFullBuild(removedVariables, changedVariables)) { String title = NewWizardMessages.VariableBlock_needsbuild_title; String message = NewWizardMessages.VariableBlock_needsbuild_message; MessageDialog buildDialog = new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2); int res = buildDialog.open(); if (res != 0 && res != 1) { return false; } needsBuild = (res == 0); } final VariableBlockRunnable runnable = new VariableBlockRunnable(removedVariables, changedElements); final ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); try { dialog.run(true, true, runnable); } catch (InvocationTargetException e) { ExceptionHandler.handle(new InvocationTargetException(new NullPointerException()), getShell(), NewWizardMessages.VariableBlock_variableSettingError_titel, NewWizardMessages.VariableBlock_variableSettingError_message); return false; } catch (InterruptedException e) { return false; } if (needsBuild) { CoreUtility.getBuildJob(null).schedule(); } } return true; }
From source file:org.eclipse.edt.ide.ui.internal.property.pages.VariableBlock.java
License:Open Source License
/** * @param initSelection the initial selection *//*from w w w . j ava 2 s . co m*/ public void refresh(String initSelection) { CPVariableElement initSelectedElement = null; String[] entries = JavaCore.getClasspathVariableNames(); ArrayList elements = new ArrayList(entries.length); for (int i = 0; i < entries.length; i++) { String name = entries[i]; CPVariableElement elem; IPath entryPath = JavaCore.getClasspathVariable(name); if (entryPath != null) { elem = new CPVariableElement(name, entryPath); elements.add(elem); if (name.equals(initSelection)) { initSelectedElement = elem; } } else { JavaPlugin.logErrorMessage("VariableBlock: Classpath variable with null value: " + name); //$NON-NLS-1$ } } fVariablesList.setElements(elements); if (initSelectedElement != null) { ISelection sel = new StructuredSelection(initSelectedElement); fVariablesList.selectElements(sel); } else { fVariablesList.selectFirstElement(); } fHasChanges = false; }
From source file:org.eclipse.jst.common.ui.internal.assembly.wizard.VariableReferenceWizardFragment.java
License:Open Source License
private CPVariableElement[] initializeElements() { String[] entries = JavaCore.getClasspathVariableNames(); ArrayList elements = new ArrayList(entries.length); for (int i = 0; i < entries.length; i++) { String name = entries[i]; IPath entryPath = JavaCore.getClasspathVariable(name); if (entryPath != null) { elements.add(new CPVariableElement(name, entryPath)); }// ww w. ja v a2 s . c o m } return (CPVariableElement[]) elements.toArray(new CPVariableElement[elements.size()]); }
From source file:org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities.java
License:Open Source License
/** * //from w w w.j a v a 2 s .c om * @param name * @return * @description the passed name should have either lib or var as its first segment e.g. * lib/D:/foo/foo.jar or var/<CLASSPATHVAR>/foo.jar */ public static IPath getResolvedPathForArchiveComponent(String name) { URI uri = URI.createURI(name); String resourceType = uri.segment(0); URI contenturi = ModuleURIUtil.trimToRelativePath(uri, 1); String contentName = contenturi.toString(); if (resourceType.equals("lib")) { //$NON-NLS-1$ // module:/classpath/lib/D:/foo/foo.jar return Path.fromOSString(contentName); } else if (resourceType.equals("var")) { //$NON-NLS-1$ // module:/classpath/var/<CLASSPATHVAR>/foo.jar String classpathVar = contenturi.segment(0); URI remainingPathuri = ModuleURIUtil.trimToRelativePath(contenturi, 1); String remainingPath = remainingPathuri.toString(); String[] classpathvars = JavaCore.getClasspathVariableNames(); boolean found = false; for (int i = 0; i < classpathvars.length; i++) { if (classpathVar.equals(classpathvars[i])) { found = true; break; } } if (found) { IPath path = JavaCore.getClasspathVariable(classpathVar); if (path != null) { URI finaluri = URI.createURI(path.toOSString() + IPath.SEPARATOR + remainingPath); return Path.fromOSString(finaluri.toString()); } } } return null; }
From source file:org.eclipse.jst.server.jetty.core.internal.wst.ModuleTraverser.java
License:Open Source License
private static IPath getResolvedPathForArchiveComponent(URI uri) { String resourceType = uri.segment(1); URI contenturi = ModuleURIUtil.trimToRelativePath(uri, 2); String contentName = contenturi.toString(); if (resourceType.equals("lib")) { //$NON-NLS-1$ // module:/classpath/lib/D:/foo/foo.jar return Path.fromOSString(contentName); } else if (resourceType.equals("var")) { //$NON-NLS-1$ // module:/classpath/var/<CLASSPATHVAR>/foo.jar String classpathVar = contenturi.segment(0); URI remainingPathuri = ModuleURIUtil.trimToRelativePath(contenturi, 1); String remainingPath = remainingPathuri.toString(); String[] classpathvars = JavaCore.getClasspathVariableNames(); boolean found = false; for (int i = 0; i < classpathvars.length; i++) { if (classpathVar.equals(classpathvars[i])) { found = true;//from ww w . j a va2 s. c o m break; } } if (found) { IPath path = JavaCore.getClasspathVariable(classpathVar); if (path != null) { URI finaluri = URI.createURI(path.toOSString() + IPath.SEPARATOR + remainingPath); return Path.fromOSString(finaluri.toString()); } } Trace.trace(Trace.WARNING, NLS.bind( "Jetty publishing could not resolve dependency URI \"{0}\". A value for classpath variable {1} was not found.", uri, classpathVar)); } return null; }
From source file:org.eclipse.jst.server.tomcat.core.internal.wst.ModuleTraverser.java
License:Open Source License
private static IPath getResolvedPathForArchiveComponent(URI uri) { String resourceType = uri.segment(1); URI contenturi = ModuleURIUtil.trimToRelativePath(uri, 2); String contentName = contenturi.toString(); if (resourceType.equals("lib")) { //$NON-NLS-1$ // module:/classpath/lib/D:/foo/foo.jar return Path.fromOSString(contentName); } else if (resourceType.equals("var")) { //$NON-NLS-1$ // module:/classpath/var/<CLASSPATHVAR>/foo.jar String classpathVar = contenturi.segment(0); URI remainingPathuri = ModuleURIUtil.trimToRelativePath(contenturi, 1); String remainingPath = remainingPathuri.toString(); String[] classpathvars = JavaCore.getClasspathVariableNames(); boolean found = false; for (int i = 0; i < classpathvars.length; i++) { if (classpathVar.equals(classpathvars[i])) { found = true;//from w w w. ja v a 2 s .c om break; } } if (found) { IPath path = JavaCore.getClasspathVariable(classpathVar); if (path != null) { URI finaluri = URI.createURI(path.toOSString() + IPath.SEPARATOR + remainingPath); return Path.fromOSString(finaluri.toString()); } } Trace.trace(Trace.WARNING, NLS.bind( "Tomcat publishing could not resolve dependency URI \"{0}\". A value for classpath variable {1} was not found.", uri, classpathVar)); } return null; }