Search in sources :

Example 1 with IStringVariableManager

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;
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) CoreException(org.eclipse.core.runtime.CoreException) IStringVariableManager(org.eclipse.core.variables.IStringVariableManager) IBinaryObject(org.eclipse.cdt.core.IBinaryParser.IBinaryObject) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 2 with IStringVariableManager

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);
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IStringVariableManager(org.eclipse.core.variables.IStringVariableManager) FileDialog(org.eclipse.swt.widgets.FileDialog) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 3 with IStringVariableManager

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;
}
Also used : HashMap(java.util.HashMap) IStringVariableManager(org.eclipse.core.variables.IStringVariableManager) Map(java.util.Map) HashMap(java.util.HashMap)

Example 4 with IStringVariableManager

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;
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IStringVariableManager(org.eclipse.core.variables.IStringVariableManager)

Example 5 with IStringVariableManager

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);
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) CoreException(org.eclipse.core.runtime.CoreException) IStringVariableManager(org.eclipse.core.variables.IStringVariableManager)

Aggregations

IStringVariableManager (org.eclipse.core.variables.IStringVariableManager)15 CoreException (org.eclipse.core.runtime.CoreException)14 File (java.io.File)9 IFile (org.eclipse.core.resources.IFile)6 IPath (org.eclipse.core.runtime.IPath)4 IResource (org.eclipse.core.resources.IResource)3 IProject (org.eclipse.core.resources.IProject)2 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)2 Path (org.eclipse.core.runtime.Path)2 FileDialog (org.eclipse.swt.widgets.FileDialog)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 IBinaryObject (org.eclipse.cdt.core.IBinaryParser.IBinaryObject)1 IManagedCommandLineInfo (org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo)1 IContainer (org.eclipse.core.resources.IContainer)1 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)1 BooleanFieldEditor (org.eclipse.jface.preference.BooleanFieldEditor)1 ComboFieldEditor (org.eclipse.jface.preference.ComboFieldEditor)1 DirectoryFieldEditor (org.eclipse.jface.preference.DirectoryFieldEditor)1 IntegerFieldEditor (org.eclipse.jface.preference.IntegerFieldEditor)1