Type | Editor Scripting printing |
Jar File | PrintScript.jar |
Applies to | editor |
GroupWriter writer = null; public void start() { writer = helper.createFileWriter("File"); if (writer == null) { context.abort("Aborting"); } }The framework will ask for a File in which subsequent
GroupWriter.print(Object... elements)
methods will create new lines in the File. Two File formats are provided for writing: a simple text format, and a XLSX format. Note that it is not necessary to flush and close the content of the File at the end of the Script. This will be performed automatically by the framework at the end of the Script. It is also possible to create more than one ScriptWriter.GroupWriter writer = null; public void start() { // this first instruction will pop a Dialog which will ask the user for a txt or xlsx file path writer = helper.createFileWriter("File"); if (writer == null) { // the writer will be null if the user click on the "Cancel" Button context.abort("Aborting"); } } public void process(ServerWidget widget) { writer.print(widget.getName(), widget.getID()); }
GroupWriter
from an existing ScriptFileWriter
. The result of creating a group depends on the file format:GroupWriter.setProperty(String, Object...)
method allows to set properties for the GroupWriter or ScriptFileWriter. The available properties depend on the format (properties which are not supported for a format will no perform anything, but will not throw any exception).setProperty("separator", ";");
setProperty("columnWidth", 1, 10);or with autoSize:
setProperty("columnWidth", 1, "autoSize");
setProperty("cellStyle", 1, 1, "verticalcenter+center+wrap");
XMLFileWriter writer = null; public void start() { // this first instruction will pop a Dialog which will ask the user for the XML file path writer = helper.createXMLFileWriter("File"); if (writer == null) { // the writer will be null if the user click on the "Cancel" Button context.abort("Aborting"); } }This writer allows to create an XML hierarchy. As for the other ScriptFileWriters, it is not necessary to flush and close the XML file at the end of the script. It will be performed automatically by the Scripting framework.
XMLFileWriter writer = null; XMLNode rootNode = null; XMLNode layerNode = null; public void start() { // this first instruction will pop a Dialog which will ask the user for the XML file path writer = helper.createXMLFileWriter("File"); if (writer == null) { context.abort("Aborting"); } // this instruction will create the root node for the XML File rootNode = writer.getRootNode("root"); } public void process(ServerLayer layer) { layerNode = new XMLNode(layer.getName()); layerNode.addAttribute("id", layer.getLayerID()); rootNode.addChild(layerNode); } public void process(ServerWidget widget) { XMLNode widgetNode = new XMLNode(widget.getName()); widgetNode.addAttribute("id", widget.getID()); layerNode.addChild(widgetNode); }
import java.io.*; BufferedWriter writer = null; public void start() { File file = helper.getNewFile("Set Text file", "txt"); BufferedWriter writer = new BufferedWriter(new FileWriter(file)); writer.write(file.getPath()); writer.newLine(); } public void end() { writer.flush(); writer.close(); }
Copyright 2016-2017 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v2 licence