1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package net.sourceforge.jarduino.gui;
18
19 import net.sourceforge.jarduino.ArduinoException;
20 import net.sourceforge.jarduino.message.ArduinoChar;
21
22 import java.io.BufferedReader;
23 import java.io.IOException;
24 import java.io.InputStream;
25 import java.io.InputStreamReader;
26
27
28
29
30 public enum ArduinoHelp {
31
32
33
34 OVERVIEW("Overview", "Overview.html"),
35
36
37
38
39 CODESTRUCT("Code Structure", "CodeStructure.html"),
40
41
42
43
44 SRCSTAB("Source Tab", "SourcesTab.html"),
45
46
47
48
49 MSGTAB("Message Tab", "MessageTab.html"),
50
51
52
53
54 METATAB("MetaData Tab", "MetaDataTab.html");
55
56
57
58
59 private final String theTitle;
60
61
62
63
64 private final String theHTMLFile;
65
66
67
68
69 private String theHTML;
70
71
72
73
74
75
76 ArduinoHelp(final String pTitle,
77 final String pHtmlFile) {
78 theTitle = pTitle;
79 theHTMLFile = pHtmlFile;
80 }
81
82 @Override
83 public String toString() {
84 return theTitle;
85 }
86
87
88
89
90
91 String getHTML() {
92 return theHTML;
93 }
94
95
96
97
98
99 static void loadAllHelp() throws ArduinoException {
100 for (ArduinoHelp myId : values()) {
101 myId.loadHelp();
102 }
103 }
104
105
106
107
108
109 private void loadHelp() throws ArduinoException {
110
111 try (InputStream myStream = ArduinoPanelHelp.class.getResourceAsStream(theHTMLFile);
112 InputStreamReader myReader = new InputStreamReader(myStream);
113 BufferedReader myInput = new BufferedReader(myReader)) {
114
115 final StringBuilder myBuilder = new StringBuilder();
116
117
118 for (;;) {
119
120 final String myLine = myInput.readLine();
121 if (myLine == null) {
122 break;
123 }
124
125
126 myBuilder.append(myLine);
127 myBuilder.append(ArduinoChar.LF);
128 }
129
130
131 theHTML = myBuilder.toString();
132
133
134 } catch (IOException e) {
135 throw new ArduinoException("Failed to load File");
136 }
137 }
138 }