本文整理汇总了Java中org.eclipse.core.variables.IStringVariableManager.addVariables方法的典型用法代码示例。如果您正苦于以下问题:Java IStringVariableManager.addVariables方法的具体用法?Java IStringVariableManager.addVariables怎么用?Java IStringVariableManager.addVariables使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.core.variables.IStringVariableManager
的用法示例。
在下文中一共展示了IStringVariableManager.addVariables方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateInstalledVersion
import org.eclipse.core.variables.IStringVariableManager; //导入方法依赖的package包/类
@Override
protected void updateInstalledVersion(String version) {
WPILibCPPPlugin.getDefault().getPreferenceStore().setValue(PreferenceConstants.LIBRARY_INSTALLED,
version);
IStringVariableManager vm = VariablesPlugin.getDefault().getStringVariableManager();
try
{
IValueVariable vv = vm.getValueVariable("USER_HOME");
if (vv == null)
{
vm.addVariables(new IValueVariable[]{vm.newValueVariable("USER_HOME", "user.home directory", false,System.getProperty("user.home"))});
} else
{
if (!System.getProperty("user.home").equals(vm.performStringSubstitution("${USER_HOME}")))
vv.setValue(System.getProperty("user.home"));
}
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new RuntimeException(e);
}
}
示例2: testVariableSubstitution
import org.eclipse.core.variables.IStringVariableManager; //导入方法依赖的package包/类
@Test
public void testVariableSubstitution() throws CoreException {
final IStringVariableManager manager =
VariablesPlugin.getDefault().getStringVariableManager();
final IValueVariable var1 = manager.newValueVariable("my", "", false,
"MyTestProject");
final IValueVariable var2 = manager.newValueVariable("hello",
"hello world!", false, "Hello");
final IValueVariable var3 = manager.newValueVariable("ext", "", true,
"g4");
final IValueVariable[] vars = new IValueVariable[] {var1, var2, var3};
manager.addVariables(vars);
final String path = "/${my}/${hello}.${ext}";
final String actual = VariableButtonListener.substituteVariables(path);
final String expected = "/MyTestProject/Hello.g4";
Assert.assertEquals(expected, actual);
}
示例3: testPythonCommandLine
import org.eclipse.core.variables.IStringVariableManager; //导入方法依赖的package包/类
public void testPythonCommandLine() throws Exception {
PythonNature nature = PythonNature.getPythonNature(mod1);
// Create a temporary variable for testing
IStringVariableManager variableManager = VariablesPlugin.getDefault().getStringVariableManager();
IValueVariable myCustomVariable = variableManager.newValueVariable("pydev_python_runner_config_test_var", "",
true, "my_custom_value");
variableManager.addVariables(new IValueVariable[] { myCustomVariable });
try {
IInterpreterManager manager = PydevPlugin.getPythonInterpreterManager(true);
InterpreterInfo info = (InterpreterInfo) manager.getDefaultInterpreterInfo(false);
info.setEnvVariables(new String[] { "MY_CUSTOM_VAR_FOR_TEST=FOO", "MY_CUSTOM_VAR_FOR_TEST2=FOO2",
"MY_CUSTOM_VAR_WITH_VAR=${pydev_python_runner_config_test_var}" });
// Make sure variable hasn't been expanded too early
assertTrue(arrayContains(info.getEnvVariables(),
"MY_CUSTOM_VAR_WITH_VAR=${pydev_python_runner_config_test_var}"));
PythonRunnerConfig runnerConfig = createConfig();
assertTrue(arrayContains(runnerConfig.envp, "MY_CUSTOM_VAR_FOR_TEST=FOO"));
assertTrue(arrayContains(runnerConfig.envp, "MY_CUSTOM_VAR_FOR_TEST2=FOO2"));
assertTrue(arrayContains(runnerConfig.envp, "MY_CUSTOM_VAR_WITH_VAR=my_custom_value"));
String[] argv = runnerConfig.getCommandLine(false);
assertFalse(arrayContains(argv, PythonRunnerConfig.getRunFilesScript()));
assertTrue(arrayContains(argv, mod1.getLocation().toOSString()));
nature.setVersion(IPythonNature.Versions.PYTHON_VERSION_LATEST, IPythonNature.DEFAULT_INTERPRETER);
assertEquals(manager.getDefaultInterpreterInfo(false).getExecutableOrJar(), nature.getProjectInterpreter()
.getExecutableOrJar());
runnerConfig = createConfig();
argv = runnerConfig.getCommandLine(false);
assertEquals(manager.getDefaultInterpreterInfo(false).getExecutableOrJar(), argv[0]);
IInterpreterManager interpreterManager = nature.getRelatedInterpreterManager();
InterpreterInfo info2 = new InterpreterInfo(IPythonNature.PYTHON_VERSION_2_6, "c:\\interpreter\\py25.exe",
new ArrayList<String>());
interpreterManager.setInfos(new IInterpreterInfo[] { info, info2 }, null, null);
nature.setVersion(IPythonNature.Versions.PYTHON_VERSION_LATEST, "c:\\interpreter\\py25.exe");
assertEquals("c:\\interpreter\\py25.exe", nature.getProjectInterpreter().getExecutableOrJar());
runnerConfig = createConfig();
argv = runnerConfig.getCommandLine(false);
assertEquals("c:\\interpreter\\py25.exe", argv[0]);
nature.setVersion(IPythonNature.Versions.PYTHON_VERSION_LATEST, IPythonNature.DEFAULT_INTERPRETER);
ILaunchConfiguration config;
config = new LaunchShortcut().createDefaultLaunchConfiguration(FileOrResource
.createArray(new IResource[] { mod1 }));
ILaunchConfigurationWorkingCopy workingCopy = config.getWorkingCopy();
HashMap<String, String> map = new HashMap<String, String>();
map.put("VAR_SPECIFIED_IN_LAUNCH", "BAR");
map.put("MY_CUSTOM_VAR_FOR_TEST2", "BAR2"); //The one in the launch configuration always has preference.
workingCopy.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, map);
config = workingCopy.doSave();
runnerConfig = new PythonRunnerConfig(config, ILaunchManager.RUN_MODE, PythonRunnerConfig.RUN_REGULAR);
assertTrue(arrayContains(runnerConfig.envp, "VAR_SPECIFIED_IN_LAUNCH=BAR"));
assertTrue(arrayContains(runnerConfig.envp, "MY_CUSTOM_VAR_FOR_TEST=FOO"));
assertTrue(arrayContains(runnerConfig.envp, "MY_CUSTOM_VAR_FOR_TEST2=BAR2"));
assertTrue(arrayContains(runnerConfig.envp, "MY_CUSTOM_VAR_WITH_VAR=my_custom_value"));
} catch (Throwable e) {
e.printStackTrace();
throw new RuntimeException(e);
} finally {
//restore the default!
nature.setVersion(IPythonNature.Versions.PYTHON_VERSION_LATEST, IPythonNature.DEFAULT_INTERPRETER);
variableManager.removeVariables(new IValueVariable[] { myCustomVariable });
}
}