use of org.eclipse.core.variables.IStringVariableManager in project linuxtools by eclipse.
the class OpenGCDialog method validateBinary.
private void validateBinary() {
binValue = binText.getText();
IStringVariableManager mgr = VariablesPlugin.getDefault().getStringVariableManager();
try {
binValue = mgr.performStringSubstitution(binValue, false);
} catch (CoreException e) {
// do nothing: never occurs
}
File f = new File(binValue);
if (f.exists()) {
IBinaryObject binary = STSymbolManager.sharedInstance.getBinaryObject(new Path(binValue));
if (binary == null) {
MessageDialog.openError(PlatformUI.getWorkbench().getDisplay().getActiveShell(), Messages.OpenGCDialog_invalid_bin_error_title, NLS.bind(Messages.OpenGCDialog_invalid_bin_error_message, binText.getText()));
return;
}
binaryValid = true;
getButton(IDialogConstants.OK_ID).setEnabled(binaryValid);
// $NON-NLS-1$
errorLabel.setText("");
} else {
binaryValid = false;
getButton(IDialogConstants.OK_ID).setEnabled(false);
if (!binValue.isEmpty()) {
errorLabel.setText(NLS.bind(Messages.OpenGCDialog_bin_dne_error_label, binText.getText()));
} else {
errorLabel.setText(Messages.OpenGCDialog_no_bin_error_label);
}
return;
}
}
use of org.eclipse.core.variables.IStringVariableManager in project linuxtools by eclipse.
the class OpenGmonDialog method handleBrowse.
private void handleBrowse(String msg, Text text) {
FileDialog dialog = new FileDialog(this.getShell(), SWT.OPEN);
dialog.setText(msg);
String t = text.getText();
IStringVariableManager mgr = VariablesPlugin.getDefault().getStringVariableManager();
try {
t = mgr.performStringSubstitution(t, false);
} catch (CoreException e) {
// do nothing: never occurs
}
File f = new File(t);
t = f.getParent();
if (t == null || t.length() == 0) {
t = this.gmonFile.removeLastSegments(1).toOSString();
}
dialog.setFilterPath(t);
String s = dialog.open();
if (s != null) {
text.setText(s);
}
}
use of org.eclipse.core.variables.IStringVariableManager in project titan.EclipsePlug-ins by eclipse.
the class EnvironmentHelper method resolveVariables.
/**
* Tries to resolve the variables in the environmental variables found in the launch configuration.
*
* @param originalVariables the original variables to use.
*
* @return the new hashmap of environment variables that were resolved.
*/
public static Map<String, String> resolveVariables(final HashMap<String, String> originalVariables) throws CoreException {
final Map<String, String> env = new HashMap<String, String>(originalVariables.size());
final IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager();
for (Map.Entry<String, String> variable : originalVariables.entrySet()) {
if (null != variable.getValue()) {
final String finalValue = manager.performStringSubstitution(variable.getValue());
if (null != finalValue) {
env.put(variable.getKey(), finalValue);
}
}
}
return env;
}
use of org.eclipse.core.variables.IStringVariableManager in project webtools.sourceediting by eclipse.
the class ResourceSelectionBlock method isValid.
@Override
public boolean isValid(ILaunchConfiguration config) {
setErrorMessage(null);
setMessage(null);
// if variables are present, we cannot resolve the directory
String workingDirPath = getText();
if (// $NON-NLS-1$
workingDirPath.indexOf("${") >= 0) {
IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager();
try {
manager.validateStringVariables(workingDirPath);
if (mustExist) {
String path = manager.performStringSubstitution(workingDirPath);
validateResource(path);
}
} catch (CoreException e) {
setErrorMessage(e.getMessage());
return false;
}
} else if (mustExist && workingDirPath.length() > 0) {
return validateResource(workingDirPath);
} else if (required && workingDirPath.length() == 0) {
setErrorMessage(getMessage(ERROR_DIRECTORY_NOT_SPECIFIED));
}
return true;
}
use of org.eclipse.core.variables.IStringVariableManager in project webtools.sourceediting by eclipse.
the class InputFileBlock method textModified.
@Override
protected void textModified() {
IPath path = null;
String workingDirPath = getText();
if (// $NON-NLS-1$
workingDirPath.indexOf("${") >= 0) {
IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager();
try {
manager.validateStringVariables(workingDirPath);
path = new Path(manager.performStringSubstitution(workingDirPath));
} catch (CoreException e) {
}
} else if (workingDirPath.length() > 0) {
path = new Path(workingDirPath);
}
}
Aggregations