Skip to content

Commit

Permalink
issue #63
Browse files Browse the repository at this point in the history
  • Loading branch information
rsoika committed Mar 24, 2017
1 parent 6549f03 commit 0007d3c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package org.imixs.report;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringWriter;
import java.net.MalformedURLException;
import java.net.URL;
Expand All @@ -15,7 +17,9 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Shell;
Expand Down Expand Up @@ -120,6 +124,23 @@ public void saveReport(ReportEditorInput reportInput, Report report, IProgressMo
if (file == null)
throw new FileNotFoundException();


// load the content of the XSL Resource file, if defined...
String sXSLResource=report.getStringValue("txtxslresource");
if (sXSLResource!=null && !sXSLResource.isEmpty()) {
// load the XSL resource from the workspace...
IFile xslFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(sXSLResource));
InputStream is = xslFile.getContents();
StringBuilder xslContent=new StringBuilder();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String read;
while((read=br.readLine()) != null) {
xslContent.append(read);
}
br.close();
report.setItemValue("txtxsl",xslContent.toString());
}

// convert the ItemCollection into a XMLItemcollection...
XMLItemCollection xmlItemCollection = XMLItemCollectionAdapter
.putItemCollection(report.getItemCollection());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,9 @@ public void createResourceSelectionControl(Composite parent, String fileExtensio
client.setLayout(layout);
client.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

final Text xsltext = toolkit.createText(client, report.getStringValue("txtxsl"), SWT.BORDER);
final Text xsltext = toolkit.createText(client, report.getStringValue("txtxslresource"), SWT.BORDER);
xsltext.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
xsltext.addModifyListener(event -> report.setItemValue("txtxsl", ((Text) event.widget).getText()));
xsltext.addModifyListener(event -> report.setItemValue("txtxslresource", ((Text) event.widget).getText()));
Button button = toolkit.createButton(client, "Browse", SWT.NONE);
final Shell shell = parent.getShell();
button.addListener(SWT.Selection, new Listener() {
Expand Down

0 comments on commit 0007d3c

Please sign in to comment.