Search in sources :

Example 1 with VariablesPlugin

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

the class UsbdmExampleSelectionPage method createControl.

@Override
public void createControl(Composite parent) {
    container = new Composite(parent, SWT.NULL);
    container.setLayout(new GridLayout(1, true));
    createExampleListControl(container);
    createUsbdmControl(container);
    setControl(container);
    // // Get values from Variable manager
    // IValueVariable  coldfirePathVariable = null;
    // IValueVariable  armPathVariable      = null;
    VariablesPlugin variablesPlugin = VariablesPlugin.getDefault();
    if (variablesPlugin != null) {
    // IStringVariableManager manager = variablesPlugin.getStringVariableManager();
    // if (manager != null) {
    // coldfirePathVariable = manager.getValueVariable(UsbdmConstants.USBDM_COLDFIRE_PATH_VAR);
    // if (coldfirePathVariable == null) {
    // coldfirePathVariable = manager.newValueVariable(UsbdmConstants.USBDM_COLDFIRE_PATH_VAR, "Path to Coldfire Tools directory");
    // }
    // armPathVariable = manager.getValueVariable(UsbdmConstants.USBDM_ARM_PATH_VAR);
    // if (armPathVariable == null) {
    // armPathVariable = manager.newValueVariable(UsbdmConstants.USBDM_ARM_PATH_VAR, "Path to ARM Tools directory");
    // }
    // }
    }
// if (coldfirePathVariable != null) {
// coldfirePathText.setText(coldfirePathVariable.getValue());
// }
// if (armPathVariable != null) {
// armPathText.setText(armPathVariable.getValue());
// }
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) VariablesPlugin(org.eclipse.core.variables.VariablesPlugin) Composite(org.eclipse.swt.widgets.Composite)

Example 2 with VariablesPlugin

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

the class AddTargetFiles method process.

public void process(IProject projectHandle, Map<String, String> variableMap, FileAction fileInfo, IProgressMonitor monitor) throws Exception {
    /*
       * Do macro substitution on path using project wizard variables
       */
    // if ((projectHandle == null)) {
    // // For debug
    // System.err.println("Debug: "+fileInfo);
    // return;
    // }
    String root = MacroSubstitute.substitute(fileInfo.getRoot(), variableMap);
    String source = MacroSubstitute.substitute(fileInfo.getSource(), variableMap);
    String target = MacroSubstitute.substitute(fileInfo.getTarget(), variableMap);
    if (source.isEmpty()) {
        // System.err.println("AddTargetFiles.process() - source is empty, fileInfo.getSource() = " + fileInfo.getSource());
        return;
    }
    /*
       * Do macro substitution on path using Eclipse Variables
       */
    VariablesPlugin varPlugin = VariablesPlugin.getDefault();
    if (varPlugin != null) {
        root = varPlugin.getStringVariableManager().performStringSubstitution(root, false);
        source = varPlugin.getStringVariableManager().performStringSubstitution(source, false);
        target = varPlugin.getStringVariableManager().performStringSubstitution(target, false);
    }
    /*
       * Make source path absolute if necessary 
       */
    Path sourcePath = Paths.get(source);
    if (fileInfo.getSourcePathType() == PathType.RELATIVE) {
        sourcePath = Paths.get(root, source);
    } else if (fileInfo.getSourcePathType() == PathType.UNKNOWN) {
        if (!sourcePath.isAbsolute()) {
            sourcePath = Paths.get(root, source);
        }
    }
    Path targetPath = Paths.get(target);
    switch(fileInfo.getFileType()) {
        case LINK:
            {
                createLink(sourcePath, target, projectHandle, monitor);
                break;
            }
        case NORMAL:
            {
                copyFiles(sourcePath, targetPath, fileInfo, variableMap, projectHandle, monitor);
                break;
            }
    }
}
Also used : Path(java.nio.file.Path) VariablesPlugin(org.eclipse.core.variables.VariablesPlugin)

Aggregations

VariablesPlugin (org.eclipse.core.variables.VariablesPlugin)2 Path (java.nio.file.Path)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1