Search in sources :

Example 1 with LaunchPipeline

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

the class XSLLaunchShortcut method promptForStylesheet.

private void promptForStylesheet() {
    // prompt for input xml file
    final LaunchPipeline promptedPipeline = new LaunchPipeline();
    StatusDialog dialog = new StatusDialog(getShell()) {

        private TransformsBlock transformsBlock = new TransformsBlock();

        @Override
        protected Control createDialogArea(Composite parent) {
            Composite comp = (Composite) super.createDialogArea(parent);
            comp.setFont(parent.getFont());
            GridLayout layout = new GridLayout(1, false);
            comp.setLayout(layout);
            Label label = new Label(comp, SWT.NONE);
            label.setFont(comp.getFont());
            GridData gd = new GridData();
            gd.horizontalIndent = 5;
            gd.verticalIndent = 5;
            gd.widthHint = 380;
            label.setLayoutData(gd);
            label.setText(Messages.XSLLaunchShortcut_7);
            promptedPipeline.setTransformDefs(new ArrayList<LaunchTransform>());
            transformsBlock.setPipeline(promptedPipeline);
            transformsBlock.createControl(comp);
            transformsBlock.initializeFrom(null);
            return comp;
        }

        @Override
        protected void okPressed() {
            savePipeline();
            super.okPressed();
        }

        private void savePipeline() {
            pipeline = promptedPipeline;
        }
    };
    dialog.setHelpAvailable(false);
    dialog.setStatusLineAboveButtons(true);
    dialog.setTitle(Messages.XSLLaunchShortcut_1);
    dialog.open();
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) LaunchTransform(org.eclipse.wst.xsl.launching.config.LaunchTransform) Composite(org.eclipse.swt.widgets.Composite) LaunchPipeline(org.eclipse.wst.xsl.launching.config.LaunchPipeline) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) StatusDialog(org.eclipse.jface.dialogs.StatusDialog) TransformsBlock(org.eclipse.wst.xsl.internal.debug.ui.tabs.main.TransformsBlock)

Example 2 with LaunchPipeline

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

the class XSLTSourcePathComputerDelegate method computeSourceContainers.

public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
    List<ISourceContainer> containers = new ArrayList<ISourceContainer>();
    String sourceFileExpr = configuration.getAttribute(XSLLaunchConfigurationConstants.ATTR_INPUT_FILE, (String) null);
    IPath sourceFile = getSubstitutedPath(sourceFileExpr);
    LaunchPipeline pipeline = hydratePipeline(configuration);
    // TODO have some way of knowing whether it is an IResource or not
    containers.add(new DirectorySourceContainer(sourceFile, false));
    for (Iterator<?> iter = pipeline.getTransformDefs().iterator(); iter.hasNext(); ) {
        LaunchTransform transform = (LaunchTransform) iter.next();
        IPath path = transform.getPath();
        ISourceContainer sourceContainer = null;
        if (transform.getPathType().equals(LaunchTransform.RESOURCE_TYPE)) {
            IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
            IContainer container = resource.getParent();
            if (container.getType() == IResource.PROJECT) {
                sourceContainer = new ProjectSourceContainer((IProject) container, false);
            } else if (container.getType() == IResource.FOLDER) {
                sourceContainer = new FolderSourceContainer(container, false);
            }
        } else {
            sourceContainer = new DirectorySourceContainer(path, false);
        }
        containers.add(sourceContainer);
    }
    return containers.toArray(new ISourceContainer[0]);
}
Also used : LaunchTransform(org.eclipse.wst.xsl.launching.config.LaunchTransform) IPath(org.eclipse.core.runtime.IPath) LaunchPipeline(org.eclipse.wst.xsl.launching.config.LaunchPipeline) FolderSourceContainer(org.eclipse.debug.core.sourcelookup.containers.FolderSourceContainer) ArrayList(java.util.ArrayList) DirectorySourceContainer(org.eclipse.debug.core.sourcelookup.containers.DirectorySourceContainer) ProjectSourceContainer(org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer) IProject(org.eclipse.core.resources.IProject) ISourceContainer(org.eclipse.debug.core.sourcelookup.ISourceContainer) IContainer(org.eclipse.core.resources.IContainer) IResource(org.eclipse.core.resources.IResource)

Example 3 with LaunchPipeline

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

the class XSLMainTab method setDefaults.

@Override
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
    LaunchPipeline lp = new LaunchPipeline();
    IResource[] resourceContext = getContext();
    IFile[] stylesheets = getXSLStylesheets(resourceContext);
    for (IFile file : stylesheets) {
        LaunchTransform lt = new LaunchTransform(file.getFullPath().toPortableString(), LaunchTransform.RESOURCE_TYPE);
        lp.addTransformDef(lt);
    }
    savePipeline(configuration, lp);
    super.setDefaults(configuration);
}
Also used : LaunchTransform(org.eclipse.wst.xsl.launching.config.LaunchTransform) IFile(org.eclipse.core.resources.IFile) LaunchPipeline(org.eclipse.wst.xsl.launching.config.LaunchPipeline) IResource(org.eclipse.core.resources.IResource)

Example 4 with LaunchPipeline

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

the class XSLMainTab method initializeFrom.

@Override
public void initializeFrom(ILaunchConfiguration configuration) {
    pipeline = null;
    try {
        String s = configuration.getAttribute(XSLLaunchConfigurationConstants.ATTR_PIPELINE, (String) null);
        if (s != null && s.length() > 0) {
            ByteArrayInputStream inputStream = new ByteArrayInputStream(s.getBytes());
            pipeline = LaunchPipeline.fromXML(inputStream);
        } else {
            pipeline = new LaunchPipeline();
        }
    } catch (CoreException e) {
        XSLDebugUIPlugin.log(e);
    }
    transformsBlock.setPipeline(pipeline);
    super.initializeFrom(configuration);
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ByteArrayInputStream(java.io.ByteArrayInputStream) LaunchPipeline(org.eclipse.wst.xsl.launching.config.LaunchPipeline)

Example 5 with LaunchPipeline

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

the class XSLLaunchShortcut method createConfiguration.

private ILaunchConfiguration createConfiguration() {
    ILaunchConfiguration config = null;
    try {
        ILaunchConfigurationType configType = getConfigurationType();
        // $NON-NLS-1$
        String lastSegment = xmlFile != null ? xmlFile.getName() : xmlFilePath != null ? xmlFilePath.lastSegment() : "XSLTransformation";
        ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager().generateUniqueLaunchConfigurationNameFrom(lastSegment));
        if (xmlFile != null)
            wc.setAttribute(XSLLaunchConfigurationConstants.ATTR_INPUT_FILE, // $NON-NLS-1$ //$NON-NLS-2$
            "${workspace_loc:" + xmlFile.getFullPath().toPortableString() + "}");
        else
            wc.setAttribute(XSLLaunchConfigurationConstants.ATTR_INPUT_FILE, xmlFilePath.toPortableString());
        wc.setAttribute(XSLLaunchConfigurationConstants.ATTR_USE_DEFAULT_OUTPUT_FILE, true);
        wc.setAttribute(XSLLaunchConfigurationConstants.ATTR_OPEN_FILE, true);
        if (pipeline == null)
            pipeline = new LaunchPipeline();
        for (IFile element : xslFiles) {
            pipeline.addTransformDef(new LaunchTransform(element.getFullPath().toPortableString(), LaunchTransform.RESOURCE_TYPE));
        }
        if (xslFilePath != null) {
            pipeline.addTransformDef(new LaunchTransform(xslFilePath, LaunchTransform.EXTERNAL_TYPE));
        }
        if (!pipeline.getTransformDefs().isEmpty()) {
            LaunchTransform lastDef = pipeline.getTransformDefs().get(pipeline.getTransformDefs().size() - 1);
            String outputFormat = guessOutputMethod(lastDef);
            if (outputFormat != null) {
                wc.setAttribute(XSLLaunchConfigurationConstants.ATTR_DEFAULT_OUTPUT_METHOD, outputFormat);
            }
        }
        wc.setAttribute(XSLLaunchConfigurationConstants.ATTR_PIPELINE, pipeline.toXML());
        if (xmlFile != null)
            wc.setMappedResources(new IResource[] { xmlFile.getProject() });
        config = wc.doSave();
    } catch (CoreException exception) {
        MessageDialog.openError(getShell(), Messages.XSLLaunchShortcut_6, exception.getStatus().getMessage());
    }
    return config;
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) LaunchTransform(org.eclipse.wst.xsl.launching.config.LaunchTransform) IFile(org.eclipse.core.resources.IFile) CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) LaunchPipeline(org.eclipse.wst.xsl.launching.config.LaunchPipeline) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) IResource(org.eclipse.core.resources.IResource)

Aggregations

LaunchPipeline (org.eclipse.wst.xsl.launching.config.LaunchPipeline)6 LaunchTransform (org.eclipse.wst.xsl.launching.config.LaunchTransform)4 IResource (org.eclipse.core.resources.IResource)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 IFile (org.eclipse.core.resources.IFile)2 CoreException (org.eclipse.core.runtime.CoreException)2 ArrayList (java.util.ArrayList)1 IContainer (org.eclipse.core.resources.IContainer)1 IProject (org.eclipse.core.resources.IProject)1 IPath (org.eclipse.core.runtime.IPath)1 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)1 ILaunchConfigurationType (org.eclipse.debug.core.ILaunchConfigurationType)1 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)1 ISourceContainer (org.eclipse.debug.core.sourcelookup.ISourceContainer)1 DirectorySourceContainer (org.eclipse.debug.core.sourcelookup.containers.DirectorySourceContainer)1 FolderSourceContainer (org.eclipse.debug.core.sourcelookup.containers.FolderSourceContainer)1 ProjectSourceContainer (org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer)1 StatusDialog (org.eclipse.jface.dialogs.StatusDialog)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1