List of usage examples for org.eclipse.jdt.core JavaCore removeClasspathVariable
public static void removeClasspathVariable(String variableName, IProgressMonitor monitor)
From source file:com.google.gwt.eclipse.core.compile.GWTCompileRunnerTest.java
License:Open Source License
/** * Tests variable support when computing classpaths. *//*from ww w . j av a 2 s . c om*/ 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()); } }
From source file:org.antlr.eclipse.core.AntlrCorePlugin.java
License:Open Source License
protected void createClasspathVariable(final String pluginName, final String variableName) { Bundle bundle = Platform.getBundle(pluginName); if (bundle == null) { JavaCore.removeClasspathVariable(variableName, null); return;//from ww w. j av a2 s. c om } else { URL installLocation = bundle.getEntry("/"); //$NON-NLS-1$ URL local = null; try { local = Platform.asLocalURL(installLocation); } catch (IOException e) { JavaCore.removeClasspathVariable(variableName, null); return; } try { String fullPath = new File(local.getPath()).getAbsolutePath(); JavaCore.setClasspathVariable(variableName, new Path(fullPath), null); } catch (JavaModelException e1) { JavaCore.removeClasspathVariable(variableName, null); } } }
From source file:org.caesarj.ui.CaesarHomeInitializer.java
License:Open Source License
public void initialize(String variable) { Bundle bundle = Platform.getBundle(CaesarPlugin.PLUGIN_ID); //$NON-NLS-1$ if (bundle == null) { JavaCore.removeClasspathVariable(CaesarPlugin.CAESAR_HOME, null); return;//from w ww . j av a2 s . c om } URL installLocation = bundle.getEntry("/"); //$NON-NLS-1$ URL local = null; try { local = FileLocator.toFileURL(installLocation); } catch (IOException e) { JavaCore.removeClasspathVariable(CaesarPlugin.CAESAR_HOME, null); return; } try { String fullPath = new File(local.getPath()).getAbsolutePath(); JavaCore.setClasspathVariable(CaesarPlugin.CAESAR_HOME, new Path(fullPath), null); } catch (JavaModelException e1) { JavaCore.removeClasspathVariable(CaesarPlugin.CAESAR_HOME, null); } }
From source file:org.cubictest.exporters.selenium.runner.SeleniumClasspathVariableInitializer.java
License:Open Source License
@Override public void initialize(String variable) { try {//w ww.j a va2 s .c o m IPath location = getBundleLocation(); if (location != null) { JavaCore.setClasspathVariable(variable, location, null); } else { JavaCore.removeClasspathVariable(variable, null); } } catch (JavaModelException e1) { JavaCore.removeClasspathVariable(variable, null); } }
From source file:org.eclim.plugin.jdt.command.classpath.ClasspathVariableDeleteCommand.java
License:Open Source License
/** * {@inheritDoc}//from w w w. j av a 2 s.c om */ public Object execute(CommandLine commandLine) throws Exception { String name = commandLine.getValue(Options.NAME_OPTION); JavaCore.removeClasspathVariable(name, null); return Services.getMessage("classpath.variable.deleted", name); }
From source file:org.seasar.eclipse.common.variable.AbstractVariable.java
License:Apache License
@Override public void initialize(String variable) { URL installLocation = getInstallLocation(); URL local = null;/* ww w .j av a2s . co m*/ try { local = FileLocator.toFileURL(installLocation); } catch (IOException e) { JavaCore.removeClasspathVariable(variable, null); return; } try { String fullPath = new File(local.getPath()).getAbsolutePath(); JavaCore.setClasspathVariable(variable, Path.fromOSString(fullPath), null); } catch (JavaModelException e1) { JavaCore.removeClasspathVariable(variable, null); } }
From source file:org.wso2.developerstudio.eclipse.utils.jdt.JavaUtils.java
License:Open Source License
public static boolean addClasspathVariable(String variableName, IPath path) { try {// ww w . j a v a 2 s.c o m if (JavaCore.getClasspathVariable(variableName) != null) { JavaCore.removeClasspathVariable(variableName, new NullProgressMonitor()); } JavaCore.setClasspathVariable(variableName, path, new NullProgressMonitor()); return true; } catch (JavaModelException e) { return false; } }