Java Code Examples for org.eclipse.jdt.core.JavaCore#getClasspathVariable()
The following examples show how to use
org.eclipse.jdt.core.JavaCore#getClasspathVariable() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IDECPListLabelProvider.java From birt with Eclipse Public License 1.0 | 6 votes |
private String getVariableString( IPath path ) { String name = getPathLabel( path, false ); IPath entryPath = JavaCore.getClasspathVariable( path.segment( 0 ) ); if ( entryPath != null ) { String appended = getPathLabel( entryPath.append( path.removeFirstSegments( 1 ) ), true ); return MessageFormat.format( "{0} - {1}", //$NON-NLS-1$ new String[]{ name, appended } ); } else { return name; } }
Example 2
Source File: GWTCompileRunnerTest.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
/** * Tests variable support when computing classpaths. */ public void testComputeClasspathForVariables() throws CoreException, IOException { // Create the classpath variable Random rand = new Random(); String varName = null; while (varName == null) { String curVarName = this.getName() + rand.nextInt(); if (JavaCore.getClasspathVariable(curVarName) == null) { varName = curVarName; } } File systemTempFile = File.createTempFile(this.getName(), ".temp"); JavaCore.setClasspathVariable(varName, Path.fromOSString(systemTempFile.getAbsolutePath()), new NullProgressMonitor()); try { // Create a variable entry and add it to the raw classpath JavaProjectUtilities.addRawClassPathEntry(javaProjectA, JavaCore.newVariableEntry(new Path(varName), null, null, true)); // Get the computed classpath List<File> actualCp = getListOfFiles( GWTCompileRunner.computeClasspath(javaProjectA)); // Ensure the paths and ordering are all the same List<File> expectedCp = new ArrayList<File>(); expectedCp.add(systemTempFile); assertEquals(expectedCp, actualCp); } finally { JavaCore.removeClasspathVariable(varName, new NullProgressMonitor()); } }
Example 3
Source File: GwtTestUtilities.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
/** * Sets up workspace variables to point at the the {@code GWT_ROOT} and {@code GWT_TOOLS} * environment variables, which point at a local clone of the GWT git repository. If those * environment variables are not set, extracts a snapshot of the GWT source tree that * is bundled with this plug-in and sets the environment variables to point at it. */ private static void setupWorkspaceVariables() throws CoreException { IPathVariableManager variableManager = ResourcesPlugin.getWorkspace().getPathVariableManager(); String gwtRoot = System.getenv("GWT_ROOT"); if (gwtRoot == null) { System.out.println("The GWT_ROOT environment variable is not set, using test bundle version"); gwtRoot = TestEnvironmentUtil.installTestSdk( GwtTestingPlugin.getDefault().getBundle(), Path.fromPortableString("/resources/gwt-root.zip")).append("trunk").toOSString(); TestEnvironmentUtil.updateEnvironmentVariable("GWT_ROOT", gwtRoot); System.out.println("The GWT_ROOT environment variable is now set"); } IPath gwtRootPath = Path.fromOSString(gwtRoot); if (variableManager.getURIValue("GWT_ROOT") == null) { CorePluginLog.logInfo("Setting GWT_ROOT = " + gwtRootPath.toOSString()); variableManager.setURIValue("GWT_ROOT", gwtRootPath.toFile().toURI()); } String gwtTools = System.getenv("GWT_TOOLS"); if (gwtTools == null) { System.out.println("The GWT_TOOLS environment variable is not set, using GWT_ROOT as a base"); gwtTools = gwtRoot + "/tools"; TestEnvironmentUtil.updateEnvironmentVariable("GWT_TOOLS", gwtTools); } IPath gwtToolsPath = Path.fromOSString(gwtTools); if (JavaCore.getClasspathVariable("GWT_TOOLS") == null) { CorePluginLog.logInfo("Setting GWT_TOOLS = " + gwtToolsPath.toOSString()); JavaCore.setClasspathVariable("GWT_TOOLS", gwtToolsPath, null); } }
Example 4
Source File: ClasspathVariablesPreferencePage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private String getCurrentSettings() { StringBuffer buf= new StringBuffer(); String[] names= JavaCore.getClasspathVariableNames(); for (int i= 0; i < names.length; i++) { String curr= names[i]; buf.append(curr).append('\0'); IPath val= JavaCore.getClasspathVariable(curr); if (val != null) { buf.append(val.toString()); } buf.append('\0'); } return buf.toString(); }
Example 5
Source File: EditVariableEntryDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private IPath getResolvedPath(IPath path) { if (path != null) { String varName= path.segment(0); if (varName != null) { IPath varPath= JavaCore.getClasspathVariable(varName); if (varPath != null) { return varPath.append(path.removeFirstSegments(1)); } } } return null; }
Example 6
Source File: NewVariableEntryDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void initializeElements() { String[] entries= JavaCore.getClasspathVariableNames(); ArrayList<CPVariableElement> elements= new ArrayList<CPVariableElement>(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)); } } fVariablesList.setElements(elements); }
Example 7
Source File: SourceAttachmentBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private IPath getResolvedPath(IPath path) { if (path != null) { String varName= path.segment(0); if (varName != null) { IPath varPath= JavaCore.getClasspathVariable(varName); if (varPath != null) { return varPath.append(path.removeFirstSegments(1)); } } } return null; }
Example 8
Source File: CPListLabelProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private String getVariableString(IPath path) { String name= BasicElementLabels.getPathLabel(path, false); IPath entryPath= JavaCore.getClasspathVariable(path.segment(0)); if (entryPath != null) { String appended= BasicElementLabels.getPathLabel(entryPath.append(path.removeFirstSegments(1)), true); return Messages.format(NewWizardMessages.CPListLabelProvider_twopart, new String[] { name, appended }); } else { return name; } }
Example 9
Source File: VariableBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * @param initSelection the initial selection */ public void refresh(String initSelection) { CPVariableElement initSelectedElement= null; String[] entries= JavaCore.getClasspathVariableNames(); ArrayList<CPVariableElement> elements= new ArrayList<CPVariableElement>(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; } } } fVariablesList.setElements(elements); if (initSelectedElement != null) { ISelection sel= new StructuredSelection(initSelectedElement); fVariablesList.selectElements(sel); } else { fVariablesList.selectFirstElement(); } fHasChanges= false; }
Example 10
Source File: VariablePathDialogField.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public IPath getResolvedPath() { String variable= getVariable(); if (variable != null) { IPath path= JavaCore.getClasspathVariable(variable); if (path != null) { return path.append(getPathExtension()); } } return null; }
Example 11
Source File: JavaUtils.java From developer-studio with Apache License 2.0 | 5 votes |
public static boolean addClasspathVariable(String variableName, IPath path) { try { if (JavaCore.getClasspathVariable(variableName)!=null){ JavaCore.removeClasspathVariable(variableName, new NullProgressMonitor()); } JavaCore.setClasspathVariable(variableName, path, new NullProgressMonitor()); return true; } catch (JavaModelException e) { return false; } }
Example 12
Source File: ClasspathVariableResolver.java From eclipse-cs with GNU Lesser General Public License v2.1 | 4 votes |
@Override public String resolve(String aName) { IPath var = JavaCore.getClasspathVariable(aName); return var != null ? var.toString() : null; }
Example 13
Source File: JavaUtils.java From developer-studio with Apache License 2.0 | 4 votes |
public static IPath getClasspathVariable(String variableName){ return JavaCore.getClasspathVariable(variableName); }
Example 14
Source File: IDEReportClasspathResolver.java From birt with Eclipse Public License 1.0 | 4 votes |
private List<String> getAllClassPathFromEntries(List<IClasspathEntry> list) { List<String> retValue = new ArrayList(); IWorkspace space = ResourcesPlugin.getWorkspace( ); IWorkspaceRoot root = space.getRoot( ); for (int i=0; i<list.size( ); i++) { IClasspathEntry curr = list.get( i ); boolean inWorkSpace = true; if ( space == null || space.getRoot( ) == null ) { inWorkSpace = false; } IPath path = curr.getPath( ); if (curr.getEntryKind( ) == IClasspathEntry.CPE_VARIABLE) { path = JavaCore.getClasspathVariable( path.segment( 0 ) ); } else { path = JavaCore.getResolvedClasspathEntry( curr ).getPath( ); } if (curr.getEntryKind( ) == IClasspathEntry.CPE_PROJECT) { if (root.findMember( path ) instanceof IProject) { List<String> strs = getProjectClasspath( (IProject)root.findMember( path ),false, true ); for (int j=0; j<strs.size( ); j++) { addToList( retValue, strs.get( j ) ); } } } else { if ( root.findMember( path ) == null ) { inWorkSpace = false; } if ( inWorkSpace ) { String absPath = getFullPath( path, root.findMember( path ).getProject( ) ); //retValue.add( absPath ); addToList( retValue, absPath ); } else { //retValue.add( path.toFile( ).getAbsolutePath( )); addToList( retValue, path.toFile( ).getAbsolutePath( ) ); } } //strs.add( JavaCore.getResolvedClasspathEntry( entry ).getPath( ).toFile( ).getAbsolutePath( ) ); } return retValue; }