From 48304a526f86f8a89ad54af684f76ac5c4f743d7 Mon Sep 17 00:00:00 2001 From: Philip Makedonski Date: Fri, 23 Jun 2023 16:33:54 +0200 Subject: [PATCH] * fixes for resource handler, correct bundle name and template path, and formatting offsets --- .../etsi/mts/tdl/tools/to/docx/poi/Generator.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/plugins/org.etsi.mts.tdl.tools.to.docx.poi/src/org/etsi/mts/tdl/tools/to/docx/poi/Generator.java b/plugins/org.etsi.mts.tdl.tools.to.docx.poi/src/org/etsi/mts/tdl/tools/to/docx/poi/Generator.java index 1df92e8c..55fe9bb8 100644 --- a/plugins/org.etsi.mts.tdl.tools.to.docx.poi/src/org/etsi/mts/tdl/tools/to/docx/poi/Generator.java +++ b/plugins/org.etsi.mts.tdl.tools.to.docx.poi/src/org/etsi/mts/tdl/tools/to/docx/poi/Generator.java @@ -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; -- GitLab