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();
}
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]);
}
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);
}
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);
}
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;
}
Aggregations