Search in sources :

Example 6 with IStringVariableManager

use of org.eclipse.core.variables.IStringVariableManager in project linuxtools by eclipse.

the class OpenGCDialog method handleBrowse.

protected 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.gcFile.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 7 with IStringVariableManager

use of org.eclipse.core.variables.IStringVariableManager in project linuxtools by eclipse.

the class OpenGmonDialog 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()) {
        binaryValid = true;
        getButton(IDialogConstants.OK_ID).setEnabled(binaryValid);
        // $NON-NLS-1$
        errorLabel.setText("");
    } else {
        binaryValid = false;
        getButton(IDialogConstants.OK_ID).setEnabled(false);
        if (!binValue.equals("")) {
            // $NON-NLS-1$
            // $NON-NLS-1$ //$NON-NLS-2$
            errorLabel.setText("\"" + binText.getText() + "\" " + Messages.OpenGmonDialog_DOES_NOT_EXIST);
        } else {
            errorLabel.setText(Messages.OpenGmonDialog_PLEASE_ENTER_BINARY_FILE);
        }
        return;
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IStringVariableManager(org.eclipse.core.variables.IStringVariableManager) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 8 with IStringVariableManager

use of org.eclipse.core.variables.IStringVariableManager in project webtools.sourceediting by eclipse.

the class ResourceSelectionBlock method getResource.

/**
 * Returns the selected workspace container,or <code>null</code>
 */
protected IResource getResource() {
    String path = getText();
    if (path.length() > 0) {
        IResource res = null;
        IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
        try {
            if (// $NON-NLS-1$
            path.startsWith("${workspace_loc:")) {
                IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager();
                path = manager.performStringSubstitution(path, false);
            }
            File f = new File(path);
            if (resourceType == IResource.FOLDER) {
                IContainer[] containers = root.findContainersForLocationURI(f.toURI());
                if (containers.length > 0) {
                    res = containers[0];
                }
            } else if (resourceType == IResource.FILE) {
                IFile[] files = root.findFilesForLocationURI(f.toURI());
                if (files.length > 0) {
                    res = files[0];
                }
            }
            return res;
        } catch (CoreException e) {
            XSLDebugUIPlugin.log(e);
        }
    }
    return null;
}
Also used : IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) CoreException(org.eclipse.core.runtime.CoreException) IStringVariableManager(org.eclipse.core.variables.IStringVariableManager) IContainer(org.eclipse.core.resources.IContainer) IFile(org.eclipse.core.resources.IFile) File(java.io.File) IResource(org.eclipse.core.resources.IResource)

Example 9 with IStringVariableManager

use of org.eclipse.core.variables.IStringVariableManager in project usbdm-eclipse-plugins by podonoghue.

the class ManagedCommandLineGenerator method generateCommandLineInfo.

@Override
public IManagedCommandLineInfo generateCommandLineInfo(ITool tool, String commandName, String[] flags, String outputFlag, String outputPrefix, String output, String[] inputResources, String commandLinePattern) {
    if ((commandLinePattern == null) || (commandLinePattern.length() == 0)) {
        commandLinePattern = DEFAULT_PATTERN;
    }
    // System.err.println("ManagedCommandLineGenerator.generateCommandLineInfo(output=\'"+output.toString()+"\')");
    output = quoteToken(output);
    String inputsStr = stringArrayToString(inputResources, false);
    String flagsStr = stringArrayToString(flags, false);
    // System.err.println("ManagedCommandLineGenerator.generateCommandLineInfo(inputsStr=\'"+inputsStr+"\')");
    // System.err.println("ManagedCommandLineGenerator.generateCommandLineInfo(flagsStr =\'"+flagsStr+"\')");
    // System.err.println("ManagedCommandLineGenerator.generateCommandLineInfo(output   =\'"+output+"\')");
    RelacementPair[] replacementPair = { new RelacementPair("COMMAND", commandName), new RelacementPair("FLAGS", flagsStr), new RelacementPair("OUTPUT_FLAG", outputFlag), new RelacementPair("OUTPUT_PREFIX", outputPrefix), new RelacementPair("OUTPUT", output), new RelacementPair("INPUTS", inputsStr) };
    String command = commandLinePattern;
    for (RelacementPair pair : replacementPair) {
        // System.err.println("/'" + makeVariable(pair.key)+ "/'==>/'" + pair.value + "/'");
        command = command.replace(makeVariable(pair.key), pair.value);
        command = command.replace(makeVariable(pair.key).toLowerCase(), pair.value);
    }
    try {
        IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager();
        // System.err.println("ManagedCommandLineGenerator.generateCommandLineInfo() Before newCommandName = \'" + newCommandName);
        commandName = manager.performStringSubstitution(commandName);
    } catch (CoreException e1) {
        e1.printStackTrace();
    }
    // System.err.println("ManagedCommandLineGenerator.generateCommandLineInfo() commandName = \'"+commandName+"\'");
    return new ManagedCommandLineInfo(command.trim(), commandLinePattern, commandName, flagsStr, outputFlag, outputPrefix, output, inputsStr);
}
Also used : IManagedCommandLineInfo(org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo) CoreException(org.eclipse.core.runtime.CoreException) IStringVariableManager(org.eclipse.core.variables.IStringVariableManager)

Example 10 with IStringVariableManager

use of org.eclipse.core.variables.IStringVariableManager in project usbdm-eclipse-plugins by podonoghue.

the class UsbdmBuiltinSpecsDetector method resolveCommand.

/* (non-Javadoc)
    * @see org.eclipse.cdt.managedbuilder.language.settings.providers.AbstractBuiltinSpecsDetector#resolveCommand(java.lang.String)
    */
@Override
protected String resolveCommand(String languageId) throws CoreException {
    String commandLine = super.resolveCommand(languageId);
    System.err.println("UsbdmBuiltinSpecsDetector.resolveCommand() => (Before)commandLine = \'" + commandLine + "\'");
    try {
        // Do variable substitution
        IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager();
        // IValueVariable variable;
        // variable = manager.getValueVariable(UsbdmConstants.CODESOURCERY_ARM_PATH_KEY);
        // if (variable != null) {
        // String codesourceryPath = variable.getValue();
        // codesourceryPath = codesourceryPath.replace('\\', '/');
        // System.err.println("UsbdmBuiltinSpecsDetector.resolveCommand() => ${"+UsbdmConstants.CODESOURCERY_ARM_PATH_KEY+"} = \'" + codesourceryPath + "\'");
        // commandLine = commandLine.replace("${"+UsbdmConstants.CODESOURCERY_ARM_PATH_KEY+"}", codesourceryPath+"/x/");
        // }
        // variable = manager.getValueVariable(UsbdmConstants.CODESOURCERY_COLDFIRE_PATH_KEY);
        // if (variable != null) {
        // String codesourceryPath = variable.getValue();
        // codesourceryPath = codesourceryPath.replace('\\', '/');
        // System.err.println("UsbdmBuiltinSpecsDetector.resolveCommand() => ${"+UsbdmConstants.CODESOURCERY_COLDFIRE_PATH_KEY+"} = \'" + codesourceryPath + "\'");
        // commandLine = commandLine.replace("${"+UsbdmConstants.CODESOURCERY_COLDFIRE_PATH_KEY+"}", codesourceryPath+"/x/");
        // }
        commandLine = manager.performStringSubstitution(commandLine);
    } catch (CoreException e1) {
        e1.printStackTrace();
    }
    System.err.println("UsbdmBuiltinSpecsDetector.resolveCommand() => (After)commandLine = \'" + commandLine + "\'");
    return commandLine;
}
Also used : 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