本文整理汇总了Java中org.eclipse.core.variables.IStringVariableManager类的典型用法代码示例。如果您正苦于以下问题:Java IStringVariableManager类的具体用法?Java IStringVariableManager怎么用?Java IStringVariableManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IStringVariableManager类属于org.eclipse.core.variables包,在下文中一共展示了IStringVariableManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: validateAbsoluteFilePath
import org.eclipse.core.variables.IStringVariableManager; //导入依赖的package包/类
/**
* Validates that the file with the specified absolute path exists and can be opened.
*
* @param path The path of the file to validate
* @return a status without error if the path is valid
*/
protected static IStatus validateAbsoluteFilePath(String path) {
final StatusInfo status = new StatusInfo();
IStringVariableManager variableManager = VariablesPlugin.getDefault().getStringVariableManager();
try {
path = variableManager.performStringSubstitution(path);
if (path.length() > 0) {
final File file = new File(path);
if (!file.exists() && (!file.isAbsolute() || !file.getParentFile().canWrite()))
status.setError(PreferencesMessages.SpellingPreferencePage_dictionary_error);
else if (file.exists() && (!file.isFile() || !file.isAbsolute() || !file.canRead() || !file.canWrite()))
status.setError(PreferencesMessages.SpellingPreferencePage_dictionary_error);
}
} catch (CoreException e) {
status.setError(e.getLocalizedMessage());
}
return status;
}
示例3: getIFile
import org.eclipse.core.variables.IStringVariableManager; //导入依赖的package包/类
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 = JSBuildFileUtil.getFileForLocation(expandedLocation);
}
}
}
catch (CoreException e) {
// do nothing
}
}
return file;
}
示例4: getCommand
import org.eclipse.core.variables.IStringVariableManager; //导入依赖的package包/类
@Override
public String getCommand() {
// anb0s: support of variables
IStringVariableManager variableManager = VariablesPlugin.getDefault().getStringVariableManager();
String resolved_location = null;
try {
resolved_location = variableManager.performStringSubstitution(this.location);
} catch (CoreException e) {
e.printStackTrace();
}
// Retrieves the real location where doxygen may be.
File realLocation = new File(resolved_location);
// Builds the path.
if (realLocation.isFile() == true) {
return realLocation.getPath();
} else {
return realLocation.getPath() + File.separator + COMMAND_NAME;
}
}
示例5: getCommandResolved
import org.eclipse.core.variables.IStringVariableManager; //导入依赖的package包/类
private String[] getCommandResolved(IStringVariableManager variableManager) throws CoreException {
String[] commandArray = null;
switch(commandTokenizer) {
case commandTokenizerSpaces:
commandArray = Utils.splitSpaces(commandValue);
break;
case commandTokenizerSpacesAndQuotes:
commandArray = Utils.splitSpacesAndQuotes(commandValue, false);
break;
case commandTokenizerSpacesAndQuotesSkip:
commandArray = Utils.splitSpacesAndQuotes(commandValue, true);
break;
case commandTokenizerDisabled:
commandArray = new String[1];
commandArray[0] = commandValue;
break;
default:
throw new IllegalArgumentException();
}
// resolve the variables
for (int i=0;i<commandArray.length;i++) {
commandArray[i] = variableManager.performStringSubstitution(commandArray[i], false);
Activator.logDebug("exc" + i + ":>" + commandArray[i]+ "<");
}
return commandArray;
}
示例6: handleExec
import org.eclipse.core.variables.IStringVariableManager; //导入依赖的package包/类
private void handleExec(IStringVariableManager variableManager) throws CoreException, IOException {
Activator.logDebug("exc:>---");
// get working directory
File workingDirectory = getWorkingDirectoryResolved(variableManager);
// get command
String[] command = getCommandResolved(variableManager);
// create process builder with command and ...
ProcessBuilder pb = new ProcessBuilder(command);
// ... set working directory and redirect error stream
if (workingDirectory != null) {
pb.directory(workingDirectory);
}
Activator.logDebug("exc:<---");
// get passed system environment
//Map<String, String> env = pb.environment();
// add own variables
pb.start();
}
示例7: initPreferencesStore
import org.eclipse.core.variables.IStringVariableManager; //导入依赖的package包/类
private void initPreferencesStore() {
IScopeContext projectScope = new ProjectScope(project);
preferences = projectScope.getNode(FileSyncPlugin.PLUGIN_ID);
buildPathMap(preferences);
preferences.addPreferenceChangeListener(this);
preferences.addNodeChangeListener(this);
IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager();
manager.addValueVariableListener(this);
jobChangeAdapter = new JobChangeAdapter(){
@Override
public void done(IJobChangeEvent event) {
// XXX dirty trick to re-evaluate dynamic egit variables on branch change
if(!event.getJob().getClass().getName().contains("org.eclipse.egit.ui.internal.branch.BranchOperationUI")){
return;
}
rebuildPathMap();
}
};
Job.getJobManager().addJobChangeListener(jobChangeAdapter);
ResourcesPlugin.getWorkspace().addResourceChangeListener(this);
}
示例8: doCheckState
import org.eclipse.core.variables.IStringVariableManager; //导入依赖的package包/类
@Override
public boolean doCheckState() {
VariablesPlugin variablesPlugin = VariablesPlugin.getDefault();
String value = getStringValue();
IStringVariableManager manager = variablesPlugin.getStringVariableManager();
// check if there are substitutions
String result;
try {
result = manager.performStringSubstitution(value, false);
if(!result.equals(getStringValue())) {
// string substitution present ... field editor cannot validate the value.
return true;
}
} catch (CoreException e) {
// replacement failed (but there are replaceable variables present)
return true;
}
if ( new File(value).isAbsolute()) {
return super.doCheckState();
}
return true;
}
示例9: checkState
import org.eclipse.core.variables.IStringVariableManager; //导入依赖的package包/类
@Override
public boolean checkState() {
VariablesPlugin variablesPlugin = VariablesPlugin.getDefault();
IStringVariableManager manager = variablesPlugin.getStringVariableManager();
// check if there are substitutions
String result;
try {
result = manager.performStringSubstitution(getStringValue(), false);
if(!result.equals(getStringValue())) {
// string substitution present ... field editor cannot validate the value.
return true;
}
} catch (CoreException e) {
e.printStackTrace();
}
return super.doCheckState();
}
示例10: validateAbsoluteFilePath
import org.eclipse.core.variables.IStringVariableManager; //导入依赖的package包/类
/**
* Validates that the file with the specified absolute path exists and can
* be opened.
*
* @param path
* The path of the file to validate
* @return a status without error if the path is valid
*/
protected static IStatus validateAbsoluteFilePath(String path) {
final StatusInfo status= new StatusInfo();
IStringVariableManager variableManager= VariablesPlugin.getDefault().getStringVariableManager();
try {
path= variableManager.performStringSubstitution(path);
if (path.length() > 0) {
final File file= new File(path);
if (!file.exists() && (!file.isAbsolute() || !file.getParentFile().canWrite()))
status.setError(PreferencesMessages.SpellingPreferencePage_dictionary_error);
else if (file.exists() && (!file.isFile() || !file.isAbsolute() || !file.canRead() || !file.canWrite()))
status.setError(PreferencesMessages.SpellingPreferencePage_dictionary_error);
}
} catch (CoreException e) {
status.setError(e.getLocalizedMessage());
}
return status;
}
示例11: resolveValue
import org.eclipse.core.variables.IStringVariableManager; //导入依赖的package包/类
@Override
public String resolveValue(IDynamicVariable variable, String argument) throws CoreException {
ArchToolchainPairList atlist = new ArchToolchainPairList();
atlist.doLoad();
String toolchainFile = atlist.get(argument);
if(toolchainFile == null) {
Status status = new Status(Status.INFO, Activator.PLUGIN_ID, "No CMake toolchainfile specified for architecture '" + argument +"'");
throw new CoreException(status);
}
IStringVariableManager varMgr = VariablesPlugin.getDefault().getStringVariableManager();
toolchainFile = varMgr.performStringSubstitution(toolchainFile);
return toolchainFile;
}
示例12: 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);
}
示例13: setDefaultMessage
import org.eclipse.core.variables.IStringVariableManager; //导入依赖的package包/类
private void setDefaultMessage( String odaDesignerID )
{
String msgExpr = Messages.getMessage( "datasource.page.title" );
// "Define ${odadesignerid.ds.displayname} Data Source";
String dsMsgExpr = msgExpr.replace( "odadesignerid", odaDesignerID ); //$NON-NLS-1$
IStringVariableManager varMgr = org.eclipse.core.variables.VariablesPlugin.getDefault( )
.getStringVariableManager( );
try
{
DEFAULT_MESSAGE = varMgr.performStringSubstitution( dsMsgExpr, false );
}
catch ( CoreException ex )
{
// TODO Auto-generated catch block
}
}
示例14: getTemplatePreference
import org.eclipse.core.variables.IStringVariableManager; //导入依赖的package包/类
/**
* Return default template preference
*
* @return String The string of default template preference
*/
public String getTemplatePreference( )
{
String temp = PreferenceFactory.getInstance( )
.getPreferences( this, UIUtil.getCurrentProject( ) )
.getString( TEMPLATE_PREFERENCE );
String str = temp;
try
{
IStringVariableManager mgr = VariablesPlugin.getDefault( )
.getStringVariableManager( );
str = mgr.performStringSubstitution( temp );
}
catch ( CoreException e )
{
str = temp;
}
return str;
}
示例15: fillMapWithEnv
import org.eclipse.core.variables.IStringVariableManager; //导入依赖的package包/类
public static void fillMapWithEnv(String[] env, Map<String, String> hashMap,
Set<String> keysThatShouldNotBeUpdated, IStringVariableManager manager) {
if (env == null || env.length == 0) {
// nothing to do
return;
}
if (keysThatShouldNotBeUpdated == null) {
keysThatShouldNotBeUpdated = Collections.emptySet();
}
for (String s : env) {
Tuple<String, String> sp = StringUtils.splitOnFirst(s, '=');
if (sp.o1.length() != 0 && sp.o2.length() != 0 && !keysThatShouldNotBeUpdated.contains(sp.o1)) {
String value = sp.o2;
if (manager != null) {
try {
value = manager.performStringSubstitution(value, false);
} catch (CoreException e) {
// Unreachable as false passed to reportUndefinedVariables above
}
}
hashMap.put(sp.o1, value);
}
}
}