a1b808bea9a3c7d477cb0ef20806e7c6641790c0
[jalview.git] / src / jalview / help / freemarker / AllignmentMenuTemplateData.java
1 package jalview.help.freemarker;
2
3 import jalview.io.AppletFormatAdapter;
4
5 import java.io.File;
6 import java.io.FileWriter;
7 import java.io.IOException;
8 import java.io.OutputStreamWriter;
9 import java.io.Writer;
10 import java.util.HashMap;
11 import java.util.Map;
12
13 import freemarker.template.Configuration;
14 import freemarker.template.Template;
15 import freemarker.template.TemplateException;
16
17 public class AllignmentMenuTemplateData
18 {
19
20   public static void main(String[] args)
21   {
22     // System.out.println("Absolute Path " + new File().getAbsoluteFile());
23     generateAllignmentMenuTemplateData();
24   }
25   public static void generateAllignmentMenuTemplateData()
26   {
27     Configuration cfg = new Configuration();
28     try
29     {
30       // Load template from source folder
31       Template template = cfg
32               .getTemplate("/help/freemarker_templates/alignmentMenu.ftl");
33
34       // Build the data-model
35       Map<String, Object> data = new HashMap<String, Object>();
36       data.put("format_adapters", AppletFormatAdapter.WRITEABLE_FORMATS);
37
38       // Console output
39       Writer out = new OutputStreamWriter(System.out);
40       template.process(data, out);
41       out.flush();
42
43       // File output
44       Writer file = new FileWriter(
45               new File(
46                       "help/html/freemarker_html_output/alignmentMenu.html"));
47       template.process(data, file);
48       file.flush();
49       file.close();
50
51     } catch (IOException e)
52     {
53       e.printStackTrace();
54     } catch (TemplateException e)
55     {
56       e.printStackTrace();
57     }
58   }
59 }