Commit 48304a52 authored by Philip Makedonski's avatar Philip Makedonski
Browse files

* fixes for resource handler, correct bundle name and template path, and formatting offsets

parent 61c0ba9f
Loading
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ import org.osgi.framework.Bundle;
public class Generator {

	int index = 0;
	String templateFilename = "template.docx";
	String templateFilename = "resource/template.docx";
	public static String selectedTemplate = "TO_4_TABLE_TEMPLATE_EDITHELP";
	XWPFDocument template;
	private boolean hierarchical = true;
@@ -295,7 +295,7 @@ public class Generator {
	}

	private XWPFDocument loadTemplate() throws Exception {
		URI templateLocation = ResourceHandler.getSourceUri(this.getClass(), "org.etsi.mts.tdl.to.docx.poi", templateFilename);
		URI templateLocation = ResourceHandler.getSourceUri(this.getClass(), "org.etsi.mts.tdl.tools.to.docx.poi", templateFilename);
		template = loadTemplateDocument(templateLocation);
		return template;
	}
@@ -477,7 +477,9 @@ public class Generator {
						String then = NodeModelUtils.getNode(expectedBehaviours.get(1)).getText();
						//TODO: a bit of a hack
						when = filterSource(when, "\n", "\\s\\s\\s\\s\\w");
						then = filterSource(then, "\n", "\\s+\\w");
						//then = filterSource(then, "\n", "\\s+\\w");
						//then = filterSource(then, "\n", "\\s+\\w");
						then = filterSource(then, "\n", "\\s\\s\\s\\s\\w");
				
						map.put(Placeholders.WHEN, "when {"+when+"\n}");
						map.put(Placeholders.THEN, "then {"+then+"\n}");
@@ -557,7 +559,8 @@ public class Generator {
			String then = NodeModelUtils.getNode(sto.getExpectedBehaviour().getThenClause()).getText();
			//TODO: a bit of a hack
			when = filterSource(when, "\n", "\\s\\s\\s\\s\\w");
			then = filterSource(then, "\n", "\\s+\\w");
			//then = filterSource(then, "\n", "\\s+\\w");
			then = filterSource(then, "\n", "\\s\\s\\s\\s\\w");
	
			map.put(Placeholders.WHEN, "when {"+when+"\n}");
			map.put(Placeholders.THEN, "then {"+then+"\n}");
@@ -625,8 +628,7 @@ public class Generator {
	}

	private XWPFDocument loadTemplateDocument(URI templateLocation) throws Exception {
		File file = new File(templateLocation);
		FileInputStream fis = new FileInputStream(file.getAbsolutePath());
		FileInputStream fis = (FileInputStream) templateLocation.toURL().openStream();
		XWPFDocument document = new XWPFDocument(fis);
		fis.close();
		return document;