/* (non-Javadoc) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration) */ public boolean isValid(ILaunchConfiguration launchConfig) { setErrorMessage(null); setMessage(null); // if variables are present, we cannot resolve the directory String workingDirPath = getWorkingDirectoryText(); if (workingDirPath.indexOf("${") >= 0) { // $NON-NLS-1$ IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); try { manager.validateStringVariables(workingDirPath); } catch (CoreException e) { setErrorMessage(e.getMessage()); return false; } } else if (workingDirPath.length() > 0) { IContainer container = getContainer(); if (container == null) { File dir = new File(workingDirPath); if (dir.isDirectory()) { return true; } setErrorMessage("Only directories can be selected"); return false; } } else if (workingDirPath.length() == 0) { setErrorMessage("A non-empty directory must be selected"); return false; } return true; }
public ICdtVariable getVariable(String macroName) { // if(contextType != DefaultMacroContextInfo.CONTEXT_WORKSPACE) // return null; if (macroName == null || "".equals(macroName)) // $NON-NLS-1$ return null; String varName = null; String param = null; IStringVariable var = null; int index = macroName.indexOf(COLON); if (index == -1) varName = macroName; else if (index > 0) { varName = macroName.substring(0, index); param = macroName.substring(index + 1); } if (varName != null) { IStringVariableManager mngr = VariablesPlugin.getDefault().getStringVariableManager(); var = mngr.getValueVariable(varName); if (var == null) var = mngr.getDynamicVariable(varName); } if (var != null) return new EclipseVarMacro(var, param); return null; }
/** @since 7.3 */ protected String resolve(String path) { try { IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); path = manager.performStringSubstitution(path, false); } catch (Exception e) { // if anything happens here just use the non-resolved one } return path; }
/** * Tests that a Java project must exist * * @throws Exception */ public void testProjectDoesNotExist() throws Exception { IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); try { manager.performStringSubstitution("${project_classpath:a_non_existant_project}"); } catch (CoreException e) { return; // expected } assertNotNull("Test should have thrown an exception due to project does not exist", null); }
/** * @return The default repository directory as configured in the preferences, with variables * substituted. An empty string if there was an error during substitution. */ public static String getDefaultRepositoryDir() { String dir = Activator.getDefault().getPreferenceStore().getString(UIPreferences.DEFAULT_REPO_DIR); IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); try { return manager.performStringSubstitution(dir); } catch (CoreException e) { return ""; //$NON-NLS-1$ } }
/** * Tests that a project name must be specified. * * @throws Exception */ public void testMissingProjectName() throws Exception { IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); setSelection(null); try { manager.performStringSubstitution("${project_classpath}"); } catch (CoreException e) { return; // expected } assertNotNull("Test should have thrown an exception due to missing project name", null); }
public void testProjectClasspath() throws Exception { IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); String projectName = get14Project().getElementName(); String cp = manager.performStringSubstitution("${project_classpath:" + projectName + "}"); StringBuffer buffer = new StringBuffer(); // expecting default output location and A.jar buffer.append( ResourcesPlugin.getWorkspace() .getRoot() .getFolder(get14Project().getOutputLocation()) .getLocation() .toOSString()); buffer.append(File.pathSeparatorChar); buffer.append( get14Project().getProject().getFolder("src").getFile("A.jar").getLocation().toOSString()); assertEquals("Wrong classpath", buffer.toString(), cp); }
private IFile getIFile(ILaunchConfigurationWorkingCopy configuration) { IFile file = null; if (fNewFile != null) { file = fNewFile; fNewFile = null; } else { IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); try { String location = configuration.getAttribute(IExternalToolConstants.ATTR_LOCATION, (String) null); if (location != null) { String expandedLocation = manager.performStringSubstitution(location); if (expandedLocation != null) { file = AntUtil.getFileForLocation(expandedLocation, null); } } } catch (CoreException e) { // do nothing } } return file; }
public ICdtVariable[] getVariables() { // if(contextType != DefaultMacroContextInfo.CONTEXT_WORKSPACE) // return null; IStringVariableManager mngr = VariablesPlugin.getDefault().getStringVariableManager(); IDynamicVariable vars[] = mngr.getDynamicVariables(); Map<String, IStringVariable> map = new HashMap<String, IStringVariable>(); for (IDynamicVariable var : vars) { final String name = var.getName(); if (!isDeadlockProneVariable(name)) { map.put(name, var); } } IValueVariable valVars[] = mngr.getValueVariables(); for (IValueVariable valVar : valVars) map.put(valVar.getName(), valVar); Collection<IStringVariable> collection = map.values(); EclipseVarMacro macros[] = new EclipseVarMacro[collection.size()]; Iterator<IStringVariable> iter = collection.iterator(); for (int i = 0; i < macros.length; i++) macros[i] = new EclipseVarMacro(iter.next()); return macros; }