Search in sources :

Example 1 with BaseLaunchHelper

use of org.eclipse.wst.xsl.launching.config.BaseLaunchHelper in project webtools.sourceediting by eclipse.

the class XSLLaunchShortcut method findOrCreateLaunchConfiguration.

private ILaunchConfiguration findOrCreateLaunchConfiguration() throws CoreException {
    ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations(getConfigurationType());
    List<ILaunchConfiguration> candidateConfigs = new ArrayList<ILaunchConfiguration>(configs.length);
    for (ILaunchConfiguration config : configs) {
        String inputFile = config.getAttribute(XSLLaunchConfigurationConstants.ATTR_INPUT_FILE, (String) null);
        try {
            inputFile = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(inputFile);
        } catch (CoreException e) {
            // just ignore this one
            continue;
        }
        Path path = new Path(inputFile);
        // the source xml file must be the same
        if (path.equals(xmlFilePath)) {
            BaseLaunchHelper lh = new BaseLaunchHelper(config);
            // all the selected stylesheets must be in the pipeline
            boolean found = false;
            for (IFile stylesheet : xslFiles) {
                found = false;
                for (Iterator<LaunchTransform> iter = lh.getPipeline().getTransformDefs().iterator(); iter.hasNext(); ) {
                    LaunchTransform lt = iter.next();
                    if (lt.getLocation().equals(stylesheet.getLocation())) {
                        found = true;
                        break;
                    }
                }
                if (!found)
                    break;
            }
            if (found)
                candidateConfigs.add(config);
        }
    }
    ILaunchConfiguration config = null;
    int candidateCount = candidateConfigs.size();
    if (candidateCount == 1)
        config = candidateConfigs.get(0);
    else if (candidateCount > 1)
        config = chooseConfiguration(candidateConfigs);
    else
        config = createConfiguration();
    return config;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) LaunchTransform(org.eclipse.wst.xsl.launching.config.LaunchTransform) IFile(org.eclipse.core.resources.IFile) ArrayList(java.util.ArrayList) CoreException(org.eclipse.core.runtime.CoreException) BaseLaunchHelper(org.eclipse.wst.xsl.launching.config.BaseLaunchHelper)

Example 2 with BaseLaunchHelper

use of org.eclipse.wst.xsl.launching.config.BaseLaunchHelper in project webtools.sourceediting by eclipse.

the class XSLDebugUILaunchListener method launchesTerminated.

public void launchesTerminated(ILaunch[] launches) {
    for (ILaunch launch : launches) {
        ILaunchConfigurationType configType = null;
        try {
            configType = launch.getLaunchConfiguration().getType();
        } catch (CoreException e) {
        // do nothing
        }
        if (configType != null && XSL_LAUNCH_CONFIGURATION_TYPE.equals(configType.getIdentifier())) {
            try {
                BaseLaunchHelper launchHelper = new BaseLaunchHelper(launch.getLaunchConfiguration());
                File file = launchHelper.getTarget();
                IFile ifile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new Path(file.getAbsolutePath()));
                if (ifile != null) {
                    // refresh this workspace file..
                    try {
                        ifile.refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor());
                    } catch (CoreException e) {
                        XSLDebugUIPlugin.log(e);
                    }
                }
                openFileIfRequired(launchHelper);
            } catch (CoreException e) {
                XSLDebugUIPlugin.log(e);
            }
        }
    }
}
Also used : Path(org.eclipse.core.runtime.Path) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunch(org.eclipse.debug.core.ILaunch) BaseLaunchHelper(org.eclipse.wst.xsl.launching.config.BaseLaunchHelper) File(java.io.File) IFile(org.eclipse.core.resources.IFile)

Aggregations

IFile (org.eclipse.core.resources.IFile)2 CoreException (org.eclipse.core.runtime.CoreException)2 Path (org.eclipse.core.runtime.Path)2 BaseLaunchHelper (org.eclipse.wst.xsl.launching.config.BaseLaunchHelper)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 IPath (org.eclipse.core.runtime.IPath)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 ILaunch (org.eclipse.debug.core.ILaunch)1 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)1 ILaunchConfigurationType (org.eclipse.debug.core.ILaunchConfigurationType)1 LaunchTransform (org.eclipse.wst.xsl.launching.config.LaunchTransform)1