Add SSH Starttime option in SSHCommand dialog
@@ -1,7 +1,3 @@ | ||
1 | -/* | |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | 1 | package net.atomique.ksar; |
6 | 2 | |
7 | 3 | import java.awt.Font; |
@@ -20,221 +16,226 @@ | ||
20 | 16 | * @author Max |
21 | 17 | */ |
22 | 18 | public class Config { |
19 | + private static Preferences myPref; | |
23 | 20 | |
24 | - private static Preferences myPref; | |
25 | - private static Config instance = new Config(); | |
21 | + private static String landf; | |
22 | + private static File lastReadDirectory; | |
23 | + private static File lastExportDirectory; | |
24 | + private static String lastCommand; | |
25 | + private static int number_host_history; | |
26 | + private static int local_configfile; | |
27 | + private static final ArrayList<String> host_history = new ArrayList<>(); | |
28 | + public static final Font DEFAULT_FONT = new Font("SansSerif", Font.BOLD, 18); | |
26 | 29 | |
27 | - public static Config getInstance() { | |
28 | - return instance; | |
29 | - } | |
30 | + private static String linuxDateFormat; | |
31 | + private static String linuxTimeFormat; | |
32 | + private static String pdfPageFormat; | |
33 | + private static int imageWidth; | |
34 | + private static int imageHeight; | |
30 | 35 | |
31 | - Config() { | |
32 | - myPref = Preferences.userNodeForPackage(Config.class); | |
33 | - if (myPref.getInt("local_configfile", -1) == -1) { | |
34 | - // new | |
35 | - try { | |
36 | - myPref.clear(); | |
37 | - myPref.flush(); | |
38 | - } catch (BackingStoreException e) { | |
39 | - } | |
40 | - local_configfile = store_configdir(); | |
41 | - myPref.putInt("local_configfile", local_configfile); | |
42 | - | |
43 | - } | |
44 | - load(); | |
45 | - } | |
36 | + private static final Config instance = new Config(); | |
37 | + public static Config getInstance(){ | |
38 | + return instance; | |
39 | + } | |
46 | 40 | |
47 | - private static void load() { | |
48 | - /* | |
49 | - * load default value or stored value | |
50 | - */ | |
51 | - setLandf(myPref.get("landf", UIManager.getLookAndFeel().getName())); | |
52 | - setLastReadDirectory(myPref.get("lastReadDirectory", null)); | |
53 | - setLastExportDirectory(myPref.get("lastExportDirectory", null)); | |
41 | + Config(){ | |
42 | + myPref = Preferences.userNodeForPackage(Config.class); | |
43 | + if(myPref.getInt("local_configfile", -1) == -1){ | |
44 | + // new | |
45 | + try{ | |
46 | + myPref.clear(); | |
47 | + myPref.flush(); | |
48 | + }catch(BackingStoreException e){ | |
49 | + } | |
50 | + local_configfile = store_configdir(); | |
51 | + myPref.putInt("local_configfile", local_configfile); | |
52 | + } | |
53 | + load(); | |
54 | + } | |
54 | 55 | |
55 | - setImageHeight(myPref.getInt("ImageHeight", 600)); | |
56 | - setImageWidth(myPref.getInt("ImageWidth", 800)); | |
57 | - setPDFPageFormat(myPref.get("PDFPageFormat","A4")); | |
58 | - setLinuxDateFormat(myPref.get("LinuxDateFormat","Always ask")); | |
56 | + private static void load(){ | |
57 | + /* | |
58 | + * load default value or stored value | |
59 | + */ | |
60 | + setLandf(myPref.get("landf", UIManager.getLookAndFeel().getName())); | |
61 | + setLastReadDirectory(myPref.get("lastReadDirectory", null)); | |
62 | + setLastExportDirectory(myPref.get("lastExportDirectory", null)); | |
59 | 63 | |
60 | - setNumber_host_history(myPref.getInt("HostHistory", 0)); | |
61 | - for (int i = 0; i < getNumber_host_history(); i++) { | |
62 | - host_history.add(myPref.get("HostHistory_" + i, null)); | |
63 | - } | |
64 | - setLocal_configfile(myPref.getInt("local_configfile", -1)); | |
65 | - } | |
64 | + setImageHeight(myPref.getInt("ImageHeight", 600)); | |
65 | + setImageWidth(myPref.getInt("ImageWidth", 800)); | |
66 | + setPDFPageFormat(myPref.get("PDFPageFormat","A4")); | |
67 | + setLinuxDateTimeFormat(myPref.get("LinuxDateFormat", net.atomique.ksar.UI.Preferences.DEFAULT_DATE_FORMAT), myPref.get("LinuxTimeFormat", net.atomique.ksar.UI.Preferences.DEFAULT_TIME_FORMAT)); | |
66 | 68 | |
67 | - public static void save() { | |
68 | - if (myPref == null) { | |
69 | - return; | |
70 | - } | |
71 | - myPref.put("landf", landf); | |
72 | - if (lastReadDirectory != null) { | |
73 | - myPref.put("lastReadDirectory", lastReadDirectory.toString()); | |
74 | - } | |
75 | - if (lastExportDirectory != null) { | |
76 | - myPref.put("lastExportDirectory", lastExportDirectory.toString()); | |
77 | - } | |
69 | + setNumber_host_history(myPref.getInt("HostHistory", 0)); | |
70 | + for(int i = 0; i < getNumber_host_history(); i++){ | |
71 | + host_history.add(myPref.get("HostHistory_" + i, null)); | |
72 | + } | |
73 | + setLocal_configfile(myPref.getInt("local_configfile", -1)); | |
74 | + } | |
78 | 75 | |
79 | - myPref.putInt("ImageHeight", ImageHeight); | |
80 | - myPref.putInt("ImageWidth", ImageWidth); | |
81 | - myPref.put("PDFPageFormat", PDFPageFormat); | |
82 | - myPref.put("LinuxDateFormat", LinuxDateFormat); | |
76 | + public static void save(){ | |
77 | + if(myPref == null){ | |
78 | + return; | |
79 | + } | |
80 | + myPref.put("landf", landf); | |
81 | + if(lastReadDirectory != null){ | |
82 | + myPref.put("lastReadDirectory", lastReadDirectory.toString()); | |
83 | + } | |
84 | + if(lastExportDirectory != null){ | |
85 | + myPref.put("lastExportDirectory", lastExportDirectory.toString()); | |
86 | + } | |
83 | 87 | |
84 | - for (int i = 0; i < host_history.size(); i++) { | |
85 | - myPref.put("HostHistory_" + i, host_history.get(i)); | |
86 | - } | |
87 | - myPref.putInt("HostHistory", host_history.size()); | |
88 | + myPref.putInt("ImageHeight", imageHeight); | |
89 | + myPref.putInt("ImageWidth", imageWidth); | |
90 | + myPref.put("PDFPageFormat", pdfPageFormat); | |
91 | + myPref.put("LinuxDateFormat", linuxDateFormat); | |
92 | + myPref.put("LinuxTimeFormat", linuxTimeFormat); | |
88 | 93 | |
89 | - myPref.putInt("local_configfile", local_configfile); | |
94 | + for(int i = 0; i < host_history.size(); i++){ | |
95 | + myPref.put("HostHistory_" + i, host_history.get(i)); | |
96 | + } | |
97 | + myPref.putInt("HostHistory", host_history.size()); | |
90 | 98 | |
91 | - } | |
99 | + myPref.putInt("local_configfile", local_configfile); | |
92 | 100 | |
93 | - public static String getLandf() { | |
94 | - return landf; | |
95 | - } | |
101 | + } | |
96 | 102 | |
97 | - public static void setLandf(String landf) { | |
98 | - Config.landf = landf; | |
99 | - } | |
103 | + public static String getLandf(){ | |
104 | + return landf; | |
105 | + } | |
100 | 106 | |
101 | - public static File getLastReadDirectory() { | |
102 | - return lastReadDirectory; | |
103 | - } | |
107 | + public static void setLandf(String landf){ | |
108 | + Config.landf = landf; | |
109 | + } | |
104 | 110 | |
105 | - public static void setLastReadDirectory(String lastReadDirectory) { | |
106 | - if (lastReadDirectory != null) { | |
107 | - Config.lastReadDirectory = new File(lastReadDirectory); | |
108 | - } | |
109 | - } | |
111 | + public static File getLastReadDirectory(){ | |
112 | + return lastReadDirectory; | |
113 | + } | |
110 | 114 | |
111 | - public static void setLastReadDirectory(File lastReadDirectory) { | |
112 | - Config.lastReadDirectory = lastReadDirectory; | |
113 | - } | |
115 | + public static void setLastReadDirectory(String lastReadDirectory){ | |
116 | + if(lastReadDirectory != null){ | |
117 | + Config.lastReadDirectory = new File(lastReadDirectory); | |
118 | + } | |
119 | + } | |
114 | 120 | |
115 | - public static File getLastExportDirectory() { | |
116 | - return lastReadDirectory; | |
117 | - } | |
121 | + public static void setLastReadDirectory(File lastReadDirectory){ | |
122 | + Config.lastReadDirectory = lastReadDirectory; | |
123 | + } | |
118 | 124 | |
119 | - public static void setLastExportDirectory(String lastExportDirectory) { | |
120 | - if (lastExportDirectory != null) { | |
121 | - Config.lastExportDirectory = new File(lastExportDirectory); | |
122 | - } | |
123 | - } | |
125 | + public static File getLastExportDirectory(){ | |
126 | + return lastReadDirectory; | |
127 | + } | |
124 | 128 | |
125 | - public static void setLastExportDirectory(File lastExportDirectory) { | |
126 | - Config.lastExportDirectory = lastExportDirectory; | |
127 | - } | |
129 | + public static void setLastExportDirectory(String lastExportDirectory){ | |
130 | + if(lastExportDirectory != null){ | |
131 | + Config.lastExportDirectory = new File(lastExportDirectory); | |
132 | + } | |
133 | + } | |
128 | 134 | |
129 | - public static String getLastCommand() { | |
130 | - return lastCommand; | |
131 | - } | |
135 | + public static void setLastExportDirectory(File lastExportDirectory){ | |
136 | + Config.lastExportDirectory = lastExportDirectory; | |
137 | + } | |
132 | 138 | |
133 | - public static void setLastCommand(String lastCommand) { | |
134 | - Config.lastCommand = lastCommand; | |
135 | - } | |
139 | + public static String getLastCommand(){ | |
140 | + return lastCommand; | |
141 | + } | |
136 | 142 | |
137 | - public static ArrayList<String> getHost_history() { | |
138 | - return host_history; | |
139 | - } | |
143 | + public static void setLastCommand(String lastCommand){ | |
144 | + Config.lastCommand = lastCommand; | |
145 | + } | |
140 | 146 | |
141 | - public static void addHost_history(String e) { | |
142 | - host_history.add(e); | |
143 | - } | |
147 | + public static ArrayList<String> getHost_history(){ | |
148 | + return host_history; | |
149 | + } | |
144 | 150 | |
145 | - public static int getNumber_host_history() { | |
146 | - return number_host_history; | |
147 | - } | |
151 | + public static void addHost_history(String e){ | |
152 | + host_history.add(e); | |
153 | + } | |
148 | 154 | |
149 | - public static void setNumber_host_history(int number_host_history) { | |
150 | - Config.number_host_history = number_host_history; | |
151 | - } | |
155 | + public static int getNumber_host_history(){ | |
156 | + return number_host_history; | |
157 | + } | |
152 | 158 | |
153 | - public static Font getDEFAULT_FONT() { | |
154 | - return DEFAULT_FONT; | |
155 | - } | |
159 | + public static void setNumber_host_history(int number_host_history){ | |
160 | + Config.number_host_history = number_host_history; | |
161 | + } | |
156 | 162 | |
157 | - public static int getImageHeight() { | |
158 | - return ImageHeight; | |
159 | - } | |
163 | + public static Font getDEFAULT_FONT(){ | |
164 | + return DEFAULT_FONT; | |
165 | + } | |
160 | 166 | |
161 | - public static void setImageHeight(int ImageHeight) { | |
162 | - Config.ImageHeight = ImageHeight; | |
163 | - } | |
167 | + public static int getImageHeight(){ | |
168 | + return imageHeight; | |
169 | + } | |
164 | 170 | |
165 | - public static int getImageWidth() { | |
166 | - return ImageWidth; | |
167 | - } | |
171 | + public static void setImageHeight(int ImageHeight){ | |
172 | + Config.imageHeight = ImageHeight; | |
173 | + } | |
168 | 174 | |
169 | - public static void setImageWidth(int ImageWidth) { | |
170 | - Config.ImageWidth = ImageWidth; | |
171 | - } | |
175 | + public static int getImageWidth(){ | |
176 | + return imageWidth; | |
177 | + } | |
172 | 178 | |
173 | - public static String getPDFPageFormat() { | |
174 | - return PDFPageFormat; | |
175 | - } | |
179 | + public static void setImageWidth(int ImageWidth){ | |
180 | + Config.imageWidth = ImageWidth; | |
181 | + } | |
176 | 182 | |
177 | - public static void setPDFPageFormat(String PDFPageFormat) { | |
178 | - Config.PDFPageFormat = PDFPageFormat; | |
179 | - } | |
183 | + public static String getPDFPageFormat(){ | |
184 | + return pdfPageFormat; | |
185 | + } | |
180 | 186 | |
181 | - | |
187 | + public static void setPDFPageFormat(String PDFPageFormat){ | |
188 | + Config.pdfPageFormat = PDFPageFormat; | |
189 | + } | |
182 | 190 | |
183 | - public static int store_configdir() { | |
184 | - Properties systemprops = System.getProperties(); | |
185 | - String userhome = (String) systemprops.get("user.home") + systemprops.get("file.separator"); | |
186 | - String username = (String) systemprops.get("user.name"); | |
187 | - String fileseparator = (String) systemprops.get("file.separator"); | |
188 | - // mkdir userhome/.ksar | |
189 | - String buffer = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n\n<ConfiG>\n</ConfiG>\n"; | |
190 | - boolean home = new File(userhome + ".ksarcfg").mkdir(); | |
191 | - if (!home) { | |
192 | - return 0; | |
193 | - } | |
191 | + public static int store_configdir(){ | |
192 | + Properties systemprops = System.getProperties(); | |
193 | + String userhome = (String) systemprops.get("user.home") + systemprops.get("file.separator"); | |
194 | + String username = (String) systemprops.get("user.name"); | |
195 | + String fileseparator = (String) systemprops.get("file.separator"); | |
196 | + // mkdir userhome/.ksar | |
197 | + String buffer = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n\n<ConfiG>\n</ConfiG>\n"; | |
198 | + boolean home = new File(userhome + ".ksarcfg").mkdir(); | |
199 | + if(!home){ | |
200 | + return 0; | |
201 | + } | |
194 | 202 | |
195 | - BufferedWriter out = null; | |
196 | - try { | |
197 | - out = new BufferedWriter(new FileWriter(userhome + ".ksarcfg" + fileseparator + "Config.xml")); | |
198 | - out.write(buffer); | |
199 | - out.flush(); | |
200 | - out.close(); | |
201 | - return 1; | |
202 | - } catch (IOException e) { | |
203 | - return 0; | |
204 | - } | |
203 | + BufferedWriter out = null; | |
204 | + try{ | |
205 | + out = new BufferedWriter(new FileWriter(userhome + ".ksarcfg" + fileseparator + "Config.xml")); | |
206 | + out.write(buffer); | |
207 | + out.flush(); | |
208 | + out.close(); | |
209 | + return 1; | |
210 | + }catch(IOException e){ | |
211 | + return 0; | |
212 | + } | |
213 | + } | |
205 | 214 | |
206 | - } | |
215 | + public static int getLocal_configfile(){ | |
216 | + return local_configfile; | |
217 | + } | |
207 | 218 | |
208 | - public static int getLocal_configfile() { | |
209 | - return local_configfile; | |
210 | - } | |
219 | + public static void setLocal_configfile(int local_configfile){ | |
220 | + Config.local_configfile = local_configfile; | |
221 | + } | |
211 | 222 | |
212 | - public static void setLocal_configfile(int local_configfile) { | |
213 | - Config.local_configfile = local_configfile; | |
214 | - } | |
223 | + public static String getLinuxDateFormat(){ | |
224 | + return linuxDateFormat; | |
225 | + } | |
215 | 226 | |
216 | - public static String getLinuxDateFormat() { | |
217 | - return LinuxDateFormat; | |
218 | - } | |
227 | + public static String getLinuxTimeFormat(){ | |
228 | + return linuxTimeFormat; | |
229 | + } | |
219 | 230 | |
220 | - public static void setLinuxDateFormat(String LinuxDateFormat) { | |
221 | - Config.LinuxDateFormat = LinuxDateFormat; | |
222 | - } | |
231 | + public static void setLinuxDateTimeFormat(String dateformat, String timeformat){ | |
232 | + if(null != dateformat){ | |
233 | + Config.linuxDateFormat = dateformat; | |
234 | + } | |
223 | 235 | |
224 | - | |
225 | - | |
226 | - private static String landf; | |
227 | - private static File lastReadDirectory; | |
228 | - private static File lastExportDirectory; | |
229 | - private static String lastCommand; | |
230 | - private static int number_host_history; | |
231 | - private static int local_configfile; | |
232 | - private static ArrayList<String> host_history = new ArrayList<String>(); | |
233 | - public static final Font DEFAULT_FONT = new Font("SansSerif", Font.BOLD, 18); | |
236 | + if(null != timeformat){ | |
237 | + Config.linuxTimeFormat = timeformat; | |
238 | + } | |
239 | + } | |
234 | 240 | |
235 | - private static String LinuxDateFormat; | |
236 | - private static String PDFPageFormat; | |
237 | - private static int ImageWidth; | |
238 | - private static int ImageHeight; | |
239 | - | |
240 | 241 | } |
@@ -1,7 +1,3 @@ | ||
1 | -/* | |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | 1 | package net.atomique.ksar; |
6 | 2 | |
7 | 3 | import java.io.BufferedReader; |
@@ -17,71 +13,71 @@ | ||
17 | 13 | * @author Max |
18 | 14 | */ |
19 | 15 | public class FileRead extends Thread implements DataCommandImpl{ |
20 | - private KSar mysar = null; | |
21 | - private String sarfilename = null; | |
22 | - private FileReader tmpfile = null; | |
23 | - private BufferedReader myfilereader = null; | |
16 | + private KSar mysar = null; | |
17 | + private String sarfilename = null; | |
18 | + private FileReader tmpfile = null; | |
19 | + private BufferedReader myfilereader = null; | |
24 | 20 | |
25 | - public FileRead(KSar hissar) { | |
26 | - mysar = hissar; | |
27 | - JFileChooser fc = new JFileChooser(); | |
28 | - if (Config.getLastReadDirectory() != null) { | |
29 | - fc.setCurrentDirectory(Config.getLastReadDirectory()); | |
30 | - } | |
31 | - int returnVal = fc.showDialog(null, "Open"); | |
32 | - if (returnVal == JFileChooser.APPROVE_OPTION) { | |
33 | - sarfilename = fc.getSelectedFile().getAbsolutePath(); | |
34 | - if (fc.getSelectedFile().isDirectory()) { | |
35 | - Config.setLastReadDirectory(fc.getSelectedFile()); | |
36 | - } else { | |
37 | - Config.setLastReadDirectory(fc.getSelectedFile().getParentFile()); | |
38 | - } | |
39 | - Config.save(); | |
40 | - } | |
41 | - } | |
21 | + public FileRead(KSar hissar){ | |
22 | + mysar = hissar; | |
23 | + JFileChooser fc = new JFileChooser(); | |
24 | + if(Config.getLastReadDirectory() != null){ | |
25 | + fc.setCurrentDirectory(Config.getLastReadDirectory()); | |
26 | + } | |
27 | + int returnVal = fc.showDialog(null, "Open"); | |
28 | + if(returnVal == JFileChooser.APPROVE_OPTION){ | |
29 | + sarfilename = fc.getSelectedFile().getAbsolutePath(); | |
30 | + if(fc.getSelectedFile().isDirectory()){ | |
31 | + Config.setLastReadDirectory(fc.getSelectedFile()); | |
32 | + }else{ | |
33 | + Config.setLastReadDirectory(fc.getSelectedFile().getParentFile()); | |
34 | + } | |
35 | + Config.save(); | |
36 | + } | |
37 | + } | |
42 | 38 | |
43 | - public FileRead(KSar hissar, String filename) { | |
44 | - mysar = hissar; | |
45 | - sarfilename = filename; | |
46 | - } | |
39 | + public FileRead(KSar hissar, String filename){ | |
40 | + mysar = hissar; | |
41 | + sarfilename = filename; | |
42 | + } | |
47 | 43 | |
48 | - public String get_action() { | |
49 | - if ( sarfilename != null ) { | |
50 | - return "file://" + sarfilename; | |
51 | - } else { | |
52 | - return null; | |
53 | - } | |
54 | - } | |
44 | + public String get_action(){ | |
45 | + if( sarfilename != null ){ | |
46 | + return "file://" + sarfilename; | |
47 | + }else{ | |
48 | + return null; | |
49 | + } | |
50 | + } | |
55 | 51 | |
56 | - private void close() { | |
57 | - try { | |
58 | - if (myfilereader != null) { | |
59 | - myfilereader.close(); | |
60 | - } | |
61 | - if (tmpfile != null) { | |
62 | - tmpfile.close(); | |
63 | - } | |
64 | - } catch (IOException ex) { | |
65 | - Logger.getLogger(FileRead.class.getName()).log(Level.SEVERE, null, ex); | |
66 | - } | |
67 | - } | |
52 | + private void close(){ | |
53 | + try{ | |
54 | + if(myfilereader != null){ | |
55 | + myfilereader.close(); | |
56 | + } | |
57 | + if(tmpfile != null){ | |
58 | + tmpfile.close(); | |
59 | + } | |
60 | + }catch(IOException ex){ | |
61 | + Logger.getLogger(FileRead.class.getName()).log(Level.SEVERE, null, ex); | |
62 | + } | |
63 | + } | |
68 | 64 | |
69 | 65 | @Override |
70 | - public void run() { | |
71 | - if (sarfilename == null) { | |
72 | - return; | |
73 | - } | |
66 | + public void run(){ | |
67 | + if(sarfilename == null){ | |
68 | + return; | |
69 | + } | |
74 | 70 | |
75 | - try { | |
76 | - tmpfile = new FileReader(sarfilename); | |
77 | - } catch (FileNotFoundException ex) { | |
78 | - Logger.getLogger(FileRead.class.getName()).log(Level.SEVERE, null, ex); | |
79 | - } | |
71 | + try{ | |
72 | + tmpfile = new FileReader(sarfilename); | |
73 | + }catch(FileNotFoundException ex){ | |
74 | + Logger.getLogger(FileRead.class.getName()).log(Level.SEVERE, null, ex); | |
75 | + } | |
80 | 76 | |
81 | - myfilereader = new BufferedReader(tmpfile); | |
77 | + myfilereader = new BufferedReader(tmpfile); | |
82 | 78 | |
83 | - mysar.parse(myfilereader); | |
79 | + mysar.parse(myfilereader); | |
84 | 80 | |
85 | - close(); | |
86 | - } | |
81 | + close(); | |
82 | + } | |
87 | 83 | } |
@@ -1,7 +1,3 @@ | ||
1 | -/* | |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | 1 | package net.atomique.ksar; |
6 | 2 | |
7 | 3 | import java.awt.Color; |
@@ -26,15 +22,27 @@ | ||
26 | 22 | * @author Max |
27 | 23 | */ |
28 | 24 | public class GlobalOptions { |
25 | + public static final String[] OSPARSERS = {"AIX", "HPUX", "Linux", "SunOS"}; | |
29 | 26 | |
27 | + private static Desktop ui = null; | |
28 | + private static Properties systemprops; | |
29 | + private static String userhome; | |
30 | + private static String username; | |
31 | + private static String fileseparator; | |
32 | + private static HashMap<String, ColumnConfig> columnlist; | |
33 | + private static HashMap<String, OSConfig> oslist; | |
34 | + private static HashMap<String, CnxHistory> history_list; | |
35 | + private static HashMap<String, HostInfo> hostinfo_list; | |
36 | + private static boolean dodebug = false; | |
37 | + private static String cl_filename = null; | |
38 | + private static HashMap<String, Class> parser_map; | |
39 | + | |
30 | 40 | private static final GlobalOptions instance = new GlobalOptions(); |
31 | - | |
32 | 41 | public static GlobalOptions getInstance(){ |
33 | 42 | return instance; |
34 | 43 | } |
35 | 44 | |
36 | - GlobalOptions() { | |
37 | - String [] OSParserNames = {"AIX", "HPUX", "Linux", "SunOS"}; | |
45 | + GlobalOptions(){ | |
38 | 46 | String filename; |
39 | 47 | InputStream is; |
40 | 48 | XMLConfig tmp; |
@@ -42,187 +50,187 @@ | ||
42 | 50 | username = (String) systemprops.get("user.name"); |
43 | 51 | userhome = (String) systemprops.get("user.home") + systemprops.get("file.separator"); |
44 | 52 | fileseparator = (String) systemprops.get("file.separator"); |
45 | - columnlist = new HashMap<String, ColumnConfig>(); | |
46 | - OSlist = new HashMap<String, OSConfig>(); | |
47 | - ParserMap = new HashMap<String, Class>(); | |
48 | - HistoryList = new HashMap<String, CnxHistory>(); | |
49 | - HostInfoList = new HashMap<String, HostInfo>(); | |
53 | + columnlist = new HashMap<>(); | |
54 | + oslist = new HashMap<>(); | |
55 | + parser_map = new HashMap<>(); | |
56 | + history_list = new HashMap<>(); | |
57 | + hostinfo_list = new HashMap<>(); | |
50 | 58 | is = this.getClass().getResourceAsStream("/Config.xml"); |
51 | 59 | tmp = new XMLConfig(is); |
52 | - for ( String OSName : OSParserNames ) { | |
53 | - try { | |
54 | - Class tmpclass = Class.forName("net.atomique.ksar.Parser."+OSName); | |
55 | - ParserMap.put(OSName, tmpclass); | |
56 | - } catch (ClassNotFoundException ex) { | |
60 | + for(String osname : OSPARSERS){ | |
61 | + try{ | |
62 | + Class tmpclass = Class.forName("net.atomique.ksar.Parser."+osname); | |
63 | + parser_map.put(osname, tmpclass); | |
64 | + }catch(ClassNotFoundException ex){ | |
57 | 65 | ex.printStackTrace(System.err); |
58 | 66 | } |
59 | 67 | } |
60 | - for (String parsername : ParserMap.keySet()) { | |
68 | + for(String parsername : parser_map.keySet()){ | |
61 | 69 | is = this.getClass().getResourceAsStream("/" + parsername + ".xml"); |
62 | - if (is != null) { | |
70 | + if(is != null){ | |
63 | 71 | tmp.load_config(is); |
64 | 72 | } |
65 | 73 | } |
66 | 74 | |
67 | 75 | filename = userhome + ".ksarcfg" + fileseparator + "Config.xml"; |
68 | - if (new File(filename).canRead()) { | |
76 | + if(new File(filename).canRead()){ | |
69 | 77 | tmp.load_config(filename); |
70 | 78 | } |
71 | 79 | filename = userhome + ".ksarcfg" + fileseparator + "History.xml"; |
72 | - if (new File(filename).canRead()) { | |
80 | + if(new File(filename).canRead()){ | |
73 | 81 | tmp.load_config(filename); |
74 | 82 | } |
75 | 83 | |
76 | 84 | } |
77 | 85 | |
78 | - public static boolean hasUI() { | |
79 | - return UI != null; | |
86 | + public static boolean hasUI(){ | |
87 | + return ui != null; | |
80 | 88 | } |
81 | 89 | |
82 | - public static Desktop getUI() { | |
83 | - return UI; | |
90 | + public static Desktop getUI(){ | |
91 | + return ui; | |
84 | 92 | } |
85 | 93 | |
86 | - public static void setUI(Desktop UI) { | |
87 | - GlobalOptions.UI = UI; | |
94 | + public static void setUI(Desktop UI){ | |
95 | + GlobalOptions.ui = UI; | |
88 | 96 | } |
89 | 97 | |
90 | - public static String getUserhome() { | |
98 | + public static String getUserhome(){ | |
91 | 99 | return userhome; |
92 | 100 | } |
93 | 101 | |
94 | - public static String getUsername() { | |
102 | + public static String getUsername(){ | |
95 | 103 | return username; |
96 | 104 | } |
97 | 105 | |
98 | - public static void setColumnConfig(String column, ColumnConfig config) { | |
106 | + public static void setColumnConfig(String column, ColumnConfig config){ | |
99 | 107 | columnlist.put(column, config); |
100 | 108 | } |
101 | 109 | |
102 | - public static HashMap<String, OSConfig> getOSlist() { | |
103 | - return OSlist; | |
110 | + public static HashMap<String, OSConfig> getOSlist(){ | |
111 | + return oslist; | |
104 | 112 | } |
105 | 113 | |
106 | - public static ColumnConfig getColumnConfig(String s) { | |
107 | - if ( columnlist.isEmpty()) { | |
114 | + public static ColumnConfig getColumnConfig(String s){ | |
115 | + if( columnlist.isEmpty()){ | |
108 | 116 | return null; |
109 | 117 | } |
110 | 118 | return columnlist.get(s); |
111 | 119 | } |
112 | - public static Color getDataColor(String s) { | |
120 | + public static Color getDataColor(String s){ | |
113 | 121 | ColumnConfig tmp = columnlist.get(s); |
114 | - if (tmp != null) { | |
122 | + if(tmp != null){ | |
115 | 123 | return tmp.getData_color(); |
116 | - } else { | |
124 | + }else{ | |
117 | 125 | System.err.println("WARN: color not found for tag " + s); |
118 | 126 | } |
119 | 127 | return null; |
120 | 128 | } |
121 | 129 | |
122 | - public static OSConfig getOSinfo(String s) { | |
123 | - return OSlist.get(s); | |
130 | + public static OSConfig getOSinfo(String s){ | |
131 | + return oslist.get(s); | |
124 | 132 | } |
125 | 133 | |
126 | - public static boolean isDodebug() { | |
134 | + public static boolean isDodebug(){ | |
127 | 135 | return dodebug; |
128 | 136 | } |
129 | 137 | |
130 | - public static void setDodebug(boolean do_debug) { | |
138 | + public static void setDodebug(boolean do_debug){ | |
131 | 139 | GlobalOptions.dodebug = do_debug; |
132 | 140 | } |
133 | 141 | |
134 | - public static String getCLfilename() { | |
135 | - return CLfilename; | |
142 | + public static String getCLfilename(){ | |
143 | + return cl_filename; | |
136 | 144 | } |
137 | 145 | |
138 | - public static void setCLfilename(String CL_filename) { | |
139 | - GlobalOptions.CLfilename = CL_filename; | |
146 | + public static void setCLfilename(String CL_filename){ | |
147 | + GlobalOptions.cl_filename = CL_filename; | |
140 | 148 | } |
141 | 149 | |
142 | - public static String getFileseparator() { | |
150 | + public static String getFileseparator(){ | |
143 | 151 | return fileseparator; |
144 | 152 | } |
145 | 153 | |
146 | - public static Class getParser(String s) { | |
154 | + public static Class getParser(String s){ | |
147 | 155 | String tmp = s.replaceAll("-", ""); |
148 | - if (ParserMap.isEmpty()) { | |
156 | + if(parser_map.isEmpty()){ | |
149 | 157 | return null; |
150 | 158 | } |
151 | - return ParserMap.get(tmp); | |
159 | + return parser_map.get(tmp); | |
152 | 160 | } |
153 | 161 | |
154 | - public static HashMap<String, HostInfo> getHostInfoList() { | |
155 | - return HostInfoList; | |
162 | + public static HashMap<String, HostInfo> getHostInfoList(){ | |
163 | + return hostinfo_list; | |
156 | 164 | } |
157 | 165 | |
158 | - public static HostInfo getHostInfo(String s) { | |
159 | - if (HostInfoList.isEmpty()) { | |
166 | + public static HostInfo getHostInfo(String s){ | |
167 | + if(hostinfo_list.isEmpty()){ | |
160 | 168 | return null; |
161 | 169 | } |
162 | - return HostInfoList.get(s); | |
170 | + return hostinfo_list.get(s); | |
163 | 171 | } |
164 | 172 | |
165 | - public static void addHostInfo(HostInfo s) { | |
166 | - HostInfoList.put(s.getHostname(), s); | |
173 | + public static void addHostInfo(HostInfo s){ | |
174 | + hostinfo_list.put(s.getHostname(), s); | |
167 | 175 | saveHistory(); |
168 | 176 | } |
169 | 177 | |
170 | - public static HashMap<String, CnxHistory> getHistoryList() { | |
171 | - return HistoryList; | |
178 | + public static HashMap<String, CnxHistory> getHistoryList(){ | |
179 | + return history_list; | |
172 | 180 | } |
173 | 181 | |
174 | - public static CnxHistory getHistory(String s) { | |
175 | - if (HistoryList.isEmpty()) { | |
182 | + public static CnxHistory getHistory(String s){ | |
183 | + if(history_list.isEmpty()){ | |
176 | 184 | return null; |
177 | 185 | } |
178 | - return HistoryList.get(s); | |
186 | + return history_list.get(s); | |
179 | 187 | } |
180 | 188 | |
181 | - public static void addHistory(CnxHistory s) { | |
182 | - CnxHistory tmp = HistoryList.get(s.getLink()); | |
183 | - if ( tmp != null) { | |
189 | + public static void addHistory(CnxHistory s){ | |
190 | + CnxHistory tmp = history_list.get(s.getLink()); | |
191 | + if( tmp != null){ | |
184 | 192 | Iterator<String> ite = s.getCommandList().iterator(); |
185 | - while (ite.hasNext()) { | |
193 | + while(ite.hasNext()){ | |
186 | 194 | tmp.addCommand(ite.next()); |
187 | 195 | } |
188 | - } else { | |
189 | - HistoryList.put(s.getLink(), s); | |
196 | + }else{ | |
197 | + history_list.put(s.getLink(), s); | |
190 | 198 | } |
191 | 199 | saveHistory(); |
192 | 200 | } |
193 | 201 | |
194 | - public static void saveHistory() { | |
202 | + public static void saveHistory(){ | |
195 | 203 | File tmpfile; |
196 | 204 | BufferedWriter tmpfile_out = null; |
197 | 205 | |
198 | - if (HistoryList.isEmpty() && HostInfoList.isEmpty()) { | |
206 | + if(history_list.isEmpty() && hostinfo_list.isEmpty()){ | |
199 | 207 | System.out.println("list is null"); |
200 | 208 | return; |
201 | 209 | } |
202 | 210 | |
203 | - try { | |
211 | + try{ | |
204 | 212 | tmpfile = new File(userhome + ".ksarcfg" + fileseparator + "History.xmltemp"); |
205 | 213 | |
206 | - if ( tmpfile.exists() ) { | |
214 | + if( tmpfile.exists() ){ | |
207 | 215 | tmpfile.delete(); |
208 | 216 | } |
209 | - if (tmpfile.createNewFile() && tmpfile.canWrite()) { | |
217 | + if(tmpfile.createNewFile() && tmpfile.canWrite()){ | |
210 | 218 | tmpfile_out = new BufferedWriter(new FileWriter(tmpfile)); |
211 | 219 | } |
212 | 220 | //xml header |
213 | 221 | tmpfile_out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<ConfiG>\n"); |
214 | 222 | tmpfile_out.write("\t<History>\n"); |
215 | - Iterator<String> ite = HistoryList.keySet().iterator(); | |
216 | - while (ite.hasNext()) { | |
217 | - CnxHistory tmp = HistoryList.get(ite.next()); | |
223 | + Iterator<String> ite = history_list.keySet().iterator(); | |
224 | + while(ite.hasNext()){ | |
225 | + CnxHistory tmp = history_list.get(ite.next()); | |
218 | 226 | tmpfile_out.write(tmp.save()); |
219 | 227 | } |
220 | 228 | //xml footer |
221 | 229 | tmpfile_out.write("\t</History>\n"); |
222 | 230 | tmpfile_out.write("\t<HostInfo>\n"); |
223 | - Iterator<String> ite2 = HostInfoList.keySet().iterator(); | |
224 | - while (ite2.hasNext()) { | |
225 | - HostInfo tmp = HostInfoList.get(ite2.next()); | |
231 | + Iterator<String> ite2 = hostinfo_list.keySet().iterator(); | |
232 | + while(ite2.hasNext()){ | |
233 | + HostInfo tmp = hostinfo_list.get(ite2.next()); | |
226 | 234 | tmpfile_out.write(tmp.save()); |
227 | 235 | } |
228 | 236 | //xml footer |
@@ -234,22 +242,9 @@ | ||
234 | 242 | oldfile.delete(); |
235 | 243 | tmpfile.renameTo(oldfile); |
236 | 244 | |
237 | - } catch (IOException ex) { | |
245 | + }catch(IOException ex){ | |
238 | 246 | Logger.getLogger(GlobalOptions.class.getName()).log(Level.SEVERE, null, ex); |
239 | 247 | } |
240 | 248 | |
241 | 249 | } |
242 | - private static Desktop UI = null; | |
243 | - private static Properties systemprops; | |
244 | - private static String userhome; | |
245 | - private static String username; | |
246 | - private static String fileseparator; | |
247 | - private static HashMap<String, ColumnConfig> columnlist; | |
248 | - private static HashMap<String, OSConfig> OSlist; | |
249 | - private static HashMap<String, CnxHistory> HistoryList; | |
250 | - private static HashMap<String, HostInfo> HostInfoList; | |
251 | - private static boolean dodebug = false; | |
252 | - private static String CLfilename = null; | |
253 | - private static HashMap<String, Class> ParserMap; | |
254 | - private static boolean firstrun = true; | |
255 | 250 | } |
@@ -1,7 +1,3 @@ | ||
1 | -/* | |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | 1 | package net.atomique.ksar.Parser; |
6 | 2 | |
7 | 3 | import java.text.ParseException; |
@@ -19,157 +15,157 @@ | ||
19 | 15 | * |
20 | 16 | * @author Max |
21 | 17 | */ |
22 | -public class SunOS extends OSParser { | |
18 | +public class SunOS extends OSParser{ | |
19 | + Second now = null; | |
20 | + boolean under_average = false; | |
23 | 21 | |
24 | - public void parse_header(String s) { | |
25 | - String[] columns = s.split("\\s+"); | |
26 | - setOstype(columns[0]); | |
27 | - setHostname(columns[1]); | |
28 | - setOSversion(columns[2]); | |
29 | - setKernel(columns[3]); | |
30 | - setCpuType(columns[4]); | |
31 | - setDate(columns[5]); | |
32 | - | |
33 | - if (GlobalOptions.hasUI()) { | |
34 | - HostInfo tmphostinfo = GlobalOptions.getHostInfo(this.gethostName()); | |
35 | - if (tmphostinfo == null) { | |
36 | - tmphostinfo = new HostInfo(this.gethostName()); | |
37 | - } | |
38 | - HostInfoView tmpview = new HostInfoView(GlobalOptions.getUI(), tmphostinfo); | |
39 | - tmpview.setVisible(true); | |
40 | - | |
41 | - } | |
42 | - | |
43 | - | |
44 | - } | |
22 | + public void parse_header(String s){ | |
23 | + String[] columns = s.split("\\s+"); | |
24 | + setOstype(columns[0]); | |
25 | + setHostname(columns[1]); | |
26 | + setOSversion(columns[2]); | |
27 | + setKernel(columns[3]); | |
28 | + setCpuType(columns[4]); | |
29 | + setDate(columns[5]); | |
30 | + | |
31 | + if(GlobalOptions.hasUI()){ | |
32 | + HostInfo tmphostinfo = GlobalOptions.getHostInfo(this.gethostName()); | |
33 | + if(tmphostinfo == null){ | |
34 | + tmphostinfo = new HostInfo(this.gethostName()); | |
35 | + } | |
36 | + HostInfoView tmpview = new HostInfoView(GlobalOptions.getUI(), tmphostinfo); | |
37 | + tmpview.setVisible(true); | |
38 | + | |
39 | + } | |
40 | + | |
41 | + | |
42 | + } | |
45 | 43 | |
46 | - @Override | |
47 | - public int parse(String line, String[] columns) { | |
48 | - int heure = 0; | |
49 | - int minute = 0; | |
50 | - int seconde = 0; | |
44 | + @Override | |
45 | + public int parse(String line, String[] columns){ | |
46 | + int heure = 0; | |
47 | + int minute = 0; | |
48 | + int seconde = 0; | |
51 | 49 | |
52 | 50 | |
53 | - if ("Average".equals(columns[0])) { | |
54 | - under_average = true; | |
55 | - return 0; | |
56 | - } | |
51 | + if("Average".equals(columns[0])){ | |
52 | + under_average = true; | |
53 | + return 0; | |
54 | + } | |
57 | 55 | |
58 | - if (line.indexOf("unix restarts") >= 0 || line.indexOf(" unix restarted") >= 0) { | |
59 | - return 0; | |
60 | - } | |
56 | + if(line.indexOf("unix restarts") >= 0 || line.indexOf(" unix restarted") >= 0){ | |
57 | + return 0; | |
58 | + } | |
61 | 59 | |
62 | - // match the System [C|c]onfiguration line on AIX | |
63 | - if (line.indexOf("System Configuration") >= 0 || line.indexOf("System configuration") >= 0) { | |
64 | - return 0; | |
65 | - } | |
60 | + // match the System [C|c]onfiguration line on AIX | |
61 | + if(line.indexOf("System Configuration") >= 0 || line.indexOf("System configuration") >= 0){ | |
62 | + return 0; | |
63 | + } | |
66 | 64 | |
67 | - if (line.indexOf("State change") >= 0) { | |
68 | - return 0; | |
69 | - } | |
65 | + if(line.indexOf("State change") >= 0){ | |
66 | + return 0; | |
67 | + } | |
70 | 68 | |
71 | 69 | |
72 | - try { | |
73 | - parsedate = new SimpleDateFormat(timeFormat).parse(columns[0]); | |
74 | - cal.setTime(parsedate); | |
75 | - heure = cal.get(cal.HOUR_OF_DAY); | |
76 | - minute = cal.get(cal.MINUTE); | |
77 | - seconde = cal.get(cal.SECOND); | |
78 | - now = new Second(seconde, minute, heure, day, month, year); | |
79 | - if (startofstat == null) { | |
80 | - startofstat = now; | |
81 | - startofgraph = now; | |
82 | - } | |
83 | - if (endofstat == null) { | |
84 | - endofstat = now; | |
85 | - endofgraph = now; | |
86 | - } | |
87 | - if (now.compareTo(endofstat) > 0) { | |
88 | - endofstat = now; | |
89 | - endofgraph = now; | |
90 | - } | |
91 | - firstdatacolumn = 1; | |
92 | - } catch (ParseException ex) { | |
93 | - if (!"DEVICE".equals(currentStat)) { | |
94 | - System.out.println("unable to parse time " + columns[0]); | |
95 | - return -1; | |
96 | - } | |
97 | - firstdatacolumn = 0; | |
98 | - } | |
70 | + try{ | |
71 | + parseTime = new SimpleDateFormat(timeFormat).parse(columns[0]); | |
72 | + cal.setTime(parseTime); | |
73 | + heure = cal.get(cal.HOUR_OF_DAY); | |
74 | + minute = cal.get(cal.MINUTE); | |
75 | + seconde = cal.get(cal.SECOND); | |
76 | + now = new Second(seconde, minute, heure, day, month, year); | |
77 | + if(startofstat == null){ | |
78 | + startofstat = now; | |
79 | + startofgraph = now; | |
80 | + } | |
81 | + if(endofstat == null){ | |
82 | + endofstat = now; | |
83 | + endofgraph = now; | |
84 | + } | |
85 | + if(now.compareTo(endofstat) > 0){ | |
86 | + endofstat = now; | |
87 | + endofgraph = now; | |
88 | + } | |
89 | + firstValueColumnIndex = 1; | |
90 | + }catch(ParseException ex){ | |
91 | + if(!"DEVICE".equals(currentStat)){ | |
92 | + System.out.println("unable to parse time " + columns[0]); | |
93 | + return -1; | |
94 | + } | |
95 | + firstValueColumnIndex = 0; | |
96 | + } | |
99 | 97 | |
100 | 98 | |
101 | - /** XML COLUMN PARSER **/ | |
102 | - String checkStat = myosconfig.getStat(columns, firstdatacolumn); | |
99 | + /** XML COLUMN PARSER **/ | |
100 | + String checkStat = osConfig.getStat(columns, firstValueColumnIndex); | |
103 | 101 | |
104 | - if (checkStat != null) { | |
105 | - Object obj = ListofGraph.get(checkStat); | |
106 | - if (obj == null) { | |
107 | - GraphConfig mygraphinfo = myosconfig.getGraphConfig(checkStat); | |
108 | - if (mygraphinfo != null) { | |
109 | - if ("unique".equals(mygraphinfo.getType())) { | |
110 | - obj = new Graph(mysar, mygraphinfo, mygraphinfo.getTitle(), line, firstdatacolumn, mysar.graphtree); | |
111 | - ListofGraph.put(checkStat, obj); | |
112 | - currentStat = checkStat; | |
113 | - return 0; | |
114 | - } | |
115 | - if ("multiple".equals(mygraphinfo.getType())) { | |
116 | - obj = new List(mysar, mygraphinfo, mygraphinfo.getTitle(), line, firstdatacolumn); | |
117 | - ListofGraph.put(checkStat, obj); | |
118 | - currentStat = checkStat; | |
119 | - return 0; | |
120 | - } | |
121 | - } else { | |
122 | - // no graph associate | |
123 | - currentStat = checkStat; | |
124 | - return 0; | |
125 | - } | |
126 | - } else { | |
127 | - currentStat = checkStat; | |
128 | - return 0; | |
129 | - } | |
130 | - } | |
102 | + if(checkStat != null){ | |
103 | + Object obj = ListofGraph.get(checkStat); | |
104 | + if(obj == null){ | |
105 | + GraphConfig mygraphinfo = osConfig.getGraphConfig(checkStat); | |
106 | + if(mygraphinfo != null){ | |
107 | + if("unique".equals(mygraphinfo.getType())){ | |
108 | + obj = new Graph(mysar, mygraphinfo, mygraphinfo.getTitle(), line, firstValueColumnIndex, mysar.getGraphTree()); | |
109 | + ListofGraph.put(checkStat, obj); | |
110 | + currentStat = checkStat; | |
111 | + return 0; | |
112 | + } | |
113 | + if("multiple".equals(mygraphinfo.getType())){ | |
114 | + obj = new List(mysar, mygraphinfo, mygraphinfo.getTitle(), line, firstValueColumnIndex); | |
115 | + ListofGraph.put(checkStat, obj); | |
116 | + currentStat = checkStat; | |
117 | + return 0; | |
118 | + } | |
119 | + }else{ | |
120 | + // no graph associate | |
121 | + currentStat = checkStat; | |
122 | + return 0; | |
123 | + } | |
124 | + }else{ | |
125 | + currentStat = checkStat; | |
126 | + return 0; | |
127 | + } | |
128 | + } | |
131 | 129 | |
132 | - //System.out.println("==" + currentStat + " " + line); | |
130 | + //System.out.println("==" + currentStat + " " + line); | |
133 | 131 | |
134 | 132 | |
135 | 133 | |
136 | - if (lastStat != null) { | |
137 | - if (!lastStat.equals(currentStat)) { | |
138 | - if (GlobalOptions.isDodebug()) { | |
139 | - System.out.println("Stat change from " + lastStat + " to " + currentStat); | |
140 | - } | |
141 | - lastStat = currentStat; | |
142 | - under_average = false; | |
143 | - } | |
144 | - } else { | |
145 | - lastStat = currentStat; | |
146 | - } | |
147 | - if ("IGNORE".equals(currentStat)) { | |
148 | - return 1; | |
149 | - } | |
150 | - if ("NONE".equals(currentStat)) { | |
151 | - return -1; | |
152 | - } | |
134 | + if(lastStat != null){ | |
135 | + if(!lastStat.equals(currentStat)){ | |
136 | + if(GlobalOptions.isDodebug()){ | |
137 | + System.out.println("Stat change from " + lastStat + " to " + currentStat); | |
138 | + } | |
139 | + lastStat = currentStat; | |
140 | + under_average = false; | |
141 | + } | |
142 | + }else{ | |
143 | + lastStat = currentStat; | |
144 | + } | |
145 | + if("IGNORE".equals(currentStat)){ | |
146 | + return 1; | |
147 | + } | |
148 | + if("NONE".equals(currentStat)){ | |
149 | + return -1; | |
150 | + } | |
153 | 151 | |
154 | - if (under_average) { | |
155 | - return 0; | |
156 | - } | |
157 | - currentStatObj = ListofGraph.get(currentStat); | |
158 | - if (currentStatObj == null) { | |
159 | - return -1; | |
160 | - } else { | |
161 | - DateSamples.add(now); | |
162 | - if (currentStatObj instanceof Graph) { | |
163 | - Graph ag = (Graph) currentStatObj; | |
164 | - return ag.parse_line(now, line); | |
165 | - } | |
166 | - if (currentStatObj instanceof List) { | |
167 | - List ag = (List) currentStatObj; | |
168 | - return ag.parse_line(now, line); | |
169 | - } | |
170 | - } | |
171 | - return -1; | |
172 | - } | |
173 | - Second now = null; | |
174 | - boolean under_average = false; | |
152 | + if(under_average){ | |
153 | + return 0; | |
154 | + } | |
155 | + currentStatObj = ListofGraph.get(currentStat); | |
156 | + if(currentStatObj == null){ | |
157 | + return -1; | |
158 | + }else{ | |
159 | + DateSamples.add(now); | |
160 | + if(currentStatObj instanceof Graph){ | |
161 | + Graph ag = (Graph) currentStatObj; | |
162 | + return ag.parse_line(now, line); | |
163 | + } | |
164 | + if(currentStatObj instanceof List){ | |
165 | + List ag = (List) currentStatObj; | |
166 | + return ag.parse_line(now, line); | |
167 | + } | |
168 | + } | |
169 | + return -1; | |
170 | + } | |
175 | 171 | } |
@@ -1,18 +1,14 @@ | ||
1 | -/* | |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | 1 | package net.atomique.ksar.Parser; |
6 | 2 | |
7 | 3 | import java.text.ParseException; |
8 | 4 | import java.text.SimpleDateFormat; |
9 | 5 | import java.util.Calendar; |
6 | +import javax.swing.JOptionPane; | |
10 | 7 | import net.atomique.ksar.Config; |
11 | 8 | import net.atomique.ksar.OSParser; |
12 | 9 | import net.atomique.ksar.GlobalOptions; |
13 | 10 | import net.atomique.ksar.Graph.Graph; |
14 | 11 | import net.atomique.ksar.Graph.List; |
15 | -import net.atomique.ksar.UI.LinuxDateFormat; | |
16 | 12 | import net.atomique.ksar.XML.GraphConfig; |
17 | 13 | import org.jfree.data.time.Second; |
18 | 14 |
@@ -19,14 +15,12 @@ | ||
19 | 15 | /** |
20 | 16 | * |
21 | 17 | * @author Max |
18 | + * updated by Pango | |
22 | 19 | */ |
23 | -public class Linux extends OSParser { | |
24 | - private String dateFormat; | |
20 | +public class Linux extends OSParser{ | |
25 | 21 | |
26 | 22 | @Override |
27 | - public void parse_header(String s) { | |
28 | - boolean retdate = false; | |
29 | - dateFormat = Config.getLinuxDateFormat(); | |
23 | + public void parse_header(String s){ | |
30 | 24 | String[] columns = s.split("\\s+"); |
31 | 25 | String tmpstr; |
32 | 26 | setOstype(columns[0]); |
@@ -33,56 +27,24 @@ | ||
33 | 27 | setKernel(columns[1]); |
34 | 28 | tmpstr = columns[2]; |
35 | 29 | setHostname(tmpstr.substring(1, tmpstr.length() - 1)); |
36 | - checkDateFormat(); | |
37 | - retdate=setDate(columns[3]); | |
38 | - } | |
39 | 30 | |
40 | - private void checkDateFormat() { | |
41 | - | |
42 | - if ("Always ask".equals(dateFormat)) { | |
43 | - askDateFormat("Provide date Format"); | |
31 | + dateFormat = Config.getLinuxDateFormat(); | |
32 | + if(!setDate(columns[3])){ | |
33 | + JOptionPane.showMessageDialog(mysar.getDataView(), String.format("Failed to parse date '%s' (format: '%s') from header.", columns[3], dateFormat), "Incorrect dateFormat", JOptionPane.WARNING_MESSAGE); | |
44 | 34 | } |
45 | - | |
46 | - if(null != dateFormat)switch(dateFormat){ | |
47 | - case "MM/DD/YYYY 23:59:59": | |
48 | - dateFormat = "MM/dd/yy"; | |
49 | - break; | |
50 | - case "MM/DD/YYYY 12:59:59 AM|PM": | |
51 | - dateFormat = "MM/dd/yy"; | |
52 | - timeFormat = "hh:mm:ss a"; | |
53 | - timeColumn=2; | |
54 | - break; | |
55 | - case "DD/MM/YYYY 23:59:59": | |
56 | - dateFormat = "dd/MM/yy"; | |
57 | - break; | |
58 | - case "YYYY-MM-DD 23:59:59": | |
59 | - dateFormat = "yy-MM-dd"; | |
60 | - break; | |
61 | - } | |
35 | + | |
36 | + timeFormat = Config.getLinuxTimeFormat(); | |
37 | + firstValueColumnIndex = timeFormat.split("\\s+").length; | |
62 | 38 | } |
63 | 39 | |
64 | - private void askDateFormat(String s) { | |
65 | - if ( GlobalOptions.hasUI() ) { | |
66 | - LinuxDateFormat tmp = new LinuxDateFormat(GlobalOptions.getUI(),true); | |
67 | - tmp.setTitle(s); | |
68 | - if ( tmp.isOk()) { | |
69 | - dateFormat=tmp.getDateFormat(); | |
70 | - if ( tmp.hasToRemenber() ) { | |
71 | - Config.setLinuxDateFormat(tmp.getDateFormat()); | |
72 | - Config.save(); | |
73 | - } | |
74 | - } | |
75 | - } | |
76 | - } | |
77 | - | |
78 | 40 | @Override |
79 | - public int parse(String line, String[] columns) { | |
41 | + public int parse(String line, String[] columns){ | |
80 | 42 | int heure; |
81 | 43 | int minute; |
82 | 44 | int seconde; |
83 | 45 | Second now; |
84 | 46 | |
85 | - if ("Average:".equals(columns[0])){ | |
47 | + if("Average:".equals(columns[0])){ | |
86 | 48 | currentStat = "NONE"; |
87 | 49 | return 0; |
88 | 50 | } |
@@ -100,68 +62,70 @@ | ||
100 | 62 | return 0; |
101 | 63 | } |
102 | 64 | |
103 | - try { | |
104 | - if ( timeColumn == 2 ) { | |
105 | - parsedate = new SimpleDateFormat(timeFormat).parse(columns[0]+" "+columns[1]); | |
106 | - } else { | |
107 | - parsedate = new SimpleDateFormat(timeFormat).parse(columns[0]); | |
65 | + try{ | |
66 | + String timestamp; | |
67 | + if(firstValueColumnIndex == 1){ | |
68 | + timestamp = columns[0]; | |
69 | + }else{ | |
70 | + timestamp = line.substring(0, line.indexOf(columns[firstValueColumnIndex-1]) + columns[firstValueColumnIndex-1].length()); | |
108 | 71 | } |
109 | - cal.setTime(parsedate); | |
72 | + parseTime = new SimpleDateFormat(timeFormat).parse(timestamp); | |
73 | + | |
74 | + cal.setTime(parseTime); | |
110 | 75 | heure = cal.get(Calendar.HOUR_OF_DAY); |
111 | 76 | minute = cal.get(Calendar.MINUTE); |
112 | 77 | seconde = cal.get(Calendar.SECOND); |
113 | 78 | now = new Second(seconde, minute, heure, day, month, year); |
114 | - if (startofstat == null) { | |
79 | + if(startofstat == null){ | |
115 | 80 | startofstat = now; |
116 | 81 | startofgraph = now; |
117 | 82 | } |
118 | - if (endofstat == null) { | |
83 | + if(endofstat == null){ | |
119 | 84 | endofstat = now; |
120 | 85 | endofgraph = now; |
121 | 86 | } |
122 | - if (now.compareTo(endofstat) > 0) { | |
87 | + if(now.compareTo(endofstat) > 0){ | |
123 | 88 | endofstat = now; |
124 | 89 | endofgraph = now; |
125 | 90 | } |
126 | - firstdatacolumn = timeColumn; | |
127 | - } catch (ParseException ex) { | |
91 | + }catch(ParseException ex){ | |
128 | 92 | System.out.println("unable to parse time " + columns[0]); |
129 | 93 | return -1; |
130 | 94 | } |
131 | 95 | |
132 | 96 | // 00:20:01 CPU i000/s i001/s i002/s i008/s i009/s i010/s i011/s i012/s i014/s |
133 | - if ("CPU".equals(columns[firstdatacolumn]) && line.matches(".*i([0-9]+)/s.*")) { | |
97 | + if("CPU".equals(columns[firstValueColumnIndex]) && line.matches(".*i([0-9]+)/s.*")){ | |
134 | 98 | currentStat = "IGNORE"; |
135 | 99 | return 1; |
136 | 100 | } |
137 | 101 | |
138 | 102 | /** XML COLUMN PARSER **/ |
139 | - String checkStat = myosconfig.getStat(columns, firstdatacolumn); | |
140 | - if (checkStat != null) { | |
103 | + String checkStat = osConfig.getStat(columns, firstValueColumnIndex); | |
104 | + if(checkStat != null){ | |
141 | 105 | Object obj = ListofGraph.get(checkStat); |
142 | - if (obj == null) { | |
143 | - GraphConfig mygraphinfo = myosconfig.getGraphConfig(checkStat); | |
144 | - if (mygraphinfo != null) { | |
145 | - if ("unique".equals(mygraphinfo.getType())) { | |
146 | - obj = new Graph(mysar, mygraphinfo, mygraphinfo.getTitle(), line, firstdatacolumn, mysar.graphtree); | |
106 | + if(obj == null){ | |
107 | + GraphConfig mygraphinfo = osConfig.getGraphConfig(checkStat); | |
108 | + if(mygraphinfo != null){ | |
109 | + if("unique".equals(mygraphinfo.getType())){ | |
110 | + obj = new Graph(mysar, mygraphinfo, mygraphinfo.getTitle(), line, firstValueColumnIndex, mysar.getGraphTree()); | |
147 | 111 | |
148 | 112 | ListofGraph.put(checkStat, obj); |
149 | 113 | currentStat = checkStat; |
150 | 114 | return 0; |
151 | 115 | } |
152 | - if ("multiple".equals(mygraphinfo.getType())) { | |
153 | - obj = new List(mysar, mygraphinfo, mygraphinfo.getTitle(), line, firstdatacolumn); | |
116 | + if("multiple".equals(mygraphinfo.getType())){ | |
117 | + obj = new List(mysar, mygraphinfo, mygraphinfo.getTitle(), line, firstValueColumnIndex); | |
154 | 118 | |
155 | 119 | ListofGraph.put(checkStat, obj); |
156 | 120 | currentStat = checkStat; |
157 | 121 | return 0; |
158 | 122 | } |
159 | - } else { | |
123 | + }else{ | |
160 | 124 | // no graph associate |
161 | 125 | currentStat = checkStat; |
162 | 126 | return 0; |
163 | 127 | } |
164 | - } else { | |
128 | + }else{ | |
165 | 129 | currentStat = checkStat; |
166 | 130 | return 0; |
167 | 131 | } |
@@ -168,34 +132,34 @@ | ||
168 | 132 | } |
169 | 133 | //System.out.println( currentStat +" " + line); |
170 | 134 | |
171 | - if (lastStat != null) { | |
172 | - if (!lastStat.equals(currentStat) ) { | |
173 | - if ( GlobalOptions.isDodebug()) { | |
135 | + if(lastStat != null){ | |
136 | + if(!lastStat.equals(currentStat) ){ | |
137 | + if( GlobalOptions.isDodebug()) { | |
174 | 138 | System.out.println("Stat change from " + lastStat + " to " + currentStat); |
175 | 139 | } |
176 | 140 | lastStat = currentStat; |
177 | 141 | } |
178 | - } else { | |
142 | + }else{ | |
179 | 143 | lastStat = currentStat; |
180 | 144 | } |
181 | 145 | |
182 | - if ("IGNORE".equals(currentStat)) { | |
146 | + if("IGNORE".equals(currentStat)){ | |
183 | 147 | return 1; |
184 | 148 | } |
185 | - if ("NONE".equals(currentStat)) { | |
149 | + if("NONE".equals(currentStat)){ | |
186 | 150 | return -1; |
187 | 151 | } |
188 | 152 | |
189 | 153 | currentStatObj = ListofGraph.get(currentStat); |
190 | - if (currentStatObj == null) { | |
154 | + if(currentStatObj == null){ | |
191 | 155 | return -1; |
192 | - } else { | |
156 | + }else{ | |
193 | 157 | DateSamples.add(now); |
194 | - if (currentStatObj instanceof Graph) { | |
158 | + if(currentStatObj instanceof Graph){ | |
195 | 159 | Graph ag = (Graph) currentStatObj; |
196 | 160 | return ag.parse_line(now, line); |
197 | 161 | } |
198 | - if (currentStatObj instanceof List) { | |
162 | + if(currentStatObj instanceof List){ | |
199 | 163 | List ag = (List) currentStatObj; |
200 | 164 | return ag.parse_line(now, line); |
201 | 165 | } |
@@ -1,7 +1,3 @@ | ||
1 | -/* | |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | 1 | package net.atomique.ksar.Parser; |
6 | 2 | |
7 | 3 | import java.text.ParseException; |
@@ -18,154 +14,152 @@ | ||
18 | 14 | * @author Max |
19 | 15 | */ |
20 | 16 | public class AIX extends OSParser { |
17 | + Second now = null; | |
18 | + boolean under_average = false; | |
21 | 19 | |
20 | + public void parse_header(String s){ | |
21 | + String [] columns = s.split("\\s+"); | |
22 | + setOstype(columns[0]); | |
22 | 23 | |
23 | - public void parse_header(String s) { | |
24 | - String [] columns = s.split("\\s+"); | |
25 | - setOstype(columns[0]); | |
24 | + setHostname(columns[1]); | |
25 | + setOSversion(columns[2]+ "." + columns[3]); | |
26 | + setMacAddress(columns[4]); | |
27 | + setDate(columns[5]); | |
28 | + | |
29 | + } | |
26 | 30 | |
27 | - setHostname(columns[1]); | |
28 | - setOSversion(columns[2]+ "." + columns[3]); | |
29 | - setMacAddress(columns[4]); | |
30 | - setDate(columns[5]); | |
31 | - | |
32 | - } | |
31 | + @Override | |
32 | + public int parse(String line, String[] columns){ | |
33 | + int heure = 0; | |
34 | + int minute = 0; | |
35 | + int seconde = 0; | |
33 | 36 | |
34 | - @Override | |
35 | - public int parse(String line, String[] columns) { | |
36 | - int heure = 0; | |
37 | - int minute = 0; | |
38 | - int seconde = 0; | |
39 | 37 | |
38 | + if("Average".equals(columns[0])){ | |
39 | + under_average = true; | |
40 | + return 0; | |
41 | + } | |
40 | 42 | |
41 | - if ("Average".equals(columns[0])) { | |
42 | - under_average = true; | |
43 | - return 0; | |
44 | - } | |
43 | + if(line.indexOf("unix restarts") >= 0 || line.indexOf(" unix restarted") >= 0){ | |
44 | + return 0; | |
45 | + } | |
45 | 46 | |
46 | - if (line.indexOf("unix restarts") >= 0 || line.indexOf(" unix restarted") >= 0) { | |
47 | - return 0; | |
48 | - } | |
47 | + // match the System [C|c]onfiguration line on AIX | |
48 | + if(line.indexOf("System Configuration") >= 0 || line.indexOf("System configuration") >= 0){ | |
49 | + return 0; | |
50 | + } | |
49 | 51 | |
50 | - // match the System [C|c]onfiguration line on AIX | |
51 | - if (line.indexOf("System Configuration") >= 0 || line.indexOf("System configuration") >= 0) { | |
52 | - return 0; | |
53 | - } | |
52 | + if(line.indexOf("State change") >= 0){ | |
53 | + return 0; | |
54 | + } | |
54 | 55 | |
55 | - if (line.indexOf("State change") >= 0) { | |
56 | - return 0; | |
57 | - } | |
58 | 56 | |
57 | + try{ | |
58 | + parseTime = new SimpleDateFormat(timeFormat).parse(columns[0]); | |
59 | + cal.setTime(parseTime); | |
60 | + heure = cal.get(cal.HOUR_OF_DAY); | |
61 | + minute = cal.get(cal.MINUTE); | |
62 | + seconde = cal.get(cal.SECOND); | |
63 | + now = new Second(seconde, minute, heure, day, month, year); | |
64 | + if(startofstat == null){ | |
65 | + startofstat = now; | |
66 | + startofgraph =now; | |
67 | + } | |
68 | + if( endofstat == null){ | |
69 | + endofstat = now; | |
70 | + endofgraph = now; | |
71 | + } | |
72 | + if(now.compareTo(endofstat) > 0){ | |
73 | + endofstat = now; | |
74 | + endofgraph = now; | |
75 | + } | |
76 | + firstValueColumnIndex = 1; | |
77 | + }catch(ParseException ex){ | |
78 | + if(! "DEVICE".equals(currentStat) || "CPUS".equals(currentStat)){ | |
79 | + System.out.println("unable to parse time " + columns[0]); | |
80 | + return -1; | |
81 | + } | |
82 | + firstValueColumnIndex = 0; | |
83 | + } | |
59 | 84 | |
60 | - try { | |
61 | - parsedate = new SimpleDateFormat(timeFormat).parse(columns[0]); | |
62 | - cal.setTime(parsedate); | |
63 | - heure = cal.get(cal.HOUR_OF_DAY); | |
64 | - minute = cal.get(cal.MINUTE); | |
65 | - seconde = cal.get(cal.SECOND); | |
66 | - now = new Second(seconde, minute, heure, day, month, year); | |
67 | - if (startofstat == null) { | |
68 | - startofstat = now; | |
69 | - startofgraph =now; | |
70 | - } | |
71 | - if ( endofstat == null) { | |
72 | - endofstat = now; | |
73 | - endofgraph = now; | |
74 | - } | |
75 | - if (now.compareTo(endofstat) > 0) { | |
76 | - endofstat = now; | |
77 | - endofgraph = now; | |
78 | - } | |
79 | - firstdatacolumn = 1; | |
80 | - } catch (ParseException ex) { | |
81 | - if (! "DEVICE".equals(currentStat) || "CPUS".equals(currentStat)) { | |
82 | - System.out.println("unable to parse time " + columns[0]); | |
83 | - return -1; | |
84 | - } | |
85 | - firstdatacolumn = 0; | |
86 | - } | |
87 | 85 | |
86 | + /** XML COLUMN PARSER **/ | |
87 | + String checkStat = osConfig.getStat(columns, firstValueColumnIndex); | |
88 | 88 | |
89 | - /** XML COLUMN PARSER **/ | |
90 | - String checkStat = myosconfig.getStat(columns, firstdatacolumn); | |
89 | + if(checkStat != null){ | |
90 | + Object obj = ListofGraph.get(checkStat); | |
91 | + if(obj == null){ | |
92 | + GraphConfig mygraphinfo = osConfig.getGraphConfig(checkStat); | |
93 | + if(mygraphinfo != null){ | |
94 | + if("unique".equals(mygraphinfo.getType())){ | |
95 | + obj = new Graph(mysar, mygraphinfo, mygraphinfo.getTitle(), line, firstValueColumnIndex, mysar.getGraphTree()); | |
96 | + ListofGraph.put(checkStat, obj); | |
97 | + currentStat = checkStat; | |
98 | + return 0; | |
99 | + } | |
100 | + if("multiple".equals(mygraphinfo.getType())){ | |
101 | + obj = new List(mysar, mygraphinfo, mygraphinfo.getTitle(), line, firstValueColumnIndex); | |
102 | + ListofGraph.put(checkStat, obj); | |
103 | + currentStat = checkStat; | |
104 | + return 0; | |
105 | + } | |
106 | + }else{ | |
107 | + // no graph associate | |
108 | + currentStat = checkStat; | |
109 | + return 0; | |
110 | + } | |
111 | + }else{ | |
112 | + currentStat = checkStat; | |
113 | + return 0; | |
114 | + } | |
115 | + } | |
91 | 116 | |
92 | - if (checkStat != null) { | |
93 | - Object obj = ListofGraph.get(checkStat); | |
94 | - if (obj == null) { | |
95 | - GraphConfig mygraphinfo = myosconfig.getGraphConfig(checkStat); | |
96 | - if (mygraphinfo != null) { | |
97 | - if ("unique".equals(mygraphinfo.getType())) { | |
98 | - obj = new Graph(mysar, mygraphinfo, mygraphinfo.getTitle(), line, firstdatacolumn, mysar.graphtree); | |
99 | - ListofGraph.put(checkStat, obj); | |
100 | - currentStat = checkStat; | |
101 | - return 0; | |
102 | - } | |
103 | - if ("multiple".equals(mygraphinfo.getType())) { | |
104 | - obj = new List(mysar, mygraphinfo, mygraphinfo.getTitle(), line, firstdatacolumn); | |
105 | - ListofGraph.put(checkStat, obj); | |
106 | - currentStat = checkStat; | |
107 | - return 0; | |
108 | - } | |
109 | - } else { | |
110 | - // no graph associate | |
111 | - currentStat = checkStat; | |
112 | - return 0; | |
113 | - } | |
114 | - } else { | |
115 | - currentStat = checkStat; | |
116 | - return 0; | |
117 | - } | |
118 | - } | |
117 | + //System.out.println(currentStat + " " + line); | |
119 | 118 | |
120 | - //System.out.println(currentStat + " " + line); | |
121 | 119 | |
122 | 120 | |
121 | + if(lastStat != null){ | |
122 | + if(!lastStat.equals(currentStat) ){ | |
123 | + if( GlobalOptions.isDodebug()) { | |
124 | + System.out.println("Stat change from " + lastStat + " to " + currentStat); | |
125 | + } | |
126 | + lastStat = currentStat; | |
127 | + under_average = false; | |
128 | + } | |
129 | + }else{ | |
130 | + lastStat = currentStat; | |
131 | + } | |
132 | + | |
133 | + if("IGNORE".equals(currentStat)){ | |
134 | + return 1; | |
135 | + } | |
136 | + if("NONE".equals(currentStat)){ | |
137 | + return -1; | |
138 | + } | |
123 | 139 | |
124 | - if (lastStat != null) { | |
125 | - if (!lastStat.equals(currentStat) ) { | |
126 | - if ( GlobalOptions.isDodebug()) { | |
127 | - System.out.println("Stat change from " + lastStat + " to " + currentStat); | |
128 | - } | |
129 | - lastStat = currentStat; | |
130 | - under_average = false; | |
131 | - } | |
132 | - } else { | |
133 | - lastStat = currentStat; | |
134 | - } | |
135 | - | |
136 | - if ("IGNORE".equals(currentStat)) { | |
137 | - return 1; | |
138 | - } | |
139 | - if ("NONE".equals(currentStat)) { | |
140 | - return -1; | |
141 | - } | |
140 | + if(under_average){ | |
141 | + return 0; | |
142 | + } | |
143 | + currentStatObj = ListofGraph.get(currentStat); | |
144 | + if(currentStatObj == null){ | |
145 | + return -1; | |
146 | + }else{ | |
147 | + DateSamples.add(now); | |
148 | + if(currentStatObj instanceof Graph){ | |
149 | + Graph ag = (Graph) currentStatObj; | |
150 | + return ag.parse_line(now, line); | |
151 | + } | |
152 | + if(currentStatObj instanceof List){ | |
153 | + List ag = (List) currentStatObj; | |
154 | + return ag.parse_line(now, line); | |
155 | + } | |
156 | + } | |
157 | + return -1; | |
158 | + } | |
142 | 159 | |
143 | - if (under_average) { | |
144 | - return 0; | |
145 | - } | |
146 | - currentStatObj = ListofGraph.get(currentStat); | |
147 | - if (currentStatObj == null) { | |
148 | - return -1; | |
149 | - } else { | |
150 | - DateSamples.add(now); | |
151 | - if (currentStatObj instanceof Graph) { | |
152 | - Graph ag = (Graph) currentStatObj; | |
153 | - return ag.parse_line(now, line); | |
154 | - } | |
155 | - if (currentStatObj instanceof List) { | |
156 | - List ag = (List) currentStatObj; | |
157 | - return ag.parse_line(now, line); | |
158 | - } | |
159 | - } | |
160 | - return -1; | |
161 | - } | |
162 | - | |
163 | - public void updateUITitle() { | |
164 | - if ( mysar.getDataView() != null) { | |
165 | - mysar.getDataView().setTitle(Hostname + " from "+ startofgraph + " to " + endofgraph); | |
166 | - } | |
167 | - } | |
168 | - | |
169 | - Second now = null; | |
170 | - boolean under_average = false; | |
160 | + public void updateUITitle(){ | |
161 | + if( mysar.getDataView() != null){ | |
162 | + mysar.getDataView().setTitle(hostname + " from "+ startofgraph + " to " + endofgraph); | |
163 | + } | |
164 | + } | |
171 | 165 | } |
@@ -1,15 +1,7 @@ | ||
1 | -/* | |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | 1 | package net.atomique.ksar.Parser; |
6 | 2 | |
7 | 3 | import java.text.ParseException; |
8 | 4 | import java.text.SimpleDateFormat; |
9 | -import java.util.Calendar; | |
10 | -import java.util.Date; | |
11 | -import java.util.logging.Level; | |
12 | -import java.util.logging.Logger; | |
13 | 5 | import net.atomique.ksar.OSParser; |
14 | 6 | import net.atomique.ksar.GlobalOptions; |
15 | 7 | import net.atomique.ksar.Graph.Graph; |
@@ -22,149 +14,140 @@ | ||
22 | 14 | * @author Max |
23 | 15 | */ |
24 | 16 | public class HPUX extends OSParser { |
17 | + Second now = null; | |
18 | + boolean under_average = false; | |
25 | 19 | |
26 | - public void parse_header(String s) { | |
27 | - String[] columns = s.split("\\s+"); | |
28 | - setOstype(columns[0]); | |
29 | - setHostname(columns[1]); | |
30 | - setOSversion(columns[2]); | |
31 | - setKernel(columns[3]); | |
32 | - setCpuType(columns[4]); | |
33 | - setDate(columns[5]); | |
20 | + @Override | |
21 | + public void parse_header(String s){ | |
22 | + String[] columns = s.split("\\s+"); | |
23 | + setOstype(columns[0]); | |
24 | + setHostname(columns[1]); | |
25 | + setOSversion(columns[2]); | |
26 | + setKernel(columns[3]); | |
27 | + setCpuType(columns[4]); | |
28 | + setDate(columns[5]); | |
29 | + } | |
30 | + | |
31 | + @Override | |
32 | + public int parse(String line, String[] columns){ | |
33 | + int heure = 0; | |
34 | + int minute = 0; | |
35 | + int seconde = 0; | |
34 | 36 | |
35 | - } | |
37 | + if("Average".equals(columns[0])){ | |
38 | + under_average = true; | |
39 | + return 0; | |
40 | + } | |
36 | 41 | |
37 | - | |
38 | - @Override | |
39 | - public int parse(String line, String[] columns) { | |
40 | - int heure = 0; | |
41 | - int minute = 0; | |
42 | - int seconde = 0; | |
42 | + if(line.indexOf("unix restarts") >= 0 || line.indexOf(" unix restarted") >= 0){ | |
43 | + return 0; | |
44 | + } | |
43 | 45 | |
46 | + // match the System [C|c]onfiguration line on AIX | |
47 | + if(line.indexOf("System Configuration") >= 0 || line.indexOf("System configuration") >= 0){ | |
48 | + return 0; | |
49 | + } | |
44 | 50 | |
45 | - if ("Average".equals(columns[0])) { | |
46 | - under_average = true; | |
47 | - return 0; | |
48 | - } | |
51 | + if(line.indexOf("State change") >= 0){ | |
52 | + return 0; | |
53 | + } | |
49 | 54 | |
50 | - if (line.indexOf("unix restarts") >= 0 || line.indexOf(" unix restarted") >= 0) { | |
51 | - return 0; | |
52 | - } | |
55 | + try{ | |
56 | + parseTime = new SimpleDateFormat("HH:mm:SS").parse(columns[0]); | |
57 | + cal.setTime(parseTime); | |
58 | + heure = cal.get(cal.HOUR_OF_DAY); | |
59 | + minute = cal.get(cal.MINUTE); | |
60 | + seconde = cal.get(cal.SECOND); | |
61 | + now = new Second(seconde, minute, heure, day, month, year); | |
62 | + if(startofstat == null){ | |
63 | + startofstat = now; | |
64 | + startofgraph =now; | |
65 | + } | |
66 | + if( endofstat == null){ | |
67 | + endofstat = now; | |
68 | + endofgraph = now; | |
69 | + } | |
70 | + if(now.compareTo(endofstat) > 0){ | |
71 | + endofstat = now; | |
72 | + endofgraph = now; | |
73 | + } | |
74 | + firstValueColumnIndex = 1; | |
75 | + }catch(ParseException ex){ | |
76 | + if( ! "DEVICE".equals(currentStat) && ! "CPU".equals(currentStat)){ | |
77 | + System.out.println("unable to parse time " + columns[0]); | |
78 | + return -1; | |
79 | + } | |
80 | + firstValueColumnIndex = 0; | |
81 | + } | |
53 | 82 | |
54 | - // match the System [C|c]onfiguration line on AIX | |
55 | - if (line.indexOf("System Configuration") >= 0 || line.indexOf("System configuration") >= 0) { | |
56 | - return 0; | |
57 | - } | |
58 | 83 | |
59 | - if (line.indexOf("State change") >= 0) { | |
60 | - return 0; | |
61 | - } | |
84 | + /** XML COLUMN PARSER **/ | |
85 | + String checkStat = osConfig.getStat(columns, firstValueColumnIndex); | |
62 | 86 | |
87 | + if(checkStat != null){ | |
88 | + Object obj = ListofGraph.get(checkStat); | |
89 | + if(obj == null){ | |
90 | + GraphConfig mygraphinfo = osConfig.getGraphConfig(checkStat); | |
91 | + if(mygraphinfo != null){ | |
92 | + if("unique".equals(mygraphinfo.getType())){ | |
93 | + obj = new Graph(mysar, mygraphinfo, mygraphinfo.getTitle(), line, firstValueColumnIndex, mysar.getGraphTree()); | |
94 | + ListofGraph.put(checkStat, obj); | |
95 | + currentStat = checkStat; | |
96 | + return 0; | |
97 | + } | |
98 | + if("multiple".equals(mygraphinfo.getType())){ | |
99 | + obj = new List(mysar, mygraphinfo, mygraphinfo.getTitle(), line, firstValueColumnIndex); | |
100 | + ListofGraph.put(checkStat, obj); | |
101 | + currentStat = checkStat; | |
102 | + return 0; | |
103 | + } | |
104 | + }else{ | |
105 | + // no graph associate | |
106 | + currentStat = checkStat; | |
107 | + return 0; | |
108 | + } | |
109 | + }else{ | |
110 | + currentStat = checkStat; | |
111 | + return 0; | |
112 | + } | |
113 | + } | |
114 | + //System.out.println(currentStat + " " + line); | |
63 | 115 | |
64 | - try { | |
65 | - parsedate = new SimpleDateFormat("HH:mm:SS").parse(columns[0]); | |
66 | - cal.setTime(parsedate); | |
67 | - heure = cal.get(cal.HOUR_OF_DAY); | |
68 | - minute = cal.get(cal.MINUTE); | |
69 | - seconde = cal.get(cal.SECOND); | |
70 | - now = new Second(seconde, minute, heure, day, month, year); | |
71 | - if (startofstat == null) { | |
72 | - startofstat = now; | |
73 | - startofgraph =now; | |
74 | - } | |
75 | - if ( endofstat == null) { | |
76 | - endofstat = now; | |
77 | - endofgraph = now; | |
78 | - } | |
79 | - if (now.compareTo(endofstat) > 0) { | |
80 | - endofstat = now; | |
81 | - endofgraph = now; | |
82 | - } | |
83 | - firstdatacolumn = 1; | |
84 | - } catch (ParseException ex) { | |
85 | - if ( ! "DEVICE".equals(currentStat) && ! "CPU".equals(currentStat)) { | |
86 | - System.out.println("unable to parse time " + columns[0]); | |
87 | - return -1; | |
88 | - } | |
89 | - firstdatacolumn = 0; | |
90 | - } | |
116 | + if(lastStat != null){ | |
117 | + if(!lastStat.equals(currentStat) ){ | |
118 | + if( GlobalOptions.isDodebug()) { | |
119 | + System.out.println("Stat change from " + lastStat + " to " + currentStat); | |
120 | + } | |
121 | + lastStat = currentStat; | |
122 | + under_average = false; | |
123 | + } | |
124 | + }else{ | |
125 | + lastStat = currentStat; | |
126 | + } | |
127 | + | |
128 | + if("IGNORE".equals(currentStat)){ | |
129 | + return 1; | |
130 | + } | |
131 | + if("NONE".equals(currentStat)){ | |
132 | + return -1; | |
133 | + } | |
91 | 134 | |
92 | - | |
93 | - /** XML COLUMN PARSER **/ | |
94 | - String checkStat = myosconfig.getStat(columns, firstdatacolumn); | |
95 | - | |
96 | - if (checkStat != null) { | |
97 | - Object obj = ListofGraph.get(checkStat); | |
98 | - if (obj == null) { | |
99 | - GraphConfig mygraphinfo = myosconfig.getGraphConfig(checkStat); | |
100 | - if (mygraphinfo != null) { | |
101 | - if ("unique".equals(mygraphinfo.getType())) { | |
102 | - obj = new Graph(mysar, mygraphinfo, mygraphinfo.getTitle(), line, firstdatacolumn, mysar.graphtree); | |
103 | - ListofGraph.put(checkStat, obj); | |
104 | - currentStat = checkStat; | |
105 | - return 0; | |
106 | - } | |
107 | - if ("multiple".equals(mygraphinfo.getType())) { | |
108 | - obj = new List(mysar, mygraphinfo, mygraphinfo.getTitle(), line, firstdatacolumn); | |
109 | - ListofGraph.put(checkStat, obj); | |
110 | - currentStat = checkStat; | |
111 | - return 0; | |
112 | - } | |
113 | - } else { | |
114 | - // no graph associate | |
115 | - currentStat = checkStat; | |
116 | - return 0; | |
117 | - } | |
118 | - } else { | |
119 | - currentStat = checkStat; | |
120 | - return 0; | |
121 | - } | |
122 | - } | |
123 | - | |
124 | - //System.out.println(currentStat + " " + line); | |
125 | - | |
126 | - | |
127 | - | |
128 | - if (lastStat != null) { | |
129 | - if (!lastStat.equals(currentStat) ) { | |
130 | - if ( GlobalOptions.isDodebug()) { | |
131 | - System.out.println("Stat change from " + lastStat + " to " + currentStat); | |
132 | - } | |
133 | - lastStat = currentStat; | |
134 | - under_average = false; | |
135 | - } | |
136 | - } else { | |
137 | - lastStat = currentStat; | |
138 | - } | |
139 | - | |
140 | - if ("IGNORE".equals(currentStat)) { | |
141 | - return 1; | |
142 | - } | |
143 | - if ("NONE".equals(currentStat)) { | |
144 | - return -1; | |
145 | - } | |
146 | - | |
147 | - if (under_average) { | |
148 | - return 0; | |
149 | - } | |
150 | - currentStatObj = ListofGraph.get(currentStat); | |
151 | - if (currentStatObj == null) { | |
152 | - return -1; | |
153 | - } else { | |
154 | - if (currentStatObj instanceof Graph) { | |
155 | - Graph ag = (Graph) currentStatObj; | |
156 | - return ag.parse_line(now, line); | |
157 | - } | |
158 | - if (currentStatObj instanceof List) { | |
159 | - List ag = (List) currentStatObj; | |
160 | - return ag.parse_line(now, line); | |
161 | - } | |
162 | - } | |
163 | - return -1; | |
164 | - } | |
165 | - Second now = null; | |
166 | - boolean under_average = false; | |
167 | - Calendar cal = Calendar.getInstance(); | |
168 | - Date parsedate = null; | |
169 | - | |
135 | + if(under_average){ | |
136 | + return 0; | |
137 | + } | |
138 | + currentStatObj = ListofGraph.get(currentStat); | |
139 | + if(currentStatObj == null){ | |
140 | + return -1; | |
141 | + }else{ | |
142 | + if(currentStatObj instanceof Graph){ | |
143 | + Graph ag = (Graph) currentStatObj; | |
144 | + return ag.parse_line(now, line); | |
145 | + } | |
146 | + if(currentStatObj instanceof List){ | |
147 | + List ag = (List) currentStatObj; | |
148 | + return ag.parse_line(now, line); | |
149 | + } | |
150 | + } | |
151 | + return -1; | |
152 | + } | |
170 | 153 | } |
@@ -1,7 +1,3 @@ | ||
1 | -/* | |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | 1 | package net.atomique.ksar.XML; |
6 | 2 | |
7 | 3 | import java.awt.Color; |
@@ -12,62 +8,62 @@ | ||
12 | 8 | */ |
13 | 9 | public class ColumnConfig { |
14 | 10 | |
15 | - public ColumnConfig(String s) { | |
11 | + public ColumnConfig(String s){ | |
16 | 12 | data_title=s; |
17 | 13 | } |
18 | - public String getData_colorstr() { | |
14 | + public String getData_colorstr(){ | |
19 | 15 | return data_colorstr; |
20 | 16 | } |
21 | 17 | |
22 | - public void setData_color(String data_color) { | |
18 | + public void setData_color(String data_color){ | |
23 | 19 | String[] color_indices = data_color.split(","); |
24 | 20 | this.data_colorstr = data_color; |
25 | - if (color_indices.length == 3) { | |
26 | - try { | |
21 | + if(color_indices.length == 3){ | |
22 | + try{ | |
27 | 23 | Integer red = new Integer(color_indices[0]); |
28 | 24 | Integer green = new Integer(color_indices[1]); |
29 | 25 | Integer blue = new Integer(color_indices[2]); |
30 | 26 | this.data_color = new Color(red, green, blue); |
31 | - } catch (NumberFormatException ee) { | |
27 | + }catch(NumberFormatException ee){ | |
32 | 28 | } |
33 | 29 | } |
34 | 30 | } |
35 | 31 | |
36 | - public Color getData_color() { | |
32 | + public Color getData_color(){ | |
37 | 33 | return data_color; |
38 | 34 | } |
39 | 35 | |
40 | - public String getData_title() { | |
36 | + public String getData_title(){ | |
41 | 37 | return data_title; |
42 | 38 | } |
43 | 39 | |
44 | - public void setData_title(String data_title) { | |
40 | + public void setData_title(String data_title){ | |
45 | 41 | this.data_title = data_title; |
46 | 42 | } |
47 | 43 | |
48 | 44 | public void setType(String s){ |
49 | - if ( "gauge".equals(s)) { | |
45 | + if( "gauge".equals(s)){ | |
50 | 46 | type=1; |
51 | 47 | } |
52 | - if ( "counter".equals(s)) { | |
48 | + if( "counter".equals(s)){ | |
53 | 49 | type=2; |
54 | 50 | } |
55 | 51 | } |
56 | 52 | |
57 | - public int getType() { | |
53 | + public int getType(){ | |
58 | 54 | return type; |
59 | 55 | } |
60 | 56 | |
61 | - public boolean is_valid() { | |
62 | - if (data_title == null) { | |
57 | + public boolean is_valid(){ | |
58 | + if(data_title == null){ | |
63 | 59 | error_message = "Column header name not found"; |
64 | 60 | return false; |
65 | 61 | } |
66 | - if (data_colorstr == null) { | |
62 | + if(data_colorstr == null){ | |
67 | 63 | error_message = "color info missing for " + data_title; |
68 | 64 | return false; |
69 | 65 | } |
70 | - if (data_color == null) { | |
66 | + if(data_color == null){ | |
71 | 67 | error_message = "color " + data_colorstr + " is not a valid color"; |
72 | 68 | return false; |
73 | 69 | } |
@@ -74,7 +70,7 @@ | ||
74 | 70 | return true; |
75 | 71 | } |
76 | 72 | |
77 | - public String getError_message() { | |
73 | + public String getError_message(){ | |
78 | 74 | return error_message; |
79 | 75 | } |
80 | 76 |
@@ -1,7 +1,3 @@ | ||
1 | -/* | |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | 1 | package net.atomique.ksar.XML; |
6 | 2 | |
7 | 3 | import java.text.NumberFormat; |
@@ -15,38 +11,38 @@ | ||
15 | 11 | */ |
16 | 12 | public class PlotConfig { |
17 | 13 | |
18 | - public PlotConfig(String s) { | |
14 | + public PlotConfig(String s){ | |
19 | 15 | Title = s; |
20 | 16 | } |
21 | 17 | |
22 | - public String[] getHeader() { | |
18 | + public String[] getHeader(){ | |
23 | 19 | return Header; |
24 | 20 | } |
25 | 21 | |
26 | - public String getTitle() { | |
22 | + public String getTitle(){ | |
27 | 23 | return Title; |
28 | 24 | } |
29 | 25 | |
30 | - public void setHeaderStr(String s) { | |
26 | + public void setHeaderStr(String s){ | |
31 | 27 | this.Header = s.split("\\s+"); |
32 | 28 | HeaderStr = s; |
33 | 29 | } |
34 | 30 | |
35 | - public String getHeaderStr() { | |
31 | + public String getHeaderStr(){ | |
36 | 32 | return HeaderStr; |
37 | 33 | } |
38 | 34 | |
39 | - public int getSize() { | |
35 | + public int getSize(){ | |
40 | 36 | return size; |
41 | 37 | } |
42 | 38 | |
43 | - public void setSize(int size) { | |
39 | + public void setSize(int size){ | |
44 | 40 | this.size = size; |
45 | 41 | } |
46 | 42 | |
47 | - public void setSize(String s) { | |
43 | + public void setSize(String s){ | |
48 | 44 | Integer tmp = new Integer(s); |
49 | - if (tmp == null) { | |
45 | + if(tmp == null){ | |
50 | 46 | return; |
51 | 47 | } |
52 | 48 | this.size = size; |
@@ -53,33 +49,33 @@ | ||
53 | 49 | } |
54 | 50 | |
55 | 51 | |
56 | - public NumberAxis getAxis() { | |
52 | + public NumberAxis getAxis(){ | |
57 | 53 | NumberAxis tmp = new NumberAxis(Title); |
58 | - if ("1024".equals(base)) { | |
54 | + if("1024".equals(base)){ | |
59 | 55 | NumberFormat decimalformat1 = new IEEE1541Number(factor.intValue()); |
60 | 56 | tmp.setNumberFormatOverride(decimalformat1); |
61 | 57 | } |
62 | 58 | |
63 | - if (range != null) { | |
59 | + if(range != null){ | |
64 | 60 | tmp.setRange(range); |
65 | 61 | } |
66 | 62 | return tmp; |
67 | 63 | } |
68 | 64 | |
69 | - public void setBase(String s) { | |
70 | - if (s == null) { | |
65 | + public void setBase(String s){ | |
66 | + if(s == null){ | |
71 | 67 | return; |
72 | 68 | } |
73 | 69 | base = s; |
74 | 70 | } |
75 | 71 | |
76 | - public void setFactor(String s) { | |
72 | + public void setFactor(String s){ | |
77 | 73 | factor = Double.parseDouble(s); |
78 | 74 | } |
79 | 75 | |
80 | - public void setRange(String s) { | |
76 | + public void setRange(String s){ | |
81 | 77 | String[] t = s.split(","); |
82 | - if (t.length == 2) { | |
78 | + if(t.length == 2){ | |
83 | 79 | Double min = Double.parseDouble(t[0]); |
84 | 80 | Double max = Double.parseDouble(t[1]); |
85 | 81 | range = new Range(min, max); |
@@ -1,8 +1,3 @@ | ||
1 | -/* | |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | - | |
6 | 1 | package net.atomique.ksar.XML; |
7 | 2 | |
8 | 3 | import java.util.HashMap; |
@@ -13,36 +8,36 @@ | ||
13 | 8 | */ |
14 | 9 | public class GraphConfig { |
15 | 10 | |
16 | - public GraphConfig(String s1, String s2, String s3) { | |
11 | + public GraphConfig(String s1, String s2, String s3){ | |
17 | 12 | name = s1; |
18 | 13 | Title = s2; |
19 | 14 | type= s3; |
20 | 15 | } |
21 | - public String getTitle() { | |
16 | + public String getTitle(){ | |
22 | 17 | return Title; |
23 | 18 | } |
24 | 19 | |
25 | - public String getName() { | |
20 | + public String getName(){ | |
26 | 21 | return name; |
27 | 22 | } |
28 | 23 | |
29 | - public String getType() { | |
24 | + public String getType(){ | |
30 | 25 | return type; |
31 | 26 | } |
32 | 27 | |
33 | - public void addPlot(PlotConfig s) { | |
28 | + public void addPlot(PlotConfig s){ | |
34 | 29 | Plotlist.put(s.getTitle(), s); |
35 | 30 | } |
36 | 31 | |
37 | - public HashMap<String, PlotConfig> getPlotlist() { | |
32 | + public HashMap<String, PlotConfig> getPlotlist(){ | |
38 | 33 | return Plotlist; |
39 | 34 | } |
40 | 35 | |
41 | - public void addStack(StackConfig s) { | |
36 | + public void addStack(StackConfig s){ | |
42 | 37 | Stacklist.put(s.getTitle(), s); |
43 | 38 | } |
44 | 39 | |
45 | - public HashMap<String, StackConfig> getStacklist() { | |
40 | + public HashMap<String, StackConfig> getStacklist(){ | |
46 | 41 | return Stacklist; |
47 | 42 | } |
48 | 43 |
@@ -1,7 +1,3 @@ | ||
1 | -/* | |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | 1 | package net.atomique.ksar.XML; |
6 | 2 | |
7 | 3 | import java.util.HashMap; |
@@ -12,29 +8,31 @@ | ||
12 | 8 | * @author alex |
13 | 9 | */ |
14 | 10 | public class OSConfig { |
11 | + private String osname = null; | |
12 | + HashMap<String, StatConfig> statMap = new HashMap<>(); | |
13 | + HashMap<String, GraphConfig> graphMap = new HashMap<>(); | |
15 | 14 | |
16 | - public OSConfig(String s) { | |
17 | - OSname = s; | |
15 | + public OSConfig(String s){ | |
16 | + osname = s; | |
18 | 17 | } |
19 | 18 | |
20 | - public void addStat(StatConfig s) { | |
21 | - StatHash.put(s.getStatName(), s); | |
19 | + public void addStat(StatConfig s){ | |
20 | + statMap.put(s.getStatName(), s); | |
22 | 21 | } |
23 | 22 | |
24 | - public void addGraph(GraphConfig s) { | |
25 | - GraphHash.put(s.getName(), s); | |
23 | + public void addGraph(GraphConfig s){ | |
24 | + graphMap.put(s.getName(), s); | |
26 | 25 | } |
27 | 26 | |
28 | - public String getOSname() { | |
29 | - return OSname; | |
27 | + public String getOSname(){ | |
28 | + return osname; | |
30 | 29 | } |
31 | 30 | |
32 | - public String getStat(String[] columns, int firstdatacolumn) { | |
33 | - | |
34 | - StringBuffer tmpbuf = new StringBuffer(); | |
31 | + public String getStat(String[] columns, int firstdatacolumn){ | |
32 | + StringBuilder tmpbuf = new StringBuilder(); | |
35 | 33 | int num = 0; |
36 | - for (int i = firstdatacolumn; i < columns.length; i++) { | |
37 | - if (tmpbuf.length() != 0) { | |
34 | + for(int i = firstdatacolumn; i < columns.length; i++){ | |
35 | + if(tmpbuf.length() != 0){ | |
38 | 36 | tmpbuf.append(" "); |
39 | 37 | } |
40 | 38 | tmpbuf.append(columns[i]); |
@@ -41,11 +39,11 @@ | ||
41 | 39 | num++; |
42 | 40 | } |
43 | 41 | |
44 | - Iterator<String> ite = StatHash.keySet().iterator(); | |
45 | - while (ite.hasNext()) { | |
42 | + Iterator<String> ite = statMap.keySet().iterator(); | |
43 | + while(ite.hasNext()){ | |
46 | 44 | String tmptitle = ite.next(); |
47 | - StatConfig tmp = (StatConfig) StatHash.get(tmptitle); | |
48 | - if (tmp.check_Header(tmpbuf.toString(), num)) { | |
45 | + StatConfig tmp = (StatConfig) statMap.get(tmptitle); | |
46 | + if(tmp.check_Header(tmpbuf.toString(), num)){ | |
49 | 47 | return tmp.getGraphName(); |
50 | 48 | } |
51 | 49 | } |
@@ -52,15 +50,15 @@ | ||
52 | 50 | return null; |
53 | 51 | } |
54 | 52 | |
55 | - public StatConfig getStat(String statName) { | |
56 | - if (StatHash.isEmpty()) { | |
53 | + public StatConfig getStat(String statName){ | |
54 | + if(statMap.isEmpty()){ | |
57 | 55 | return null; |
58 | 56 | } |
59 | - Iterator<String> ite = StatHash.keySet().iterator(); | |
60 | - while (ite.hasNext()) { | |
57 | + Iterator<String> ite = statMap.keySet().iterator(); | |
58 | + while(ite.hasNext()){ | |
61 | 59 | String tmptitle = ite.next(); |
62 | - StatConfig tmp = (StatConfig) StatHash.get(tmptitle); | |
63 | - if ( tmp.getGraphName().equals(statName)) { | |
60 | + StatConfig tmp = (StatConfig) statMap.get(tmptitle); | |
61 | + if( tmp.getGraphName().equals(statName)){ | |
64 | 62 | return tmp; |
65 | 63 | } |
66 | 64 | } |
@@ -67,21 +65,18 @@ | ||
67 | 65 | return null; |
68 | 66 | } |
69 | 67 | |
70 | - public GraphConfig getGraphConfig(String s) { | |
71 | - if (GraphHash.isEmpty()) { | |
68 | + public GraphConfig getGraphConfig(String s){ | |
69 | + if(graphMap.isEmpty()){ | |
72 | 70 | return null; |
73 | 71 | } |
74 | - return GraphHash.get(s); | |
72 | + return graphMap.get(s); | |
75 | 73 | } |
76 | 74 | |
77 | - public HashMap<String, StatConfig> getStatHash() { | |
78 | - return StatHash; | |
75 | + public HashMap<String, StatConfig> getStatHash(){ | |
76 | + return statMap; | |
79 | 77 | } |
80 | 78 | |
81 | - public HashMap<String, GraphConfig> getGraphHash() { | |
82 | - return GraphHash; | |
79 | + public HashMap<String, GraphConfig> getGraphHash(){ | |
80 | + return graphMap; | |
83 | 81 | } |
84 | - private String OSname = null; | |
85 | - HashMap<String, StatConfig> StatHash = new HashMap<String, StatConfig>(); | |
86 | - HashMap<String, GraphConfig> GraphHash = new HashMap<String, GraphConfig>(); | |
87 | 82 | } |
@@ -1,8 +1,3 @@ | ||
1 | -/* | |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | - | |
6 | 1 | package net.atomique.ksar.XML; |
7 | 2 | |
8 | 3 | /** |
@@ -11,50 +6,50 @@ | ||
11 | 6 | */ |
12 | 7 | public class HostInfo { |
13 | 8 | |
14 | - public HostInfo(String s) { | |
9 | + public HostInfo(String s){ | |
15 | 10 | this.setHostname(s); |
16 | 11 | } |
17 | 12 | |
18 | - public Integer getMemBlockSize() { | |
13 | + public Integer getMemBlockSize(){ | |
19 | 14 | return MemBlockSize; |
20 | 15 | } |
21 | 16 | |
22 | - public void setMemBlockSize(Integer MemBlockSize) { | |
17 | + public void setMemBlockSize(Integer MemBlockSize){ | |
23 | 18 | this.MemBlockSize = MemBlockSize; |
24 | 19 | } |
25 | 20 | |
26 | - public void setMemBlockSize(String MemBlockSizestr) { | |
27 | - try { | |
21 | + public void setMemBlockSize(String MemBlockSizestr){ | |
22 | + try{ | |
28 | 23 | this.MemBlockSize = Integer.parseInt(MemBlockSizestr); |
29 | - } catch ( NumberFormatException nfe) { | |
24 | + } catch ( NumberFormatException nfe){ | |
30 | 25 | } |
31 | 26 | } |
32 | 27 | |
33 | - public String getAlias() { | |
28 | + public String getAlias(){ | |
34 | 29 | return aka_hostname; |
35 | 30 | } |
36 | 31 | |
37 | - public void setAlias(String aka_hostname) { | |
32 | + public void setAlias(String aka_hostname){ | |
38 | 33 | this.aka_hostname = aka_hostname; |
39 | 34 | } |
40 | 35 | |
41 | - public String getDescription() { | |
36 | + public String getDescription(){ | |
42 | 37 | return description; |
43 | 38 | } |
44 | 39 | |
45 | - public void setDescription(String description) { | |
40 | + public void setDescription(String description){ | |
46 | 41 | this.description = description; |
47 | 42 | } |
48 | 43 | |
49 | - public String getHostname() { | |
44 | + public String getHostname(){ | |
50 | 45 | return sar_hostname; |
51 | 46 | } |
52 | 47 | |
53 | - public void setHostname(String sar_hostname) { | |
48 | + public void setHostname(String sar_hostname){ | |
54 | 49 | this.sar_hostname = sar_hostname; |
55 | 50 | } |
56 | 51 | |
57 | - public String save() { | |
52 | + public String save(){ | |
58 | 53 | StringBuilder tmp = new StringBuilder(); |
59 | 54 | tmp.append("\t\t<host name=\"" + sar_hostname + "\">\n"); |
60 | 55 | tmp.append("\t\t\t<alias>" + aka_hostname + "</alias>\n"); |
@@ -1,7 +1,3 @@ | ||
1 | -/* | |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | 1 | package net.atomique.ksar.XML; |
6 | 2 | |
7 | 3 | import java.util.Iterator; |
@@ -13,91 +9,91 @@ | ||
13 | 9 | */ |
14 | 10 | public class CnxHistory { |
15 | 11 | |
16 | - public CnxHistory(String link) { | |
12 | + public CnxHistory(String link){ | |
17 | 13 | this.link=link; |
18 | 14 | commandList = new TreeSet<String>(); |
19 | 15 | String[] s = link.split("@", 2); |
20 | - if (s.length != 2) { | |
16 | + if(s.length != 2){ | |
21 | 17 | return; |
22 | 18 | } |
23 | 19 | this.setUsername(s[0]); |
24 | 20 | String[] t = s[1].split(":"); |
25 | - if (t.length == 2) { | |
21 | + if(t.length == 2){ | |
26 | 22 | this.setHostname(t[0]); |
27 | 23 | this.setPort(t[1]); |
28 | - } else { | |
24 | + }else{ | |
29 | 25 | this.setHostname(s[1]); |
30 | 26 | this.setPort("22"); |
31 | 27 | } |
32 | 28 | } |
33 | 29 | |
34 | - public void addCommand(String s) { | |
30 | + public void addCommand(String s){ | |
35 | 31 | commandList.add(s); |
36 | 32 | } |
37 | 33 | |
38 | - public TreeSet<String> getCommandList() { | |
34 | + public TreeSet<String> getCommandList(){ | |
39 | 35 | return commandList; |
40 | 36 | } |
41 | 37 | |
42 | - public String getHostname() { | |
38 | + public String getHostname(){ | |
43 | 39 | return hostname; |
44 | 40 | } |
45 | 41 | |
46 | - public void setHostname(String hostname) { | |
42 | + public void setHostname(String hostname){ | |
47 | 43 | this.hostname = hostname; |
48 | 44 | } |
49 | 45 | |
50 | - public String getUsername() { | |
46 | + public String getUsername(){ | |
51 | 47 | return username; |
52 | 48 | } |
53 | 49 | |
54 | - public void setUsername(String username) { | |
50 | + public void setUsername(String username){ | |
55 | 51 | this.username = username; |
56 | 52 | } |
57 | 53 | |
58 | - public String getPort() { | |
54 | + public String getPort(){ | |
59 | 55 | return port; |
60 | 56 | } |
61 | 57 | |
62 | - public int getPortInt() { | |
58 | + public int getPortInt(){ | |
63 | 59 | Integer tmp = Integer.parseInt(port); |
64 | 60 | return tmp.intValue(); |
65 | 61 | } |
66 | 62 | |
67 | - public void setPort(String port) { | |
63 | + public void setPort(String port){ | |
68 | 64 | this.port = port; |
69 | 65 | } |
70 | 66 | |
71 | - public String getLink() { | |
67 | + public String getLink(){ | |
72 | 68 | return link; |
73 | 69 | } |
74 | 70 | |
75 | - public boolean isValid() { | |
76 | - if (username == null) { | |
71 | + public boolean isValid(){ | |
72 | + if(username == null){ | |
77 | 73 | return false; |
78 | 74 | } |
79 | - if (hostname == null) { | |
75 | + if(hostname == null){ | |
80 | 76 | return false; |
81 | 77 | } |
82 | - if (commandList.isEmpty()) { | |
78 | + if(commandList.isEmpty()){ | |
83 | 79 | return false; |
84 | 80 | } |
85 | 81 | return true; |
86 | 82 | } |
87 | 83 | |
88 | - public void dump() { | |
84 | + public void dump(){ | |
89 | 85 | System.out.println(username + "@" + hostname + ":" + commandList); |
90 | 86 | } |
91 | 87 | |
92 | - public String save() { | |
88 | + public String save(){ | |
93 | 89 | StringBuilder tmp = new StringBuilder(); |
94 | - if ( "22".equals(port)) { | |
90 | + if( "22".equals(port)){ | |
95 | 91 | tmp.append("\t\t<cnx link=\"" + username + "@" + hostname + "\">\n"); |
96 | - } else { | |
92 | + }else{ | |
97 | 93 | tmp.append("\t\t<cnx link=\"" + username + "@" + hostname + ":" + port + "\">\n"); |
98 | 94 | } |
99 | 95 | Iterator<String> ite = commandList.iterator(); |
100 | - while (ite.hasNext()) { | |
96 | + while(ite.hasNext()){ | |
101 | 97 | tmp.append("\t\t\t<command>").append(ite.next()).append("</command>\n"); |
102 | 98 | } |
103 | 99 | tmp.append("\t\t</cnx>\n"); |
@@ -1,7 +1,3 @@ | ||
1 | -/* | |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | 1 | package net.atomique.ksar.XML; |
6 | 2 | |
7 | 3 | import java.text.NumberFormat; |
@@ -15,28 +11,28 @@ | ||
15 | 11 | */ |
16 | 12 | public class StackConfig { |
17 | 13 | |
18 | - public StackConfig(String s) { | |
14 | + public StackConfig(String s){ | |
19 | 15 | Title = s; |
20 | 16 | } |
21 | 17 | |
22 | - public String[] getHeader() { | |
18 | + public String[] getHeader(){ | |
23 | 19 | return Header; |
24 | 20 | } |
25 | 21 | |
26 | - public String getTitle() { | |
22 | + public String getTitle(){ | |
27 | 23 | return Title; |
28 | 24 | } |
29 | 25 | |
30 | - public void setHeaderStr(String s) { | |
26 | + public void setHeaderStr(String s){ | |
31 | 27 | this.Header = s.split("\\s+"); |
32 | 28 | HeaderStr = s; |
33 | 29 | } |
34 | 30 | |
35 | - public String getHeaderStr() { | |
31 | + public String getHeaderStr(){ | |
36 | 32 | return HeaderStr; |
37 | 33 | } |
38 | 34 | |
39 | - public void print() { | |
35 | + public void print(){ | |
40 | 36 | System.out.println("Title " + Title); |
41 | 37 | System.out.println("HeaderStr " + HeaderStr); |
42 | 38 | System.out.println("Header " + Header); |
@@ -43,49 +39,49 @@ | ||
43 | 39 | |
44 | 40 | } |
45 | 41 | |
46 | - public int getSize() { | |
42 | + public int getSize(){ | |
47 | 43 | return size; |
48 | 44 | } |
49 | 45 | |
50 | - public void setSize(int size) { | |
46 | + public void setSize(int size){ | |
51 | 47 | this.size = size; |
52 | 48 | } |
53 | 49 | |
54 | - public void setSize(String s) { | |
50 | + public void setSize(String s){ | |
55 | 51 | Integer tmp = new Integer(s); |
56 | - if (tmp == null) { | |
52 | + if(tmp == null){ | |
57 | 53 | return; |
58 | 54 | } |
59 | 55 | this.size = tmp.intValue(); |
60 | 56 | } |
61 | 57 | |
62 | - public NumberAxis getAxis() { | |
58 | + public NumberAxis getAxis(){ | |
63 | 59 | NumberAxis tmp = new NumberAxis(Title); |
64 | - if ("1024".equals(base)) { | |
60 | + if("1024".equals(base)){ | |
65 | 61 | NumberFormat decimalformat1 = new IEEE1541Number(factor.intValue()); |
66 | 62 | tmp.setNumberFormatOverride(decimalformat1); |
67 | 63 | } |
68 | 64 | |
69 | - if (range != null) { | |
65 | + if(range != null){ | |
70 | 66 | tmp.setRange(range); |
71 | 67 | } |
72 | 68 | return tmp; |
73 | 69 | } |
74 | 70 | |
75 | - public void setBase(String s) { | |
76 | - if (s == null) { | |
71 | + public void setBase(String s){ | |
72 | + if(s == null){ | |
77 | 73 | return; |
78 | 74 | } |
79 | 75 | base = s; |
80 | 76 | } |
81 | 77 | |
82 | - public void setFactor(String s) { | |
78 | + public void setFactor(String s){ | |
83 | 79 | factor = Double.parseDouble(s); |
84 | 80 | } |
85 | 81 | |
86 | - public void setRange(String s) { | |
82 | + public void setRange(String s){ | |
87 | 83 | String[] t = s.split(","); |
88 | - if (t.length == 2) { | |
84 | + if(t.length == 2){ | |
89 | 85 | Double min = Double.parseDouble(t[0]); |
90 | 86 | Double max = Double.parseDouble(t[1]); |
91 | 87 | range = new Range(min, max); |
@@ -1,7 +1,3 @@ | ||
1 | -/* | |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | 1 | package net.atomique.ksar.XML; |
6 | 2 | |
7 | 3 | /** |
@@ -10,60 +6,60 @@ | ||
10 | 6 | */ |
11 | 7 | public class StatConfig { |
12 | 8 | |
13 | - public StatConfig(String s) { | |
9 | + public StatConfig(String s){ | |
14 | 10 | StatName = s; |
15 | 11 | } |
16 | 12 | |
17 | - public String getGraphName() { | |
13 | + public String getGraphName(){ | |
18 | 14 | return GraphName; |
19 | 15 | } |
20 | 16 | |
21 | - public void setGraphName(String GraphName) { | |
17 | + public void setGraphName(String GraphName){ | |
22 | 18 | this.GraphName = GraphName; |
23 | 19 | } |
24 | 20 | |
25 | - public String[] getHeader() { | |
21 | + public String[] getHeader(){ | |
26 | 22 | return Header; |
27 | 23 | } |
28 | 24 | |
29 | - public String getHeaderStr() { | |
25 | + public String getHeaderStr(){ | |
30 | 26 | return HeaderStr; |
31 | 27 | } |
32 | 28 | |
33 | - public void setHeaderStr(String s) { | |
29 | + public void setHeaderStr(String s){ | |
34 | 30 | HeaderStr = s; |
35 | 31 | this.Header = HeaderStr.split("\\s+"); |
36 | 32 | HeaderNum = Header.length; |
37 | 33 | } |
38 | 34 | |
39 | - public String getStatName() { | |
35 | + public String getStatName(){ | |
40 | 36 | return StatName; |
41 | 37 | } |
42 | 38 | |
43 | - public boolean check_Header(String c, int i) { | |
44 | - if (!compare_Header(i)) { | |
39 | + public boolean check_Header(String c, int i){ | |
40 | + if(!compare_Header(i)){ | |
45 | 41 | return false; |
46 | 42 | } |
47 | 43 | |
48 | - if (HeaderStr.equals(c)) { | |
44 | + if(HeaderStr.equals(c)){ | |
49 | 45 | return true; |
50 | 46 | } |
51 | 47 | return false; |
52 | 48 | } |
53 | 49 | |
54 | - public boolean compare_Header(int i) { | |
55 | - if (i == HeaderNum) { | |
50 | + public boolean compare_Header(int i){ | |
51 | + if(i == HeaderNum){ | |
56 | 52 | return true; |
57 | 53 | } |
58 | 54 | return false; |
59 | 55 | } |
60 | 56 | |
61 | - public boolean canDuplicateTime() { | |
57 | + public boolean canDuplicateTime(){ | |
62 | 58 | return duplicatetime; |
63 | 59 | } |
64 | 60 | |
65 | - public void setDuplicateTime(String s) { | |
66 | - if ( "yes".equals(s) || "true".equals(s) ){ | |
61 | + public void setDuplicateTime(String s){ | |
62 | + if( "yes".equals(s) || "true".equals(s) ){ | |
67 | 63 | duplicatetime=true; |
68 | 64 | } |
69 | 65 | } |
@@ -1,8 +1,3 @@ | ||
1 | -/* | |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | - | |
6 | 1 | package net.atomique.ksar.Graph; |
7 | 2 | |
8 | 3 | import java.text.DecimalFormat; |
@@ -16,45 +11,45 @@ | ||
16 | 11 | */ |
17 | 12 | public class IEEE1541Number extends NumberFormat { |
18 | 13 | |
19 | - private static final long serialVersionUID = 5L; | |
14 | + private static final long serialVersionUID = 5L; | |
20 | 15 | |
21 | - public IEEE1541Number() { | |
22 | - } | |
16 | + public IEEE1541Number(){ | |
17 | + } | |
23 | 18 | |
24 | - public IEEE1541Number(int value) { | |
25 | - kilo = value; | |
26 | - } | |
19 | + public IEEE1541Number(int value){ | |
20 | + kilo = value; | |
21 | + } | |
27 | 22 | |
28 | - public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) { | |
29 | - if (kilo == 0) { | |
30 | - return toAppendTo.append(number); | |
31 | - } | |
32 | - if ((number * kilo) < 1024) { | |
33 | - return toAppendTo.append(number); | |
34 | - } | |
35 | - if ((number * kilo) < (1024 * 1024)) { | |
36 | - DecimalFormat formatter = new DecimalFormat("#,##0.0"); | |
37 | - toAppendTo.append(formatter.format((double) number / 1024.0)).append(" KB"); | |
38 | - return toAppendTo; | |
39 | - } | |
40 | - if ((number * kilo) < (1024 * 1024 * 1024)) { | |
41 | - DecimalFormat formatter = new DecimalFormat("#,##0.0"); | |
42 | - toAppendTo.append(formatter.format((double) (number * kilo) / (1024.0 * 1024.0))).append(" MB"); | |
43 | - return toAppendTo; | |
44 | - } | |
23 | + public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos){ | |
24 | + if(kilo == 0){ | |
25 | + return toAppendTo.append(number); | |
26 | + } | |
27 | + if((number * kilo) < 1024){ | |
28 | + return toAppendTo.append(number); | |
29 | + } | |
30 | + if((number * kilo) < (1024 * 1024)){ | |
31 | + DecimalFormat formatter = new DecimalFormat("#,##0.0"); | |
32 | + toAppendTo.append(formatter.format((double) number / 1024.0)).append(" KB"); | |
33 | + return toAppendTo; | |
34 | + } | |
35 | + if((number * kilo) < (1024 * 1024 * 1024)){ | |
36 | + DecimalFormat formatter = new DecimalFormat("#,##0.0"); | |
37 | + toAppendTo.append(formatter.format((double) (number * kilo) / (1024.0 * 1024.0))).append(" MB"); | |
38 | + return toAppendTo; | |
39 | + } | |
45 | 40 | |
46 | - DecimalFormat formatter = new DecimalFormat("#,##0.0"); | |
47 | - toAppendTo.append(formatter.format((double) (number * kilo) / (1024.0 * 1024.0 * 1024.0))).append(" GB"); | |
48 | - return toAppendTo; | |
49 | - } | |
41 | + DecimalFormat formatter = new DecimalFormat("#,##0.0"); | |
42 | + toAppendTo.append(formatter.format((double) (number * kilo) / (1024.0 * 1024.0 * 1024.0))).append(" GB"); | |
43 | + return toAppendTo; | |
44 | + } | |
50 | 45 | |
51 | - public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos) { | |
52 | - return format((double) (number * kilo), toAppendTo, pos); | |
53 | - } | |
46 | + public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos){ | |
47 | + return format((double) (number * kilo), toAppendTo, pos); | |
48 | + } | |
54 | 49 | |
55 | - public Number parse(String source, ParsePosition parsePosition) { | |
56 | - return null; | |
57 | - } | |
58 | - | |
59 | - int kilo = 0; | |
50 | + public Number parse(String source, ParsePosition parsePosition){ | |
51 | + return null; | |
52 | + } | |
53 | + | |
54 | + int kilo = 0; | |
60 | 55 | } |
@@ -1,8 +1,3 @@ | ||
1 | -/* | |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | - | |
6 | 1 | package net.atomique.ksar.Graph; |
7 | 2 | |
8 | 3 | import java.awt.LayoutManager; |
@@ -24,98 +19,95 @@ | ||
24 | 19 | * |
25 | 20 | * @author alex |
26 | 21 | */ |
27 | -public class List { | |
22 | +public class List{ | |
23 | + protected GraphConfig graphconfig = null; | |
24 | + protected SortedTreeNode parentTreeNode = null; | |
25 | + protected KSar mysar = null; | |
26 | + protected String HeaderStr = null; | |
27 | + protected Map<String, Graph> nodeHashList = new HashMap<>(); | |
28 | + protected int skipColumn = 0; | |
29 | + protected String Title = null; | |
28 | 30 | |
29 | - public List(KSar hissar, GraphConfig g,String stitle, String sheader, int i) { | |
30 | - mysar = hissar; | |
31 | - HeaderStr = sheader; | |
32 | - graphconfig =g ; | |
33 | - Title = stitle; | |
34 | - skipColumn = i; | |
35 | - ParentNodeInfo tmp = new ParentNodeInfo(Title, this); | |
36 | - parentTreeNode = new SortedTreeNode(tmp); | |
37 | - mysar.add2tree(mysar.graphtree, parentTreeNode); | |
38 | - } | |
31 | + public List(KSar hissar, GraphConfig g,String stitle, String sheader, int i){ | |
32 | + mysar = hissar; | |
33 | + HeaderStr = sheader; | |
34 | + graphconfig =g ; | |
35 | + Title = stitle; | |
36 | + skipColumn = i; | |
37 | + ParentNodeInfo tmp = new ParentNodeInfo(Title, this); | |
38 | + parentTreeNode = new SortedTreeNode(tmp); | |
39 | + mysar.add2tree(mysar.getGraphTree(), parentTreeNode); | |
40 | + } | |
39 | 41 | |
40 | - public int parse_line(Second now,String s) { | |
41 | - String cols[] = s.split("\\s+"); | |
42 | - Graph tmp = null; | |
43 | - if ( ! nodeHashList.containsKey(cols[skipColumn])) { | |
44 | - tmp= new Graph(mysar, graphconfig,Title + " " + cols[skipColumn], HeaderStr, skipColumn+1, null); | |
45 | - nodeHashList.put(cols[skipColumn], tmp); | |
46 | - TreeNodeInfo infotmp= new TreeNodeInfo( cols[skipColumn], tmp); | |
47 | - SortedTreeNode nodetmp = new SortedTreeNode(infotmp); | |
48 | - mysar.add2tree(parentTreeNode, nodetmp); | |
49 | - } else { | |
50 | - tmp = (Graph)nodeHashList.get(cols[skipColumn]); | |
51 | - } | |
42 | + public int parse_line(Second now,String s){ | |
43 | + String cols[] = s.split("\\s+"); | |
44 | + Graph tmp = null; | |
45 | + if( ! nodeHashList.containsKey(cols[skipColumn])){ | |
46 | + tmp= new Graph(mysar, graphconfig,Title + " " + cols[skipColumn], HeaderStr, skipColumn+1, null); | |
47 | + nodeHashList.put(cols[skipColumn], tmp); | |
48 | + TreeNodeInfo infotmp= new TreeNodeInfo( cols[skipColumn], tmp); | |
49 | + SortedTreeNode nodetmp = new SortedTreeNode(infotmp); | |
50 | + mysar.add2tree(parentTreeNode, nodetmp); | |
51 | + }else{ | |
52 | + tmp = (Graph)nodeHashList.get(cols[skipColumn]); | |
53 | + } | |
52 | 54 | |
53 | - return tmp.parse_line(now,s); | |
54 | - } | |
55 | + return tmp.parse_line(now,s); | |
56 | + } | |
55 | 57 | |
56 | 58 | |
57 | - public JPanel run() { | |
58 | - JPanel tmppanel = new JPanel(); | |
59 | - LayoutManager tmplayout = null; | |
60 | - int graphnumber = nodeHashList.size(); | |
61 | - int linenum = (int) Math.floor(graphnumber / 2); | |
62 | - if (graphnumber % 2 != 0) { | |
63 | - linenum++; | |
64 | - } | |
65 | - tmplayout = new java.awt.GridLayout(linenum, 2); | |
66 | - tmppanel.setLayout(tmplayout); | |
59 | + public JPanel run(){ | |
60 | + JPanel tmppanel = new JPanel(); | |
61 | + LayoutManager tmplayout = null; | |
62 | + int graphnumber = nodeHashList.size(); | |
63 | + int linenum = (int) Math.floor(graphnumber / 2); | |
64 | + if(graphnumber % 2 != 0){ | |
65 | + linenum++; | |
66 | + } | |
67 | + tmplayout = new java.awt.GridLayout(linenum, 2); | |
68 | + tmppanel.setLayout(tmplayout); | |
67 | 69 | |
68 | 70 | |
69 | - SortedSet<String> sortedset = new TreeSet<String>(nodeHashList.keySet()); | |
71 | + SortedSet<String> sortedset = new TreeSet<String>(nodeHashList.keySet()); | |
70 | 72 | |
71 | - Iterator<String> it = sortedset.iterator(); | |
73 | + Iterator<String> it = sortedset.iterator(); | |
72 | 74 | |
73 | - while (it.hasNext()) { | |
74 | - Graph tmpgraph = (Graph) nodeHashList.get(it.next()); | |
75 | - tmppanel.add(tmpgraph.get_ChartPanel()); | |
76 | - } | |
75 | + while(it.hasNext()){ | |
76 | + Graph tmpgraph = (Graph) nodeHashList.get(it.next()); | |
77 | + tmppanel.add(tmpgraph.get_ChartPanel()); | |
78 | + } | |
77 | 79 | |
78 | - return tmppanel; | |
79 | - } | |
80 | + return tmppanel; | |
81 | + } | |
80 | 82 | |
81 | - public boolean isPrintSelected() { | |
82 | - boolean leaftoprint = false; | |
83 | - SortedSet<String> sortedset = new TreeSet<String>(nodeHashList.keySet()); | |
83 | + public boolean isPrintSelected(){ | |
84 | + boolean leaftoprint = false; | |
85 | + SortedSet<String> sortedset = new TreeSet<String>(nodeHashList.keySet()); | |
84 | 86 | |
85 | - Iterator<String> it = sortedset.iterator(); | |
87 | + Iterator<String> it = sortedset.iterator(); | |
86 | 88 | |
87 | - while (it.hasNext()) { | |
88 | - Graph tmpgraph = (Graph) nodeHashList.get(it.next()); | |
89 | - if (tmpgraph.printSelected) { | |
90 | - leaftoprint = true; | |
91 | - break; | |
92 | - } | |
93 | - } | |
94 | - if (leaftoprint) { | |
95 | - return true; | |
96 | - } else { | |
97 | - return false; | |
98 | - } | |
99 | - } | |
89 | + while(it.hasNext()){ | |
90 | + Graph tmpgraph = (Graph) nodeHashList.get(it.next()); | |
91 | + if(tmpgraph.printSelected){ | |
92 | + leaftoprint = true; | |
93 | + break; | |
94 | + } | |
95 | + } | |
96 | + if(leaftoprint){ | |
97 | + return true; | |
98 | + }else{ | |
99 | + return false; | |
100 | + } | |
101 | + } | |
100 | 102 | |
101 | - public String getTitle() { | |
102 | - return Title; | |
103 | - } | |
103 | + public String getTitle(){ | |
104 | + return Title; | |
105 | + } | |
104 | 106 | |
105 | - public JPanel getprintform() { | |
106 | - JPanel panel = new JPanel(); | |
107 | - panel.setBorder(new TitledBorder(Title)); | |
108 | - panel.setLayout(new javax.swing.BoxLayout(panel, javax.swing.BoxLayout.PAGE_AXIS)); | |
109 | - return panel; | |
110 | - } | |
111 | - | |
112 | - | |
113 | - protected GraphConfig graphconfig = null; | |
114 | - protected SortedTreeNode parentTreeNode = null; | |
115 | - protected KSar mysar = null; | |
116 | - protected String HeaderStr = null; | |
117 | - protected Map<String, Graph> nodeHashList = new HashMap<String, Graph>(); | |
118 | - protected int skipColumn = 0; | |
119 | - protected String Title = null; | |
120 | - | |
107 | + public JPanel getprintform(){ | |
108 | + JPanel panel = new JPanel(); | |
109 | + panel.setBorder(new TitledBorder(Title)); | |
110 | + panel.setLayout(new javax.swing.BoxLayout(panel, javax.swing.BoxLayout.PAGE_AXIS)); | |
111 | + return panel; | |
112 | + } | |
121 | 113 | } |
@@ -1,7 +1,3 @@ | ||
1 | -/* | |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | 1 | package net.atomique.ksar.Graph; |
6 | 2 | |
7 | 3 | import java.awt.BasicStroke; |
@@ -52,388 +48,388 @@ | ||
52 | 48 | */ |
53 | 49 | public class Graph { |
54 | 50 | |
55 | - public Graph(KSar hissar, GraphConfig g, String Title, String hdrs, int skipcol, SortedTreeNode pp) { | |
56 | - mysar = hissar; | |
57 | - graphtitle = Title; | |
58 | - graphconfig = g; | |
59 | - printCheckBox = new JCheckBox(graphtitle, printSelected); | |
60 | - printCheckBox.addItemListener(new java.awt.event.ItemListener() { | |
51 | + public Graph(KSar hissar, GraphConfig g, String Title, String hdrs, int skipcol, SortedTreeNode pp){ | |
52 | + mysar = hissar; | |
53 | + graphtitle = Title; | |
54 | + graphconfig = g; | |
55 | + printCheckBox = new JCheckBox(graphtitle, printSelected); | |
56 | + printCheckBox.addItemListener(new java.awt.event.ItemListener(){ | |
61 | 57 | |
62 | - public void itemStateChanged(java.awt.event.ItemEvent evt) { | |
63 | - if (evt.getSource() == printCheckBox) { | |
64 | - printSelected = printCheckBox.isSelected(); | |
65 | - } | |
66 | - } | |
67 | - }); | |
68 | - skipColumn = skipcol; | |
69 | - if (pp != null) { | |
70 | - TreeNodeInfo infotmp = new TreeNodeInfo(Title, this); | |
71 | - SortedTreeNode nodetmp = new SortedTreeNode(infotmp); | |
72 | - mysar.add2tree(pp, nodetmp); | |
73 | - } | |
74 | - HeaderStr = hdrs.split("\\s+"); | |
75 | - create_DataStore(); | |
76 | - } | |
58 | + public void itemStateChanged(java.awt.event.ItemEvent evt){ | |
59 | + if(evt.getSource() == printCheckBox){ | |
60 | + printSelected = printCheckBox.isSelected(); | |
61 | + } | |
62 | + } | |
63 | + }); | |
64 | + skipColumn = skipcol; | |
65 | + if(pp != null){ | |
66 | + TreeNodeInfo infotmp = new TreeNodeInfo(Title, this); | |
67 | + SortedTreeNode nodetmp = new SortedTreeNode(infotmp); | |
68 | + mysar.add2tree(pp, nodetmp); | |
69 | + } | |
70 | + HeaderStr = hdrs.split("\\s+"); | |
71 | + create_DataStore(); | |
72 | + } | |
77 | 73 | |
78 | - private void create_DataStore() { | |
79 | - // create timeseries | |
80 | - for (int i = skipColumn; i < HeaderStr.length; i++) { | |
81 | - Stats.add(new TimeSeries(HeaderStr[i])); | |
82 | - } | |
83 | - // create stack | |
84 | - SortedSet<String> sortedset = new TreeSet<String>(graphconfig.getStacklist().keySet()); | |
85 | - Iterator<String> it = sortedset.iterator(); | |
86 | - while (it.hasNext()) { | |
87 | - StackConfig tmp = (StackConfig) graphconfig.getStacklist().get(it.next()); | |
88 | - TimeTableXYDataset tmp2 = new TimeTableXYDataset(); | |
89 | - String[] s = tmp.getHeaderStr().split("\\s+"); | |
90 | - for (int i = 0; i < s.length; i++) { | |
91 | - StackListbyCol.put(s[i], tmp2); | |
92 | - } | |
93 | - StackListbyName.put(tmp.getTitle(), tmp2); | |
94 | - } | |
95 | - } | |
74 | + private void create_DataStore(){ | |
75 | + // create timeseries | |
76 | + for(int i = skipColumn; i < HeaderStr.length; i++){ | |
77 | + Stats.add(new TimeSeries(HeaderStr[i])); | |
78 | + } | |
79 | + // create stack | |
80 | + SortedSet<String> sortedset = new TreeSet<String>(graphconfig.getStacklist().keySet()); | |
81 | + Iterator<String> it = sortedset.iterator(); | |
82 | + while(it.hasNext()){ | |
83 | + StackConfig tmp = (StackConfig) graphconfig.getStacklist().get(it.next()); | |
84 | + TimeTableXYDataset tmp2 = new TimeTableXYDataset(); | |
85 | + String[] s = tmp.getHeaderStr().split("\\s+"); | |
86 | + for(int i = 0; i < s.length; i++){ | |
87 | + StackListbyCol.put(s[i], tmp2); | |
88 | + } | |
89 | + StackListbyName.put(tmp.getTitle(), tmp2); | |
90 | + } | |
91 | + } | |
96 | 92 | |
97 | - public int parse_line(Second now, String s) { | |
98 | - String[] cols = s.split("\\s+"); | |
99 | - Double colvalue = null; | |
100 | - //System.out.println("graph parsing:" + s); | |
101 | - for (int i = skipColumn; i < HeaderStr.length; i++) { | |
102 | - try { | |
103 | - colvalue = new Double(cols[i]); | |
104 | - } catch (NumberFormatException ne) { | |
105 | - System.out.println(graphtitle + " " + cols[i] + " is NaN"); | |
106 | - return 0; | |
107 | - } catch (Exception ae) { | |
108 | - System.out.println(graphtitle + " " + cols[i] + " is undef " + s); | |
109 | - ae.printStackTrace(); | |
110 | - return 0; | |
111 | - } | |
93 | + public int parse_line(Second now, String s){ | |
94 | + String[] cols = s.split("\\s+"); | |
95 | + Double colvalue = null; | |
96 | + //System.out.println("graph parsing:" + s); | |
97 | + for(int i = skipColumn; i < HeaderStr.length; i++){ | |
98 | + try{ | |
99 | + colvalue = new Double(cols[i]); | |
100 | + }catch(NumberFormatException ne){ | |
101 | + System.out.println(graphtitle + " " + cols[i] + " is NaN"); | |
102 | + return 0; | |
103 | + }catch(Exception ae){ | |
104 | + System.out.println(graphtitle + " " + cols[i] + " is undef " + s); | |
105 | + ae.printStackTrace(); | |
106 | + return 0; | |
107 | + } | |
112 | 108 | |
113 | - add_datapoint_plot(now, i-skipColumn , HeaderStr[i-skipColumn], colvalue); | |
109 | + add_datapoint_plot(now, i-skipColumn , HeaderStr[i-skipColumn], colvalue); | |
114 | 110 | |
115 | 111 | |
116 | - TimeTableXYDataset tmp = StackListbyCol.get(HeaderStr[i]); | |
117 | - if (tmp != null) { | |
118 | - add_datapoint_stack(tmp, now, i , HeaderStr[i], colvalue); | |
119 | - } | |
120 | - } | |
112 | + TimeTableXYDataset tmp = StackListbyCol.get(HeaderStr[i]); | |
113 | + if(tmp != null){ | |
114 | + add_datapoint_stack(tmp, now, i , HeaderStr[i], colvalue); | |
115 | + } | |
116 | + } | |
121 | 117 | |
122 | - return 0; | |
123 | - } | |
118 | + return 0; | |
119 | + } | |
124 | 120 | |
125 | - private boolean add_datapoint_stack(TimeTableXYDataset dataset, Second now, int col, String colheader, Double value) { | |
126 | - try { | |
127 | - dataset.add(now, value, colheader); | |
121 | + private boolean add_datapoint_stack(TimeTableXYDataset dataset, Second now, int col, String colheader, Double value){ | |
122 | + try{ | |
123 | + dataset.add(now, value, colheader); | |
128 | 124 | |
129 | - return true; | |
130 | - } catch (SeriesException se) { | |
131 | - /* | |
132 | - * | |
133 | - * not update on stack | |
134 | - * | |
135 | - int indexcol = -1; | |
136 | - // add not working | |
137 | - // find timeseries index | |
138 | - for (int i = 0; i < dataset.getSeriesCount(); i++) { | |
139 | - String name = (String) dataset.getSeriesKey(i); | |
140 | - if (colheader.equals(name)) { | |
141 | - indexcol = i; | |
142 | - break; | |
143 | - } | |
144 | - System.out.println(dataset.indexOf(name) + ": " + name); | |
145 | - } | |
146 | - if (indexcol == -1) { | |
147 | - return false; | |
148 | - } | |
149 | - StatConfig statconfig = ((OSParser) mysar.myparser).get_OSConfig().getStat(mysar.myparser.getCurrentStat()); | |
150 | - if (statconfig != null) { | |
151 | - if (statconfig.canDuplicateTime()) { | |
152 | - Number oldval = dataset.getXValue(indexcol, col); | |
153 | - Double tempval; | |
154 | - if (oldval == null) { | |
155 | - return false; | |
156 | - } | |
157 | - ColumnConfig colconfig = GlobalOptions.getColumnConfig(colheader); | |
158 | - if (colconfig.getType() == 1) { | |
159 | - tempval = new Double((oldval.doubleValue() + value) / 2); | |
160 | - } else if (colconfig.getType() == 2) { | |
161 | - tempval = new Double(oldval.doubleValue() + value); | |
162 | - } else { | |
163 | - return false; | |
164 | - } | |
125 | + return true; | |
126 | + }catch(SeriesException se){ | |
127 | + /* | |
128 | + * | |
129 | + * not update on stack | |
130 | + * | |
131 | + int indexcol = -1; | |
132 | + // add not working | |
133 | + // find timeseries index | |
134 | + for(int i = 0; i < dataset.getSeriesCount(); i++){ | |
135 | + String name = (String) dataset.getSeriesKey(i); | |
136 | + if(colheader.equals(name)){ | |
137 | + indexcol = i; | |
138 | + break; | |
139 | + } | |
140 | + System.out.println(dataset.indexOf(name) + ": " + name); | |
141 | + } | |
142 | + if(indexcol == -1){ | |
143 | + return false; | |
144 | + } | |
145 | + StatConfig statconfig = ((OSParser) mysar.myparser).get_OSConfig().getStat(mysar.myparser.getCurrentStat()); | |
146 | + if(statconfig != null){ | |
147 | + if(statconfig.canDuplicateTime()){ | |
148 | + Number oldval = dataset.getXValue(indexcol, col); | |
149 | + Double tempval; | |
150 | + if(oldval == null){ | |
151 | + return false; | |
152 | + } | |
153 | + ColumnConfig colconfig = GlobalOptions.getColumnConfig(colheader); | |
154 | + if(colconfig.getType() == 1){ | |
155 | + tempval = new Double((oldval.doubleValue() + value) / 2); | |
156 | + }else if(colconfig.getType() == 2){ | |
157 | + tempval = new Double(oldval.doubleValue() + value); | |
158 | + }else{ | |
159 | + return false; | |
160 | + } | |
165 | 161 | |
166 | - try { | |
167 | - ((TimeSeries) (Stats.get(col))).update(now, tempval); | |
168 | - return true; | |
169 | - } catch (SeriesException se2) { | |
170 | - return false; | |
171 | - } | |
172 | - } | |
173 | - } | |
174 | - */ | |
175 | - return false; | |
176 | - } | |
162 | + try{ | |
163 | + ((TimeSeries) (Stats.get(col))).update(now, tempval); | |
164 | + return true; | |
165 | + }catch(SeriesException se2){ | |
166 | + return false; | |
167 | + } | |
168 | + } | |
169 | + } | |
170 | + */ | |
171 | + return false; | |
172 | + } | |
177 | 173 | |
178 | - } | |
174 | + } | |
179 | 175 | |
180 | - private boolean add_datapoint_plot(Second now, int col, String colheader, Double value) { | |
181 | - try { | |
182 | - ((TimeSeries) (Stats.get(col))).add(now, value); | |
183 | - return true; | |
184 | - } catch (SeriesException se) { | |
185 | - // insert not possible | |
186 | - // check if column can be update | |
187 | - StatConfig statconfig = ((OSParser) mysar.myparser).get_OSConfig().getStat(mysar.myparser.getCurrentStat()); | |
188 | - if (statconfig != null) { | |
189 | - if (statconfig.canDuplicateTime()) { | |
190 | - Number oldval = ((TimeSeries) (Stats.get(col))).getValue(now); | |
191 | - Double tempval; | |
192 | - if (oldval == null) { | |
193 | - return false; | |
194 | - } | |
195 | - ColumnConfig colconfig = GlobalOptions.getColumnConfig(colheader); | |
196 | - if ( colconfig == null ) { | |
197 | - return false; | |
198 | - } | |
199 | - if (colconfig.getType() == 1) { | |
200 | - tempval = new Double((oldval.doubleValue() + value) / 2); | |
201 | - } else if (colconfig.getType() == 2) { | |
202 | - tempval = new Double(oldval.doubleValue() + value); | |
203 | - } else { | |
204 | - return false; | |
205 | - } | |
176 | + private boolean add_datapoint_plot(Second now, int col, String colheader, Double value){ | |
177 | + try{ | |
178 | + ((TimeSeries) (Stats.get(col))).add(now, value); | |
179 | + return true; | |
180 | + }catch(SeriesException se){ | |
181 | + // insert not possible | |
182 | + // check if column can be update | |
183 | + StatConfig statconfig = ((OSParser) mysar.myparser).get_OSConfig().getStat(mysar.myparser.getCurrentStat()); | |
184 | + if(statconfig != null){ | |
185 | + if(statconfig.canDuplicateTime()){ | |
186 | + Number oldval = ((TimeSeries) (Stats.get(col))).getValue(now); | |
187 | + Double tempval; | |
188 | + if(oldval == null){ | |
189 | + return false; | |
190 | + } | |
191 | + ColumnConfig colconfig = GlobalOptions.getColumnConfig(colheader); | |
192 | + if( colconfig == null ){ | |
193 | + return false; | |
194 | + } | |
195 | + if(colconfig.getType() == 1){ | |
196 | + tempval = new Double((oldval.doubleValue() + value) / 2); | |
197 | + }else if(colconfig.getType() == 2){ | |
198 | + tempval = new Double(oldval.doubleValue() + value); | |
199 | + }else{ | |
200 | + return false; | |
201 | + } | |
206 | 202 | |
207 | - try { | |
208 | - ((TimeSeries) (Stats.get(col))).update(now, tempval); | |
209 | - return true; | |
210 | - } catch (SeriesException se2) { | |
211 | - return false; | |
212 | - } | |
213 | - } | |
214 | - } | |
215 | - return false; | |
216 | - } | |
203 | + try{ | |
204 | + ((TimeSeries) (Stats.get(col))).update(now, tempval); | |
205 | + return true; | |
206 | + }catch(SeriesException se2){ | |
207 | + return false; | |
208 | + } | |
209 | + } | |
210 | + } | |
211 | + return false; | |
212 | + } | |
217 | 213 | |
218 | - } | |
214 | + } | |
219 | 215 | |
220 | - public String make_csv() { | |
221 | - StringBuilder tmp = new StringBuilder(); | |
222 | - tmp.append("Date;"); | |
223 | - tmp.append(getCsvHeader()); | |
224 | - tmp.append("\n"); | |
225 | - TimeSeries datelist = (TimeSeries) Stats.get(0); | |
226 | - Iterator ite = datelist.getTimePeriods().iterator(); | |
227 | - while (ite.hasNext()) { | |
228 | - TimePeriod item = (TimePeriod) ite.next(); | |
229 | - tmp.append(item.toString()); | |
230 | - tmp.append(";"); | |
231 | - tmp.append(getCsvLine((RegularTimePeriod) item)); | |
232 | - tmp.append("\n"); | |
233 | - } | |
216 | + public String make_csv(){ | |
217 | + StringBuilder tmp = new StringBuilder(); | |
218 | + tmp.append("Date;"); | |
219 | + tmp.append(getCsvHeader()); | |
220 | + tmp.append("\n"); | |
221 | + TimeSeries datelist = (TimeSeries) Stats.get(0); | |
222 | + Iterator ite = datelist.getTimePeriods().iterator(); | |
223 | + while(ite.hasNext()){ | |
224 | + TimePeriod item = (TimePeriod) ite.next(); | |
225 | + tmp.append(item.toString()); | |
226 | + tmp.append(";"); | |
227 | + tmp.append(getCsvLine((RegularTimePeriod) item)); | |
228 | + tmp.append("\n"); | |
229 | + } | |
234 | 230 | |
235 | - return tmp.toString(); | |
236 | - } | |
231 | + return tmp.toString(); | |
232 | + } | |
237 | 233 | |
238 | - public String getCsvHeader() { | |
239 | - StringBuilder tmp = new StringBuilder(); | |
240 | - for (int i = 1 + skipColumn; i < HeaderStr.length; i++) { | |
241 | - TimeSeries tmpseries = (TimeSeries) Stats.get(i - skipColumn); | |
242 | - tmp.append(graphtitle).append(" ").append(tmpseries.getKey()); | |
243 | - tmp.append(";"); | |
244 | - } | |
245 | - return tmp.toString(); | |
246 | - } | |
234 | + public String getCsvHeader(){ | |
235 | + StringBuilder tmp = new StringBuilder(); | |
236 | + for(int i = 1 + skipColumn; i < HeaderStr.length; i++){ | |
237 | + TimeSeries tmpseries = (TimeSeries) Stats.get(i - skipColumn); | |
238 | + tmp.append(graphtitle).append(" ").append(tmpseries.getKey()); | |
239 | + tmp.append(";"); | |
240 | + } | |
241 | + return tmp.toString(); | |
242 | + } | |
247 | 243 | |
248 | - public String getCsvLine(RegularTimePeriod t) { | |
249 | - StringBuilder tmp = new StringBuilder(); | |
250 | - for (int i = 1 + skipColumn; i < HeaderStr.length; i++) { | |
251 | - TimeSeries tmpseries = (TimeSeries) Stats.get(i - skipColumn); | |
252 | - tmp.append(tmpseries.getValue(t)); | |
244 | + public String getCsvLine(RegularTimePeriod t){ | |
245 | + StringBuilder tmp = new StringBuilder(); | |
246 | + for(int i = 1 + skipColumn; i < HeaderStr.length; i++){ | |
247 | + TimeSeries tmpseries = (TimeSeries) Stats.get(i - skipColumn); | |
248 | + tmp.append(tmpseries.getValue(t)); | |
253 | 249 | |
254 | - tmp.append(";"); | |
255 | - } | |
256 | - return tmp.toString(); | |
257 | - } | |
250 | + tmp.append(";"); | |
251 | + } | |
252 | + return tmp.toString(); | |
253 | + } | |
258 | 254 | |
259 | - public int savePNG(final Second g_start, final Second g_end, final String filename, final int width, final int height) { | |
260 | - try { | |
261 | - ChartUtilities.saveChartAsPNG(new File(filename), this.getgraph(mysar.myparser.get_startofgraph(), mysar.myparser.get_endofgraph()), width, height); | |
262 | - } catch (IOException e) { | |
263 | - System.err.println("Unable to write to : " + filename); | |
264 | - return -1; | |
265 | - } | |
266 | - return 0; | |
267 | - } | |
255 | + public int savePNG(final Second g_start, final Second g_end, final String filename, final int width, final int height){ | |
256 | + try{ | |
257 | + ChartUtilities.saveChartAsPNG(new File(filename), this.getgraph(mysar.myparser.getStartOfGraph(), mysar.myparser.getEndOfGraph()), width, height); | |
258 | + }catch(IOException e){ | |
259 | + System.err.println("Unable to write to : " + filename); | |
260 | + return -1; | |
261 | + } | |
262 | + return 0; | |
263 | + } | |
268 | 264 | |
269 | - public int saveJPG(final Second g_start, final Second g_end, final String filename, final int width, final int height) { | |
270 | - try { | |
271 | - ChartUtilities.saveChartAsJPEG(new File(filename), this.getgraph(mysar.myparser.get_startofgraph(), mysar.myparser.get_endofgraph()), width, height); | |
272 | - } catch (IOException e) { | |
273 | - System.err.println("Unable to write to : " + filename); | |
274 | - return -1; | |
275 | - } | |
276 | - return 0; | |
277 | - } | |
265 | + public int saveJPG(final Second g_start, final Second g_end, final String filename, final int width, final int height){ | |
266 | + try{ | |
267 | + ChartUtilities.saveChartAsJPEG(new File(filename), this.getgraph(mysar.myparser.getStartOfGraph(), mysar.myparser.getEndOfGraph()), width, height); | |
268 | + }catch(IOException e){ | |
269 | + System.err.println("Unable to write to : " + filename); | |
270 | + return -1; | |
271 | + } | |
272 | + return 0; | |
273 | + } | |
278 | 274 | |
279 | - public JCheckBox getprintform() { | |
280 | - return printCheckBox; | |
281 | - } | |
275 | + public JCheckBox getprintform(){ | |
276 | + return printCheckBox; | |
277 | + } | |
282 | 278 | |
283 | - public boolean doPrint() { | |
284 | - return printSelected; | |
285 | - } | |
279 | + public boolean doPrint(){ | |
280 | + return printSelected; | |
281 | + } | |
286 | 282 | |
287 | - public JFreeChart getgraph(Second g_start, Second g_end) { | |
288 | - if (mygraph == null) { | |
289 | - mygraph = makegraph(g_start, g_end); | |
290 | - } else { | |
291 | - if (!axisofdate.getMaximumDate().equals(mysar.myparser.get_endofgraph().getEnd())) { | |
292 | - axisofdate.setMaximumDate(mysar.myparser.get_endofgraph().getEnd()); | |
293 | - } | |
294 | - if (!axisofdate.getMinimumDate().equals(mysar.myparser.get_startofgraph().getStart())) { | |
295 | - axisofdate.setMinimumDate(mysar.myparser.get_startofgraph().getStart()); | |
296 | - } | |
297 | - } | |
298 | - return mygraph; | |
299 | - } | |
283 | + public JFreeChart getgraph(Second g_start, Second g_end){ | |
284 | + if(mygraph == null){ | |
285 | + mygraph = makegraph(g_start, g_end); | |
286 | + }else{ | |
287 | + if(!axisofdate.getMaximumDate().equals(mysar.myparser.getEndOfGraph().getEnd())){ | |
288 | + axisofdate.setMaximumDate(mysar.myparser.getEndOfGraph().getEnd()); | |
289 | + } | |
290 | + if(!axisofdate.getMinimumDate().equals(mysar.myparser.getStartOfGraph().getStart())){ | |
291 | + axisofdate.setMinimumDate(mysar.myparser.getStartOfGraph().getStart()); | |
292 | + } | |
293 | + } | |
294 | + return mygraph; | |
295 | + } | |
300 | 296 | |
301 | - public String getTitle() { | |
302 | - return graphtitle; | |
303 | - } | |
297 | + public String getTitle(){ | |
298 | + return graphtitle; | |
299 | + } | |
304 | 300 | |
305 | - public boolean isPrintSelected() { | |
306 | - return printSelected; | |
307 | - } | |
301 | + public boolean isPrintSelected(){ | |
302 | + return printSelected; | |
303 | + } | |
308 | 304 | |
309 | - private XYDataset create_collection(ArrayList l) { | |
310 | - TimeSeriesCollection graphcollection = new TimeSeriesCollection(); | |
311 | - TimeSeries found = null; | |
312 | - boolean hasdata = false; | |
313 | - for (int i = 0; i < l.size(); i++) { | |
314 | - found = null; | |
315 | - for (int j = 0; j < Stats.size(); j++) { | |
316 | - found = (TimeSeries) Stats.get(j); | |
317 | - if (found.getKey().equals(l.get(i))) { | |
318 | - break; | |
319 | - } else { | |
320 | - found = null; | |
321 | - } | |
322 | - } | |
305 | + private XYDataset create_collection(ArrayList l){ | |
306 | + TimeSeriesCollection graphcollection = new TimeSeriesCollection(); | |
307 | + TimeSeries found = null; | |
308 | + boolean hasdata = false; | |
309 | + for(int i = 0; i < l.size(); i++){ | |
310 | + found = null; | |
311 | + for(int j = 0; j < Stats.size(); j++){ | |
312 | + found = (TimeSeries) Stats.get(j); | |
313 | + if(found.getKey().equals(l.get(i))){ | |
314 | + break; | |
315 | + }else{ | |
316 | + found = null; | |
317 | + } | |
318 | + } | |
323 | 319 | |
324 | - if (found != null) { | |
325 | - graphcollection.addSeries(found); | |
326 | - hasdata = true; | |
327 | - } | |
328 | - } | |
329 | - if (!hasdata) { | |
330 | - return null; | |
331 | - } | |
332 | - return graphcollection; | |
333 | - } | |
320 | + if(found != null){ | |
321 | + graphcollection.addSeries(found); | |
322 | + hasdata = true; | |
323 | + } | |
324 | + } | |
325 | + if(!hasdata){ | |
326 | + return null; | |
327 | + } | |
328 | + return graphcollection; | |
329 | + } | |
334 | 330 | |
335 | - public ChartPanel get_ChartPanel() { | |
336 | - if (chartpanel == null) { | |
337 | - if (mysar.isParsing()) { | |
338 | - chartpanel = new ChartPanel(getgraph(null, null)); | |
339 | - } else { | |
340 | - chartpanel = new ChartPanel(getgraph(mysar.myparser.get_startofgraph(), mysar.myparser.get_endofgraph())); | |
341 | - } | |
342 | - } else { | |
343 | - if (!mysar.isParsing()) { | |
344 | - if (!axisofdate.getMaximumDate().equals(mysar.myparser.get_endofgraph().getEnd())) { | |
345 | - axisofdate.setMaximumDate(mysar.myparser.get_endofgraph().getEnd()); | |
346 | - } | |
347 | - if (!axisofdate.getMinimumDate().equals(mysar.myparser.get_startofgraph().getStart())) { | |
348 | - axisofdate.setMinimumDate(mysar.myparser.get_startofgraph().getStart()); | |
349 | - } | |
350 | - } | |
351 | - } | |
352 | - return chartpanel; | |
353 | - } | |
331 | + public ChartPanel get_ChartPanel(){ | |
332 | + if(chartpanel == null){ | |
333 | + if(mysar.isParsing()){ | |
334 | + chartpanel = new ChartPanel(getgraph(null, null)); | |
335 | + }else{ | |
336 | + chartpanel = new ChartPanel(getgraph(mysar.myparser.getStartOfGraph(), mysar.myparser.getEndOfGraph())); | |
337 | + } | |
338 | + }else{ | |
339 | + if(!mysar.isParsing()){ | |
340 | + if(!axisofdate.getMaximumDate().equals(mysar.myparser.getEndOfGraph().getEnd())){ | |
341 | + axisofdate.setMaximumDate(mysar.myparser.getEndOfGraph().getEnd()); | |
342 | + } | |
343 | + if(!axisofdate.getMinimumDate().equals(mysar.myparser.getStartOfGraph().getStart())){ | |
344 | + axisofdate.setMinimumDate(mysar.myparser.getStartOfGraph().getStart()); | |
345 | + } | |
346 | + } | |
347 | + } | |
348 | + return chartpanel; | |
349 | + } | |
354 | 350 | |
355 | - private JFreeChart makegraph(Second g_start, Second g_end) { | |
356 | - long begingenerate = System.currentTimeMillis(); | |
351 | + private JFreeChart makegraph(Second g_start, Second g_end){ | |
352 | + long begingenerate = System.currentTimeMillis(); | |
357 | 353 | |
358 | - CombinedDomainXYPlot plot = new CombinedDomainXYPlot(axisofdate); | |
359 | - // do the stacked stuff | |
360 | - SortedSet<String> sortedset = new TreeSet<String>(graphconfig.getStacklist().keySet()); | |
361 | - Iterator<String> it = sortedset.iterator(); | |
362 | - while (it.hasNext()) { | |
363 | - StackConfig tmp = (StackConfig) graphconfig.getStacklist().get(it.next()); | |
364 | - if (tmp == null) { | |
365 | - continue; | |
366 | - } | |
367 | - TimeTableXYDataset tmp2 = StackListbyName.get(tmp.getTitle()); | |
354 | + CombinedDomainXYPlot plot = new CombinedDomainXYPlot(axisofdate); | |
355 | + // do the stacked stuff | |
356 | + SortedSet<String> sortedset = new TreeSet<String>(graphconfig.getStacklist().keySet()); | |
357 | + Iterator<String> it = sortedset.iterator(); | |
358 | + while(it.hasNext()){ | |
359 | + StackConfig tmp = (StackConfig) graphconfig.getStacklist().get(it.next()); | |
360 | + if(tmp == null){ | |
361 | + continue; | |
362 | + } | |
363 | + TimeTableXYDataset tmp2 = StackListbyName.get(tmp.getTitle()); | |
368 | 364 | |
369 | - if (tmp2 != null) { | |
370 | - StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2(); | |
371 | - NumberAxis graphaxistitle = tmp.getAxis(); | |
372 | - XYPlot temp_plot = new XYPlot(tmp2, axisofdate, graphaxistitle, renderer); | |
373 | - for (int i = 0; i < tmp2.getSeriesCount(); i++) { | |
374 | - Color color = GlobalOptions.getDataColor(tmp2.getSeriesKey(i).toString()); | |
375 | - if (color != null) { | |
376 | - renderer.setSeriesPaint(i, color); | |
377 | - renderer.setBaseStroke(new BasicStroke(1.0F)); | |
378 | - } | |
379 | - } | |
380 | - plot.add(temp_plot, tmp.getSize()); | |
381 | - } | |
382 | - } | |
383 | - // do the line stuff | |
384 | - sortedset = new TreeSet<String>(graphconfig.getPlotlist().keySet()); | |
385 | - it = sortedset.iterator(); | |
386 | - while (it.hasNext()) { | |
387 | - PlotConfig tmp = (PlotConfig) graphconfig.getPlotlist().get(it.next()); | |
388 | - XYItemRenderer renderer = new StandardXYItemRenderer(); | |
389 | - ArrayList<String> t = new ArrayList<String>(); | |
390 | - String[] s = tmp.getHeaderStr().split("\\s+"); | |
391 | - for (int i = 0; i < s.length; i++) { | |
392 | - t.add(s[i]); | |
393 | - } | |
394 | - XYDataset c = create_collection(t); | |
395 | - NumberAxis graphaxistitle = tmp.getAxis(); | |
396 | - XYPlot tmpplot = new XYPlot(c, axisofdate, graphaxistitle, renderer); | |
365 | + if(tmp2 != null){ | |
366 | + StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2(); | |
367 | + NumberAxis graphaxistitle = tmp.getAxis(); | |
368 | + XYPlot temp_plot = new XYPlot(tmp2, axisofdate, graphaxistitle, renderer); | |
369 | + for(int i = 0; i < tmp2.getSeriesCount(); i++){ | |
370 | + Color color = GlobalOptions.getDataColor(tmp2.getSeriesKey(i).toString()); | |
371 | + if(color != null){ | |
372 | + renderer.setSeriesPaint(i, color); | |
373 | + renderer.setBaseStroke(new BasicStroke(1.0F)); | |
374 | + } | |
375 | + } | |
376 | + plot.add(temp_plot, tmp.getSize()); | |
377 | + } | |
378 | + } | |
379 | + // do the line stuff | |
380 | + sortedset = new TreeSet<String>(graphconfig.getPlotlist().keySet()); | |
381 | + it = sortedset.iterator(); | |
382 | + while(it.hasNext()){ | |
383 | + PlotConfig tmp = (PlotConfig) graphconfig.getPlotlist().get(it.next()); | |
384 | + XYItemRenderer renderer = new StandardXYItemRenderer(); | |
385 | + ArrayList<String> t = new ArrayList<String>(); | |
386 | + String[] s = tmp.getHeaderStr().split("\\s+"); | |
387 | + for(int i = 0; i < s.length; i++){ | |
388 | + t.add(s[i]); | |
389 | + } | |
390 | + XYDataset c = create_collection(t); | |
391 | + NumberAxis graphaxistitle = tmp.getAxis(); | |
392 | + XYPlot tmpplot = new XYPlot(c, axisofdate, graphaxistitle, renderer); | |
397 | 393 | |
398 | - if (tmpplot == null) { | |
399 | - continue; | |
400 | - } | |
401 | - for (int i = 0; i < s.length; i++) { | |
402 | - Color color = GlobalOptions.getDataColor(s[i].toString()); | |
403 | - if (color != null) { | |
404 | - renderer.setSeriesPaint(i, color); | |
405 | - renderer.setBaseStroke(new BasicStroke(1.0F)); | |
406 | - } | |
407 | - } | |
408 | - plot.add(tmpplot, tmp.getSize()); | |
409 | - } | |
410 | - if (plot.getSubplots().isEmpty()) { | |
411 | - return null; | |
412 | - } | |
413 | - if (g_start != null && g_end != null) { | |
414 | - axisofdate.setRange(g_start.getStart(), g_end.getEnd()); | |
415 | - } | |
394 | + if(tmpplot == null){ | |
395 | + continue; | |
396 | + } | |
397 | + for(int i = 0; i < s.length; i++){ | |
398 | + Color color = GlobalOptions.getDataColor(s[i].toString()); | |
399 | + if(color != null){ | |
400 | + renderer.setSeriesPaint(i, color); | |
401 | + renderer.setBaseStroke(new BasicStroke(1.0F)); | |
402 | + } | |
403 | + } | |
404 | + plot.add(tmpplot, tmp.getSize()); | |
405 | + } | |
406 | + if(plot.getSubplots().isEmpty()){ | |
407 | + return null; | |
408 | + } | |
409 | + if(g_start != null && g_end != null){ | |
410 | + axisofdate.setRange(g_start.getStart(), g_end.getEnd()); | |
411 | + } | |
416 | 412 | |
417 | - plot.setOrientation(PlotOrientation.VERTICAL); | |
418 | - JFreeChart mychart = new JFreeChart(graphtitle, Config.getDEFAULT_FONT(), plot, true); | |
419 | - long endgenerate = System.currentTimeMillis(); | |
420 | - mychart.setBackgroundPaint(Color.white); | |
421 | - if (GlobalOptions.isDodebug()) { | |
422 | - System.out.println("graph generation: " + (endgenerate - begingenerate) + " ms"); | |
423 | - } | |
424 | - return mychart; | |
425 | - } | |
426 | - private DateAxis axisofdate = new DateAxis(""); | |
427 | - private KSar mysar = null; | |
428 | - private JFreeChart mygraph = null; | |
429 | - private ChartPanel chartpanel = null; | |
430 | - private String graphtitle = null; | |
431 | - public boolean printSelected = true; | |
432 | - private JCheckBox printCheckBox = null; | |
433 | - private GraphConfig graphconfig = null; | |
434 | - private int skipColumn = 0; | |
435 | - private String[] HeaderStr = null; | |
436 | - private ArrayList<TimeSeries> Stats = new ArrayList<TimeSeries>(); | |
437 | - private Map<String, TimeTableXYDataset> StackListbyName = new HashMap<String, TimeTableXYDataset>(); | |
438 | - private Map<String, TimeTableXYDataset> StackListbyCol = new HashMap<String, TimeTableXYDataset>(); | |
413 | + plot.setOrientation(PlotOrientation.VERTICAL); | |
414 | + JFreeChart mychart = new JFreeChart(graphtitle, Config.getDEFAULT_FONT(), plot, true); | |
415 | + long endgenerate = System.currentTimeMillis(); | |
416 | + mychart.setBackgroundPaint(Color.white); | |
417 | + if(GlobalOptions.isDodebug()){ | |
418 | + System.out.println("graph generation: " + (endgenerate - begingenerate) + " ms"); | |
419 | + } | |
420 | + return mychart; | |
421 | + } | |
422 | + private DateAxis axisofdate = new DateAxis(""); | |
423 | + private KSar mysar = null; | |
424 | + private JFreeChart mygraph = null; | |
425 | + private ChartPanel chartpanel = null; | |
426 | + private String graphtitle = null; | |
427 | + public boolean printSelected = true; | |
428 | + private JCheckBox printCheckBox = null; | |
429 | + private GraphConfig graphconfig = null; | |
430 | + private int skipColumn = 0; | |
431 | + private String[] HeaderStr = null; | |
432 | + private ArrayList<TimeSeries> Stats = new ArrayList<TimeSeries>(); | |
433 | + private Map<String, TimeTableXYDataset> StackListbyName = new HashMap<String, TimeTableXYDataset>(); | |
434 | + private Map<String, TimeTableXYDataset> StackListbyCol = new HashMap<String, TimeTableXYDataset>(); | |
439 | 435 | } |
@@ -1,11 +1,6 @@ | ||
1 | -/* | |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | 1 | package net.atomique.ksar; |
6 | 2 | |
7 | 3 | import java.awt.event.ActionEvent; |
8 | -import java.awt.event.ActionListener; | |
9 | 4 | import java.util.ResourceBundle; |
10 | 5 | import java.util.logging.Level; |
11 | 6 | import java.util.logging.Logger; |
@@ -26,51 +21,40 @@ | ||
26 | 21 | static GlobalOptions globaloptions = null; |
27 | 22 | static ResourceBundle resource = ResourceBundle.getBundle("net/atomique/ksar/Language/Message"); |
28 | 23 | |
29 | - ; | |
30 | - | |
31 | - public static void usage() { | |
24 | + public static void usage(){ | |
32 | 25 | show_version(); |
33 | 26 | } |
34 | 27 | |
35 | - public static void show_version() { | |
28 | + public static void show_version(){ | |
36 | 29 | System.err.println("ksar Version : " + VersionNumber.getVersionNumber()); |
37 | 30 | } |
38 | 31 | |
39 | - private static void set_lookandfeel() { | |
40 | - for (UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) { | |
41 | - if (Config.getLandf().equals(laf.getName())) { | |
42 | - try { | |
32 | + private static void set_lookandfeel(){ | |
33 | + for(UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()){ | |
34 | + if(Config.getLandf().equals(laf.getName())){ | |
35 | + try{ | |
43 | 36 | UIManager.setLookAndFeel(laf.getClassName()); |
44 | - } catch (ClassNotFoundException ex) { | |
37 | + }catch(ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex){ | |
45 | 38 | Logger.getLogger(Desktop.class.getName()).log(Level.SEVERE, null, ex); |
46 | - } catch (InstantiationException ex) { | |
47 | - Logger.getLogger(Desktop.class.getName()).log(Level.SEVERE, null, ex); | |
48 | - } catch (IllegalAccessException ex) { | |
49 | - Logger.getLogger(Desktop.class.getName()).log(Level.SEVERE, null, ex); | |
50 | - } catch (UnsupportedLookAndFeelException ex) { | |
51 | - Logger.getLogger(Desktop.class.getName()).log(Level.SEVERE, null, ex); | |
52 | 39 | } |
53 | 40 | } |
54 | 41 | } |
55 | 42 | } |
56 | 43 | |
57 | - public static void make_ui() { | |
44 | + public static void make_ui(){ | |
58 | 45 | final SplashScreen mysplash = new SplashScreen(null, 1000); |
59 | 46 | |
60 | -// while (mysplash.isVisible()) { | |
61 | -// try { | |
47 | +// while(mysplash.isVisible()){ | |
48 | +// try{ | |
62 | 49 | // Thread.sleep(500); sleep in loop warning. Swing is single threaded. Calling Thread.sleep in the EDT prevents UI updates. |
63 | -// } catch (InterruptedException ie) { | |
50 | +// }catch(InterruptedException ie){ | |
64 | 51 | // ie.printStackTrace(System.out); |
65 | 52 | // } |
66 | 53 | // } |
67 | - Timer timer = new Timer(500, new ActionListener() { | |
68 | - @Override | |
69 | - public void actionPerformed(ActionEvent e) { | |
70 | - if( !mysplash.isVisible() ){ | |
71 | - Timer timer = (Timer) e.getSource(); | |
72 | - timer.stop(); | |
73 | - } | |
54 | + Timer timer = new Timer(500, (ActionEvent e)->{ | |
55 | + if(!mysplash.isVisible()){ | |
56 | + Timer timer1 = (Timer) e.getSource(); | |
57 | + timer1.stop(); | |
74 | 58 | } |
75 | 59 | }); |
76 | 60 | timer.setRepeats(true); |
@@ -77,25 +61,21 @@ | ||
77 | 61 | timer.start(); |
78 | 62 | |
79 | 63 | set_lookandfeel(); |
80 | - javax.swing.SwingUtilities.invokeLater(new Runnable() { | |
81 | - | |
82 | - @Override | |
83 | - public void run() { | |
84 | - GlobalOptions.setUI(new Desktop()); | |
85 | - SwingUtilities.updateComponentTreeUI(GlobalOptions.getUI()); | |
86 | - GlobalOptions.getUI().add_window(); | |
87 | - GlobalOptions.getUI().maxall(); | |
88 | - } | |
64 | + javax.swing.SwingUtilities.invokeLater(()->{ | |
65 | + GlobalOptions.setUI(new Desktop()); | |
66 | + SwingUtilities.updateComponentTreeUI(GlobalOptions.getUI()); | |
67 | + GlobalOptions.getUI().add_window(); | |
68 | + GlobalOptions.getUI().maxall(); | |
89 | 69 | }); |
90 | 70 | |
91 | 71 | } |
92 | 72 | |
93 | - public static void main(String[] args) { | |
73 | + public static void main(String[] args){ | |
94 | 74 | int i = 0; |
95 | 75 | String arg; |
96 | 76 | /// load default |
97 | 77 | String mrjVersion = System.getProperty("mrj.version"); |
98 | - if (mrjVersion != null) { | |
78 | + if(mrjVersion != null){ | |
99 | 79 | System.setProperty("com.apple.mrj.application.growbox.intrudes", "false"); |
100 | 80 | System.setProperty("com.apple.mrj.application.apple.menu.about.name", "kSar"); |
101 | 81 | System.setProperty("apple.laf.useScreenMenuBar", "true"); |
@@ -104,27 +84,25 @@ | ||
104 | 84 | config = Config.getInstance(); |
105 | 85 | globaloptions = GlobalOptions.getInstance(); |
106 | 86 | |
107 | - | |
108 | - | |
109 | - if (args.length > 0) { | |
110 | - while (i < args.length && args[i].startsWith("-")) { | |
87 | + if(args.length > 0){ | |
88 | + while(i < args.length && args[i].startsWith("-")){ | |
111 | 89 | arg = args[i++]; |
112 | - if ("-version".equals(arg)) { | |
90 | + if("-version".equals(arg)){ | |
113 | 91 | show_version(); |
114 | 92 | System.exit(0); |
115 | 93 | } |
116 | - if ("-help".equals(arg)) { | |
94 | + if("-help".equals(arg)){ | |
117 | 95 | usage(); |
118 | 96 | continue; |
119 | 97 | } |
120 | - if ("-test".equals(arg)) { | |
98 | + if("-test".equals(arg)){ | |
121 | 99 | GlobalOptions.setDodebug(true); |
122 | 100 | continue; |
123 | 101 | } |
124 | - if ("-input".equals(arg)) { | |
125 | - if (i < args.length) { | |
102 | + if("-input".equals(arg)){ | |
103 | + if(i < args.length){ | |
126 | 104 | GlobalOptions.setCLfilename(args[i++]); |
127 | - } else { | |
105 | + }else{ | |
128 | 106 | exit_error(resource.getString("INPUT_REQUIRE_ARG")); |
129 | 107 | } |
130 | 108 | //continue; //last, unecessary |
@@ -137,7 +115,7 @@ | ||
137 | 115 | System.out.println("exit"); |
138 | 116 | } |
139 | 117 | |
140 | - public static void exit_error(final String message) { | |
118 | + public static void exit_error(final String message){ | |
141 | 119 | System.err.println(message); |
142 | 120 | System.exit(1); |
143 | 121 | } |
@@ -1,8 +1,3 @@ | ||
1 | -/* | |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | - | |
6 | 1 | package net.atomique.ksar; |
7 | 2 | |
8 | 3 | import java.text.ParseException; |
@@ -18,7 +13,33 @@ | ||
18 | 13 | * @author alex |
19 | 14 | */ |
20 | 15 | public abstract class AllParser{ |
16 | + protected Second startofstat = null; | |
17 | + protected Second endofstat = null; | |
18 | + protected String sarStartDate = null; | |
19 | + protected String sarEndDate = null; | |
21 | 20 | |
21 | + protected Second startofgraph = null; | |
22 | + protected Second endofgraph =null; | |
23 | + protected TreeSet<Second> DateSamples = new TreeSet<>(); | |
24 | + | |
25 | + abstract public String getInfo(); | |
26 | + abstract public void parse_header(String s); | |
27 | + abstract public void updateUITitle(); | |
28 | + | |
29 | + protected KSar mysar = null; | |
30 | + protected OSConfig osConfig = null; | |
31 | + protected String parserName = null; | |
32 | + | |
33 | + protected Calendar cal = Calendar.getInstance(); | |
34 | + protected Date parseTime = null; | |
35 | + protected int year = 0; | |
36 | + protected int month = 0; | |
37 | + protected int day = 0; | |
38 | + protected String currentStat = "NONE"; | |
39 | + protected String dateFormat = "MM/dd/yy"; | |
40 | + protected String timeFormat = "HH:mm:ss"; | |
41 | + protected int firstValueColumnIndex = 1; | |
42 | + | |
22 | 43 | public AllParser(){ |
23 | 44 | } |
24 | 45 |
@@ -25,12 +46,12 @@ | ||
25 | 46 | public void init(KSar hissar, String header){ |
26 | 47 | String [] s = header.split("\\s+"); |
27 | 48 | mysar = hissar; |
28 | - ParserName = s[0]; | |
49 | + parserName = s[0]; | |
29 | 50 | parse_header(header); |
30 | 51 | } |
31 | - | |
52 | + private void _init_(KSar hissar, String header){init(hissar, header);} | |
32 | 53 | public AllParser(KSar hissar, String header){ |
33 | - init(hissar, header); | |
54 | + _init_(hissar, header); | |
34 | 55 | } |
35 | 56 | |
36 | 57 | public int parse(String line, String[] columns){ |
@@ -38,15 +59,15 @@ | ||
38 | 59 | return -1; |
39 | 60 | } |
40 | 61 | |
41 | - public Second get_startofgraph(){ | |
62 | + public Second getStartOfGraph(){ | |
42 | 63 | return startofgraph; |
43 | 64 | } |
44 | - public Second get_endofgraph(){ | |
65 | + public Second getEndOfGraph(){ | |
45 | 66 | return endofgraph; |
46 | 67 | } |
47 | 68 | |
48 | 69 | public String getParserName(){ |
49 | - return ParserName; | |
70 | + return parserName; | |
50 | 71 | } |
51 | 72 | |
52 | 73 | public boolean setDate(String s){ |
@@ -54,28 +75,29 @@ | ||
54 | 75 | Date dateSimple2; |
55 | 76 | Date dateSimple3; |
56 | 77 | |
57 | - if (sarStartDate == null){ | |
78 | + if(sarStartDate == null){ | |
58 | 79 | sarStartDate = s; |
59 | 80 | } |
60 | - if (sarEndDate == null){ | |
81 | + if(sarEndDate == null){ | |
61 | 82 | sarEndDate = s; |
62 | 83 | } |
63 | 84 | |
64 | - try { | |
65 | - dateSimple1 = new SimpleDateFormat(dateFormat).parse(s); | |
85 | + try{ | |
86 | + dateSimple1 = new SimpleDateFormat(dateFormat).parse(s); | |
66 | 87 | cal.setTime(dateSimple1); |
67 | - day=cal.get(Calendar.DAY_OF_MONTH); | |
68 | - month=cal.get(Calendar.MONTH)+1; | |
69 | - year=cal.get(Calendar.YEAR); | |
88 | + year = cal.get(Calendar.YEAR); | |
89 | + month = cal.get(Calendar.MONTH)+1; | |
90 | + day = cal.get(Calendar.DAY_OF_MONTH); | |
70 | 91 | dateSimple2 = new SimpleDateFormat(dateFormat).parse(sarStartDate); |
71 | 92 | dateSimple3 = new SimpleDateFormat(dateFormat).parse(sarEndDate); |
72 | - } catch (ParseException e){ | |
93 | + }catch(ParseException e){ | |
73 | 94 | return false; |
74 | 95 | } |
75 | - if (dateSimple1.compareTo(dateSimple2) < 0){ | |
96 | + | |
97 | + if(dateSimple1.compareTo(dateSimple2) < 0){ | |
76 | 98 | sarStartDate = s; |
77 | 99 | } |
78 | - if (dateSimple1.compareTo(dateSimple3) > 0){ | |
100 | + if(dateSimple1.compareTo(dateSimple3) > 0){ | |
79 | 101 | sarEndDate = s; |
80 | 102 | } |
81 | 103 | return true; |
@@ -82,9 +104,9 @@ | ||
82 | 104 | } |
83 | 105 | |
84 | 106 | public String getDate(){ |
85 | - if (sarStartDate.equals(sarEndDate)){ | |
107 | + if(sarStartDate.equals(sarEndDate)){ | |
86 | 108 | return sarStartDate; |
87 | - } else { | |
109 | + }else{ | |
88 | 110 | return sarStartDate + " to " + sarEndDate; |
89 | 111 | } |
90 | 112 | } |
@@ -96,33 +118,4 @@ | ||
96 | 118 | public String getCurrentStat(){ |
97 | 119 | return currentStat; |
98 | 120 | } |
99 | - | |
100 | - | |
101 | - protected Second startofstat = null; | |
102 | - protected Second endofstat = null; | |
103 | - protected String sarStartDate = null; | |
104 | - protected String sarEndDate = null; | |
105 | - | |
106 | - protected Second startofgraph = null; | |
107 | - protected Second endofgraph =null; | |
108 | - protected TreeSet<Second> DateSamples = new TreeSet<Second>(); | |
109 | - protected int firstdatacolumn =0; | |
110 | - | |
111 | - abstract public String getInfo(); | |
112 | - abstract public void parse_header(String s); | |
113 | - abstract public void updateUITitle(); | |
114 | - | |
115 | - protected KSar mysar = null; | |
116 | - protected OSConfig myosconfig = null; | |
117 | - protected String ParserName = null; | |
118 | - | |
119 | - protected Calendar cal=Calendar.getInstance(); | |
120 | - protected Date parsedate = null; | |
121 | - protected int day = 0; | |
122 | - protected int month = 0; | |
123 | - protected int year = 0; | |
124 | - protected String currentStat = "NONE"; | |
125 | - protected String dateFormat = "MM/dd/yy"; | |
126 | - protected String timeFormat = "HH:mm:ss"; | |
127 | - protected int timeColumn = 1; | |
128 | 121 | } |
@@ -1,7 +1,3 @@ | ||
1 | -/* | |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | 1 | package net.atomique.ksar; |
6 | 2 | |
7 | 3 | import java.io.IOException; |
@@ -35,12 +31,12 @@ | ||
35 | 31 | */ |
36 | 32 | public class XMLConfig extends DefaultHandler { |
37 | 33 | |
38 | - public XMLConfig(String filename) { | |
34 | + public XMLConfig(String filename){ | |
39 | 35 | load_config(filename); |
40 | 36 | |
41 | 37 | } |
42 | 38 | |
43 | - public XMLConfig(InputStream is) { | |
39 | + public XMLConfig(InputStream is){ | |
44 | 40 | load_config(is); |
45 | 41 | } |
46 | 42 |
@@ -47,11 +43,11 @@ | ||
47 | 43 | public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { |
48 | 44 | |
49 | 45 | InputSource inputSource = null; |
50 | - try { | |
46 | + try{ | |
51 | 47 | String dtdFile = systemId.substring(systemId.lastIndexOf("/")); |
52 | 48 | InputStream inputStream = EntityResolver.class.getResourceAsStream(dtdFile); |
53 | 49 | inputSource = new InputSource(inputStream); |
54 | - } catch (Exception e) { | |
50 | + }catch(Exception e){ | |
55 | 51 | // No action; just let the null InputSource pass through |
56 | 52 | } |
57 | 53 |
@@ -59,58 +55,58 @@ | ||
59 | 55 | return inputSource; |
60 | 56 | } |
61 | 57 | |
62 | - public void load_config(InputStream is) { | |
58 | + public void load_config(InputStream is){ | |
63 | 59 | SAXParserFactory fabric = null; |
64 | 60 | SAXParser parser = null; |
65 | 61 | XMLReader reader = null; |
66 | - try { | |
62 | + try{ | |
67 | 63 | fabric = SAXParserFactory.newInstance(); |
68 | 64 | parser = fabric.newSAXParser(); |
69 | 65 | parser.parse(is, this); |
70 | 66 | |
71 | - } catch (ParserConfigurationException ex) { | |
67 | + }catch(ParserConfigurationException ex){ | |
72 | 68 | ex.printStackTrace(); |
73 | - } catch (SAXException ex) { | |
69 | + }catch(SAXException ex){ | |
74 | 70 | ex.printStackTrace(); |
75 | - } catch (IOException ioe) { | |
71 | + }catch(IOException ioe){ | |
76 | 72 | ioe.printStackTrace(); |
77 | 73 | System.exit(1); |
78 | 74 | } |
79 | 75 | //dump_XML(); |
80 | - try { | |
76 | + try{ | |
81 | 77 | is.close(); |
82 | - } catch (IOException ex) { | |
78 | + }catch(IOException ex){ | |
83 | 79 | Logger.getLogger(XMLConfig.class.getName()).log(Level.SEVERE, null, ex); |
84 | 80 | } |
85 | 81 | } |
86 | 82 | |
87 | - public void load_config(String xmlfile) { | |
83 | + public void load_config(String xmlfile){ | |
88 | 84 | SAXParserFactory fabric = null; |
89 | 85 | SAXParser parser = null; |
90 | - try { | |
86 | + try{ | |
91 | 87 | fabric = SAXParserFactory.newInstance(); |
92 | 88 | parser = fabric.newSAXParser(); |
93 | 89 | parser.parse(xmlfile, this); |
94 | 90 | |
95 | - } catch (ParserConfigurationException ex) { | |
91 | + }catch(ParserConfigurationException ex){ | |
96 | 92 | ex.printStackTrace(); |
97 | - } catch (SAXException ex) { | |
93 | + }catch(SAXException ex){ | |
98 | 94 | ex.printStackTrace(); |
99 | - } catch (IOException ioe) { | |
95 | + }catch(IOException ioe){ | |
100 | 96 | ioe.printStackTrace(); |
101 | 97 | } |
102 | 98 | |
103 | 99 | } |
104 | 100 | |
105 | - public void dump_XML() { | |
101 | + public void dump_XML(){ | |
106 | 102 | SortedSet<String> sortedset = new TreeSet<String>(GlobalOptions.getOSlist().keySet()); |
107 | 103 | Iterator<String> it = sortedset.iterator(); |
108 | - while (it.hasNext()) { | |
104 | + while(it.hasNext()){ | |
109 | 105 | OSConfig tmp = (OSConfig) GlobalOptions.getOSlist().get(it.next()); |
110 | 106 | System.out.println("-OS-" + tmp.getOSname()); |
111 | 107 | SortedSet<String> sortedset2 = new TreeSet<String>(tmp.getStatHash().keySet()); |
112 | 108 | Iterator<String> it2 = sortedset2.iterator(); |
113 | - while (it2.hasNext()) { | |
109 | + while(it2.hasNext()){ | |
114 | 110 | StatConfig tmp2 = (StatConfig) tmp.getStatHash().get(it2.next()); |
115 | 111 | System.out.println("--STAT-- " |
116 | 112 | + tmp2.getStatName() + "=> " |
@@ -119,7 +115,7 @@ | ||
119 | 115 | } |
120 | 116 | SortedSet<String> sortedset3 = new TreeSet<String>(tmp.getGraphHash().keySet()); |
121 | 117 | Iterator<String> it3 = sortedset3.iterator(); |
122 | - while (it3.hasNext()) { | |
118 | + while(it3.hasNext()){ | |
123 | 119 | GraphConfig tmp3 = (GraphConfig) tmp.getGraphHash().get(it3.next()); |
124 | 120 | System.out.println("---GRAPH--- " |
125 | 121 | + tmp3.getName() + "=> " |
@@ -126,7 +122,7 @@ | ||
126 | 122 | + tmp3.getTitle()); |
127 | 123 | SortedSet<String> sortedset4 = new TreeSet<String>(tmp3.getPlotlist().keySet()); |
128 | 124 | Iterator<String> it4 = sortedset4.iterator(); |
129 | - while (it4.hasNext()) { | |
125 | + while(it4.hasNext()){ | |
130 | 126 | PlotConfig tmp4 = (PlotConfig) tmp3.getPlotlist().get(it4.next()); |
131 | 127 | System.out.println("----PLOT---- " |
132 | 128 | + tmp4.getTitle() + "=> " |
@@ -144,27 +140,27 @@ | ||
144 | 140 | |
145 | 141 | public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { |
146 | 142 | |
147 | - if ("ConfiG".equals(qName)) { | |
143 | + if("ConfiG".equals(qName)){ | |
148 | 144 | // config found |
149 | 145 | } |
150 | - if ("colors".equals(qName)) { | |
146 | + if("colors".equals(qName)){ | |
151 | 147 | in_colors = true; |
152 | 148 | } |
153 | - if ("OS".equals(qName)) { | |
149 | + if("OS".equals(qName)){ | |
154 | 150 | in_OS = true; |
155 | 151 | } |
156 | 152 | |
157 | - if ("History".equals(qName)) { | |
153 | + if("History".equals(qName)){ | |
158 | 154 | in_history = true; |
159 | 155 | } |
160 | 156 | |
161 | - if ( "HostInfo".equals(qName)) { | |
157 | + if( "HostInfo".equals(qName)){ | |
162 | 158 | in_hostinfo=true; |
163 | 159 | } |
164 | 160 | |
165 | 161 | // COLORS |
166 | - if (in_colors) { | |
167 | - if ("itemcolor".equals(qName)) { | |
162 | + if(in_colors){ | |
163 | + if("itemcolor".equals(qName)){ | |
168 | 164 | currentColor = new ColumnConfig(attributes.getValue("name")); |
169 | 165 | in_color = true; |
170 | 166 | } |
@@ -171,15 +167,15 @@ | ||
171 | 167 | } |
172 | 168 | |
173 | 169 | // history |
174 | - if (in_history) { | |
175 | - if ("cnx".equals(qName)) { | |
170 | + if(in_history){ | |
171 | + if("cnx".equals(qName)){ | |
176 | 172 | currentCnx = new CnxHistory(attributes.getValue("link")); |
177 | 173 | in_cnx = true; |
178 | 174 | } |
179 | 175 | } |
180 | 176 | // hostinfo |
181 | - if (in_hostinfo) { | |
182 | - if ("host".equals(qName)) { | |
177 | + if(in_hostinfo){ | |
178 | + if("host".equals(qName)){ | |
183 | 179 | currentHost = new HostInfo(attributes.getValue("name")); |
184 | 180 | in_host=true; |
185 | 181 | } |
@@ -186,49 +182,49 @@ | ||
186 | 182 | } |
187 | 183 | |
188 | 184 | // OS |
189 | - if (in_OS) { | |
190 | - if ("OSType".equals(qName)) { | |
185 | + if(in_OS){ | |
186 | + if("OSType".equals(qName)){ | |
191 | 187 | currentOS = GlobalOptions.getOSlist().get(attributes.getValue("name")); |
192 | - if (currentOS == null) { | |
188 | + if(currentOS == null){ | |
193 | 189 | currentOS = new OSConfig(attributes.getValue("name")); |
194 | 190 | GlobalOptions.getOSlist().put(currentOS.getOSname(), currentOS); |
195 | 191 | } |
196 | 192 | } |
197 | - if (currentOS != null) { | |
198 | - if ("Stat".equals(qName)) { | |
193 | + if(currentOS != null){ | |
194 | + if("Stat".equals(qName)){ | |
199 | 195 | currentStat = new StatConfig(attributes.getValue("name")); |
200 | 196 | currentOS.addStat(currentStat); |
201 | 197 | } |
202 | - if ("Graph".equals(qName)) { | |
198 | + if("Graph".equals(qName)){ | |
203 | 199 | currentGraph = new GraphConfig(attributes.getValue("name"), attributes.getValue("Title"), attributes.getValue("type")); |
204 | 200 | currentOS.addGraph(currentGraph); |
205 | 201 | } |
206 | - if (currentGraph != null) { | |
207 | - if ("Plot".equals(qName)) { | |
202 | + if(currentGraph != null){ | |
203 | + if("Plot".equals(qName)){ | |
208 | 204 | currentPlot = new PlotConfig(attributes.getValue("Title")); |
209 | 205 | String size_tmp = attributes.getValue("size"); |
210 | - if (size_tmp != null) { | |
206 | + if(size_tmp != null){ | |
211 | 207 | currentPlot.setSize(size_tmp); |
212 | 208 | } |
213 | 209 | currentGraph.addPlot(currentPlot); |
214 | 210 | } |
215 | - if ("Stack".equals(qName)) { | |
211 | + if("Stack".equals(qName)){ | |
216 | 212 | currentStack = new StackConfig(attributes.getValue("Title")); |
217 | 213 | String size_tmp = attributes.getValue("size"); |
218 | - if (size_tmp != null) { | |
214 | + if(size_tmp != null){ | |
219 | 215 | currentStack.setSize(size_tmp); |
220 | 216 | } |
221 | 217 | currentGraph.addStack(currentStack); |
222 | 218 | } |
223 | 219 | |
224 | - if (currentPlot != null) { | |
225 | - if ("format".equals(qName)) { | |
220 | + if(currentPlot != null){ | |
221 | + if("format".equals(qName)){ | |
226 | 222 | currentPlot.setBase(attributes.getValue("base")); |
227 | 223 | currentPlot.setFactor(attributes.getValue("factor")); |
228 | 224 | } |
229 | 225 | } |
230 | - if (currentStack != null) { | |
231 | - if ("format".equals(qName)) { | |
226 | + if(currentStack != null){ | |
227 | + if("format".equals(qName)){ | |
232 | 228 | currentStack.setBase(attributes.getValue("base")); |
233 | 229 | currentStack.setFactor(attributes.getValue("factor")); |
234 | 230 | } |
@@ -243,71 +239,71 @@ | ||
243 | 239 | |
244 | 240 | // clean up tempval; |
245 | 241 | tempval = tempval.trim(); |
246 | - if ("ConfiG".equals(qName)) { | |
242 | + if("ConfiG".equals(qName)){ | |
247 | 243 | beenparse = true; |
248 | 244 | } |
249 | - if ("colors".equals(qName)) { | |
245 | + if("colors".equals(qName)){ | |
250 | 246 | in_colors = false; |
251 | 247 | } |
252 | - if ("OSType".equals(qName)) { | |
248 | + if("OSType".equals(qName)){ | |
253 | 249 | currentOS = null; |
254 | 250 | } |
255 | - if ("Stat".equals(qName)) { | |
251 | + if("Stat".equals(qName)){ | |
256 | 252 | currentStat = null; |
257 | 253 | } |
258 | - if ("Graph".equals(qName)) { | |
254 | + if("Graph".equals(qName)){ | |
259 | 255 | currentGraph = null; |
260 | 256 | } |
261 | - if ("Cnx".equals(qName)) { | |
257 | + if("Cnx".equals(qName)){ | |
262 | 258 | currentCnx = null; |
263 | 259 | } |
264 | - if ("Plot".equals(qName)) { | |
260 | + if("Plot".equals(qName)){ | |
265 | 261 | currentPlot = null; |
266 | 262 | } |
267 | - if ("Stack".equals(qName)) { | |
263 | + if("Stack".equals(qName)){ | |
268 | 264 | currentStack = null; |
269 | 265 | } |
270 | - if ("HostInfo".equals(qName)) { | |
266 | + if("HostInfo".equals(qName)){ | |
271 | 267 | in_hostinfo = false; |
272 | 268 | } |
273 | 269 | |
274 | 270 | |
275 | 271 | |
276 | - if (currentStat != null) { | |
277 | - if ("headerstr".equals(qName)) { | |
272 | + if(currentStat != null){ | |
273 | + if("headerstr".equals(qName)){ | |
278 | 274 | currentStat.setHeaderStr(tempval); |
279 | 275 | } |
280 | - if ("graphname".equals(qName)) { | |
276 | + if("graphname".equals(qName)){ | |
281 | 277 | currentStat.setGraphName(tempval); |
282 | 278 | } |
283 | - if ("duplicate".equals(qName)) { | |
279 | + if("duplicate".equals(qName)){ | |
284 | 280 | currentStat.setDuplicateTime(tempval); |
285 | 281 | } |
286 | 282 | } |
287 | 283 | |
288 | - if ("cols".equals(qName)) { | |
289 | - if (currentPlot != null) { | |
284 | + if("cols".equals(qName)){ | |
285 | + if(currentPlot != null){ | |
290 | 286 | currentPlot.setHeaderStr(tempval); |
291 | 287 | |
292 | 288 | } |
293 | - if (currentStack != null) { | |
289 | + if(currentStack != null){ | |
294 | 290 | currentStack.setHeaderStr(tempval); |
295 | 291 | } |
296 | 292 | } |
297 | - if ("range".equals(qName)) { | |
298 | - if (currentPlot != null) { | |
293 | + if("range".equals(qName)){ | |
294 | + if(currentPlot != null){ | |
299 | 295 | currentPlot.setRange(tempval); |
300 | 296 | |
301 | 297 | } |
302 | - if (currentStack != null) { | |
298 | + if(currentStack != null){ | |
303 | 299 | currentStack.setRange(tempval); |
304 | 300 | } |
305 | 301 | } |
306 | 302 | |
307 | - if ("itemcolor".equals(qName)) { | |
308 | - if (currentColor.is_valid()){ | |
303 | + if("itemcolor".equals(qName)){ | |
304 | + if(currentColor.is_valid()){ | |
309 | 305 | GlobalOptions.setColumnConfig(currentColor.getData_title(), currentColor); |
310 | - } else { | |
306 | + }else{ | |
311 | 307 | System.err.println("Err: " + currentColor.getError_message()); |
312 | 308 | currentColor = null; |
313 | 309 | } |
@@ -314,37 +310,37 @@ | ||
314 | 310 | in_color = false; |
315 | 311 | } |
316 | 312 | |
317 | - if (in_color) { | |
318 | - if ("color".equals(qName) && currentColor != null) { | |
313 | + if(in_color){ | |
314 | + if("color".equals(qName) && currentColor != null){ | |
319 | 315 | currentColor.setData_color(tempval); |
320 | 316 | } |
321 | 317 | } |
322 | 318 | |
323 | - if (in_cnx) { | |
324 | - if ("command".equals(qName) && currentCnx != null) { | |
319 | + if(in_cnx){ | |
320 | + if("command".equals(qName) && currentCnx != null){ | |
325 | 321 | currentCnx.addCommand(tempval); |
326 | 322 | } |
327 | 323 | } |
328 | - if ("cnx".equals(qName)) { | |
329 | - if (currentCnx.isValid()) { | |
324 | + if("cnx".equals(qName)){ | |
325 | + if(currentCnx.isValid()){ | |
330 | 326 | GlobalOptions.getHistoryList().put(currentCnx.getLink(), currentCnx); |
331 | - } else { | |
327 | + }else{ | |
332 | 328 | System.err.println("Err cnx is not valid"); |
333 | 329 | currentCnx = null; |
334 | 330 | } |
335 | 331 | } |
336 | - if ( in_hostinfo ) { | |
337 | - if ( "alias".equals(qName)) { | |
332 | + if( in_hostinfo ){ | |
333 | + if( "alias".equals(qName)){ | |
338 | 334 | currentHost.setAlias(tempval); |
339 | 335 | } |
340 | - if ( "description".equals(qName)) { | |
336 | + if( "description".equals(qName)){ | |
341 | 337 | currentHost.setDescription(tempval); |
342 | 338 | } |
343 | - if ( "memblocksize".equals(qName)) { | |
339 | + if( "memblocksize".equals(qName)){ | |
344 | 340 | currentHost.setMemBlockSize(tempval); |
345 | 341 | } |
346 | 342 | } |
347 | - if ( "host".equals(qName)) { | |
343 | + if( "host".equals(qName)){ | |
348 | 344 | GlobalOptions.getHostInfoList().put(currentHost.getHostname(), currentHost); |
349 | 345 | currentHost=null; |
350 | 346 | } |
@@ -1,7 +1,3 @@ | ||
1 | -/* | |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | 1 | package net.atomique.ksar; |
6 | 2 | |
7 | 3 | import java.io.BufferedReader; |
@@ -20,89 +16,89 @@ | ||
20 | 16 | * @author Max |
21 | 17 | */ |
22 | 18 | public class LocalCommand extends Thread implements DataCommandImpl{ |
23 | - private KSar mysar = null; | |
24 | - private InputStream in = null; | |
25 | - private String command = null; | |
26 | - private BufferedReader myfilereader = null; | |
27 | - private Process p = null; | |
19 | + private KSar mysar = null; | |
20 | + private InputStream in = null; | |
21 | + private String command = null; | |
22 | + private BufferedReader myfilereader = null; | |
23 | + private Process p = null; | |
28 | 24 | |
29 | - public LocalCommand(KSar hissar) { | |
30 | - mysar = hissar; | |
31 | - try { | |
32 | - command = JOptionPane.showInputDialog("Enter local command ", "sar -A"); | |
33 | - if (command == null) { | |
34 | - return; | |
35 | - } | |
36 | - String[] cmdArray = command.split(" +"); | |
37 | - List<String> cmdList = new ArrayList<>(); | |
38 | - cmdList.addAll(Arrays.asList(cmdArray)); | |
39 | - ProcessBuilder pb = new ProcessBuilder(cmdList); | |
40 | - pb.environment().put("LC_ALL", "C"); | |
41 | - p = pb.start(); | |
42 | - in = p.getInputStream(); | |
43 | - } catch (Exception e) { | |
44 | - JOptionPane.showMessageDialog(null, "There was a problem while running the command ", "Local error", JOptionPane.ERROR_MESSAGE); | |
45 | - in = null; | |
46 | - } | |
47 | - } | |
25 | + public LocalCommand(KSar hissar){ | |
26 | + mysar = hissar; | |
27 | + try{ | |
28 | + command = JOptionPane.showInputDialog("Enter local command ", "sar -A"); | |
29 | + if(command == null){ | |
30 | + return; | |
31 | + } | |
32 | + String[] cmdArray = command.split(" +"); | |
33 | + List<String> cmdList = new ArrayList<>(); | |
34 | + cmdList.addAll(Arrays.asList(cmdArray)); | |
35 | + ProcessBuilder pb = new ProcessBuilder(cmdList); | |
36 | + pb.environment().put("LC_ALL", "C"); | |
37 | + p = pb.start(); | |
38 | + in = p.getInputStream(); | |
39 | + }catch(Exception e){ | |
40 | + JOptionPane.showMessageDialog(null, "There was a problem while running the command ", "Local error", JOptionPane.ERROR_MESSAGE); | |
41 | + in = null; | |
42 | + } | |
43 | + } | |
48 | 44 | |
49 | - public LocalCommand(KSar hissar, String hiscommand) { | |
50 | - mysar = hissar; | |
51 | - command = hiscommand; | |
52 | - try { | |
53 | - String[] envvar; | |
54 | - envvar = new String[1]; | |
55 | - envvar[0] = "LC_ALL=C"; | |
45 | + public LocalCommand(KSar hissar, String hiscommand){ | |
46 | + mysar = hissar; | |
47 | + command = hiscommand; | |
48 | + try{ | |
49 | + String[] envvar; | |
50 | + envvar = new String[1]; | |
51 | + envvar[0] = "LC_ALL=C"; | |
56 | 52 | |
57 | - p = Runtime.getRuntime().exec(command, envvar); | |
58 | - in = p.getInputStream(); | |
59 | - } catch (Exception e) { | |
60 | - if (GlobalOptions.hasUI() ) { | |
61 | - JOptionPane.showMessageDialog(GlobalOptions.getUI(), "There was a problem while running the command " + command, "Local error", JOptionPane.ERROR_MESSAGE); | |
62 | - } else { | |
63 | - System.err.println("There was a problem while running the command " + command); | |
64 | - } | |
65 | - in = null; | |
66 | - } | |
67 | - } | |
53 | + p = Runtime.getRuntime().exec(command, envvar); | |
54 | + in = p.getInputStream(); | |
55 | + }catch(Exception e){ | |
56 | + if(GlobalOptions.hasUI() ){ | |
57 | + JOptionPane.showMessageDialog(GlobalOptions.getUI(), "There was a problem while running the command " + command, "Local error", JOptionPane.ERROR_MESSAGE); | |
58 | + }else{ | |
59 | + System.err.println("There was a problem while running the command " + command); | |
60 | + } | |
61 | + in = null; | |
62 | + } | |
63 | + } | |
68 | 64 | |
69 | - private void close() { | |
70 | - if ( p != null ) { | |
71 | - p.destroy(); | |
72 | - } | |
65 | + private void close(){ | |
66 | + if( p != null ){ | |
67 | + p.destroy(); | |
68 | + } | |
73 | 69 | |
74 | - try { | |
75 | - if (myfilereader != null) { | |
76 | - myfilereader.close(); | |
77 | - } | |
78 | - } catch (IOException ex) { | |
79 | - Logger.getLogger(LocalCommand.class.getName()).log(Level.SEVERE, null, ex); | |
80 | - } | |
81 | - } | |
70 | + try{ | |
71 | + if(myfilereader != null){ | |
72 | + myfilereader.close(); | |
73 | + } | |
74 | + }catch(IOException ex){ | |
75 | + Logger.getLogger(LocalCommand.class.getName()).log(Level.SEVERE, null, ex); | |
76 | + } | |
77 | + } | |
82 | 78 | |
83 | 79 | @Override |
84 | - public void run() { | |
85 | - String current_line; | |
80 | + public void run(){ | |
81 | + String current_line; | |
86 | 82 | |
87 | - if (in == null) { | |
88 | - return; | |
89 | - } | |
90 | - myfilereader = new BufferedReader(new InputStreamReader(in)); | |
91 | - if (myfilereader == null) { | |
92 | - return; | |
93 | - } | |
83 | + if(in == null){ | |
84 | + return; | |
85 | + } | |
86 | + myfilereader = new BufferedReader(new InputStreamReader(in)); | |
87 | + if(myfilereader == null){ | |
88 | + return; | |
89 | + } | |
94 | 90 | |
95 | - mysar.parse(myfilereader); | |
91 | + mysar.parse(myfilereader); | |
96 | 92 | |
97 | - close(); | |
98 | - } | |
93 | + close(); | |
94 | + } | |
99 | 95 | |
100 | 96 | @Override |
101 | - public String get_action() { | |
102 | - if ( command != null ) { | |
103 | - return "cmd://" + command; | |
104 | - } else { | |
105 | - return null; | |
106 | - } | |
107 | - } | |
97 | + public String get_action(){ | |
98 | + if( command != null ){ | |
99 | + return "cmd://" + command; | |
100 | + }else{ | |
101 | + return null; | |
102 | + } | |
103 | + } | |
108 | 104 | } |
@@ -5,5 +5,5 @@ | ||
5 | 5 | * @author Pango |
6 | 6 | */ |
7 | 7 | public interface DataCommandImpl{ |
8 | - public String get_action(); | |
8 | + public String get_action(); | |
9 | 9 | } |
@@ -8,6 +8,7 @@ | ||
8 | 8 | import com.jcraft.jsch.UIKeyboardInteractive; |
9 | 9 | import com.jcraft.jsch.UserInfo; |
10 | 10 | import java.awt.Container; |
11 | +import java.awt.Dialog; | |
11 | 12 | import java.awt.GridBagConstraints; |
12 | 13 | import java.awt.GridBagLayout; |
13 | 14 | import java.awt.HeadlessException; |
@@ -18,12 +19,14 @@ | ||
18 | 19 | import java.io.IOException; |
19 | 20 | import java.io.InputStream; |
20 | 21 | import java.io.InputStreamReader; |
22 | +import java.text.SimpleDateFormat; | |
23 | +import java.util.Calendar; | |
24 | +import java.util.Date; | |
21 | 25 | import java.util.HashMap; |
22 | 26 | import java.util.Iterator; |
23 | 27 | import java.util.logging.Level; |
24 | 28 | import java.util.logging.Logger; |
25 | 29 | import javax.swing.DefaultComboBoxModel; |
26 | -import javax.swing.JButton; | |
27 | 30 | import javax.swing.JComboBox; |
28 | 31 | import javax.swing.JDialog; |
29 | 32 | import javax.swing.JLabel; |
@@ -32,6 +35,7 @@ | ||
32 | 35 | import javax.swing.JPasswordField; |
33 | 36 | import javax.swing.JTextField; |
34 | 37 | import net.atomique.ksar.XML.CnxHistory; |
38 | +import org.jfree.data.time.Minute; | |
35 | 39 | |
36 | 40 | /** |
37 | 41 | * |
@@ -67,25 +71,25 @@ | ||
67 | 71 | private javax.swing.JPanel infoPanel; |
68 | 72 | private javax.swing.JPanel passwordPanel; |
69 | 73 | private javax.swing.JLabel titleLabel; |
74 | + private javax.swing.JPanel optionPanel; | |
75 | + private javax.swing.JLabel optionWithStartTimeLabel; | |
76 | + private javax.swing.JTextField optionStartTimeText; | |
77 | + private javax.swing.JCheckBox optionStartTimeCheckBox; | |
70 | 78 | // End of variables declaration |
71 | 79 | |
72 | - public SSHCommand(KSar hissar, String cmd) { | |
80 | + public SSHCommand(KSar hissar, String cmd){ | |
73 | 81 | mysar = hissar; |
74 | 82 | command = cmd; |
75 | 83 | } |
76 | 84 | |
77 | - public SSHCommand(KSar hissar) { | |
85 | + public SSHCommand(KSar hissar){ | |
78 | 86 | mysar = hissar; |
79 | 87 | showDialog(); |
80 | 88 | } |
81 | 89 | |
82 | 90 | @Override |
83 | - public String get_action() { | |
84 | - if ( command != null ) { | |
85 | - return "ssh://" + command; | |
86 | - } else { | |
87 | - return null; | |
88 | - } | |
91 | + public String get_action(){ | |
92 | + return ( command != null ) ? "ssh://" + command : null; | |
89 | 93 | } |
90 | 94 | |
91 | 95 | private void showDialog(){ |
@@ -102,11 +106,12 @@ | ||
102 | 106 | } |
103 | 107 | |
104 | 108 | dialog.setLocationRelativeTo(GlobalOptions.getUI()); |
105 | - dialog.setAlwaysOnTop(true); | |
109 | + dialog.setModal(true); | |
110 | + //dialog.setModalityType(Dialog.ModalityType.); | |
106 | 111 | dialog.setVisible(true); |
107 | 112 | } |
108 | 113 | |
109 | - private void initComponents(JDialog diag) { | |
114 | + private void initComponents(JDialog diag){ | |
110 | 115 | headerPanel = new javax.swing.JPanel(); |
111 | 116 | titleLabel = new javax.swing.JLabel(); |
112 | 117 | infoPanel = new javax.swing.JPanel(); |
@@ -163,7 +168,6 @@ | ||
163 | 168 | infoPanel.add(passwordPanel); |
164 | 169 | |
165 | 170 | commandPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); |
166 | - | |
167 | 171 | commandLabel.setLabelFor(cmdComboBox); |
168 | 172 | commandLabel.setText("Command"); |
169 | 173 | commandLabel.setPreferredSize(new java.awt.Dimension(69, 16)); |
@@ -176,6 +180,32 @@ | ||
176 | 180 | |
177 | 181 | infoPanel.add(commandPanel); |
178 | 182 | |
183 | + optionPanel = new javax.swing.JPanel(); | |
184 | + optionWithStartTimeLabel = new javax.swing.JLabel(); | |
185 | + optionWithStartTimeLabel.setText("Starttime"); | |
186 | + optionPanel.add(optionWithStartTimeLabel); | |
187 | + optionStartTimeText = new javax.swing.JTextField(); | |
188 | + optionPanel.add(optionStartTimeText); | |
189 | + optionStartTimeCheckBox = new javax.swing.JCheckBox(); | |
190 | + optionPanel.add(optionStartTimeCheckBox); | |
191 | + infoPanel.add(optionPanel); | |
192 | + | |
193 | + if(null != mysar.myparser){ | |
194 | + Minute graph_endtimestamp = mysar.myparser.getEndOfGraph().getMinute(); | |
195 | + optionStartTimeText.setText(String.format("%02d:%02d:00", graph_endtimestamp.getHourValue(), graph_endtimestamp.getMinute())); | |
196 | + optionStartTimeCheckBox.setSelected(true); | |
197 | + }else{ | |
198 | + Calendar cal = Calendar.getInstance(); | |
199 | + cal.setTime(new Date()); | |
200 | + cal.set(Calendar.SECOND, 0); | |
201 | + int min = cal.get(Calendar.MINUTE); | |
202 | + min -= min%30; | |
203 | + cal.set(Calendar.MINUTE, min); | |
204 | + | |
205 | + optionStartTimeText.setText((new SimpleDateFormat("HH:mm:ss")).format(cal.getTime())); | |
206 | + optionStartTimeCheckBox.setSelected(false); | |
207 | + } | |
208 | + | |
179 | 209 | diag.getContentPane().add(infoPanel, java.awt.BorderLayout.CENTER); |
180 | 210 | |
181 | 211 | connectButton.setText("Connect"); |
@@ -209,11 +239,11 @@ | ||
209 | 239 | } |
210 | 240 | } |
211 | 241 | } |
212 | - private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) { | |
242 | + private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt){ | |
213 | 243 | dialog.dispose(); |
214 | 244 | } |
215 | 245 | |
216 | - private void connectButtonActionPerformed(java.awt.event.ActionEvent e) { | |
246 | + private void connectButtonActionPerformed(java.awt.event.ActionEvent e){ | |
217 | 247 | dialog.dispose(); |
218 | 248 | |
219 | 249 | CnxHistory history = new CnxHistory((String) hostComboBox.getSelectedItem()); |
@@ -223,21 +253,21 @@ | ||
223 | 253 | GlobalOptions.addHistory(history); |
224 | 254 | |
225 | 255 | // TODO |
226 | - mysar.getDataView().enableSSHUpdate(); | |
256 | + //mysar.getDataView().enableAutoUpdate(); | |
227 | 257 | } |
228 | 258 | } |
229 | 259 | |
230 | - private void hostComboBoxActionPerformed(java.awt.event.ActionEvent evt) { | |
260 | + private void hostComboBoxActionPerformed(java.awt.event.ActionEvent evt){ | |
231 | 261 | JComboBox cb = (JComboBox) evt.getSource(); |
232 | 262 | String link = (String) cb.getSelectedItem(); |
233 | 263 | CnxHistory tmp = GlobalOptions.getHistory(link); |
234 | 264 | commandModel.removeAllElements(); |
235 | - if (tmp != null) { | |
265 | + if(tmp != null){ | |
236 | 266 | Iterator<String> ite = tmp.getCommandList().iterator(); |
237 | - while (ite.hasNext()) { | |
267 | + while(ite.hasNext()){ | |
238 | 268 | commandModel.addElement(ite.next()); |
239 | 269 | } |
240 | - } else { | |
270 | + }else{ | |
241 | 271 | commandModel.addElement("sar -A"); |
242 | 272 | } |
243 | 273 | } |
@@ -245,9 +275,9 @@ | ||
245 | 275 | private boolean connect(String user, String host, int port){ |
246 | 276 | jsch = new JSch(); |
247 | 277 | //JSch.setLogger(new MyLogger()); |
248 | - try { | |
278 | + try{ | |
249 | 279 | session = jsch.getSession(user, host, port); |
250 | - } catch (JSchException ex) { | |
280 | + }catch(JSchException ex){ | |
251 | 281 | Logger.getLogger(SSHCommand.class.getName()).log(Level.SEVERE, null, ex); |
252 | 282 | } |
253 | 283 | java.util.Properties config = new java.util.Properties(); |
@@ -256,7 +286,7 @@ | ||
256 | 286 | char[] response = new char[passwordField.getPassword().length]; |
257 | 287 | StringBuilder t = new StringBuilder(); |
258 | 288 | |
259 | - for (int i = 0; i < passwordField.getPassword().length; i++) { | |
289 | + for(int i = 0; i < passwordField.getPassword().length; i++){ | |
260 | 290 | response[i] = passwordField.getPassword()[i]; |
261 | 291 | t.append(response[i]); |
262 | 292 | } |
@@ -265,63 +295,67 @@ | ||
265 | 295 | UserInfo ui = new MyUserInfo(); |
266 | 296 | session.setUserInfo(ui); |
267 | 297 | //session.setPassword(t.toString()); |
268 | - try { | |
298 | + try{ | |
269 | 299 | session.connect(); |
270 | - } catch (JSchException ex) { | |
271 | - if (GlobalOptions.hasUI()) { | |
300 | + }catch(JSchException ex){ | |
301 | + if(GlobalOptions.hasUI()){ | |
272 | 302 | JOptionPane.showMessageDialog(GlobalOptions.getUI(), "Unable to connect", "SSH error", JOptionPane.ERROR_MESSAGE); |
273 | 303 | mysar.cleared(); |
274 | - } else { | |
304 | + }else{ | |
275 | 305 | System.err.println("Err: unable to connect"); |
276 | 306 | } |
277 | 307 | return false; |
278 | 308 | } |
279 | - try { | |
309 | + try{ | |
280 | 310 | channel = session.openChannel("exec"); |
281 | - } catch (JSchException ex) { | |
282 | - if (GlobalOptions.hasUI()) { | |
311 | + }catch(JSchException ex){ | |
312 | + if(GlobalOptions.hasUI()){ | |
283 | 313 | JOptionPane.showMessageDialog(GlobalOptions.getUI(), "Unable to open Channel", "SSH error", JOptionPane.ERROR_MESSAGE); |
284 | 314 | mysar.cleared(); |
285 | - } else { | |
315 | + }else{ | |
286 | 316 | System.err.println("Err: unable to open Channel"); |
287 | 317 | } |
288 | 318 | return false; |
289 | 319 | } |
290 | - ((ChannelExec) channel).setCommand("LC_ALL=C " + cmdComboBox.getSelectedItem() + "\n"); | |
320 | + String cmd = cmdComboBox.getSelectedItem().toString(); | |
321 | + if(optionStartTimeCheckBox.isSelected()){ | |
322 | + cmd += " -s " + optionStartTimeText.getText(); | |
323 | + } | |
324 | + ((ChannelExec) channel).setCommand("LC_ALL=C " + cmd + "\n"); | |
291 | 325 | channel.setInputStream(null); |
292 | 326 | channel.setXForwarding(false); |
293 | 327 | //((ChannelExec) channel).setErrStream(err); |
294 | 328 | |
295 | - try { | |
329 | + try{ | |
296 | 330 | in = channel.getInputStream(); |
297 | 331 | err = ((ChannelExec) channel).getErrStream(); |
298 | - } catch (IOException ex) { | |
299 | - if (GlobalOptions.hasUI()) { | |
332 | + }catch(IOException ex){ | |
333 | + if(GlobalOptions.hasUI()){ | |
300 | 334 | JOptionPane.showMessageDialog(GlobalOptions.getUI(), "Unable to open pipe", "SSH error", JOptionPane.ERROR_MESSAGE); |
301 | 335 | mysar.cleared(); |
302 | - } else { | |
336 | + }else{ | |
303 | 337 | System.err.println("Err: unable to open pipe"); |
304 | 338 | } |
305 | 339 | return false; |
306 | 340 | } |
307 | - try { | |
341 | + try{ | |
308 | 342 | channel.connect(); |
309 | - } catch (JSchException ex) { | |
310 | - if (GlobalOptions.hasUI()) { | |
343 | + }catch(JSchException ex){ | |
344 | + if(GlobalOptions.hasUI()){ | |
311 | 345 | JOptionPane.showMessageDialog(GlobalOptions.getUI(), "Unable to connect Channel", "SSH error", JOptionPane.ERROR_MESSAGE); |
312 | 346 | mysar.cleared(); |
313 | - } else { | |
347 | + }else{ | |
314 | 348 | System.err.println("Err: unable to connect Channel"); |
315 | 349 | } |
316 | 350 | return false; |
317 | 351 | } |
318 | - if (channel.isClosed()) { | |
352 | + if(channel.isClosed()){ | |
319 | 353 | System.out.println("exit" + channel.getExitStatus() ); |
320 | - if (channel.getExitStatus() != 0) { | |
321 | - if (GlobalOptions.hasUI()) { | |
354 | + if(channel.getExitStatus() != 0){ | |
355 | + if(GlobalOptions.hasUI()){ | |
322 | 356 | JOptionPane.showMessageDialog(GlobalOptions.getUI(), "There was a problem while retrieving stat", "SSH error", JOptionPane.ERROR_MESSAGE); |
323 | 357 | mysar.cleared(); |
324 | - } else { | |
358 | + }else{ | |
325 | 359 | System.err.println("Err: Problem during ssh connection"); |
326 | 360 | } |
327 | 361 | return false; |
@@ -332,12 +366,12 @@ | ||
332 | 366 | } |
333 | 367 | |
334 | 368 | @Override |
335 | - public void run() { | |
369 | + public void run(){ | |
336 | 370 | StringBuilder tmpmessage = new StringBuilder(); |
337 | 371 | int max_waitdata = 10; |
338 | 372 | |
339 | - try { | |
340 | - if (in == null) { | |
373 | + try{ | |
374 | + if(in == null){ | |
341 | 375 | return; |
342 | 376 | } |
343 | 377 | // old fashion lead to error; |
@@ -345,7 +379,7 @@ | ||
345 | 379 | InputStreamReader tmpin= new InputStreamReader(in); |
346 | 380 | InputStreamReader tmperr = new InputStreamReader(err); |
347 | 381 | |
348 | - while ( max_waitdata > 0 && ! tmpin.ready() ) { | |
382 | + while(max_waitdata > 0 && ! tmpin.ready() ){ | |
349 | 383 | // no data and not in timeout |
350 | 384 | try { Thread.sleep( 100 ); }catch( Exception ee ) {} |
351 | 385 | max_waitdata--; |
@@ -357,12 +391,12 @@ | ||
357 | 391 | mysar.parse(myfile); |
358 | 392 | String current_line; |
359 | 393 | |
360 | - while ( (current_line = myerror.readLine()) != null) { | |
394 | + while((current_line = myerror.readLine()) != null){ | |
361 | 395 | tmpmessage.append(current_line); |
362 | 396 | tmpmessage.append("\n"); |
363 | 397 | } |
364 | - if ( tmpmessage.length() >0 ) { | |
365 | - if ( GlobalOptions.hasUI()) { | |
398 | + if( tmpmessage.length() >0 ){ | |
399 | + if( GlobalOptions.hasUI()){ | |
366 | 400 | JOptionPane.showMessageDialog(GlobalOptions.getUI(), tmpmessage.toString(),"SSH error", JOptionPane.ERROR_MESSAGE); |
367 | 401 | } |
368 | 402 | } |
@@ -376,7 +410,7 @@ | ||
376 | 410 | session.disconnect(); |
377 | 411 | channel=null; |
378 | 412 | session=null; |
379 | - } catch (IOException | HeadlessException e) { | |
413 | + }catch(IOException | HeadlessException e){ | |
380 | 414 | e.printStackTrace(System.err); |
381 | 415 | } |
382 | 416 | } |
@@ -388,33 +422,33 @@ | ||
388 | 422 | String passphrase; |
389 | 423 | |
390 | 424 | @Override |
391 | - public boolean promptYesNo(String str) { | |
425 | + public boolean promptYesNo(String str){ | |
392 | 426 | String[] options = {"yes", "no"}; |
393 | - if (GlobalOptions.hasUI()) { | |
427 | + if(GlobalOptions.hasUI()){ | |
394 | 428 | int foo = JOptionPane.showOptionDialog(GlobalOptions.getUI(), str, "Warning", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]); |
395 | 429 | return foo == 0; |
396 | - } else { | |
430 | + }else{ | |
397 | 431 | return true; |
398 | 432 | } |
399 | 433 | } |
400 | 434 | |
401 | 435 | @Override |
402 | - public String getPassphrase() { | |
436 | + public String getPassphrase(){ | |
403 | 437 | return passphrase; |
404 | 438 | } |
405 | 439 | |
406 | 440 | @Override |
407 | - public boolean promptPassphrase(String message) { | |
408 | - if (num_try > 0) { | |
441 | + public boolean promptPassphrase(String message){ | |
442 | + if(num_try > 0){ | |
409 | 443 | Object[] ob = {passphraseField}; |
410 | 444 | int result = JOptionPane.showConfirmDialog(GlobalOptions.getUI(), ob, message, JOptionPane.OK_CANCEL_OPTION); |
411 | - if (result == JOptionPane.OK_OPTION) { | |
445 | + if(result == JOptionPane.OK_OPTION){ | |
412 | 446 | passphrase = passphraseField.getText(); |
413 | 447 | return true; |
414 | - } else { | |
448 | + }else{ | |
415 | 449 | return false; |
416 | 450 | } |
417 | - } else { | |
451 | + }else{ | |
418 | 452 | num_try++; |
419 | 453 | return true; |
420 | 454 | } |
@@ -421,8 +455,8 @@ | ||
421 | 455 | } |
422 | 456 | |
423 | 457 | @Override |
424 | - public String getPassword() { | |
425 | - if ( password != null) { | |
458 | + public String getPassword(){ | |
459 | + if( password != null){ | |
426 | 460 | return password; |
427 | 461 | } |
428 | 462 | return passwd; |
@@ -429,21 +463,21 @@ | ||
429 | 463 | } |
430 | 464 | |
431 | 465 | @Override |
432 | - public boolean promptPassword(String message) { | |
433 | - if ( num_try > 0 || password != null) { | |
466 | + public boolean promptPassword(String message){ | |
467 | + if( num_try > 0 || password != null){ | |
434 | 468 | Object[] ob = {passwordField}; |
435 | - if (GlobalOptions.hasUI()) { | |
469 | + if(GlobalOptions.hasUI()){ | |
436 | 470 | int result = JOptionPane.showConfirmDialog(GlobalOptions.getUI(), ob, message, JOptionPane.OK_CANCEL_OPTION); |
437 | - if (result == JOptionPane.OK_OPTION) { | |
471 | + if(result == JOptionPane.OK_OPTION){ | |
438 | 472 | passwd = passwordField.getText(); |
439 | 473 | return true; |
440 | - } else { | |
474 | + }else{ | |
441 | 475 | return false; |
442 | 476 | } |
443 | - } else { | |
477 | + }else{ | |
444 | 478 | return false; |
445 | 479 | } |
446 | - } else { | |
480 | + }else{ | |
447 | 481 | num_try++; |
448 | 482 | return true; |
449 | 483 | } |
@@ -452,9 +486,9 @@ | ||
452 | 486 | private Container panel; |
453 | 487 | |
454 | 488 | @Override |
455 | - public String[] promptKeyboardInteractive(String destination, String name, String instruction, String[] prompt, boolean[] echo) { | |
489 | + public String[] promptKeyboardInteractive(String destination, String name, String instruction, String[] prompt, boolean[] echo){ | |
456 | 490 | |
457 | - if (password != null) { | |
491 | + if(password != null){ | |
458 | 492 | num_try++; |
459 | 493 | return password.split("[.]"); |
460 | 494 | } |
@@ -470,7 +504,7 @@ | ||
470 | 504 | gbc.gridwidth = GridBagConstraints.RELATIVE; |
471 | 505 | |
472 | 506 | JTextField[] texts = new JTextField[prompt.length]; |
473 | - for (int i = 0; i < prompt.length; i++) { | |
507 | + for(int i = 0; i < prompt.length; i++){ | |
474 | 508 | gbc.fill = GridBagConstraints.NONE; |
475 | 509 | gbc.gridx = 0; |
476 | 510 | gbc.weightx = 1; |
@@ -479,9 +513,9 @@ | ||
479 | 513 | gbc.gridx = 1; |
480 | 514 | gbc.fill = GridBagConstraints.HORIZONTAL; |
481 | 515 | gbc.weighty = 1; |
482 | - if (echo[i]) { | |
516 | + if(echo[i]){ | |
483 | 517 | texts[i] = new JTextField(20); |
484 | - } else { | |
518 | + }else{ | |
485 | 519 | texts[i] = new JPasswordField(20); |
486 | 520 | } |
487 | 521 | panel.add(texts[i], gbc); |
@@ -488,23 +522,23 @@ | ||
488 | 522 | gbc.gridy++; |
489 | 523 | } |
490 | 524 | |
491 | - if (JOptionPane.showConfirmDialog(GlobalOptions.getUI(), panel, destination + " : " + name, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION) { | |
525 | + if(JOptionPane.showConfirmDialog(GlobalOptions.getUI(), panel, destination + " : " + name, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION){ | |
492 | 526 | String[] response = new String[prompt.length]; |
493 | 527 | StringBuilder t = new StringBuilder(); |
494 | 528 | |
495 | - for (int i = 0; i < prompt.length; i++) { | |
529 | + for(int i = 0; i < prompt.length; i++){ | |
496 | 530 | response[i] = texts[i].getText(); |
497 | 531 | t.append(response[i]); |
498 | 532 | } |
499 | 533 | return response; |
500 | - } else { | |
501 | - return null; // cancel | |
534 | + }else{ | |
535 | + return null; // cancel | |
502 | 536 | } |
503 | 537 | } |
504 | 538 | |
505 | 539 | @Override |
506 | - public void showMessage(String message) { | |
507 | - if (GlobalOptions.hasUI()) { | |
540 | + public void showMessage(String message){ | |
541 | + if(GlobalOptions.hasUI()){ | |
508 | 542 | JOptionPane.showMessageDialog(GlobalOptions.getUI(), message); |
509 | 543 | } |
510 | 544 | } |
@@ -523,12 +557,12 @@ | ||
523 | 557 | } |
524 | 558 | |
525 | 559 | @Override |
526 | - public boolean isEnabled(int level) { | |
560 | + public boolean isEnabled(int level){ | |
527 | 561 | return true; |
528 | 562 | } |
529 | 563 | |
530 | 564 | @Override |
531 | - public void log(int level, String message) { | |
565 | + public void log(int level, String message){ | |
532 | 566 | System.err.print(name.get(level)); |
533 | 567 | System.err.println(message); |
534 | 568 | } |
@@ -1,127 +0,0 @@ | ||
1 | -/* | |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | - | |
6 | -/* | |
7 | - * LinuxDateFormat.java | |
8 | - * | |
9 | - * Created on 1 sept. 2010, 13:50:29 | |
10 | - */ | |
11 | - | |
12 | -package net.atomique.ksar.UI; | |
13 | - | |
14 | -import javax.swing.DefaultComboBoxModel; | |
15 | - | |
16 | -/** | |
17 | - * | |
18 | - * @author alex | |
19 | - */ | |
20 | -public class LinuxDateFormat extends javax.swing.JDialog { | |
21 | - | |
22 | - /** Creates new form LinuxDateFormat */ | |
23 | - public LinuxDateFormat(java.awt.Frame parent, boolean modal) { | |
24 | - super(parent, modal); | |
25 | - initComponents(); | |
26 | - load_linuxformat(); | |
27 | - pack(); | |
28 | - setLocationRelativeTo(parent); | |
29 | - toFront(); | |
30 | - setVisible(true); | |
31 | - | |
32 | - } | |
33 | - | |
34 | - private void load_linuxformat() { | |
35 | - LinuxFormatComboModel.addElement("MM/DD/YYYY 23:59:59"); | |
36 | - LinuxFormatComboModel.addElement("DD/MM/YYYY 23:59:59"); | |
37 | - LinuxFormatComboModel.addElement("YYYY-MM-DD 23:59:59"); | |
38 | - LinuxFormatComboModel.addElement("MM/DD/YYYY 12:59:59 AM|PM"); | |
39 | - } | |
40 | - | |
41 | - /** This method is called from within the constructor to | |
42 | - * initialize the form. | |
43 | - * WARNING: Do NOT modify this code. The content of this method is | |
44 | - * always regenerated by the Form Editor. | |
45 | - */ | |
46 | - @SuppressWarnings("unchecked") | |
47 | - // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents | |
48 | - private void initComponents() { | |
49 | - | |
50 | - jPanel1 = new javax.swing.JPanel(); | |
51 | - jPanel3 = new javax.swing.JPanel(); | |
52 | - jLabel1 = new javax.swing.JLabel(); | |
53 | - jComboBox1 = new javax.swing.JComboBox(); | |
54 | - jPanel4 = new javax.swing.JPanel(); | |
55 | - jCheckBox1 = new javax.swing.JCheckBox(); | |
56 | - jPanel2 = new javax.swing.JPanel(); | |
57 | - OkButton = new javax.swing.JButton(); | |
58 | - | |
59 | - setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); | |
60 | - | |
61 | - jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1, javax.swing.BoxLayout.PAGE_AXIS)); | |
62 | - | |
63 | - jPanel3.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); | |
64 | - | |
65 | - jLabel1.setLabelFor(jComboBox1); | |
66 | - jLabel1.setText("Select date format:"); | |
67 | - jPanel3.add(jLabel1); | |
68 | - | |
69 | - jComboBox1.setModel(LinuxFormatComboModel); | |
70 | - jComboBox1.setPreferredSize(new java.awt.Dimension(300, 27)); | |
71 | - jPanel3.add(jComboBox1); | |
72 | - | |
73 | - jPanel1.add(jPanel3); | |
74 | - | |
75 | - jPanel4.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); | |
76 | - | |
77 | - jCheckBox1.setText("Always use this format"); | |
78 | - jPanel4.add(jCheckBox1); | |
79 | - | |
80 | - jPanel1.add(jPanel4); | |
81 | - | |
82 | - getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER); | |
83 | - | |
84 | - OkButton.setText("Ok"); | |
85 | - OkButton.addActionListener(new java.awt.event.ActionListener() { | |
86 | - public void actionPerformed(java.awt.event.ActionEvent evt) { | |
87 | - OkButtonActionPerformed(evt); | |
88 | - } | |
89 | - }); | |
90 | - jPanel2.add(OkButton); | |
91 | - | |
92 | - getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH); | |
93 | - | |
94 | - pack(); | |
95 | - }// </editor-fold>//GEN-END:initComponents | |
96 | - | |
97 | - private void OkButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_OkButtonActionPerformed | |
98 | - this.dispose(); | |
99 | - ok_to_proceed=true; | |
100 | - }//GEN-LAST:event_OkButtonActionPerformed | |
101 | - | |
102 | - public boolean hasToRemenber() { | |
103 | - return jCheckBox1.isSelected(); | |
104 | - } | |
105 | - | |
106 | - public String getDateFormat() { | |
107 | - return (String)jComboBox1.getSelectedItem(); | |
108 | - } | |
109 | - | |
110 | - public boolean isOk() { | |
111 | - return ok_to_proceed; | |
112 | - } | |
113 | - | |
114 | - // Variables declaration - do not modify//GEN-BEGIN:variables | |
115 | - private javax.swing.JButton OkButton; | |
116 | - private javax.swing.JCheckBox jCheckBox1; | |
117 | - private javax.swing.JComboBox jComboBox1; | |
118 | - private javax.swing.JLabel jLabel1; | |
119 | - private javax.swing.JPanel jPanel1; | |
120 | - private javax.swing.JPanel jPanel2; | |
121 | - private javax.swing.JPanel jPanel3; | |
122 | - private javax.swing.JPanel jPanel4; | |
123 | - // End of variables declaration//GEN-END:variables | |
124 | - | |
125 | - DefaultComboBoxModel LinuxFormatComboModel = new DefaultComboBoxModel(); | |
126 | - boolean ok_to_proceed =false; | |
127 | -} |
@@ -1,9 +1,4 @@ | ||
1 | 1 | /* |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | - | |
6 | -/* | |
7 | 2 | * Desktop.java |
8 | 3 | * |
9 | 4 | * Created on 29 juil. 2010, 16:54:23 |
@@ -28,7 +23,7 @@ | ||
28 | 23 | public class Desktop extends javax.swing.JFrame { |
29 | 24 | |
30 | 25 | /** Creates new form Desktop */ |
31 | - public Desktop() { | |
26 | + public Desktop(){ | |
32 | 27 | int wmargins = 90; |
33 | 28 | int hmargins = 60; |
34 | 29 | Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
@@ -39,9 +34,7 @@ | ||
39 | 34 | setVisible(true); |
40 | 35 | } |
41 | 36 | |
42 | - | |
43 | - | |
44 | - private static JInternalFrame[] filterFrame(JInternalFrame[] frames) { | |
37 | + private static JInternalFrame[] filterFrame(JInternalFrame[] frames){ | |
45 | 38 | int n = 0; |
46 | 39 | for(JInternalFrame frame : frames){ |
47 | 40 | if(frame.isVisible() && !frame.isIcon()){ |
@@ -59,16 +52,16 @@ | ||
59 | 52 | return newfs; |
60 | 53 | } |
61 | 54 | |
62 | - public static void iconify(JDesktopPane desktopPane) { | |
55 | + public static void iconify(JDesktopPane desktopPane){ | |
63 | 56 | JInternalFrame[] frames = filterFrame(desktopPane.getAllFrames()); |
64 | - if (frames.length == 0) { | |
57 | + if(frames.length == 0){ | |
65 | 58 | return; |
66 | 59 | } |
67 | 60 | for( JInternalFrame frame : frames ){ |
68 | - if (frame.isVisible() && !frame.isIcon()) { | |
69 | - try { | |
61 | + if(frame.isVisible() && !frame.isIcon()){ | |
62 | + try{ | |
70 | 63 | frame.setIcon(true); |
71 | - } catch (PropertyVetoException ex) { | |
64 | + }catch(PropertyVetoException ex){ | |
72 | 65 | Logger.getLogger(Desktop.class.getName()).log(Level.SEVERE, null, ex); |
73 | 66 | } |
74 | 67 | } |
@@ -75,20 +68,20 @@ | ||
75 | 68 | } |
76 | 69 | } |
77 | 70 | |
78 | - public void maxall() { | |
71 | + public void maxall(){ | |
79 | 72 | maximize(DesktopPane); |
80 | 73 | } |
81 | 74 | |
82 | - private static void maximize(JDesktopPane desktopPane) { | |
75 | + private static void maximize(JDesktopPane desktopPane){ | |
83 | 76 | JInternalFrame[] frames = filterFrame(desktopPane.getAllFrames()); |
84 | - if (frames.length == 0) { | |
77 | + if(frames.length == 0){ | |
85 | 78 | return; |
86 | 79 | } |
87 | 80 | for( JInternalFrame frame : frames ){ |
88 | - if (frame.isVisible() && !frame.isIcon()) { | |
89 | - try { | |
81 | + if(frame.isVisible() && !frame.isIcon()){ | |
82 | + try{ | |
90 | 83 | frame.setMaximum(true); |
91 | - } catch (PropertyVetoException ex) { | |
84 | + }catch(PropertyVetoException ex){ | |
92 | 85 | Logger.getLogger(Desktop.class.getName()).log(Level.SEVERE, null, ex); |
93 | 86 | } |
94 | 87 | } |
@@ -95,9 +88,9 @@ | ||
95 | 88 | } |
96 | 89 | } |
97 | 90 | |
98 | - public static void tile(JDesktopPane desktopPane) { | |
91 | + public static void tile(JDesktopPane desktopPane){ | |
99 | 92 | JInternalFrame[] frames = filterFrame(desktopPane.getAllFrames()); |
100 | - if (frames.length == 0) { | |
93 | + if(frames.length == 0){ | |
101 | 94 | return; |
102 | 95 | } |
103 | 96 |
@@ -104,21 +97,21 @@ | ||
104 | 97 | tile(frames, desktopPane.getBounds()); |
105 | 98 | } |
106 | 99 | |
107 | - private static void tile(JInternalFrame[] frames, Rectangle dBounds) { | |
100 | + private static void tile(JInternalFrame[] frames, Rectangle dBounds){ | |
108 | 101 | int cols = (int) Math.sqrt(frames.length); |
109 | 102 | int rows = (int) (Math.ceil(((double) frames.length) / cols)); |
110 | 103 | int lastRow = frames.length - cols * (rows - 1); |
111 | 104 | int width, height; |
112 | 105 | |
113 | - if (lastRow == 0) { | |
106 | + if(lastRow == 0){ | |
114 | 107 | rows--; |
115 | 108 | height = dBounds.height / rows; |
116 | - } else { | |
109 | + }else{ | |
117 | 110 | height = dBounds.height / rows; |
118 | - if (lastRow < cols) { | |
111 | + if(lastRow < cols){ | |
119 | 112 | rows--; |
120 | 113 | width = dBounds.width / lastRow; |
121 | - for (int i = 0; i < lastRow; i++) { | |
114 | + for(int i = 0; i < lastRow; i++){ | |
122 | 115 | frames[cols * rows + i].setBounds(i * width, rows * height, width, height); |
123 | 116 | } |
124 | 117 | } |
@@ -125,8 +118,8 @@ | ||
125 | 118 | } |
126 | 119 | |
127 | 120 | width = dBounds.width / cols; |
128 | - for (int j = 0; j < rows; j++) { | |
129 | - for (int i = 0; i < cols; i++) { | |
121 | + for(int j = 0; j < rows; j++){ | |
122 | + for(int i = 0; i < cols; i++){ | |
130 | 123 | frames[i + j * cols].setBounds(i * width, j * height, width, height); |
131 | 124 | } |
132 | 125 | } |
@@ -138,171 +131,171 @@ | ||
138 | 131 | * always regenerated by the Form Editor. |
139 | 132 | */ |
140 | 133 | @SuppressWarnings("unchecked") |
141 | - // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents | |
142 | - private void initComponents() { | |
134 | + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents | |
135 | + private void initComponents(){ | |
143 | 136 | |
144 | - DesktopPane = new javax.swing.JDesktopPane(); | |
145 | - MenuBar = new javax.swing.JMenuBar(); | |
146 | - FileMenu = new javax.swing.JMenu(); | |
147 | - NewMenu = new javax.swing.JMenuItem(); | |
148 | - QuitMenu = new javax.swing.JMenuItem(); | |
149 | - OptionsMenu = new javax.swing.JMenu(); | |
150 | - SysprefMenu = new javax.swing.JMenuItem(); | |
151 | - WindowMenu = new javax.swing.JMenu(); | |
152 | - TileMenu = new javax.swing.JMenuItem(); | |
153 | - IconifyMenu = new javax.swing.JMenuItem(); | |
154 | - MaximizeMenu = new javax.swing.JMenuItem(); | |
155 | - HelpMenu = new javax.swing.JMenu(); | |
156 | - AboutMenu = new javax.swing.JMenuItem(); | |
137 | + DesktopPane = new javax.swing.JDesktopPane(); | |
138 | + MenuBar = new javax.swing.JMenuBar(); | |
139 | + FileMenu = new javax.swing.JMenu(); | |
140 | + NewMenu = new javax.swing.JMenuItem(); | |
141 | + QuitMenu = new javax.swing.JMenuItem(); | |
142 | + OptionsMenu = new javax.swing.JMenu(); | |
143 | + SysprefMenu = new javax.swing.JMenuItem(); | |
144 | + WindowMenu = new javax.swing.JMenu(); | |
145 | + TileMenu = new javax.swing.JMenuItem(); | |
146 | + IconifyMenu = new javax.swing.JMenuItem(); | |
147 | + MaximizeMenu = new javax.swing.JMenuItem(); | |
148 | + HelpMenu = new javax.swing.JMenu(); | |
149 | + AboutMenu = new javax.swing.JMenuItem(); | |
157 | 150 | |
158 | - setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); | |
159 | - setTitle("kSar : a sar grapher"); | |
160 | - addWindowListener(new java.awt.event.WindowAdapter() { | |
161 | - public void windowClosing(java.awt.event.WindowEvent evt) { | |
162 | - formWindowClosing(evt); | |
163 | - } | |
164 | - }); | |
165 | - getContentPane().add(DesktopPane, java.awt.BorderLayout.CENTER); | |
151 | + setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); | |
152 | + setTitle("kSar : a sar grapher"); | |
153 | + addWindowListener(new java.awt.event.WindowAdapter(){ | |
154 | + public void windowClosing(java.awt.event.WindowEvent evt){ | |
155 | + formWindowClosing(evt); | |
156 | + } | |
157 | + }); | |
158 | + getContentPane().add(DesktopPane, java.awt.BorderLayout.CENTER); | |
166 | 159 | |
167 | - FileMenu.setText("File"); // NOI18N | |
160 | + FileMenu.setText("File"); // NOI18N | |
168 | 161 | |
169 | - NewMenu.setText("New window"); | |
170 | - NewMenu.addActionListener(new java.awt.event.ActionListener() { | |
171 | - public void actionPerformed(java.awt.event.ActionEvent evt) { | |
172 | - NewMenuActionPerformed(evt); | |
173 | - } | |
174 | - }); | |
175 | - FileMenu.add(NewMenu); | |
162 | + NewMenu.setText("New window"); | |
163 | + NewMenu.addActionListener(new java.awt.event.ActionListener(){ | |
164 | + public void actionPerformed(java.awt.event.ActionEvent evt){ | |
165 | + NewMenuActionPerformed(evt); | |
166 | + } | |
167 | + }); | |
168 | + FileMenu.add(NewMenu); | |
176 | 169 | |
177 | - QuitMenu.setText("Quit"); | |
178 | - QuitMenu.addActionListener(new java.awt.event.ActionListener() { | |
179 | - public void actionPerformed(java.awt.event.ActionEvent evt) { | |
180 | - QuitMenuActionPerformed(evt); | |
181 | - } | |
182 | - }); | |
183 | - FileMenu.add(QuitMenu); | |
170 | + QuitMenu.setText("Quit"); | |
171 | + QuitMenu.addActionListener(new java.awt.event.ActionListener(){ | |
172 | + public void actionPerformed(java.awt.event.ActionEvent evt){ | |
173 | + QuitMenuActionPerformed(evt); | |
174 | + } | |
175 | + }); | |
176 | + FileMenu.add(QuitMenu); | |
184 | 177 | |
185 | - MenuBar.add(FileMenu); | |
178 | + MenuBar.add(FileMenu); | |
186 | 179 | |
187 | - OptionsMenu.setText("Options"); // NOI18N | |
180 | + OptionsMenu.setText("Options"); // NOI18N | |
188 | 181 | |
189 | - SysprefMenu.setText("System Preferences"); | |
190 | - SysprefMenu.addActionListener(new java.awt.event.ActionListener() { | |
191 | - public void actionPerformed(java.awt.event.ActionEvent evt) { | |
192 | - SysprefMenuActionPerformed(evt); | |
193 | - } | |
194 | - }); | |
195 | - OptionsMenu.add(SysprefMenu); | |
182 | + SysprefMenu.setText("System Preferences"); | |
183 | + SysprefMenu.addActionListener(new java.awt.event.ActionListener(){ | |
184 | + public void actionPerformed(java.awt.event.ActionEvent evt){ | |
185 | + SysprefMenuActionPerformed(evt); | |
186 | + } | |
187 | + }); | |
188 | + OptionsMenu.add(SysprefMenu); | |
196 | 189 | |
197 | - MenuBar.add(OptionsMenu); | |
190 | + MenuBar.add(OptionsMenu); | |
198 | 191 | |
199 | - WindowMenu.setText("Window"); | |
192 | + WindowMenu.setText("Window"); | |
200 | 193 | |
201 | - TileMenu.setText("Tile"); | |
202 | - TileMenu.setActionCommand("TileMenu"); | |
203 | - TileMenu.addActionListener(new java.awt.event.ActionListener() { | |
204 | - public void actionPerformed(java.awt.event.ActionEvent evt) { | |
205 | - TileMenuActionPerformed(evt); | |
206 | - } | |
207 | - }); | |
208 | - WindowMenu.add(TileMenu); | |
194 | + TileMenu.setText("Tile"); | |
195 | + TileMenu.setActionCommand("TileMenu"); | |
196 | + TileMenu.addActionListener(new java.awt.event.ActionListener(){ | |
197 | + public void actionPerformed(java.awt.event.ActionEvent evt){ | |
198 | + TileMenuActionPerformed(evt); | |
199 | + } | |
200 | + }); | |
201 | + WindowMenu.add(TileMenu); | |
209 | 202 | |
210 | - IconifyMenu.setText("Iconify"); | |
211 | - IconifyMenu.setActionCommand("IconifyMenu"); | |
212 | - IconifyMenu.addActionListener(new java.awt.event.ActionListener() { | |
213 | - public void actionPerformed(java.awt.event.ActionEvent evt) { | |
214 | - IconifyMenuActionPerformed(evt); | |
215 | - } | |
216 | - }); | |
217 | - WindowMenu.add(IconifyMenu); | |
203 | + IconifyMenu.setText("Iconify"); | |
204 | + IconifyMenu.setActionCommand("IconifyMenu"); | |
205 | + IconifyMenu.addActionListener(new java.awt.event.ActionListener(){ | |
206 | + public void actionPerformed(java.awt.event.ActionEvent evt){ | |
207 | + IconifyMenuActionPerformed(evt); | |
208 | + } | |
209 | + }); | |
210 | + WindowMenu.add(IconifyMenu); | |
218 | 211 | |
219 | - MaximizeMenu.setText("Maximize"); | |
220 | - MaximizeMenu.addActionListener(new java.awt.event.ActionListener() { | |
221 | - public void actionPerformed(java.awt.event.ActionEvent evt) { | |
222 | - MaximizeMenuActionPerformed(evt); | |
223 | - } | |
224 | - }); | |
225 | - WindowMenu.add(MaximizeMenu); | |
212 | + MaximizeMenu.setText("Maximize"); | |
213 | + MaximizeMenu.addActionListener(new java.awt.event.ActionListener(){ | |
214 | + public void actionPerformed(java.awt.event.ActionEvent evt){ | |
215 | + MaximizeMenuActionPerformed(evt); | |
216 | + } | |
217 | + }); | |
218 | + WindowMenu.add(MaximizeMenu); | |
226 | 219 | |
227 | - MenuBar.add(WindowMenu); | |
220 | + MenuBar.add(WindowMenu); | |
228 | 221 | |
229 | - HelpMenu.setText("?"); | |
222 | + HelpMenu.setText("?"); | |
230 | 223 | |
231 | - AboutMenu.setText("About"); | |
232 | - AboutMenu.addActionListener(new java.awt.event.ActionListener() { | |
233 | - public void actionPerformed(java.awt.event.ActionEvent evt) { | |
234 | - AboutMenuActionPerformed(evt); | |
235 | - } | |
236 | - }); | |
237 | - HelpMenu.add(AboutMenu); | |
224 | + AboutMenu.setText("About"); | |
225 | + AboutMenu.addActionListener(new java.awt.event.ActionListener(){ | |
226 | + public void actionPerformed(java.awt.event.ActionEvent evt){ | |
227 | + AboutMenuActionPerformed(evt); | |
228 | + } | |
229 | + }); | |
230 | + HelpMenu.add(AboutMenu); | |
238 | 231 | |
239 | - MenuBar.add(HelpMenu); | |
232 | + MenuBar.add(HelpMenu); | |
240 | 233 | |
241 | - setJMenuBar(MenuBar); | |
234 | + setJMenuBar(MenuBar); | |
242 | 235 | |
243 | - pack(); | |
244 | - }// </editor-fold>//GEN-END:initComponents | |
236 | + pack(); | |
237 | + }// </editor-fold>//GEN-END:initComponents | |
245 | 238 | |
246 | - private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing | |
239 | + private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing | |
247 | 240 | tryToQuit(); |
248 | - }//GEN-LAST:event_formWindowClosing | |
241 | + }//GEN-LAST:event_formWindowClosing | |
249 | 242 | |
250 | - private void QuitMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_QuitMenuActionPerformed | |
243 | + private void QuitMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_QuitMenuActionPerformed | |
251 | 244 | tryToQuit(); |
252 | - }//GEN-LAST:event_QuitMenuActionPerformed | |
245 | + }//GEN-LAST:event_QuitMenuActionPerformed | |
253 | 246 | |
254 | - private void AboutMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AboutMenuActionPerformed | |
247 | + private void AboutMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AboutMenuActionPerformed | |
255 | 248 | AboutBox myAboutBox = new AboutBox(this); |
256 | - }//GEN-LAST:event_AboutMenuActionPerformed | |
249 | + }//GEN-LAST:event_AboutMenuActionPerformed | |
257 | 250 | |
258 | - private void SysprefMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SysprefMenuActionPerformed | |
251 | + private void SysprefMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SysprefMenuActionPerformed | |
259 | 252 | Preferences myPreferences = new Preferences(this); |
260 | - }//GEN-LAST:event_SysprefMenuActionPerformed | |
253 | + }//GEN-LAST:event_SysprefMenuActionPerformed | |
261 | 254 | |
262 | - private void NewMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NewMenuActionPerformed | |
255 | + private void NewMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NewMenuActionPerformed | |
263 | 256 | add_window(); |
264 | - }//GEN-LAST:event_NewMenuActionPerformed | |
257 | + }//GEN-LAST:event_NewMenuActionPerformed | |
265 | 258 | |
266 | - private void TileMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TileMenuActionPerformed | |
259 | + private void TileMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TileMenuActionPerformed | |
267 | 260 | tile(DesktopPane); |
268 | - }//GEN-LAST:event_TileMenuActionPerformed | |
261 | + }//GEN-LAST:event_TileMenuActionPerformed | |
269 | 262 | |
270 | - private void IconifyMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_IconifyMenuActionPerformed | |
263 | + private void IconifyMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_IconifyMenuActionPerformed | |
271 | 264 | iconify(DesktopPane); |
272 | - }//GEN-LAST:event_IconifyMenuActionPerformed | |
265 | + }//GEN-LAST:event_IconifyMenuActionPerformed | |
273 | 266 | |
274 | - private void MaximizeMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MaximizeMenuActionPerformed | |
267 | + private void MaximizeMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MaximizeMenuActionPerformed | |
275 | 268 | maximize(DesktopPane); |
276 | - }//GEN-LAST:event_MaximizeMenuActionPerformed | |
269 | + }//GEN-LAST:event_MaximizeMenuActionPerformed | |
277 | 270 | |
278 | - public void add_window() { | |
271 | + public void add_window(){ | |
279 | 272 | KSar mysar = new KSar(DesktopPane); |
280 | 273 | } |
281 | 274 | |
282 | - public JDesktopPane getDesktopPane() { | |
275 | + public JDesktopPane getDesktopPane(){ | |
283 | 276 | return DesktopPane; |
284 | 277 | } |
285 | 278 | |
286 | 279 | |
287 | - private void tryToQuit() { | |
280 | + private void tryToQuit(){ | |
288 | 281 | int i = JOptionPane.showConfirmDialog(this, "Are you sure you want to exit kSar ?", "Confirm", JOptionPane.YES_NO_OPTION); |
289 | - if (i == JOptionPane.YES_OPTION) { | |
282 | + if(i == JOptionPane.YES_OPTION){ | |
290 | 283 | System.exit(0); |
291 | 284 | } |
292 | 285 | } |
293 | - // Variables declaration - do not modify//GEN-BEGIN:variables | |
294 | - private javax.swing.JMenuItem AboutMenu; | |
295 | - private javax.swing.JDesktopPane DesktopPane; | |
296 | - private javax.swing.JMenu FileMenu; | |
297 | - private javax.swing.JMenu HelpMenu; | |
298 | - private javax.swing.JMenuItem IconifyMenu; | |
299 | - private javax.swing.JMenuItem MaximizeMenu; | |
300 | - private javax.swing.JMenuBar MenuBar; | |
301 | - private javax.swing.JMenuItem NewMenu; | |
302 | - private javax.swing.JMenu OptionsMenu; | |
303 | - private javax.swing.JMenuItem QuitMenu; | |
304 | - private javax.swing.JMenuItem SysprefMenu; | |
305 | - private javax.swing.JMenuItem TileMenu; | |
306 | - private javax.swing.JMenu WindowMenu; | |
307 | - // End of variables declaration//GEN-END:variables | |
286 | + // Variables declaration - do not modify//GEN-BEGIN:variables | |
287 | + private javax.swing.JMenuItem AboutMenu; | |
288 | + private javax.swing.JDesktopPane DesktopPane; | |
289 | + private javax.swing.JMenu FileMenu; | |
290 | + private javax.swing.JMenu HelpMenu; | |
291 | + private javax.swing.JMenuItem IconifyMenu; | |
292 | + private javax.swing.JMenuItem MaximizeMenu; | |
293 | + private javax.swing.JMenuBar MenuBar; | |
294 | + private javax.swing.JMenuItem NewMenu; | |
295 | + private javax.swing.JMenu OptionsMenu; | |
296 | + private javax.swing.JMenuItem QuitMenu; | |
297 | + private javax.swing.JMenuItem SysprefMenu; | |
298 | + private javax.swing.JMenuItem TileMenu; | |
299 | + private javax.swing.JMenu WindowMenu; | |
300 | + // End of variables declaration//GEN-END:variables | |
308 | 301 | } |
@@ -1,8 +1,3 @@ | ||
1 | -/* | |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | - | |
6 | 1 | package net.atomique.ksar.UI; |
7 | 2 | |
8 | 3 | import net.atomique.ksar.Graph.List; |
@@ -13,21 +8,21 @@ | ||
13 | 8 | */ |
14 | 9 | public class ParentNodeInfo { |
15 | 10 | |
16 | - public ParentNodeInfo(String t, List list) { | |
11 | + public ParentNodeInfo(String t, List list){ | |
17 | 12 | node_title = t; |
18 | 13 | node_object = list; |
19 | 14 | } |
20 | 15 | |
21 | - public List getNode_object() { | |
16 | + public List getNode_object(){ | |
22 | 17 | return node_object; |
23 | 18 | } |
24 | 19 | |
25 | - public String getNode_title() { | |
20 | + public String getNode_title(){ | |
26 | 21 | return node_title; |
27 | 22 | } |
28 | 23 | |
29 | 24 | @Override |
30 | - public String toString() { | |
25 | + public String toString(){ | |
31 | 26 | return node_title; |
32 | 27 | } |
33 | 28 |
@@ -1,8 +1,3 @@ | ||
1 | -/* | |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | - | |
6 | 1 | package net.atomique.ksar.UI; |
7 | 2 | |
8 | 3 | import net.atomique.ksar.Graph.Graph; |
@@ -13,20 +8,20 @@ | ||
13 | 8 | */ |
14 | 9 | public class TreeNodeInfo { |
15 | 10 | |
16 | - public TreeNodeInfo(String t, Graph graph) { | |
11 | + public TreeNodeInfo(String t, Graph graph){ | |
17 | 12 | node_title = t; |
18 | 13 | node_object = graph; |
19 | 14 | } |
20 | 15 | |
21 | - public Graph getNode_object() { | |
16 | + public Graph getNode_object(){ | |
22 | 17 | return node_object; |
23 | 18 | } |
24 | 19 | |
25 | - public String getNode_title() { | |
20 | + public String getNode_title(){ | |
26 | 21 | return node_title; |
27 | 22 | } |
28 | 23 | |
29 | - public String toString() { | |
24 | + public String toString(){ | |
30 | 25 | return node_title; |
31 | 26 | } |
32 | 27 |
@@ -1,9 +1,4 @@ | ||
1 | 1 | /* |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | - | |
6 | -/* | |
7 | 2 | * AboutBox.java |
8 | 3 | * |
9 | 4 | * Created on 29 juil. 2010, 17:31:33 |
@@ -20,139 +15,139 @@ | ||
20 | 15 | */ |
21 | 16 | public class AboutBox extends javax.swing.JDialog { |
22 | 17 | |
23 | - /** Creates new form AboutBox | |
18 | + /** Creates new form AboutBox | |
24 | 19 | * @param parent */ |
25 | - public AboutBox(java.awt.Frame parent) { | |
26 | - super(parent); | |
27 | - initComponents(); | |
28 | - Dimension d1 = getSize(); | |
29 | - Dimension d2 = parent.getSize(); | |
30 | - int x = (d2.width -(d1.width/2) ) / 2 ; | |
31 | - int y = (d2.height- (d1.height/2) ) /2 ; | |
32 | - setBounds(x, y, d1.width, d1.height); | |
33 | - setModal(true); | |
34 | - setVisible(true); | |
35 | - } | |
20 | + public AboutBox(java.awt.Frame parent){ | |
21 | + super(parent); | |
22 | + initComponents(); | |
23 | + Dimension d1 = getSize(); | |
24 | + Dimension d2 = parent.getSize(); | |
25 | + int x = (d2.width -(d1.width/2) ) / 2 ; | |
26 | + int y = (d2.height- (d1.height/2) ) /2 ; | |
27 | + setBounds(x, y, d1.width, d1.height); | |
28 | + setModal(true); | |
29 | + setVisible(true); | |
30 | + } | |
36 | 31 | |
37 | - /** This method is called from within the constructor to | |
38 | - * initialize the form. | |
39 | - * WARNING: Do NOT modify this code. The content of this method is | |
40 | - * always regenerated by the Form Editor. | |
41 | - */ | |
42 | - @SuppressWarnings("unchecked") | |
43 | - // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents | |
44 | - private void initComponents() { | |
32 | + /** This method is called from within the constructor to | |
33 | + * initialize the form. | |
34 | + * WARNING: Do NOT modify this code. The content of this method is | |
35 | + * always regenerated by the Form Editor. | |
36 | + */ | |
37 | + @SuppressWarnings("unchecked") | |
38 | + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents | |
39 | + private void initComponents(){ | |
45 | 40 | |
46 | - jPanel3 = new javax.swing.JPanel(); | |
47 | - versionlabel = new javax.swing.JLabel(); | |
48 | - jPanel2 = new javax.swing.JPanel(); | |
49 | - jSeparator2 = new javax.swing.JSeparator(); | |
50 | - urllabel = new javax.swing.JLabel(); | |
51 | - authorlabel = new javax.swing.JLabel(); | |
52 | - licencelabel = new javax.swing.JLabel(); | |
53 | - tipslabel = new javax.swing.JLabel(); | |
54 | - jSeparator1 = new javax.swing.JSeparator(); | |
55 | - jLabel1 = new javax.swing.JLabel(); | |
56 | - jLabel2 = new javax.swing.JLabel(); | |
57 | - jPanel1 = new javax.swing.JPanel(); | |
58 | - OkButton = new javax.swing.JButton(); | |
41 | + jPanel3 = new javax.swing.JPanel(); | |
42 | + versionlabel = new javax.swing.JLabel(); | |
43 | + jPanel2 = new javax.swing.JPanel(); | |
44 | + jSeparator2 = new javax.swing.JSeparator(); | |
45 | + urllabel = new javax.swing.JLabel(); | |
46 | + authorlabel = new javax.swing.JLabel(); | |
47 | + licencelabel = new javax.swing.JLabel(); | |
48 | + tipslabel = new javax.swing.JLabel(); | |
49 | + jSeparator1 = new javax.swing.JSeparator(); | |
50 | + jLabel1 = new javax.swing.JLabel(); | |
51 | + jLabel2 = new javax.swing.JLabel(); | |
52 | + jPanel1 = new javax.swing.JPanel(); | |
53 | + OkButton = new javax.swing.JButton(); | |
59 | 54 | |
60 | - setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); | |
61 | - getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.PAGE_AXIS)); | |
55 | + setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); | |
56 | + getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.PAGE_AXIS)); | |
62 | 57 | |
63 | - jPanel3.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); | |
58 | + jPanel3.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); | |
64 | 59 | |
65 | - versionlabel.setText("kSar version: " + VersionNumber.getVersionNumber()); | |
60 | + versionlabel.setText("kSar version: " + VersionNumber.getVersionNumber()); | |
66 | 61 | |
67 | - javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); | |
68 | - jPanel3.setLayout(jPanel3Layout); | |
69 | - jPanel3Layout.setHorizontalGroup( | |
70 | - jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
71 | - .addGap(0, 518, Short.MAX_VALUE) | |
72 | - .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
73 | - .addGroup(jPanel3Layout.createSequentialGroup() | |
74 | - .addGap(0, 217, Short.MAX_VALUE) | |
75 | - .addComponent(versionlabel) | |
76 | - .addGap(0, 217, Short.MAX_VALUE))) | |
77 | - ); | |
78 | - jPanel3Layout.setVerticalGroup( | |
79 | - jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
80 | - .addGap(0, 16, Short.MAX_VALUE) | |
81 | - .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
82 | - .addGroup(jPanel3Layout.createSequentialGroup() | |
83 | - .addGap(0, 0, Short.MAX_VALUE) | |
84 | - .addComponent(versionlabel) | |
85 | - .addGap(0, 0, Short.MAX_VALUE))) | |
86 | - ); | |
62 | + javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); | |
63 | + jPanel3.setLayout(jPanel3Layout); | |
64 | + jPanel3Layout.setHorizontalGroup( | |
65 | + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
66 | + .addGap(0, 518, Short.MAX_VALUE) | |
67 | + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
68 | + .addGroup(jPanel3Layout.createSequentialGroup() | |
69 | + .addGap(0, 217, Short.MAX_VALUE) | |
70 | + .addComponent(versionlabel) | |
71 | + .addGap(0, 217, Short.MAX_VALUE))) | |
72 | + ); | |
73 | + jPanel3Layout.setVerticalGroup( | |
74 | + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
75 | + .addGap(0, 16, Short.MAX_VALUE) | |
76 | + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
77 | + .addGroup(jPanel3Layout.createSequentialGroup() | |
78 | + .addGap(0, 0, Short.MAX_VALUE) | |
79 | + .addComponent(versionlabel) | |
80 | + .addGap(0, 0, Short.MAX_VALUE))) | |
81 | + ); | |
87 | 82 | |
88 | - getContentPane().add(jPanel3); | |
83 | + getContentPane().add(jPanel3); | |
89 | 84 | |
90 | - jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.PAGE_AXIS)); | |
85 | + jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.PAGE_AXIS)); | |
91 | 86 | |
92 | - jSeparator2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); | |
93 | - jSeparator2.setMaximumSize(new java.awt.Dimension(800, 1)); | |
94 | - jSeparator2.setMinimumSize(new java.awt.Dimension(0, 1)); | |
95 | - jPanel2.add(jSeparator2); | |
87 | + jSeparator2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); | |
88 | + jSeparator2.setMaximumSize(new java.awt.Dimension(800, 1)); | |
89 | + jSeparator2.setMinimumSize(new java.awt.Dimension(0, 1)); | |
90 | + jPanel2.add(jSeparator2); | |
96 | 91 | |
97 | - urllabel.setText("Website(original project): http://sourceforge.net/projects/ksar/"); | |
98 | - jPanel2.add(urllabel); | |
92 | + urllabel.setText("Website(original project): http://sourceforge.net/projects/ksar/"); | |
93 | + jPanel2.add(urllabel); | |
99 | 94 | |
100 | - authorlabel.setText("Author: xavier cherif"); | |
101 | - jPanel2.add(authorlabel); | |
95 | + authorlabel.setText("Author: xavier cherif"); | |
96 | + jPanel2.add(authorlabel); | |
102 | 97 | |
103 | - licencelabel.setText("License: BSD (see LICENCE file)"); | |
104 | - jPanel2.add(licencelabel); | |
98 | + licencelabel.setText("License: BSD (see LICENCE file)"); | |
99 | + jPanel2.add(licencelabel); | |
105 | 100 | |
106 | - tipslabel.setText("ARS LONGA, VITA BREVIS"); | |
107 | - jPanel2.add(tipslabel); | |
101 | + tipslabel.setText("ARS LONGA, VITA BREVIS"); | |
102 | + jPanel2.add(tipslabel); | |
108 | 103 | |
109 | - jSeparator1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); | |
110 | - jSeparator1.setMaximumSize(new java.awt.Dimension(800, 1)); | |
111 | - jSeparator1.setMinimumSize(new java.awt.Dimension(0, 1)); | |
112 | - jPanel2.add(jSeparator1); | |
104 | + jSeparator1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); | |
105 | + jSeparator1.setMaximumSize(new java.awt.Dimension(800, 1)); | |
106 | + jSeparator1.setMinimumSize(new java.awt.Dimension(0, 1)); | |
107 | + jPanel2.add(jSeparator1); | |
113 | 108 | |
114 | - jLabel1.setText("Last update by Pango Chan, 2015/06/09."); | |
115 | - jPanel2.add(jLabel1); | |
109 | + jLabel1.setText("Last update by Pango Chan, 2015/06/09."); | |
110 | + jPanel2.add(jLabel1); | |
116 | 111 | |
117 | - jLabel2.setText("Website(current, temporary): https://osdn.jp/projects/hinemoshelper/"); | |
118 | - jPanel2.add(jLabel2); | |
112 | + jLabel2.setText("Website(current, temporary): https://osdn.jp/projects/hinemoshelper/"); | |
113 | + jPanel2.add(jLabel2); | |
119 | 114 | |
120 | - getContentPane().add(jPanel2); | |
115 | + getContentPane().add(jPanel2); | |
121 | 116 | |
122 | - OkButton.setText("Close"); | |
123 | - OkButton.addActionListener(new java.awt.event.ActionListener() { | |
124 | - public void actionPerformed(java.awt.event.ActionEvent evt) { | |
125 | - OkButtonActionPerformed(evt); | |
126 | - } | |
127 | - }); | |
128 | - jPanel1.add(OkButton); | |
117 | + OkButton.setText("Close"); | |
118 | + OkButton.addActionListener(new java.awt.event.ActionListener(){ | |
119 | + public void actionPerformed(java.awt.event.ActionEvent evt){ | |
120 | + OkButtonActionPerformed(evt); | |
121 | + } | |
122 | + }); | |
123 | + jPanel1.add(OkButton); | |
129 | 124 | |
130 | - getContentPane().add(jPanel1); | |
125 | + getContentPane().add(jPanel1); | |
131 | 126 | |
132 | - pack(); | |
133 | - }// </editor-fold>//GEN-END:initComponents | |
127 | + pack(); | |
128 | + }// </editor-fold>//GEN-END:initComponents | |
134 | 129 | |
135 | - private void OkButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_OkButtonActionPerformed | |
136 | - setVisible(false); | |
137 | - dispose(); | |
138 | - }//GEN-LAST:event_OkButtonActionPerformed | |
130 | + private void OkButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_OkButtonActionPerformed | |
131 | + setVisible(false); | |
132 | + dispose(); | |
133 | + }//GEN-LAST:event_OkButtonActionPerformed | |
139 | 134 | |
140 | 135 | |
141 | 136 | |
142 | - // Variables declaration - do not modify//GEN-BEGIN:variables | |
143 | - private javax.swing.JButton OkButton; | |
144 | - private javax.swing.JLabel authorlabel; | |
145 | - private javax.swing.JLabel jLabel1; | |
146 | - private javax.swing.JLabel jLabel2; | |
147 | - private javax.swing.JPanel jPanel1; | |
148 | - private javax.swing.JPanel jPanel2; | |
149 | - private javax.swing.JPanel jPanel3; | |
150 | - private javax.swing.JSeparator jSeparator1; | |
151 | - private javax.swing.JSeparator jSeparator2; | |
152 | - private javax.swing.JLabel licencelabel; | |
153 | - private javax.swing.JLabel tipslabel; | |
154 | - private javax.swing.JLabel urllabel; | |
155 | - private javax.swing.JLabel versionlabel; | |
156 | - // End of variables declaration//GEN-END:variables | |
137 | + // Variables declaration - do not modify//GEN-BEGIN:variables | |
138 | + private javax.swing.JButton OkButton; | |
139 | + private javax.swing.JLabel authorlabel; | |
140 | + private javax.swing.JLabel jLabel1; | |
141 | + private javax.swing.JLabel jLabel2; | |
142 | + private javax.swing.JPanel jPanel1; | |
143 | + private javax.swing.JPanel jPanel2; | |
144 | + private javax.swing.JPanel jPanel3; | |
145 | + private javax.swing.JSeparator jSeparator1; | |
146 | + private javax.swing.JSeparator jSeparator2; | |
147 | + private javax.swing.JLabel licencelabel; | |
148 | + private javax.swing.JLabel tipslabel; | |
149 | + private javax.swing.JLabel urllabel; | |
150 | + private javax.swing.JLabel versionlabel; | |
151 | + // End of variables declaration//GEN-END:variables | |
157 | 152 | |
158 | 153 | } |
@@ -1,9 +1,4 @@ | ||
1 | 1 | /* |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | - | |
6 | -/* | |
7 | 2 | * HostInfoView.java |
8 | 3 | * |
9 | 4 | * Created on 25 oct. 2010, 16:08:27 |
@@ -20,145 +15,145 @@ | ||
20 | 15 | */ |
21 | 16 | public class HostInfoView extends javax.swing.JDialog { |
22 | 17 | |
23 | - /** Creates new form HostInfoView */ | |
24 | - public HostInfoView(java.awt.Frame parent, HostInfo tmphostinfo) { | |
25 | - | |
26 | - super(parent, true); | |
27 | - hostinfo = tmphostinfo; | |
28 | - initComponents(); | |
29 | - Hostname.setText(hostinfo.getHostname()); | |
30 | - AliasField.setText(hostinfo.getAlias()); | |
31 | - jTextArea1.setText(hostinfo.getDescription()); | |
32 | - memboxcombo.setSelectedItem(hostinfo.getMemBlockSize().toString()); | |
33 | - setLocationRelativeTo(GlobalOptions.getUI()); | |
34 | - } | |
18 | + /** Creates new form HostInfoView */ | |
19 | + public HostInfoView(java.awt.Frame parent, HostInfo tmphostinfo){ | |
20 | + | |
21 | + super(parent, true); | |
22 | + hostinfo = tmphostinfo; | |
23 | + initComponents(); | |
24 | + Hostname.setText(hostinfo.getHostname()); | |
25 | + AliasField.setText(hostinfo.getAlias()); | |
26 | + jTextArea1.setText(hostinfo.getDescription()); | |
27 | + memboxcombo.setSelectedItem(hostinfo.getMemBlockSize().toString()); | |
28 | + setLocationRelativeTo(GlobalOptions.getUI()); | |
29 | + } | |
35 | 30 | |
36 | - /** This method is called from within the constructor to | |
37 | - * initialize the form. | |
38 | - * WARNING: Do NOT modify this code. The content of this method is | |
39 | - * always regenerated by the Form Editor. | |
40 | - */ | |
41 | - @SuppressWarnings("unchecked") | |
42 | - // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents | |
43 | - private void initComponents() { | |
31 | + /** This method is called from within the constructor to | |
32 | + * initialize the form. | |
33 | + * WARNING: Do NOT modify this code. The content of this method is | |
34 | + * always regenerated by the Form Editor. | |
35 | + */ | |
36 | + @SuppressWarnings("unchecked") | |
37 | + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents | |
38 | + private void initComponents(){ | |
44 | 39 | |
45 | - jPanel1 = new javax.swing.JPanel(); | |
46 | - hostnamePanel = new javax.swing.JPanel(); | |
47 | - HostNameLabel = new javax.swing.JLabel(); | |
48 | - Hostname = new javax.swing.JLabel(); | |
49 | - AliasPanel = new javax.swing.JPanel(); | |
50 | - AliasLabel = new javax.swing.JLabel(); | |
51 | - AliasField = new javax.swing.JTextField(); | |
52 | - DescriptionPanel = new javax.swing.JPanel(); | |
53 | - descriptionLabel = new javax.swing.JLabel(); | |
54 | - jScrollPane1 = new javax.swing.JScrollPane(); | |
55 | - jTextArea1 = new javax.swing.JTextArea(); | |
56 | - MemoryPanel = new javax.swing.JPanel(); | |
57 | - memBlockSizeLabel = new javax.swing.JLabel(); | |
58 | - memboxcombo = new javax.swing.JComboBox(); | |
59 | - jPanel2 = new javax.swing.JPanel(); | |
60 | - OkButton = new javax.swing.JButton(); | |
40 | + jPanel1 = new javax.swing.JPanel(); | |
41 | + hostnamePanel = new javax.swing.JPanel(); | |
42 | + HostNameLabel = new javax.swing.JLabel(); | |
43 | + Hostname = new javax.swing.JLabel(); | |
44 | + AliasPanel = new javax.swing.JPanel(); | |
45 | + AliasLabel = new javax.swing.JLabel(); | |
46 | + AliasField = new javax.swing.JTextField(); | |
47 | + DescriptionPanel = new javax.swing.JPanel(); | |
48 | + descriptionLabel = new javax.swing.JLabel(); | |
49 | + jScrollPane1 = new javax.swing.JScrollPane(); | |
50 | + jTextArea1 = new javax.swing.JTextArea(); | |
51 | + MemoryPanel = new javax.swing.JPanel(); | |
52 | + memBlockSizeLabel = new javax.swing.JLabel(); | |
53 | + memboxcombo = new javax.swing.JComboBox(); | |
54 | + jPanel2 = new javax.swing.JPanel(); | |
55 | + OkButton = new javax.swing.JButton(); | |
61 | 56 | |
62 | - setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); | |
63 | - setTitle("Host Information"); | |
57 | + setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); | |
58 | + setTitle("Host Information"); | |
64 | 59 | |
65 | - jPanel1.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); | |
66 | - jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1, javax.swing.BoxLayout.PAGE_AXIS)); | |
60 | + jPanel1.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); | |
61 | + jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1, javax.swing.BoxLayout.PAGE_AXIS)); | |
67 | 62 | |
68 | - hostnamePanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); | |
63 | + hostnamePanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); | |
69 | 64 | |
70 | - HostNameLabel.setLabelFor(Hostname); | |
71 | - HostNameLabel.setText("Hostname:"); | |
72 | - hostnamePanel.add(HostNameLabel); | |
65 | + HostNameLabel.setLabelFor(Hostname); | |
66 | + HostNameLabel.setText("Hostname:"); | |
67 | + hostnamePanel.add(HostNameLabel); | |
73 | 68 | |
74 | - Hostname.setText("hostname"); | |
75 | - hostnamePanel.add(Hostname); | |
69 | + Hostname.setText("hostname"); | |
70 | + hostnamePanel.add(Hostname); | |
76 | 71 | |
77 | - jPanel1.add(hostnamePanel); | |
72 | + jPanel1.add(hostnamePanel); | |
78 | 73 | |
79 | - AliasPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); | |
74 | + AliasPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); | |
80 | 75 | |
81 | - AliasLabel.setText("Alias"); | |
82 | - AliasLabel.setPreferredSize(new java.awt.Dimension(52, 14)); | |
83 | - AliasPanel.add(AliasLabel); | |
76 | + AliasLabel.setText("Alias"); | |
77 | + AliasLabel.setPreferredSize(new java.awt.Dimension(52, 14)); | |
78 | + AliasPanel.add(AliasLabel); | |
84 | 79 | |
85 | - AliasField.setMinimumSize(new java.awt.Dimension(120, 20)); | |
86 | - AliasField.setPreferredSize(new java.awt.Dimension(120, 20)); | |
87 | - AliasPanel.add(AliasField); | |
80 | + AliasField.setMinimumSize(new java.awt.Dimension(120, 20)); | |
81 | + AliasField.setPreferredSize(new java.awt.Dimension(120, 20)); | |
82 | + AliasPanel.add(AliasField); | |
88 | 83 | |
89 | - jPanel1.add(AliasPanel); | |
84 | + jPanel1.add(AliasPanel); | |
90 | 85 | |
91 | - DescriptionPanel.setLayout(new javax.swing.BoxLayout(DescriptionPanel, javax.swing.BoxLayout.PAGE_AXIS)); | |
86 | + DescriptionPanel.setLayout(new javax.swing.BoxLayout(DescriptionPanel, javax.swing.BoxLayout.PAGE_AXIS)); | |
92 | 87 | |
93 | - descriptionLabel.setText("Description"); | |
94 | - descriptionLabel.setPreferredSize(new java.awt.Dimension(52, 14)); | |
95 | - DescriptionPanel.add(descriptionLabel); | |
88 | + descriptionLabel.setText("Description"); | |
89 | + descriptionLabel.setPreferredSize(new java.awt.Dimension(52, 14)); | |
90 | + DescriptionPanel.add(descriptionLabel); | |
96 | 91 | |
97 | - jScrollPane1.setPreferredSize(new java.awt.Dimension(300, 200)); | |
92 | + jScrollPane1.setPreferredSize(new java.awt.Dimension(300, 200)); | |
98 | 93 | |
99 | - jTextArea1.setColumns(20); | |
100 | - jTextArea1.setRows(5); | |
101 | - jTextArea1.setPreferredSize(new java.awt.Dimension(300, 200)); | |
102 | - jScrollPane1.setViewportView(jTextArea1); | |
94 | + jTextArea1.setColumns(20); | |
95 | + jTextArea1.setRows(5); | |
96 | + jTextArea1.setPreferredSize(new java.awt.Dimension(300, 200)); | |
97 | + jScrollPane1.setViewportView(jTextArea1); | |
103 | 98 | |
104 | - DescriptionPanel.add(jScrollPane1); | |
99 | + DescriptionPanel.add(jScrollPane1); | |
105 | 100 | |
106 | - jPanel1.add(DescriptionPanel); | |
101 | + jPanel1.add(DescriptionPanel); | |
107 | 102 | |
108 | - MemoryPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); | |
103 | + MemoryPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); | |
109 | 104 | |
110 | - memBlockSizeLabel.setText("Memory Block Size:"); | |
111 | - MemoryPanel.add(memBlockSizeLabel); | |
105 | + memBlockSizeLabel.setText("Memory Block Size:"); | |
106 | + MemoryPanel.add(memBlockSizeLabel); | |
112 | 107 | |
113 | - memboxcombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1024", "2048", "4096", "8192", "16384" })); | |
114 | - MemoryPanel.add(memboxcombo); | |
108 | + memboxcombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1024", "2048", "4096", "8192", "16384" })); | |
109 | + MemoryPanel.add(memboxcombo); | |
115 | 110 | |
116 | - jPanel1.add(MemoryPanel); | |
111 | + jPanel1.add(MemoryPanel); | |
117 | 112 | |
118 | - getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER); | |
113 | + getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER); | |
119 | 114 | |
120 | - jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 15, 5)); | |
115 | + jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 15, 5)); | |
121 | 116 | |
122 | - OkButton.setText("Ok"); | |
123 | - OkButton.addActionListener(new java.awt.event.ActionListener() { | |
124 | - public void actionPerformed(java.awt.event.ActionEvent evt) { | |
125 | - OkButtonActionPerformed(evt); | |
126 | - } | |
127 | - }); | |
128 | - jPanel2.add(OkButton); | |
117 | + OkButton.setText("Ok"); | |
118 | + OkButton.addActionListener(new java.awt.event.ActionListener(){ | |
119 | + public void actionPerformed(java.awt.event.ActionEvent evt){ | |
120 | + OkButtonActionPerformed(evt); | |
121 | + } | |
122 | + }); | |
123 | + jPanel2.add(OkButton); | |
129 | 124 | |
130 | - getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH); | |
125 | + getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH); | |
131 | 126 | |
132 | - pack(); | |
133 | - }// </editor-fold>//GEN-END:initComponents | |
127 | + pack(); | |
128 | + }// </editor-fold>//GEN-END:initComponents | |
134 | 129 | |
135 | - private void OkButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_OkButtonActionPerformed | |
136 | - this.dispose(); | |
137 | - hostinfo.setAlias(AliasField.getText()); | |
138 | - hostinfo.setDescription(jTextArea1.getText()); | |
139 | - hostinfo.setMemBlockSize(memboxcombo.getSelectedItem().toString()); | |
140 | - GlobalOptions.addHostInfo(hostinfo); | |
141 | - }//GEN-LAST:event_OkButtonActionPerformed | |
130 | + private void OkButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_OkButtonActionPerformed | |
131 | + this.dispose(); | |
132 | + hostinfo.setAlias(AliasField.getText()); | |
133 | + hostinfo.setDescription(jTextArea1.getText()); | |
134 | + hostinfo.setMemBlockSize(memboxcombo.getSelectedItem().toString()); | |
135 | + GlobalOptions.addHostInfo(hostinfo); | |
136 | + }//GEN-LAST:event_OkButtonActionPerformed | |
142 | 137 | |
143 | 138 | |
144 | 139 | |
145 | - // Variables declaration - do not modify//GEN-BEGIN:variables | |
146 | - private javax.swing.JTextField AliasField; | |
147 | - private javax.swing.JLabel AliasLabel; | |
148 | - private javax.swing.JPanel AliasPanel; | |
149 | - private javax.swing.JPanel DescriptionPanel; | |
150 | - private javax.swing.JLabel HostNameLabel; | |
151 | - private javax.swing.JLabel Hostname; | |
152 | - private javax.swing.JPanel MemoryPanel; | |
153 | - private javax.swing.JButton OkButton; | |
154 | - private javax.swing.JLabel descriptionLabel; | |
155 | - private javax.swing.JPanel hostnamePanel; | |
156 | - private javax.swing.JPanel jPanel1; | |
157 | - private javax.swing.JPanel jPanel2; | |
158 | - private javax.swing.JScrollPane jScrollPane1; | |
159 | - private javax.swing.JTextArea jTextArea1; | |
160 | - private javax.swing.JLabel memBlockSizeLabel; | |
161 | - private javax.swing.JComboBox memboxcombo; | |
162 | - // End of variables declaration//GEN-END:variables | |
163 | - HostInfo hostinfo = null; | |
140 | + // Variables declaration - do not modify//GEN-BEGIN:variables | |
141 | + private javax.swing.JTextField AliasField; | |
142 | + private javax.swing.JLabel AliasLabel; | |
143 | + private javax.swing.JPanel AliasPanel; | |
144 | + private javax.swing.JPanel DescriptionPanel; | |
145 | + private javax.swing.JLabel HostNameLabel; | |
146 | + private javax.swing.JLabel Hostname; | |
147 | + private javax.swing.JPanel MemoryPanel; | |
148 | + private javax.swing.JButton OkButton; | |
149 | + private javax.swing.JLabel descriptionLabel; | |
150 | + private javax.swing.JPanel hostnamePanel; | |
151 | + private javax.swing.JPanel jPanel1; | |
152 | + private javax.swing.JPanel jPanel2; | |
153 | + private javax.swing.JScrollPane jScrollPane1; | |
154 | + private javax.swing.JTextArea jTextArea1; | |
155 | + private javax.swing.JLabel memBlockSizeLabel; | |
156 | + private javax.swing.JComboBox memboxcombo; | |
157 | + // End of variables declaration//GEN-END:variables | |
158 | + HostInfo hostinfo = null; | |
164 | 159 | } |
@@ -1,7 +1,3 @@ | ||
1 | -/* | |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | 1 | package net.atomique.ksar.UI; |
6 | 2 | |
7 | 3 | import java.awt.Graphics; |
@@ -18,15 +14,16 @@ | ||
18 | 14 | public static final long serialVersionUID = 501L; |
19 | 15 | Image img = null; |
20 | 16 | |
21 | - public SplashPicture() { | |
17 | + public SplashPicture(){ | |
22 | 18 | img = new ImageIcon(this.getClass().getResource("/logo.jpg")).getImage(); |
23 | 19 | repaint(); |
24 | 20 | } |
25 | 21 | |
26 | - public void paintComponent(Graphics g) { | |
22 | + @Override | |
23 | + public void paintComponent(Graphics g){ | |
27 | 24 | super.paintComponent(g); |
28 | 25 | |
29 | - if (img == null) { | |
26 | + if(img == null){ | |
30 | 27 | return; |
31 | 28 | } |
32 | 29 |
@@ -34,9 +31,9 @@ | ||
34 | 31 | int h = img.getHeight(this); |
35 | 32 | boolean zoom = ((w > getWidth()) || (h > getHeight())); |
36 | 33 | |
37 | - if (zoom) { | |
34 | + if(zoom){ | |
38 | 35 | g.drawImage(img, 0, 0, getWidth(), getHeight(), this); |
39 | - } else { | |
36 | + }else{ | |
40 | 37 | g.drawImage(img, (getWidth() - w) / 2, (getHeight() - h) / 2, this); |
41 | 38 | } |
42 | 39 | } |
@@ -1,8 +1,3 @@ | ||
1 | -/* | |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | - | |
6 | 1 | package net.atomique.ksar.UI; |
7 | 2 | |
8 | 3 | import java.util.Collections; |
@@ -17,40 +12,42 @@ | ||
17 | 12 | |
18 | 13 | public static final long serialVersionUID = 15071L; |
19 | 14 | |
20 | - public SortedTreeNode(String name) { | |
15 | + private int leaf_num=0; | |
16 | + | |
17 | + public SortedTreeNode(String name){ | |
21 | 18 | super(name); |
22 | 19 | } |
23 | 20 | |
24 | - public SortedTreeNode(TreeNodeInfo tmp) { | |
21 | + public SortedTreeNode(TreeNodeInfo tmp){ | |
25 | 22 | super(tmp); |
26 | 23 | } |
27 | 24 | |
28 | - public SortedTreeNode(ParentNodeInfo tmp) { | |
25 | + public SortedTreeNode(ParentNodeInfo tmp){ | |
29 | 26 | super(tmp); |
30 | 27 | } |
31 | 28 | /* |
32 | - public SortedTreeNode (GraphDescription graphdesc) { | |
29 | + public SortedTreeNode (GraphDescription graphdesc){ | |
33 | 30 | super(graphdesc); |
34 | 31 | } |
35 | 32 | */ |
36 | 33 | |
37 | - public void count_graph(SortedTreeNode node) { | |
34 | + public void count_graph(SortedTreeNode node){ | |
38 | 35 | int num = node.getChildCount(); |
39 | 36 | |
40 | - if (num > 0) { | |
41 | - for (int i = 0; i < num; i++) { | |
37 | + if(num > 0){ | |
38 | + for(int i = 0; i < num; i++){ | |
42 | 39 | SortedTreeNode l = (SortedTreeNode) node.getChildAt(i); |
43 | 40 | count_graph(l); |
44 | 41 | } |
45 | - } else { | |
42 | + }else{ | |
46 | 43 | Object obj1 = node.getUserObject(); |
47 | - if (obj1 instanceof TreeNodeInfo) { | |
44 | + if(obj1 instanceof TreeNodeInfo){ | |
48 | 45 | leaf_num++; |
49 | 46 | } |
50 | 47 | } |
51 | 48 | } |
52 | 49 | |
53 | - public int LeafCount() { | |
50 | + public int LeafCount(){ | |
54 | 51 | leaf_num=0; |
55 | 52 | count_graph(this); |
56 | 53 | return leaf_num; |
@@ -57,15 +54,13 @@ | ||
57 | 54 | } |
58 | 55 | |
59 | 56 | @Override |
60 | - public void insert(final MutableTreeNode newChild, final int childIndex) { | |
57 | + public void insert(final MutableTreeNode newChild, final int childIndex){ | |
61 | 58 | super.insert(newChild, childIndex); |
62 | 59 | Collections.sort(this.children); |
63 | 60 | } |
64 | 61 | |
65 | 62 | @Override |
66 | - public int compareTo(final Object o) { | |
63 | + public int compareTo(final Object o){ | |
67 | 64 | return this.toString().compareToIgnoreCase(o.toString()); |
68 | 65 | } |
69 | - | |
70 | - private int leaf_num=0; | |
71 | 66 | } |
@@ -1,7 +1,3 @@ | ||
1 | -/* | |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | 1 | package net.atomique.ksar.UI; |
6 | 2 | |
7 | 3 | import java.awt.BorderLayout; |
@@ -24,7 +20,7 @@ | ||
24 | 20 | |
25 | 21 | private static final long serialVersionUID = 8L; |
26 | 22 | |
27 | - public SplashScreen( Frame f, int waitTime) { | |
23 | + public SplashScreen( Frame f, int waitTime){ | |
28 | 24 | super(f); |
29 | 25 | JPanel p = new JPanel(); |
30 | 26 | p.setLayout(new BorderLayout()); |
@@ -36,27 +32,27 @@ | ||
36 | 32 | setVisible(true); |
37 | 33 | Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
38 | 34 | setLocation(screenSize.width / 2 - (450 / 2), screenSize.height / 2 - (300 / 2)); |
39 | - addMouseListener(new MouseAdapter() { | |
40 | - public void mousePressed(MouseEvent e) { | |
35 | + addMouseListener(new MouseAdapter(){ | |
36 | + public void mousePressed(MouseEvent e){ | |
41 | 37 | setVisible(false); |
42 | 38 | dispose(); |
43 | 39 | } |
44 | 40 | }); |
45 | 41 | final int pause = waitTime; |
46 | - final Runnable closerRunner = new Runnable() { | |
42 | + final Runnable closerRunner = new Runnable(){ | |
47 | 43 | |
48 | - public void run() { | |
44 | + public void run(){ | |
49 | 45 | setVisible(false); |
50 | 46 | dispose(); |
51 | 47 | } |
52 | 48 | }; |
53 | - Runnable waitRunner = new Runnable() { | |
49 | + Runnable waitRunner = new Runnable(){ | |
54 | 50 | |
55 | - public void run() { | |
56 | - try { | |
51 | + public void run(){ | |
52 | + try{ | |
57 | 53 | Thread.sleep(pause); |
58 | 54 | SwingUtilities.invokeAndWait(closerRunner); |
59 | - } catch (Exception e) { | |
55 | + }catch(Exception e){ | |
60 | 56 | e.printStackTrace(); |
61 | 57 | } |
62 | 58 | } |
@@ -1,9 +1,4 @@ | ||
1 | 1 | /* |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | - | |
6 | -/* | |
7 | 2 | * GraphView.java |
8 | 3 | * |
9 | 4 | * Created on 12 août 2010, 11:26:02 |
@@ -27,188 +22,188 @@ | ||
27 | 22 | */ |
28 | 23 | public class GraphView extends javax.swing.JPanel { |
29 | 24 | |
30 | - /** Creates new form GraphView */ | |
31 | - public GraphView() { | |
32 | - initComponents(); | |
33 | - } | |
25 | + /** Creates new form GraphView */ | |
26 | + public GraphView(){ | |
27 | + initComponents(); | |
28 | + } | |
34 | 29 | |
35 | 30 | |
36 | - public void setGraph(Graph graph) { | |
37 | - this.thegraph = graph; | |
38 | - if ( mychartpanel != null) { | |
39 | - graphPanel.remove(mychartpanel); | |
40 | - } | |
41 | - mychartpanel = graph.get_ChartPanel(); | |
42 | - graphPanel.add(mychartpanel); | |
43 | - this.validate(); | |
44 | - } | |
31 | + public void setGraph(Graph graph){ | |
32 | + this.thegraph = graph; | |
33 | + if( mychartpanel != null){ | |
34 | + graphPanel.remove(mychartpanel); | |
35 | + } | |
36 | + mychartpanel = graph.get_ChartPanel(); | |
37 | + graphPanel.add(mychartpanel); | |
38 | + this.validate(); | |
39 | + } | |
45 | 40 | |
46 | - /** This method is called from within the constructor to | |
47 | - * initialize the form. | |
48 | - * WARNING: Do NOT modify this code. The content of this method is | |
49 | - * always regenerated by the Form Editor. | |
50 | - */ | |
51 | - @SuppressWarnings("unchecked") | |
52 | - // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents | |
53 | - private void initComponents() { | |
41 | + /** This method is called from within the constructor to | |
42 | + * initialize the form. | |
43 | + * WARNING: Do NOT modify this code. The content of this method is | |
44 | + * always regenerated by the Form Editor. | |
45 | + */ | |
46 | + @SuppressWarnings("unchecked") | |
47 | + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents | |
48 | + private void initComponents(){ | |
54 | 49 | |
55 | - graphPanel = new javax.swing.JPanel(); | |
56 | - buttonPanel = new javax.swing.JPanel(); | |
57 | - csvButton = new javax.swing.JButton(); | |
58 | - jpgBuitton = new javax.swing.JButton(); | |
59 | - pngButton = new javax.swing.JButton(); | |
60 | - ctrlcButton = new javax.swing.JButton(); | |
61 | - printButton = new javax.swing.JButton(); | |
50 | + graphPanel = new javax.swing.JPanel(); | |
51 | + buttonPanel = new javax.swing.JPanel(); | |
52 | + csvButton = new javax.swing.JButton(); | |
53 | + jpgBuitton = new javax.swing.JButton(); | |
54 | + pngButton = new javax.swing.JButton(); | |
55 | + ctrlcButton = new javax.swing.JButton(); | |
56 | + printButton = new javax.swing.JButton(); | |
62 | 57 | |
63 | - setLayout(new java.awt.BorderLayout()); | |
58 | + setLayout(new java.awt.BorderLayout()); | |
64 | 59 | |
65 | - graphPanel.setLayout(new java.awt.BorderLayout()); | |
66 | - add(graphPanel, java.awt.BorderLayout.CENTER); | |
60 | + graphPanel.setLayout(new java.awt.BorderLayout()); | |
61 | + add(graphPanel, java.awt.BorderLayout.CENTER); | |
67 | 62 | |
68 | - csvButton.setText("export CSV"); | |
69 | - csvButton.addActionListener(new java.awt.event.ActionListener() { | |
70 | - public void actionPerformed(java.awt.event.ActionEvent evt) { | |
71 | - csvButtonActionPerformed(evt); | |
72 | - } | |
73 | - }); | |
74 | - buttonPanel.add(csvButton); | |
63 | + csvButton.setText("export CSV"); | |
64 | + csvButton.addActionListener(new java.awt.event.ActionListener(){ | |
65 | + public void actionPerformed(java.awt.event.ActionEvent evt){ | |
66 | + csvButtonActionPerformed(evt); | |
67 | + } | |
68 | + }); | |
69 | + buttonPanel.add(csvButton); | |
75 | 70 | |
76 | - jpgBuitton.setText("export JPG"); | |
77 | - jpgBuitton.addActionListener(new java.awt.event.ActionListener() { | |
78 | - public void actionPerformed(java.awt.event.ActionEvent evt) { | |
79 | - jpgBuittonActionPerformed(evt); | |
80 | - } | |
81 | - }); | |
82 | - buttonPanel.add(jpgBuitton); | |
71 | + jpgBuitton.setText("export JPG"); | |
72 | + jpgBuitton.addActionListener(new java.awt.event.ActionListener(){ | |
73 | + public void actionPerformed(java.awt.event.ActionEvent evt){ | |
74 | + jpgBuittonActionPerformed(evt); | |
75 | + } | |
76 | + }); | |
77 | + buttonPanel.add(jpgBuitton); | |
83 | 78 | |
84 | - pngButton.setText("Export PNG"); | |
85 | - pngButton.addActionListener(new java.awt.event.ActionListener() { | |
86 | - public void actionPerformed(java.awt.event.ActionEvent evt) { | |
87 | - pngButtonActionPerformed(evt); | |
88 | - } | |
89 | - }); | |
90 | - buttonPanel.add(pngButton); | |
79 | + pngButton.setText("Export PNG"); | |
80 | + pngButton.addActionListener(new java.awt.event.ActionListener(){ | |
81 | + public void actionPerformed(java.awt.event.ActionEvent evt){ | |
82 | + pngButtonActionPerformed(evt); | |
83 | + } | |
84 | + }); | |
85 | + buttonPanel.add(pngButton); | |
91 | 86 | |
92 | - ctrlcButton.setText("Copy"); | |
93 | - ctrlcButton.addActionListener(new java.awt.event.ActionListener() { | |
94 | - public void actionPerformed(java.awt.event.ActionEvent evt) { | |
95 | - ctrlcButtonActionPerformed(evt); | |
96 | - } | |
97 | - }); | |
98 | - buttonPanel.add(ctrlcButton); | |
87 | + ctrlcButton.setText("Copy"); | |
88 | + ctrlcButton.addActionListener(new java.awt.event.ActionListener(){ | |
89 | + public void actionPerformed(java.awt.event.ActionEvent evt){ | |
90 | + ctrlcButtonActionPerformed(evt); | |
91 | + } | |
92 | + }); | |
93 | + buttonPanel.add(ctrlcButton); | |
99 | 94 | |
100 | - printButton.setText("Print"); | |
101 | - printButton.addActionListener(new java.awt.event.ActionListener() { | |
102 | - public void actionPerformed(java.awt.event.ActionEvent evt) { | |
103 | - printButtonActionPerformed(evt); | |
104 | - } | |
105 | - }); | |
106 | - buttonPanel.add(printButton); | |
95 | + printButton.setText("Print"); | |
96 | + printButton.addActionListener(new java.awt.event.ActionListener(){ | |
97 | + public void actionPerformed(java.awt.event.ActionEvent evt){ | |
98 | + printButtonActionPerformed(evt); | |
99 | + } | |
100 | + }); | |
101 | + buttonPanel.add(printButton); | |
107 | 102 | |
108 | - add(buttonPanel, java.awt.BorderLayout.SOUTH); | |
109 | - }// </editor-fold>//GEN-END:initComponents | |
103 | + add(buttonPanel, java.awt.BorderLayout.SOUTH); | |
104 | + }// </editor-fold>//GEN-END:initComponents | |
110 | 105 | |
111 | - private void csvButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_csvButtonActionPerformed | |
112 | - String filename = null; | |
113 | - String buffer = null; | |
114 | - | |
115 | - filename = askSaveFilename("Export CSV", Config.getLastExportDirectory()); | |
106 | + private void csvButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_csvButtonActionPerformed | |
107 | + String filename = null; | |
108 | + String buffer = null; | |
109 | + | |
110 | + filename = askSaveFilename("Export CSV", Config.getLastExportDirectory()); | |
116 | 111 | |
117 | - if (filename == null) { | |
118 | - return; | |
119 | - } | |
120 | - Config.setLastExportDirectory(filename); | |
121 | - if (!Config.getLastExportDirectory().isDirectory()) { | |
122 | - Config.setLastExportDirectory(Config.getLastExportDirectory().getParentFile()); | |
123 | - Config.save(); | |
124 | - } | |
112 | + if(filename == null){ | |
113 | + return; | |
114 | + } | |
115 | + Config.setLastExportDirectory(filename); | |
116 | + if(!Config.getLastExportDirectory().isDirectory()){ | |
117 | + Config.setLastExportDirectory(Config.getLastExportDirectory().getParentFile()); | |
118 | + Config.save(); | |
119 | + } | |
125 | 120 | |
126 | - buffer = thegraph.make_csv(); | |
121 | + buffer = thegraph.make_csv(); | |
127 | 122 | |
128 | - if ( GlobalOptions.isDodebug() ) { | |
129 | - System.out.println(buffer); | |
130 | - } | |
131 | - BufferedWriter out = null; | |
132 | - try { | |
133 | - out = new BufferedWriter(new FileWriter(filename)); | |
134 | - } catch (IOException e) { | |
135 | - out = null; | |
136 | - } | |
137 | - if ( out == null ) { | |
138 | - return; | |
139 | - } | |
140 | - try { | |
141 | - out.write(buffer); | |
142 | - out.flush(); | |
143 | - out.close(); | |
144 | - } catch (IOException e) { | |
145 | - | |
146 | - } | |
147 | - | |
123 | + if( GlobalOptions.isDodebug() ){ | |
124 | + System.out.println(buffer); | |
125 | + } | |
126 | + BufferedWriter out = null; | |
127 | + try{ | |
128 | + out = new BufferedWriter(new FileWriter(filename)); | |
129 | + }catch(IOException e){ | |
130 | + out = null; | |
131 | + } | |
132 | + if( out == null ){ | |
133 | + return; | |
134 | + } | |
135 | + try{ | |
136 | + out.write(buffer); | |
137 | + out.flush(); | |
138 | + out.close(); | |
139 | + }catch(IOException e){ | |
140 | + | |
141 | + } | |
142 | + | |
148 | 143 | |
149 | - }//GEN-LAST:event_csvButtonActionPerformed | |
144 | + }//GEN-LAST:event_csvButtonActionPerformed | |
150 | 145 | |
151 | - private void jpgBuittonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jpgBuittonActionPerformed | |
152 | - String filename = askSaveFilename("Export JPG", Config.getLastExportDirectory()); | |
153 | - if ( filename == null ) { | |
154 | - return; | |
155 | - } | |
156 | - thegraph.saveJPG(null, null, filename, Config.getImageWidth(), Config.getImageHeight()); | |
157 | - }//GEN-LAST:event_jpgBuittonActionPerformed | |
146 | + private void jpgBuittonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jpgBuittonActionPerformed | |
147 | + String filename = askSaveFilename("Export JPG", Config.getLastExportDirectory()); | |
148 | + if( filename == null ){ | |
149 | + return; | |
150 | + } | |
151 | + thegraph.saveJPG(null, null, filename, Config.getImageWidth(), Config.getImageHeight()); | |
152 | + }//GEN-LAST:event_jpgBuittonActionPerformed | |
158 | 153 | |
159 | - private void ctrlcButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ctrlcButtonActionPerformed | |
160 | - mychartpanel.doCopy(); | |
161 | - }//GEN-LAST:event_ctrlcButtonActionPerformed | |
154 | + private void ctrlcButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ctrlcButtonActionPerformed | |
155 | + mychartpanel.doCopy(); | |
156 | + }//GEN-LAST:event_ctrlcButtonActionPerformed | |
162 | 157 | |
163 | - private void printButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_printButtonActionPerformed | |
164 | - mychartpanel.createChartPrintJob(); | |
165 | - }//GEN-LAST:event_printButtonActionPerformed | |
158 | + private void printButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_printButtonActionPerformed | |
159 | + mychartpanel.createChartPrintJob(); | |
160 | + }//GEN-LAST:event_printButtonActionPerformed | |
166 | 161 | |
167 | - private void pngButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pngButtonActionPerformed | |
168 | - String filename = askSaveFilename("Export PNG", Config.getLastExportDirectory()); | |
169 | - if ( filename == null ) { | |
170 | - return; | |
171 | - } | |
172 | - thegraph.savePNG(null, null, filename, Config.getImageWidth(), Config.getImageHeight()); | |
173 | - }//GEN-LAST:event_pngButtonActionPerformed | |
162 | + private void pngButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pngButtonActionPerformed | |
163 | + String filename = askSaveFilename("Export PNG", Config.getLastExportDirectory()); | |
164 | + if( filename == null ){ | |
165 | + return; | |
166 | + } | |
167 | + thegraph.savePNG(null, null, filename, Config.getImageWidth(), Config.getImageHeight()); | |
168 | + }//GEN-LAST:event_pngButtonActionPerformed | |
174 | 169 | |
175 | 170 | |
176 | - | |
177 | - private String askSaveFilename(String title, File chdirto) { | |
178 | - String filename = null; | |
179 | - JFileChooser chooser = new JFileChooser(); | |
180 | - chooser.setDialogTitle(title); | |
181 | - if (chdirto != null) { | |
182 | - chooser.setCurrentDirectory(chdirto); | |
183 | - } | |
184 | - int returnVal = chooser.showSaveDialog(GlobalOptions.getUI()); | |
185 | - if (returnVal == JFileChooser.APPROVE_OPTION) { | |
186 | - filename = chooser.getSelectedFile().getAbsolutePath(); | |
187 | - } | |
171 | + | |
172 | + private String askSaveFilename(String title, File chdirto){ | |
173 | + String filename = null; | |
174 | + JFileChooser chooser = new JFileChooser(); | |
175 | + chooser.setDialogTitle(title); | |
176 | + if(chdirto != null){ | |
177 | + chooser.setCurrentDirectory(chdirto); | |
178 | + } | |
179 | + int returnVal = chooser.showSaveDialog(GlobalOptions.getUI()); | |
180 | + if(returnVal == JFileChooser.APPROVE_OPTION){ | |
181 | + filename = chooser.getSelectedFile().getAbsolutePath(); | |
182 | + } | |
188 | 183 | |
189 | - if (filename == null) { | |
190 | - return null; | |
191 | - } | |
184 | + if(filename == null){ | |
185 | + return null; | |
186 | + } | |
192 | 187 | |
193 | - if (new File(filename).exists()) { | |
194 | - String[] choix = {"Yes", "No"}; | |
195 | - int resultat = JOptionPane.showOptionDialog(null, "Overwrite " + filename + " ?", "File Exist", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, choix, choix[1]); | |
196 | - if (resultat != 0) { | |
197 | - return null; | |
198 | - } | |
199 | - } | |
200 | - return filename; | |
201 | - } | |
202 | - | |
203 | - // Variables declaration - do not modify//GEN-BEGIN:variables | |
204 | - private javax.swing.JPanel buttonPanel; | |
205 | - private javax.swing.JButton csvButton; | |
206 | - private javax.swing.JButton ctrlcButton; | |
207 | - private javax.swing.JPanel graphPanel; | |
208 | - private javax.swing.JButton jpgBuitton; | |
209 | - private javax.swing.JButton pngButton; | |
210 | - private javax.swing.JButton printButton; | |
211 | - // End of variables declaration//GEN-END:variables | |
212 | - private Graph thegraph = null; | |
213 | - private ChartPanel mychartpanel = null; | |
188 | + if(new File(filename).exists()){ | |
189 | + String[] choix = {"Yes", "No"}; | |
190 | + int resultat = JOptionPane.showOptionDialog(null, "Overwrite " + filename + " ?", "File Exist", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, choix, choix[1]); | |
191 | + if(resultat != 0){ | |
192 | + return null; | |
193 | + } | |
194 | + } | |
195 | + return filename; | |
196 | + } | |
197 | + | |
198 | + // Variables declaration - do not modify//GEN-BEGIN:variables | |
199 | + private javax.swing.JPanel buttonPanel; | |
200 | + private javax.swing.JButton csvButton; | |
201 | + private javax.swing.JButton ctrlcButton; | |
202 | + private javax.swing.JPanel graphPanel; | |
203 | + private javax.swing.JButton jpgBuitton; | |
204 | + private javax.swing.JButton pngButton; | |
205 | + private javax.swing.JButton printButton; | |
206 | + // End of variables declaration//GEN-END:variables | |
207 | + private Graph thegraph = null; | |
208 | + private ChartPanel mychartpanel = null; | |
214 | 209 | } |
@@ -1,9 +1,4 @@ | ||
1 | 1 | /* |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | - | |
6 | -/* | |
7 | 2 | * Preferences.java |
8 | 3 | * |
9 | 4 | * Created on 30 juil. 2010, 13:55:43 |
@@ -25,8 +20,54 @@ | ||
25 | 20 | */ |
26 | 21 | public class Preferences extends javax.swing.JDialog { |
27 | 22 | |
28 | - /** Creates new form Preferences */ | |
29 | - public Preferences(java.awt.Frame parent) { | |
23 | + // Variables declaration - do not modify//GEN-BEGIN:variables | |
24 | + private javax.swing.JButton CancelButton; | |
25 | + private javax.swing.JButton OkButton; | |
26 | + private javax.swing.JComboBox jComboBox1; | |
27 | + private javax.swing.JComboBox jComboBox2; | |
28 | + private javax.swing.JLabel jLabel1; | |
29 | + private javax.swing.JLabel jLabel3; | |
30 | + private javax.swing.JLabel jLabel4; | |
31 | + private javax.swing.JLabel jLabel5; | |
32 | + private javax.swing.JLabel jLabel6; | |
33 | + private javax.swing.JLabel jLabel7; | |
34 | + private javax.swing.JLabel jLabel8; | |
35 | + private javax.swing.JPanel jPanel1; | |
36 | + private javax.swing.JPanel jPanel10; | |
37 | + private javax.swing.JPanel jPanel11; | |
38 | + private javax.swing.JPanel jPanel2; | |
39 | + private javax.swing.JPanel jPanel3; | |
40 | + private javax.swing.JPanel jPanel4; | |
41 | + private javax.swing.JPanel jPanel5; | |
42 | + private javax.swing.JPanel jPanel7; | |
43 | + private javax.swing.JPanel jPanel8; | |
44 | + private javax.swing.JPanel jPanel9; | |
45 | + private javax.swing.JScrollPane jScrollPane1; | |
46 | + private javax.swing.JSpinner jSpinner1; | |
47 | + private javax.swing.JSpinner jSpinner2; | |
48 | + private javax.swing.JComboBox linuxDateFormatComboBox; | |
49 | + private javax.swing.JComboBox linuxTimeFormatComboBox; | |
50 | + // End of variables declaration//GEN-END:variables | |
51 | + | |
52 | + public static final String DEFAULT_DATE_FORMAT = "MM/dd/yy"; | |
53 | + public static final String DEFAULT_TIME_FORMAT = "HH:mm:ss"; | |
54 | + | |
55 | + DefaultComboBoxModel ui_lanf_model = new DefaultComboBoxModel(); | |
56 | + DefaultComboBoxModel pageFormatComboBox = new DefaultComboBoxModel(); | |
57 | + DefaultComboBoxModel linuxDateFormatComboModel = new DefaultComboBoxModel(); | |
58 | + DefaultComboBoxModel linuxTimeFormatComboModel = new DefaultComboBoxModel(); | |
59 | + SpinnerNumberModel imageWidthSpinner = new javax.swing.SpinnerNumberModel(Config.getImageWidth(), Integer.valueOf(1), null, Integer.valueOf(1)); | |
60 | + SpinnerNumberModel imageHeightSpinner = new javax.swing.SpinnerNumberModel(Config.getImageHeight(), Integer.valueOf(1), null, Integer.valueOf(1)); | |
61 | + | |
62 | + public Preferences(){ | |
63 | + | |
64 | + } | |
65 | + | |
66 | + /** | |
67 | + * Creates new form Preferences | |
68 | + * @param parent | |
69 | + */ | |
70 | + public Preferences(java.awt.Frame parent){ | |
30 | 71 | super(parent); |
31 | 72 | initComponents(); |
32 | 73 | load_landf(); |
@@ -41,34 +82,37 @@ | ||
41 | 82 | setVisible(true); |
42 | 83 | } |
43 | 84 | |
44 | - private void load_landf() { | |
85 | + private void load_landf(){ | |
45 | 86 | UIManager.LookAndFeelInfo looks[] = UIManager.getInstalledLookAndFeels(); |
46 | - for (int i = 0, n = looks.length; i < n; i++) { | |
87 | + for(int i = 0, n = looks.length; i < n; i++){ | |
47 | 88 | String tmp = looks[i].getName(); |
48 | - UI_lanf_model.addElement(tmp); | |
49 | - if (Config.getLandf().equals(tmp)) { | |
89 | + ui_lanf_model.addElement(tmp); | |
90 | + if(Config.getLandf().equals(tmp)){ | |
50 | 91 | jComboBox1.setSelectedItem(tmp); |
51 | 92 | } |
52 | 93 | } |
53 | 94 | } |
54 | 95 | |
55 | - private void load_linuxformat() { | |
56 | - LinuxFormatComboModel.addElement("Always ask"); | |
57 | - LinuxFormatComboModel.addElement("MM/DD/YYYY 12:59:59 AM|PM"); | |
58 | - LinuxFormatComboModel.addElement("MM/DD/YYYY 23:59:59"); | |
59 | - LinuxFormatComboModel.addElement("DD/MM/YYYY 23:59:59"); | |
60 | - LinuxFormatComboModel.addElement("YYYY-MM-DD 23:59:59"); | |
61 | - jComboBox3.setSelectedItem(Config.getLinuxDateFormat()); | |
96 | + private void load_linuxformat(){ | |
97 | + linuxDateFormatComboModel.addElement(DEFAULT_DATE_FORMAT); | |
98 | + linuxDateFormatComboModel.addElement("MM/dd/yyyy"); | |
99 | + linuxDateFormatComboModel.addElement("dd/MM/yyyy"); | |
100 | + linuxDateFormatComboModel.addElement("yyyy-MM-dd"); | |
101 | + linuxDateFormatComboBox.setSelectedItem(Config.getLinuxDateFormat()); | |
102 | + | |
103 | + linuxTimeFormatComboModel.addElement(DEFAULT_TIME_FORMAT); | |
104 | + linuxTimeFormatComboModel.addElement("hh:mm:ss a"); | |
105 | + linuxTimeFormatComboBox.setSelectedItem(Config.getLinuxTimeFormat()); | |
62 | 106 | } |
63 | - | |
64 | - private void load_pageformat() { | |
65 | - PageFormatComboBox.addElement("A4"); | |
66 | - PageFormatComboBox.addElement("LETTER"); | |
67 | - PageFormatComboBox.addElement("LEGAL"); | |
107 | + | |
108 | + private void load_pageformat(){ | |
109 | + pageFormatComboBox.addElement("A4"); | |
110 | + pageFormatComboBox.addElement("LETTER"); | |
111 | + pageFormatComboBox.addElement("LEGAL"); | |
68 | 112 | jComboBox2.setSelectedItem(Config.getPDFPageFormat()); |
69 | - | |
70 | 113 | } |
71 | - /** This method is called from within the constructor to | |
114 | + | |
115 | + /** This method is called from within the constructor to | |
72 | 116 | * initialize the form. |
73 | 117 | * WARNING: Do NOT modify this code. The content of this method is |
74 | 118 | * always regenerated by the Form Editor. |
@@ -85,9 +129,10 @@ | ||
85 | 129 | jComboBox1 = new javax.swing.JComboBox(); |
86 | 130 | jPanel10 = new javax.swing.JPanel(); |
87 | 131 | jLabel7 = new javax.swing.JLabel(); |
88 | - jComboBox3 = new javax.swing.JComboBox(); | |
89 | - jPanel6 = new javax.swing.JPanel(); | |
90 | - jLabel2 = new javax.swing.JLabel(); | |
132 | + linuxDateFormatComboBox = new javax.swing.JComboBox(); | |
133 | + jPanel11 = new javax.swing.JPanel(); | |
134 | + jLabel8 = new javax.swing.JLabel(); | |
135 | + linuxTimeFormatComboBox = new javax.swing.JComboBox(); | |
91 | 136 | jPanel8 = new javax.swing.JPanel(); |
92 | 137 | jLabel5 = new javax.swing.JLabel(); |
93 | 138 | jPanel7 = new javax.swing.JPanel(); |
@@ -105,7 +150,8 @@ | ||
105 | 150 | |
106 | 151 | setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); |
107 | 152 | |
108 | - jPanel1.setPreferredSize(new java.awt.Dimension(430, 430)); | |
153 | + jPanel1.setMinimumSize(new java.awt.Dimension(200, 100)); | |
154 | + jPanel1.setPreferredSize(new java.awt.Dimension(500, 200)); | |
109 | 155 | jPanel1.setLayout(new java.awt.BorderLayout()); |
110 | 156 | |
111 | 157 | jPanel4.setLayout(new javax.swing.BoxLayout(jPanel4, javax.swing.BoxLayout.PAGE_AXIS)); |
@@ -115,7 +161,7 @@ | ||
115 | 161 | jLabel1.setText("Look and Feel: "); |
116 | 162 | jPanel5.add(jLabel1); |
117 | 163 | |
118 | - jComboBox1.setModel(UI_lanf_model); | |
164 | + jComboBox1.setModel(ui_lanf_model); | |
119 | 165 | jComboBox1.addActionListener(new java.awt.event.ActionListener() { |
120 | 166 | public void actionPerformed(java.awt.event.ActionEvent evt) { |
121 | 167 | jComboBox1ActionPerformed(evt); |
@@ -127,22 +173,39 @@ | ||
127 | 173 | |
128 | 174 | jPanel10.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); |
129 | 175 | |
130 | - jLabel7.setLabelFor(jComboBox3); | |
131 | - jLabel7.setText("Linux Format:"); | |
176 | + jLabel7.setLabelFor(linuxDateFormatComboBox); | |
177 | + jLabel7.setText("Linux Date Format:"); | |
132 | 178 | jPanel10.add(jLabel7); |
133 | 179 | |
134 | - jComboBox3.setModel(LinuxFormatComboModel); | |
135 | - jPanel10.add(jComboBox3); | |
180 | + linuxDateFormatComboBox.setEditable(true); | |
181 | + linuxDateFormatComboBox.setModel(linuxDateFormatComboModel); | |
182 | + linuxDateFormatComboBox.addActionListener(new java.awt.event.ActionListener() { | |
183 | + public void actionPerformed(java.awt.event.ActionEvent evt) { | |
184 | + linuxDateFormatComboBoxActionPerformed(evt); | |
185 | + } | |
186 | + }); | |
187 | + jPanel10.add(linuxDateFormatComboBox); | |
188 | + linuxDateFormatComboBox.getAccessibleContext().setAccessibleName("Linux Date Format:"); | |
136 | 189 | |
137 | - jPanel4.add(jPanel10); | |
190 | + jPanel11.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); | |
138 | 191 | |
139 | - jPanel6.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 2, 2)); | |
192 | + jLabel8.setLabelFor(linuxDateFormatComboBox); | |
193 | + jLabel8.setText("Linux Time Format:"); | |
194 | + jPanel11.add(jLabel8); | |
140 | 195 | |
141 | - jLabel2.setText("Language: "); | |
142 | - jPanel6.add(jLabel2); | |
196 | + linuxTimeFormatComboBox.setEditable(true); | |
197 | + linuxTimeFormatComboBox.setModel(linuxTimeFormatComboModel); | |
198 | + linuxTimeFormatComboBox.addActionListener(new java.awt.event.ActionListener() { | |
199 | + public void actionPerformed(java.awt.event.ActionEvent evt) { | |
200 | + linuxTimeFormatComboBoxActionPerformed(evt); | |
201 | + } | |
202 | + }); | |
203 | + jPanel11.add(linuxTimeFormatComboBox); | |
143 | 204 | |
144 | - jPanel4.add(jPanel6); | |
205 | + jPanel10.add(jPanel11); | |
145 | 206 | |
207 | + jPanel4.add(jPanel10); | |
208 | + | |
146 | 209 | jPanel8.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); |
147 | 210 | |
148 | 211 | jLabel5.setText("JPG/PNG"); |
@@ -176,7 +239,7 @@ | ||
176 | 239 | jLabel6.setText("PDF Page Format:"); |
177 | 240 | jPanel9.add(jLabel6); |
178 | 241 | |
179 | - jComboBox2.setModel(PageFormatComboBox); | |
242 | + jComboBox2.setModel(pageFormatComboBox); | |
180 | 243 | jComboBox2.setMinimumSize(new java.awt.Dimension(100, 27)); |
181 | 244 | jComboBox2.setPreferredSize(new java.awt.Dimension(100, 27)); |
182 | 245 | jPanel9.add(jComboBox2); |
@@ -216,25 +279,21 @@ | ||
216 | 279 | |
217 | 280 | private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed |
218 | 281 | Object source = evt.getSource(); |
219 | - String lafClassName = null; | |
220 | - if (source == jComboBox1) { | |
282 | + if(source == jComboBox1){ | |
221 | 283 | JComboBox comboBox = (JComboBox) source; |
222 | - lafClassName = (String) comboBox.getSelectedItem(); | |
223 | - if (lafClassName != null) { | |
224 | - String finalLafClassName = lafClassName; | |
225 | - for (UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) { | |
226 | - if (lafClassName.equals(laf.getName())) { | |
227 | - try { | |
284 | + String lafClassName = (String) comboBox.getSelectedItem(); | |
285 | + if(lafClassName != null){ | |
286 | + for(UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()){ | |
287 | + if(lafClassName.equals(laf.getName())){ | |
288 | + try{ | |
228 | 289 | UIManager.setLookAndFeel(laf.getClassName()); |
229 | 290 | SwingUtilities.updateComponentTreeUI(GlobalOptions.getUI()); |
230 | - } catch (Exception e) { | |
291 | + }catch(Exception e){ | |
231 | 292 | } |
232 | - | |
233 | 293 | } |
234 | 294 | } |
235 | 295 | } |
236 | 296 | } |
237 | - | |
238 | 297 | }//GEN-LAST:event_jComboBox1ActionPerformed |
239 | 298 | |
240 | 299 | private void OkButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_OkButtonActionPerformed |
@@ -242,7 +301,7 @@ | ||
242 | 301 | Config.setPDFPageFormat(jComboBox2.getSelectedItem().toString()); |
243 | 302 | Config.setImageHeight((Integer)jSpinner2.getModel().getValue()); |
244 | 303 | Config.setImageWidth((Integer)jSpinner1.getModel().getValue()); |
245 | - Config.setLinuxDateFormat(jComboBox3.getSelectedItem().toString()); | |
304 | + Config.setLinuxDateTimeFormat(linuxDateFormatComboBox.getSelectedItem().toString(), linuxTimeFormatComboBox.getSelectedItem().toString()); | |
246 | 305 | Config.save(); |
247 | 306 | dispose(); |
248 | 307 | }//GEN-LAST:event_OkButtonActionPerformed |
@@ -251,36 +310,7 @@ | ||
251 | 310 | dispose(); |
252 | 311 | }//GEN-LAST:event_CancelButtonActionPerformed |
253 | 312 | |
254 | - // Variables declaration - do not modify//GEN-BEGIN:variables | |
255 | - private javax.swing.JButton CancelButton; | |
256 | - private javax.swing.JButton OkButton; | |
257 | - private javax.swing.JComboBox jComboBox1; | |
258 | - private javax.swing.JComboBox jComboBox2; | |
259 | - private javax.swing.JComboBox jComboBox3; | |
260 | - private javax.swing.JLabel jLabel1; | |
261 | - private javax.swing.JLabel jLabel2; | |
262 | - private javax.swing.JLabel jLabel3; | |
263 | - private javax.swing.JLabel jLabel4; | |
264 | - private javax.swing.JLabel jLabel5; | |
265 | - private javax.swing.JLabel jLabel6; | |
266 | - private javax.swing.JLabel jLabel7; | |
267 | - private javax.swing.JPanel jPanel1; | |
268 | - private javax.swing.JPanel jPanel10; | |
269 | - private javax.swing.JPanel jPanel2; | |
270 | - private javax.swing.JPanel jPanel3; | |
271 | - private javax.swing.JPanel jPanel4; | |
272 | - private javax.swing.JPanel jPanel5; | |
273 | - private javax.swing.JPanel jPanel6; | |
274 | - private javax.swing.JPanel jPanel7; | |
275 | - private javax.swing.JPanel jPanel8; | |
276 | - private javax.swing.JPanel jPanel9; | |
277 | - private javax.swing.JScrollPane jScrollPane1; | |
278 | - private javax.swing.JSpinner jSpinner1; | |
279 | - private javax.swing.JSpinner jSpinner2; | |
280 | - // End of variables declaration//GEN-END:variables | |
281 | - DefaultComboBoxModel UI_lanf_model = new DefaultComboBoxModel(); | |
282 | - DefaultComboBoxModel PageFormatComboBox = new DefaultComboBoxModel(); | |
283 | - DefaultComboBoxModel LinuxFormatComboModel = new DefaultComboBoxModel(); | |
284 | - SpinnerNumberModel imageWidthSpinner = new javax.swing.SpinnerNumberModel(Config.getImageWidth(), Integer.valueOf(1), null, Integer.valueOf(1)); | |
285 | - SpinnerNumberModel imageHeightSpinner = new javax.swing.SpinnerNumberModel(Config.getImageHeight(), Integer.valueOf(1), null, Integer.valueOf(1)); | |
313 | + private void linuxDateFormatComboBoxActionPerformed(java.awt.event.ActionEvent evt){} | |
314 | + private void linuxTimeFormatComboBoxActionPerformed(java.awt.event.ActionEvent evt){} | |
315 | + | |
286 | 316 | } |
@@ -1,9 +1,4 @@ | ||
1 | 1 | /* |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | - | |
6 | -/* | |
7 | 2 | * DataView.java |
8 | 3 | * |
9 | 4 | * Created on 30 juil. 2010, 15:38:01 |
@@ -37,15 +32,18 @@ | ||
37 | 32 | private boolean has_fresh_data = false; |
38 | 33 | private KSar mysar = null; |
39 | 34 | private JPanel current_panel = null; |
40 | - private GraphView mygraphview = new GraphView(); | |
35 | + private final GraphView mygraphview = new GraphView(); | |
41 | 36 | private JPanel askparentPanel = null; |
42 | - private int total_graph=0; | |
37 | + private final int total_graph=0; | |
43 | 38 | |
44 | - /** Creates new form DataView */ | |
45 | - public DataView(KSar sar) { | |
39 | + /** | |
40 | + * Creates new form DataView | |
41 | + * @param sar | |
42 | + */ | |
43 | + public DataView(KSar sar){ | |
46 | 44 | initComponents(); |
47 | 45 | mysar = sar; |
48 | - jTree1.setModel(new DefaultTreeModel(mysar.graphtree)); | |
46 | + sarTree.setModel(new DefaultTreeModel(mysar.getGraphTree())); | |
49 | 47 | } |
50 | 48 | |
51 | 49 | /** This method is called from within the constructor to |
@@ -54,171 +52,169 @@ | ||
54 | 52 | * always regenerated by the Form Editor. |
55 | 53 | */ |
56 | 54 | @SuppressWarnings("unchecked") |
57 | - // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents | |
58 | - private void initComponents() { | |
55 | + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents | |
56 | + private void initComponents() { | |
59 | 57 | |
60 | - jSeparator1 = new javax.swing.JSeparator(); | |
61 | - jPanel1 = new javax.swing.JPanel(); | |
62 | - jSplitPane1 = new javax.swing.JSplitPane(); | |
63 | - jPanel2 = new javax.swing.JPanel(); | |
64 | - jScrollPane1 = new javax.swing.JScrollPane(); | |
65 | - jTree1 = new javax.swing.JTree(); | |
66 | - jButton1 = new javax.swing.JButton(); | |
67 | - displayPanel = new javax.swing.JPanel(); | |
68 | - jMenuBar1 = new javax.swing.JMenuBar(); | |
69 | - dataMenu = new javax.swing.JMenu(); | |
70 | - LoadFile = new javax.swing.JMenuItem(); | |
71 | - jSeparator3 = new javax.swing.JPopupMenu.Separator(); | |
72 | - LoadCommand = new javax.swing.JMenuItem(); | |
73 | - jSeparator2 = new javax.swing.JPopupMenu.Separator(); | |
74 | - LoadSSH = new javax.swing.JMenuItem(); | |
75 | - updateSSHMenuItem = new javax.swing.JMenuItem(); | |
76 | - GraphMenu = new javax.swing.JMenu(); | |
77 | - addgraphMenu = new javax.swing.JMenuItem(); | |
78 | - exportMenu = new javax.swing.JMenu(); | |
79 | - PDFMenu = new javax.swing.JMenuItem(); | |
80 | - CSVMenu = new javax.swing.JMenuItem(); | |
58 | + jSeparator1 = new javax.swing.JSeparator(); | |
59 | + jPanel1 = new javax.swing.JPanel(); | |
60 | + jSplitPane1 = new javax.swing.JSplitPane(); | |
61 | + jPanel2 = new javax.swing.JPanel(); | |
62 | + jScrollPane1 = new javax.swing.JScrollPane(); | |
63 | + sarTree = new javax.swing.JTree(); | |
64 | + jButton1 = new javax.swing.JButton(); | |
65 | + displayPanel = new javax.swing.JPanel(); | |
66 | + jMenuBar1 = new javax.swing.JMenuBar(); | |
67 | + dataMenu = new javax.swing.JMenu(); | |
68 | + LoadFile = new javax.swing.JMenuItem(); | |
69 | + LoadCommand = new javax.swing.JMenuItem(); | |
70 | + LoadSSH = new javax.swing.JMenuItem(); | |
71 | + jSeparator2 = new javax.swing.JPopupMenu.Separator(); | |
72 | + updateSSHMenuItem = new javax.swing.JMenuItem(); | |
73 | + GraphMenu = new javax.swing.JMenu(); | |
74 | + addgraphMenu = new javax.swing.JMenuItem(); | |
75 | + exportMenu = new javax.swing.JMenu(); | |
76 | + PDFMenu = new javax.swing.JMenuItem(); | |
77 | + CSVMenu = new javax.swing.JMenuItem(); | |
81 | 78 | |
82 | - setClosable(true); | |
83 | - setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); | |
84 | - setIconifiable(true); | |
85 | - setMaximizable(true); | |
86 | - setResizable(true); | |
87 | - try { | |
88 | - setSelected(true); | |
89 | - } catch (java.beans.PropertyVetoException e1) { | |
90 | - e1.printStackTrace(System.err); | |
91 | - } | |
92 | - setVisible(true); | |
93 | - addInternalFrameListener(new javax.swing.event.InternalFrameListener() { | |
94 | - public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) { | |
95 | - } | |
96 | - public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) { | |
97 | - formInternalFrameClosing(evt); | |
98 | - } | |
99 | - public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) { | |
100 | - } | |
101 | - public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) { | |
102 | - } | |
103 | - public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) { | |
104 | - } | |
105 | - public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) { | |
106 | - } | |
107 | - public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) { | |
108 | - } | |
109 | - }); | |
79 | + setClosable(true); | |
80 | + setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); | |
81 | + setIconifiable(true); | |
82 | + setMaximizable(true); | |
83 | + setResizable(true); | |
84 | + try { | |
85 | + setSelected(true); | |
86 | + } catch (java.beans.PropertyVetoException e1) { | |
87 | + e1.printStackTrace(); | |
88 | + } | |
89 | + setVisible(true); | |
90 | + addInternalFrameListener(new javax.swing.event.InternalFrameListener() { | |
91 | + public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) { | |
92 | + } | |
93 | + public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) { | |
94 | + formInternalFrameClosing(evt); | |
95 | + } | |
96 | + public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) { | |
97 | + } | |
98 | + public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) { | |
99 | + } | |
100 | + public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) { | |
101 | + } | |
102 | + public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) { | |
103 | + } | |
104 | + public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) { | |
105 | + } | |
106 | + }); | |
110 | 107 | |
111 | - jPanel1.setLayout(new java.awt.BorderLayout()); | |
108 | + jPanel1.setLayout(new java.awt.BorderLayout()); | |
112 | 109 | |
113 | - jPanel2.setMinimumSize(new java.awt.Dimension(150, 46)); | |
114 | - jPanel2.setLayout(new java.awt.BorderLayout()); | |
110 | + jPanel2.setMinimumSize(new java.awt.Dimension(150, 46)); | |
111 | + jPanel2.setLayout(new java.awt.BorderLayout()); | |
115 | 112 | |
116 | - jTree1.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() { | |
117 | - public void valueChanged(javax.swing.event.TreeSelectionEvent evt) { | |
118 | - jTree1ValueChanged(evt); | |
119 | - } | |
120 | - }); | |
121 | - jScrollPane1.setViewportView(jTree1); | |
113 | + sarTree.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() { | |
114 | + public void valueChanged(javax.swing.event.TreeSelectionEvent evt) { | |
115 | + sarTreeValueChanged(evt); | |
116 | + } | |
117 | + }); | |
118 | + jScrollPane1.setViewportView(sarTree); | |
122 | 119 | |
123 | - jPanel2.add(jScrollPane1, java.awt.BorderLayout.CENTER); | |
120 | + jPanel2.add(jScrollPane1, java.awt.BorderLayout.CENTER); | |
124 | 121 | |
125 | - jButton1.setEnabled(false); | |
126 | - jButton1.addActionListener(new java.awt.event.ActionListener() { | |
127 | - public void actionPerformed(java.awt.event.ActionEvent evt) { | |
128 | - jButton1ActionPerformed(evt); | |
129 | - } | |
130 | - }); | |
131 | - jPanel2.add(jButton1, java.awt.BorderLayout.SOUTH); | |
122 | + jButton1.setEnabled(false); | |
123 | + jButton1.addActionListener(new java.awt.event.ActionListener() { | |
124 | + public void actionPerformed(java.awt.event.ActionEvent evt) { | |
125 | + jButton1ActionPerformed(evt); | |
126 | + } | |
127 | + }); | |
128 | + jPanel2.add(jButton1, java.awt.BorderLayout.SOUTH); | |
132 | 129 | |
133 | - jSplitPane1.setLeftComponent(jPanel2); | |
130 | + jSplitPane1.setLeftComponent(jPanel2); | |
134 | 131 | |
135 | - displayPanel.setLayout(new java.awt.BorderLayout()); | |
136 | - jSplitPane1.setRightComponent(displayPanel); | |
132 | + displayPanel.setLayout(new java.awt.BorderLayout()); | |
133 | + jSplitPane1.setRightComponent(displayPanel); | |
137 | 134 | |
138 | - jPanel1.add(jSplitPane1, java.awt.BorderLayout.CENTER); | |
135 | + jPanel1.add(jSplitPane1, java.awt.BorderLayout.CENTER); | |
139 | 136 | |
140 | - getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER); | |
137 | + getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER); | |
141 | 138 | |
142 | - dataMenu.setText("Data"); | |
139 | + dataMenu.setText("Data"); | |
143 | 140 | |
144 | - LoadFile.setText("Load from a file..."); | |
145 | - LoadFile.addActionListener(new java.awt.event.ActionListener() { | |
146 | - public void actionPerformed(java.awt.event.ActionEvent evt) { | |
147 | - LoadFileActionPerformed(evt); | |
148 | - } | |
149 | - }); | |
150 | - dataMenu.add(LoadFile); | |
151 | - dataMenu.add(jSeparator3); | |
141 | + LoadFile.setText("Load from a file..."); | |
142 | + LoadFile.addActionListener(new java.awt.event.ActionListener() { | |
143 | + public void actionPerformed(java.awt.event.ActionEvent evt) { | |
144 | + LoadFileActionPerformed(evt); | |
145 | + } | |
146 | + }); | |
147 | + dataMenu.add(LoadFile); | |
152 | 148 | |
153 | - LoadCommand.setText("Load from a local Command..."); | |
154 | - LoadCommand.addActionListener(new java.awt.event.ActionListener() { | |
155 | - public void actionPerformed(java.awt.event.ActionEvent evt) { | |
156 | - LoadCommandActionPerformed(evt); | |
157 | - } | |
158 | - }); | |
159 | - dataMenu.add(LoadCommand); | |
160 | - dataMenu.add(jSeparator2); | |
149 | + LoadCommand.setText("Load from a local Command..."); | |
150 | + LoadCommand.addActionListener(new java.awt.event.ActionListener() { | |
151 | + public void actionPerformed(java.awt.event.ActionEvent evt) { | |
152 | + LoadCommandActionPerformed(evt); | |
153 | + } | |
154 | + }); | |
155 | + dataMenu.add(LoadCommand); | |
161 | 156 | |
162 | - LoadSSH.setText("Load from a SSH Command..."); | |
163 | - LoadSSH.addActionListener(new java.awt.event.ActionListener() { | |
164 | - public void actionPerformed(java.awt.event.ActionEvent evt) { | |
165 | - LoadSSHActionPerformed(evt); | |
166 | - } | |
167 | - }); | |
168 | - dataMenu.add(LoadSSH); | |
157 | + LoadSSH.setText("Load from a SSH Command..."); | |
158 | + LoadSSH.addActionListener(new java.awt.event.ActionListener() { | |
159 | + public void actionPerformed(java.awt.event.ActionEvent evt) { | |
160 | + LoadSSHActionPerformed(evt); | |
161 | + } | |
162 | + }); | |
163 | + dataMenu.add(LoadSSH); | |
164 | + dataMenu.add(jSeparator2); | |
169 | 165 | |
170 | - updateSSHMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R, java.awt.event.InputEvent.CTRL_MASK)); | |
171 | - updateSSHMenuItem.setText("Auto-update through SSH ..."); | |
172 | - updateSSHMenuItem.setEnabled(false); | |
173 | - updateSSHMenuItem.setName(""); // NOI18N | |
174 | - updateSSHMenuItem.addActionListener(new java.awt.event.ActionListener() { | |
175 | - public void actionPerformed(java.awt.event.ActionEvent evt) { | |
176 | - updateSSHMenuItemActionPerformed(evt); | |
177 | - } | |
178 | - }); | |
179 | - dataMenu.add(updateSSHMenuItem); | |
180 | - updateSSHMenuItem.getAccessibleContext().setAccessibleName("testMenuItem"); | |
166 | + updateSSHMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R, java.awt.event.InputEvent.CTRL_MASK)); | |
167 | + updateSSHMenuItem.setText("Auto-update ..."); | |
168 | + updateSSHMenuItem.setEnabled(false); | |
169 | + updateSSHMenuItem.setName(""); // NOI18N | |
170 | + updateSSHMenuItem.addActionListener(new java.awt.event.ActionListener() { | |
171 | + public void actionPerformed(java.awt.event.ActionEvent evt) { | |
172 | + updateSSHMenuItemActionPerformed(evt); | |
173 | + } | |
174 | + }); | |
175 | + dataMenu.add(updateSSHMenuItem); | |
176 | + updateSSHMenuItem.getAccessibleContext().setAccessibleName("testMenuItem"); | |
181 | 177 | |
182 | - jMenuBar1.add(dataMenu); | |
178 | + jMenuBar1.add(dataMenu); | |
183 | 179 | |
184 | - GraphMenu.setText("Graph"); | |
185 | - GraphMenu.setEnabled(false); | |
180 | + GraphMenu.setText("Graph"); | |
181 | + GraphMenu.setEnabled(false); | |
186 | 182 | |
187 | - addgraphMenu.setText("Add a Graph"); | |
188 | - addgraphMenu.addActionListener(new java.awt.event.ActionListener() { | |
189 | - public void actionPerformed(java.awt.event.ActionEvent evt) { | |
190 | - addgraphMenuActionPerformed(evt); | |
191 | - } | |
192 | - }); | |
193 | - GraphMenu.add(addgraphMenu); | |
183 | + addgraphMenu.setText("Add a Graph"); | |
184 | + addgraphMenu.addActionListener(new java.awt.event.ActionListener() { | |
185 | + public void actionPerformed(java.awt.event.ActionEvent evt) { | |
186 | + addgraphMenuActionPerformed(evt); | |
187 | + } | |
188 | + }); | |
189 | + GraphMenu.add(addgraphMenu); | |
194 | 190 | |
195 | - jMenuBar1.add(GraphMenu); | |
191 | + jMenuBar1.add(GraphMenu); | |
196 | 192 | |
197 | - exportMenu.setText("Export"); | |
198 | - exportMenu.setEnabled(false); | |
193 | + exportMenu.setText("Export"); | |
194 | + exportMenu.setEnabled(false); | |
199 | 195 | |
200 | - PDFMenu.setText("Export to PDF..."); | |
201 | - PDFMenu.addActionListener(new java.awt.event.ActionListener() { | |
202 | - public void actionPerformed(java.awt.event.ActionEvent evt) { | |
203 | - PDFMenuActionPerformed(evt); | |
204 | - } | |
205 | - }); | |
206 | - exportMenu.add(PDFMenu); | |
196 | + PDFMenu.setText("Export to PDF..."); | |
197 | + PDFMenu.addActionListener(new java.awt.event.ActionListener() { | |
198 | + public void actionPerformed(java.awt.event.ActionEvent evt) { | |
199 | + PDFMenuActionPerformed(evt); | |
200 | + } | |
201 | + }); | |
202 | + exportMenu.add(PDFMenu); | |
207 | 203 | |
208 | - CSVMenu.setText("Export to CSV..."); | |
209 | - CSVMenu.addActionListener(new java.awt.event.ActionListener() { | |
210 | - public void actionPerformed(java.awt.event.ActionEvent evt) { | |
211 | - CSVMenuActionPerformed(evt); | |
212 | - } | |
213 | - }); | |
214 | - exportMenu.add(CSVMenu); | |
204 | + CSVMenu.setText("Export to CSV..."); | |
205 | + CSVMenu.addActionListener(new java.awt.event.ActionListener() { | |
206 | + public void actionPerformed(java.awt.event.ActionEvent evt) { | |
207 | + CSVMenuActionPerformed(evt); | |
208 | + } | |
209 | + }); | |
210 | + exportMenu.add(CSVMenu); | |
215 | 211 | |
216 | - jMenuBar1.add(exportMenu); | |
212 | + jMenuBar1.add(exportMenu); | |
217 | 213 | |
218 | - setJMenuBar(jMenuBar1); | |
214 | + setJMenuBar(jMenuBar1); | |
219 | 215 | |
220 | - pack(); | |
221 | - }// </editor-fold>//GEN-END:initComponents | |
216 | + pack(); | |
217 | + }// </editor-fold>//GEN-END:initComponents | |
222 | 218 | |
223 | 219 | private void formInternalFrameClosing(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameClosing |
224 | 220 | save_data(); |
@@ -225,18 +221,18 @@ | ||
225 | 221 | dispose(); |
226 | 222 | }//GEN-LAST:event_formInternalFrameClosing |
227 | 223 | |
228 | - private void jTree1ValueChanged(javax.swing.event.TreeSelectionEvent evt) {//GEN-FIRST:event_jTree1ValueChanged | |
224 | + private void sarTreeValueChanged(javax.swing.event.TreeSelectionEvent evt) {//GEN-FIRST:event_sarTreeValueChanged | |
229 | 225 | TreePath treepath = evt.getPath(); |
230 | 226 | Object obj = treepath.getLastPathComponent(); |
231 | - if (obj != null) { | |
232 | - if ( GlobalOptions.isDodebug()) { | |
227 | + if(obj != null){ | |
228 | + if( GlobalOptions.isDodebug()){ | |
233 | 229 | System.out.print("mem:" + Runtime.getRuntime().totalMemory()); |
234 | 230 | System.out.println("free:" + Runtime.getRuntime().freeMemory()); |
235 | 231 | } |
236 | 232 | |
237 | 233 | SortedTreeNode treenode = (SortedTreeNode) obj; |
238 | - if ( treenode.getRoot() == treenode) { | |
239 | - if (current_panel != null) { | |
234 | + if( treenode.getRoot() == treenode){ | |
235 | + if(current_panel != null){ | |
240 | 236 | displayPanel.removeAll(); |
241 | 237 | current_panel=null; |
242 | 238 | } |
@@ -243,10 +239,10 @@ | ||
243 | 239 | displayPanel.repaint(); |
244 | 240 | } |
245 | 241 | Object obj1 = treenode.getUserObject(); |
246 | - if (obj1 instanceof TreeNodeInfo) { | |
242 | + if(obj1 instanceof TreeNodeInfo){ | |
247 | 243 | TreeNodeInfo tmpnode = (TreeNodeInfo) obj1; |
248 | 244 | Graph nodeobj = tmpnode.getNode_object(); |
249 | - if (current_panel != null) { | |
245 | + if(current_panel != null){ | |
250 | 246 | displayPanel.removeAll(); |
251 | 247 | current_panel=null; |
252 | 248 | } |
@@ -256,10 +252,10 @@ | ||
256 | 252 | displayPanel.validate(); |
257 | 253 | displayPanel.repaint(); |
258 | 254 | } |
259 | - if (obj1 instanceof ParentNodeInfo) { | |
255 | + if(obj1 instanceof ParentNodeInfo){ | |
260 | 256 | ParentNodeInfo tmpnode = (ParentNodeInfo) obj1; |
261 | 257 | List nodeobj = tmpnode.getNode_object(); |
262 | - if (current_panel != null) { | |
258 | + if(current_panel != null){ | |
263 | 259 | displayPanel.removeAll(); |
264 | 260 | current_panel=null; |
265 | 261 | } |
@@ -270,7 +266,7 @@ | ||
270 | 266 | } |
271 | 267 | } |
272 | 268 | |
273 | - }//GEN-LAST:event_jTree1ValueChanged | |
269 | + }//GEN-LAST:event_sarTreeValueChanged | |
274 | 270 | |
275 | 271 | private void LoadCommandActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LoadCommandActionPerformed |
276 | 272 | mysar.do_localcommand(null); |
@@ -286,19 +282,19 @@ | ||
286 | 282 | |
287 | 283 | private void PDFMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PDFMenuActionPerformed |
288 | 284 | GraphSelection tmp = new GraphSelection( GlobalOptions.getUI() ,true,this); |
289 | - ask_treenode(mysar.graphtree,tmp); | |
285 | + ask_treenode(mysar.getGraphTree(), tmp); | |
290 | 286 | tmp.setVisible(true); |
291 | - if ( ! tmp.OkforExport ) { | |
287 | + if( ! tmp.OkforExport ){ | |
292 | 288 | tmp=null; |
293 | 289 | return ; |
294 | 290 | } |
295 | 291 | tmp=null; |
296 | 292 | String filename = askSaveFilename("Export PDF", Config.getLastExportDirectory()); |
297 | - if (filename == null) { | |
293 | + if(filename == null){ | |
298 | 294 | return; |
299 | 295 | } |
300 | 296 | Config.setLastExportDirectory(filename); |
301 | - if (!Config.getLastExportDirectory().isDirectory()) { | |
297 | + if(!Config.getLastExportDirectory().isDirectory()){ | |
302 | 298 | Config.setLastExportDirectory(Config.getLastExportDirectory().getParentFile()); |
303 | 299 | Config.save(); |
304 | 300 | } |
@@ -307,18 +303,18 @@ | ||
307 | 303 | |
308 | 304 | private void CSVMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CSVMenuActionPerformed |
309 | 305 | GraphSelection tmp = new GraphSelection( GlobalOptions.getUI() ,true,this); |
310 | - ask_treenode(mysar.graphtree,tmp); | |
306 | + ask_treenode(mysar.getGraphTree(), tmp); | |
311 | 307 | tmp.setVisible(true); |
312 | - if ( ! tmp.OkforExport ) { | |
308 | + if( ! tmp.OkforExport ){ | |
313 | 309 | return ; |
314 | 310 | |
315 | 311 | } |
316 | 312 | String filename = askSaveFilename("Export CSV", Config.getLastExportDirectory()); |
317 | - if (filename == null) { | |
313 | + if(filename == null){ | |
318 | 314 | return; |
319 | 315 | } |
320 | 316 | Config.setLastExportDirectory(filename); |
321 | - if (!Config.getLastExportDirectory().isDirectory()) { | |
317 | + if(!Config.getLastExportDirectory().isDirectory()){ | |
322 | 318 | Config.setLastExportDirectory(Config.getLastExportDirectory().getParentFile()); |
323 | 319 | Config.save(); |
324 | 320 | } |
@@ -338,26 +334,26 @@ | ||
338 | 334 | mysar.do_sshupdate(); |
339 | 335 | }//GEN-LAST:event_updateSSHMenuItemActionPerformed |
340 | 336 | |
341 | - private String askSaveFilename(String title, File chdirto) { | |
337 | + private String askSaveFilename(String title, File chdirto){ | |
342 | 338 | String filename = null; |
343 | 339 | JFileChooser chooser = new JFileChooser(); |
344 | 340 | chooser.setDialogTitle(title); |
345 | - if (chdirto != null) { | |
341 | + if(chdirto != null){ | |
346 | 342 | chooser.setCurrentDirectory(chdirto); |
347 | 343 | } |
348 | 344 | int returnVal = chooser.showSaveDialog(GlobalOptions.getUI()); |
349 | - if (returnVal == JFileChooser.APPROVE_OPTION) { | |
345 | + if(returnVal == JFileChooser.APPROVE_OPTION){ | |
350 | 346 | filename = chooser.getSelectedFile().getAbsolutePath(); |
351 | 347 | } |
352 | 348 | |
353 | - if (filename == null) { | |
349 | + if(filename == null){ | |
354 | 350 | return null; |
355 | 351 | } |
356 | 352 | |
357 | - if (new File(filename).exists()) { | |
353 | + if(new File(filename).exists()){ | |
358 | 354 | String[] choix = {"Yes", "No"}; |
359 | 355 | int resultat = JOptionPane.showOptionDialog(null, "Overwrite " + filename + " ?", "File Exist", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, choix, choix[1]); |
360 | - if (resultat != 0) { | |
356 | + if(resultat != 0){ | |
361 | 357 | return null; |
362 | 358 | } |
363 | 359 | } |
@@ -364,15 +360,13 @@ | ||
364 | 360 | return filename; |
365 | 361 | } |
366 | 362 | |
367 | - public void doExportPDF(String filename) { | |
368 | - int pages = 0; | |
369 | - pages= mysar.get_page_to_print(); | |
363 | + public void doExportPDF(String filename){ | |
370 | 364 | JPanel panel0 = new JPanel(); |
371 | 365 | JPanel panel1 = new JPanel(); |
372 | 366 | JPanel panel2 = new JPanel(); |
373 | 367 | JProgressBar pbar = new JProgressBar(); |
374 | 368 | pbar.setMinimum(0); |
375 | - pbar.setMaximum(pages); | |
369 | + pbar.setMaximum(mysar.get_page_to_print()); | |
376 | 370 | pbar.setStringPainted(true); |
377 | 371 | JLabel mytitre = new JLabel("Exporting: "); |
378 | 372 | panel1.add(mytitre); |
@@ -393,7 +387,7 @@ | ||
393 | 387 | |
394 | 388 | } |
395 | 389 | |
396 | - public void doExportCSV(String filename) { | |
390 | + public void doExportCSV(String filename){ | |
397 | 391 | int pages = 0; |
398 | 392 | pages= mysar.myparser.getDateSamples().size(); |
399 | 393 | JPanel panel0 = new JPanel(); |
@@ -423,31 +417,31 @@ | ||
423 | 417 | } |
424 | 418 | |
425 | 419 | |
426 | - public void ask_treenode(SortedTreeNode node,GraphSelection graphselection) { | |
420 | + public void ask_treenode(SortedTreeNode node,GraphSelection graphselection){ | |
427 | 421 | int num = node.getChildCount(); |
428 | 422 | |
429 | - if (num > 0) { | |
423 | + if(num > 0){ | |
430 | 424 | Object obj1 = node.getUserObject(); |
431 | - if (obj1 instanceof ParentNodeInfo) { | |
425 | + if(obj1 instanceof ParentNodeInfo) { | |
432 | 426 | ParentNodeInfo tmpnode = (ParentNodeInfo) obj1; |
433 | 427 | List nodeobj = tmpnode.getNode_object(); |
434 | 428 | askparentPanel= nodeobj.getprintform(); |
435 | 429 | graphselection.addPrintCheckBox(askparentPanel); |
436 | 430 | } |
437 | - for (int i = 0; i < num; i++) { | |
431 | + for(int i = 0; i < num; i++){ | |
438 | 432 | SortedTreeNode l = (SortedTreeNode) node.getChildAt(i); |
439 | 433 | ask_treenode(l, graphselection); |
440 | 434 | } |
441 | 435 | askparentPanel=null; |
442 | - } else { | |
436 | + }else{ | |
443 | 437 | Object obj1 = node.getUserObject(); |
444 | - if (obj1 instanceof TreeNodeInfo) { | |
438 | + if(obj1 instanceof TreeNodeInfo){ | |
445 | 439 | TreeNodeInfo tmpnode = (TreeNodeInfo) obj1; |
446 | 440 | Graph nodeobj = tmpnode.getNode_object(); |
447 | 441 | JCheckBox tmp = nodeobj.getprintform(); |
448 | - if ( askparentPanel == null) { | |
442 | + if( askparentPanel == null){ | |
449 | 443 | graphselection.addPrintCheckBox(tmp); |
450 | - } else { | |
444 | + }else{ | |
451 | 445 | askparentPanel.add(tmp); |
452 | 446 | } |
453 | 447 | } |
@@ -454,77 +448,78 @@ | ||
454 | 448 | } |
455 | 449 | } |
456 | 450 | |
457 | - public void add2tree(SortedTreeNode parent, SortedTreeNode newNode) { | |
458 | - DefaultTreeModel model = (DefaultTreeModel) jTree1.getModel(); | |
451 | + public void add2tree(SortedTreeNode parent, SortedTreeNode newNode){ | |
452 | + DefaultTreeModel model = (DefaultTreeModel) sarTree.getModel(); | |
459 | 453 | model.insertNodeInto(newNode, parent, parent.getChildCount()); |
460 | - /*if( newNode.getUserObject() instanceof TreeNodeInfo ) { | |
454 | + /*if( newNode.getUserObject() instanceof TreeNodeInfo ){ | |
461 | 455 | model.reload(); |
462 | 456 | }*/ |
463 | 457 | } |
464 | 458 | |
465 | - public void treehome() { | |
466 | - jTree1.setSelectionRow(0); | |
467 | - jTree1.expandRow(0); | |
468 | - jTree1.repaint(); | |
459 | + public void treehome(){ | |
460 | + sarTree.setSelectionRow(0); | |
461 | + for(int i=0; i<sarTree.getRowCount(); i++){ | |
462 | + sarTree.expandRow(i); | |
463 | + } | |
464 | + sarTree.repaint(); | |
469 | 465 | } |
470 | 466 | |
471 | - public void notifyrun(boolean t) { | |
467 | + public void notifyrun(boolean t){ | |
472 | 468 | exportMenu.setEnabled(!t); |
473 | 469 | dataMenu.setEnabled(!t); |
474 | - if ( t ) { | |
470 | + if( t ){ | |
475 | 471 | jButton1.setText("Stop"); |
476 | 472 | jButton1.setEnabled(true); |
477 | - } else { | |
473 | + }else{ | |
478 | 474 | jButton1.setText(""); |
479 | 475 | jButton1.setEnabled(false); |
480 | 476 | } |
481 | 477 | } |
482 | 478 | |
483 | - public void setHasData(boolean actif) { | |
484 | - has_fresh_data=actif; | |
479 | + public void setHasData(boolean actif){ | |
480 | + has_fresh_data = actif; | |
485 | 481 | exportMenu.setEnabled(actif); |
486 | - if (actif) { | |
487 | - LoadFile.setText("Append from a file..."); | |
488 | - LoadCommand.setText("Append from a local Command..."); | |
489 | - LoadSSH.setText("Append from a SSH Command..."); | |
490 | - } else { | |
491 | - LoadFile.setText("Load from a file..."); | |
492 | - LoadCommand.setText("Load from a local Command..."); | |
493 | - LoadSSH.setText("Load from a SSH Command..."); | |
482 | + if(actif){ | |
483 | + LoadFile.setText("Append from a file ..."); | |
484 | + LoadCommand.setText("Append from a local command ..."); | |
485 | + LoadSSH.setText("Append from a SSH command ..."); | |
486 | + }else{ | |
487 | + LoadFile.setText("Load from a file ..."); | |
488 | + LoadCommand.setText("Load from a local command ..."); | |
489 | + LoadSSH.setText("Load from a SSH command ..."); | |
494 | 490 | } |
495 | 491 | } |
496 | 492 | |
497 | - private void save_data() { | |
498 | - if (has_fresh_data) { | |
493 | + private void save_data(){ | |
494 | + if(has_fresh_data){ | |
499 | 495 | System.out.println("need backup"); |
500 | 496 | } |
501 | 497 | } |
502 | 498 | |
503 | - public void enableSSHUpdate(){ | |
499 | + public void enableAutoUpdate(){ | |
504 | 500 | updateSSHMenuItem.setEnabled(true); |
505 | 501 | } |
506 | 502 | |
507 | - // Variables declaration - do not modify//GEN-BEGIN:variables | |
508 | - private javax.swing.JMenuItem CSVMenu; | |
509 | - private javax.swing.JMenu GraphMenu; | |
510 | - private javax.swing.JMenuItem LoadCommand; | |
511 | - private javax.swing.JMenuItem LoadFile; | |
512 | - private javax.swing.JMenuItem LoadSSH; | |
513 | - private javax.swing.JMenuItem PDFMenu; | |
514 | - private javax.swing.JMenuItem addgraphMenu; | |
515 | - private javax.swing.JMenu dataMenu; | |
516 | - private javax.swing.JPanel displayPanel; | |
517 | - private javax.swing.JMenu exportMenu; | |
518 | - private javax.swing.JButton jButton1; | |
519 | - private javax.swing.JMenuBar jMenuBar1; | |
520 | - private javax.swing.JPanel jPanel1; | |
521 | - private javax.swing.JPanel jPanel2; | |
522 | - private javax.swing.JScrollPane jScrollPane1; | |
523 | - private javax.swing.JSeparator jSeparator1; | |
524 | - private javax.swing.JPopupMenu.Separator jSeparator2; | |
525 | - private javax.swing.JPopupMenu.Separator jSeparator3; | |
526 | - private javax.swing.JSplitPane jSplitPane1; | |
527 | - private javax.swing.JTree jTree1; | |
528 | - private javax.swing.JMenuItem updateSSHMenuItem; | |
529 | - // End of variables declaration//GEN-END:variables | |
503 | + // Variables declaration - do not modify//GEN-BEGIN:variables | |
504 | + private javax.swing.JMenuItem CSVMenu; | |
505 | + private javax.swing.JMenu GraphMenu; | |
506 | + private javax.swing.JMenuItem LoadCommand; | |
507 | + private javax.swing.JMenuItem LoadFile; | |
508 | + private javax.swing.JMenuItem LoadSSH; | |
509 | + private javax.swing.JMenuItem PDFMenu; | |
510 | + private javax.swing.JMenuItem addgraphMenu; | |
511 | + private javax.swing.JMenu dataMenu; | |
512 | + private javax.swing.JPanel displayPanel; | |
513 | + private javax.swing.JMenu exportMenu; | |
514 | + private javax.swing.JButton jButton1; | |
515 | + private javax.swing.JMenuBar jMenuBar1; | |
516 | + private javax.swing.JPanel jPanel1; | |
517 | + private javax.swing.JPanel jPanel2; | |
518 | + private javax.swing.JScrollPane jScrollPane1; | |
519 | + private javax.swing.JSeparator jSeparator1; | |
520 | + private javax.swing.JPopupMenu.Separator jSeparator2; | |
521 | + private javax.swing.JSplitPane jSplitPane1; | |
522 | + private javax.swing.JTree sarTree; | |
523 | + private javax.swing.JMenuItem updateSSHMenuItem; | |
524 | + // End of variables declaration//GEN-END:variables | |
530 | 525 | } |
@@ -1,9 +1,4 @@ | ||
1 | 1 | /* |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | - | |
6 | -/* | |
7 | 2 | * GraphSelection.java |
8 | 3 | * |
9 | 4 | * Created on 16 août 2010, 18:48:32 |
@@ -22,140 +17,140 @@ | ||
22 | 17 | */ |
23 | 18 | public class GraphSelection extends javax.swing.JDialog { |
24 | 19 | |
25 | - /** Creates new form GraphSelection */ | |
26 | - public GraphSelection(java.awt.Frame parent, boolean modal, DataView myview) { | |
27 | - super(parent, modal); | |
28 | - this.myview = myview; | |
29 | - initComponents(); | |
30 | - setLocationRelativeTo(parent); | |
31 | - toFront(); | |
32 | - } | |
20 | + /** Creates new form GraphSelection */ | |
21 | + public GraphSelection(java.awt.Frame parent, boolean modal, DataView myview){ | |
22 | + super(parent, modal); | |
23 | + this.myview = myview; | |
24 | + initComponents(); | |
25 | + setLocationRelativeTo(parent); | |
26 | + toFront(); | |
27 | + } | |
33 | 28 | |
34 | - /** This method is called from within the constructor to | |
35 | - * initialize the form. | |
36 | - * WARNING: Do NOT modify this code. The content of this method is | |
37 | - * always regenerated by the Form Editor. | |
38 | - */ | |
39 | - @SuppressWarnings("unchecked") | |
40 | - // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents | |
41 | - private void initComponents() { | |
29 | + /** This method is called from within the constructor to | |
30 | + * initialize the form. | |
31 | + * WARNING: Do NOT modify this code. The content of this method is | |
32 | + * always regenerated by the Form Editor. | |
33 | + */ | |
34 | + @SuppressWarnings("unchecked") | |
35 | + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents | |
36 | + private void initComponents(){ | |
42 | 37 | |
43 | - jPanel1 = new javax.swing.JPanel(); | |
44 | - jScrollPane1 = new javax.swing.JScrollPane(); | |
45 | - jPanel3 = new javax.swing.JPanel(); | |
46 | - jPanel2 = new javax.swing.JPanel(); | |
47 | - selectallButton = new javax.swing.JButton(); | |
48 | - unselectallButton = new javax.swing.JButton(); | |
49 | - jSeparator2 = new javax.swing.JSeparator(); | |
50 | - cancelButton = new javax.swing.JButton(); | |
51 | - okButton = new javax.swing.JButton(); | |
38 | + jPanel1 = new javax.swing.JPanel(); | |
39 | + jScrollPane1 = new javax.swing.JScrollPane(); | |
40 | + jPanel3 = new javax.swing.JPanel(); | |
41 | + jPanel2 = new javax.swing.JPanel(); | |
42 | + selectallButton = new javax.swing.JButton(); | |
43 | + unselectallButton = new javax.swing.JButton(); | |
44 | + jSeparator2 = new javax.swing.JSeparator(); | |
45 | + cancelButton = new javax.swing.JButton(); | |
46 | + okButton = new javax.swing.JButton(); | |
52 | 47 | |
53 | - setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); | |
48 | + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); | |
54 | 49 | |
55 | - jPanel1.setLayout(new java.awt.BorderLayout()); | |
50 | + jPanel1.setLayout(new java.awt.BorderLayout()); | |
56 | 51 | |
57 | - jScrollPane1.setPreferredSize(new java.awt.Dimension(300, 400)); | |
58 | - jScrollPane1.setRequestFocusEnabled(false); | |
52 | + jScrollPane1.setPreferredSize(new java.awt.Dimension(300, 400)); | |
53 | + jScrollPane1.setRequestFocusEnabled(false); | |
59 | 54 | |
60 | - jPanel3.setLayout(new javax.swing.BoxLayout(jPanel3, javax.swing.BoxLayout.PAGE_AXIS)); | |
61 | - jScrollPane1.setViewportView(jPanel3); | |
55 | + jPanel3.setLayout(new javax.swing.BoxLayout(jPanel3, javax.swing.BoxLayout.PAGE_AXIS)); | |
56 | + jScrollPane1.setViewportView(jPanel3); | |
62 | 57 | |
63 | - jPanel1.add(jScrollPane1, java.awt.BorderLayout.CENTER); | |
58 | + jPanel1.add(jScrollPane1, java.awt.BorderLayout.CENTER); | |
64 | 59 | |
65 | - getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER); | |
60 | + getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER); | |
66 | 61 | |
67 | - selectallButton.setText("Select All"); | |
68 | - selectallButton.addActionListener(new java.awt.event.ActionListener() { | |
69 | - public void actionPerformed(java.awt.event.ActionEvent evt) { | |
70 | - selectallButtonActionPerformed(evt); | |
71 | - } | |
72 | - }); | |
73 | - jPanel2.add(selectallButton); | |
62 | + selectallButton.setText("Select All"); | |
63 | + selectallButton.addActionListener(new java.awt.event.ActionListener(){ | |
64 | + public void actionPerformed(java.awt.event.ActionEvent evt){ | |
65 | + selectallButtonActionPerformed(evt); | |
66 | + } | |
67 | + }); | |
68 | + jPanel2.add(selectallButton); | |
74 | 69 | |
75 | - unselectallButton.setText("Unselect All"); | |
76 | - unselectallButton.addActionListener(new java.awt.event.ActionListener() { | |
77 | - public void actionPerformed(java.awt.event.ActionEvent evt) { | |
78 | - unselectallButtonActionPerformed(evt); | |
79 | - } | |
80 | - }); | |
81 | - jPanel2.add(unselectallButton); | |
70 | + unselectallButton.setText("Unselect All"); | |
71 | + unselectallButton.addActionListener(new java.awt.event.ActionListener(){ | |
72 | + public void actionPerformed(java.awt.event.ActionEvent evt){ | |
73 | + unselectallButtonActionPerformed(evt); | |
74 | + } | |
75 | + }); | |
76 | + jPanel2.add(unselectallButton); | |
82 | 77 | |
83 | - jSeparator2.setOrientation(javax.swing.SwingConstants.VERTICAL); | |
84 | - jPanel2.add(jSeparator2); | |
78 | + jSeparator2.setOrientation(javax.swing.SwingConstants.VERTICAL); | |
79 | + jPanel2.add(jSeparator2); | |
85 | 80 | |
86 | - cancelButton.setText("Cancel"); | |
87 | - cancelButton.addActionListener(new java.awt.event.ActionListener() { | |
88 | - public void actionPerformed(java.awt.event.ActionEvent evt) { | |
89 | - cancelButtonActionPerformed(evt); | |
90 | - } | |
91 | - }); | |
92 | - jPanel2.add(cancelButton); | |
81 | + cancelButton.setText("Cancel"); | |
82 | + cancelButton.addActionListener(new java.awt.event.ActionListener(){ | |
83 | + public void actionPerformed(java.awt.event.ActionEvent evt){ | |
84 | + cancelButtonActionPerformed(evt); | |
85 | + } | |
86 | + }); | |
87 | + jPanel2.add(cancelButton); | |
93 | 88 | |
94 | - okButton.setText("Ok"); | |
95 | - okButton.addActionListener(new java.awt.event.ActionListener() { | |
96 | - public void actionPerformed(java.awt.event.ActionEvent evt) { | |
97 | - okButtonActionPerformed(evt); | |
98 | - } | |
99 | - }); | |
100 | - jPanel2.add(okButton); | |
89 | + okButton.setText("Ok"); | |
90 | + okButton.addActionListener(new java.awt.event.ActionListener(){ | |
91 | + public void actionPerformed(java.awt.event.ActionEvent evt){ | |
92 | + okButtonActionPerformed(evt); | |
93 | + } | |
94 | + }); | |
95 | + jPanel2.add(okButton); | |
101 | 96 | |
102 | - getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH); | |
97 | + getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH); | |
103 | 98 | |
104 | - pack(); | |
105 | - }// </editor-fold>//GEN-END:initComponents | |
99 | + pack(); | |
100 | + }// </editor-fold>//GEN-END:initComponents | |
106 | 101 | |
107 | - private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed | |
108 | - this.dispose(); | |
109 | - }//GEN-LAST:event_cancelButtonActionPerformed | |
102 | + private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed | |
103 | + this.dispose(); | |
104 | + }//GEN-LAST:event_cancelButtonActionPerformed | |
110 | 105 | |
111 | - private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed | |
112 | - this.dispose(); | |
113 | - OkforExport=true; | |
114 | - }//GEN-LAST:event_okButtonActionPerformed | |
106 | + private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed | |
107 | + this.dispose(); | |
108 | + OkforExport=true; | |
109 | + }//GEN-LAST:event_okButtonActionPerformed | |
115 | 110 | |
116 | - private void selectallButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectallButtonActionPerformed | |
117 | - toggle_checkbox(jPanel3,true); | |
118 | - }//GEN-LAST:event_selectallButtonActionPerformed | |
111 | + private void selectallButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectallButtonActionPerformed | |
112 | + toggle_checkbox(jPanel3,true); | |
113 | + }//GEN-LAST:event_selectallButtonActionPerformed | |
119 | 114 | |
120 | - private void unselectallButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_unselectallButtonActionPerformed | |
121 | - toggle_checkbox(jPanel3,false); | |
122 | - }//GEN-LAST:event_unselectallButtonActionPerformed | |
115 | + private void unselectallButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_unselectallButtonActionPerformed | |
116 | + toggle_checkbox(jPanel3,false); | |
117 | + }//GEN-LAST:event_unselectallButtonActionPerformed | |
123 | 118 | |
124 | - public void toggle_checkbox(JPanel panel, boolean checked) { | |
125 | - Component [] list = panel.getComponents(); | |
126 | - for (int i= 0; i < list.length ; i++) { | |
127 | - Component tmp = (Component)list[i]; | |
128 | - if ( tmp instanceof JPanel) { | |
129 | - JPanel obj = (JPanel) tmp; | |
130 | - toggle_checkbox(obj, checked); | |
131 | - } | |
132 | - if ( tmp instanceof JCheckBox) { | |
133 | - JCheckBox obj = (JCheckBox) tmp; | |
134 | - obj.setSelected(checked); | |
135 | - } | |
136 | - } | |
137 | - } | |
138 | - | |
139 | - public void addPrintCheckBox(JCheckBox tmp) { | |
140 | - jPanel3.add(tmp); | |
141 | - jPanel1.validate(); | |
142 | - } | |
143 | - public void addPrintCheckBox(JPanel tmp) { | |
144 | - jPanel3.add(tmp); | |
145 | - jPanel1.validate(); | |
146 | - } | |
119 | + public void toggle_checkbox(JPanel panel, boolean checked){ | |
120 | + Component [] list = panel.getComponents(); | |
121 | + for(int i= 0; i < list.length ; i++){ | |
122 | + Component tmp = (Component)list[i]; | |
123 | + if( tmp instanceof JPanel){ | |
124 | + JPanel obj = (JPanel) tmp; | |
125 | + toggle_checkbox(obj, checked); | |
126 | + } | |
127 | + if( tmp instanceof JCheckBox){ | |
128 | + JCheckBox obj = (JCheckBox) tmp; | |
129 | + obj.setSelected(checked); | |
130 | + } | |
131 | + } | |
132 | + } | |
133 | + | |
134 | + public void addPrintCheckBox(JCheckBox tmp){ | |
135 | + jPanel3.add(tmp); | |
136 | + jPanel1.validate(); | |
137 | + } | |
138 | + public void addPrintCheckBox(JPanel tmp){ | |
139 | + jPanel3.add(tmp); | |
140 | + jPanel1.validate(); | |
141 | + } | |
147 | 142 | |
148 | - // Variables declaration - do not modify//GEN-BEGIN:variables | |
149 | - private javax.swing.JButton cancelButton; | |
150 | - private javax.swing.JPanel jPanel1; | |
151 | - private javax.swing.JPanel jPanel2; | |
152 | - private javax.swing.JPanel jPanel3; | |
153 | - private javax.swing.JScrollPane jScrollPane1; | |
154 | - private javax.swing.JSeparator jSeparator2; | |
155 | - private javax.swing.JButton okButton; | |
156 | - private javax.swing.JButton selectallButton; | |
157 | - private javax.swing.JButton unselectallButton; | |
158 | - // End of variables declaration//GEN-END:variables | |
159 | - private DataView myview =null; | |
160 | - public boolean OkforExport = false; | |
143 | + // Variables declaration - do not modify//GEN-BEGIN:variables | |
144 | + private javax.swing.JButton cancelButton; | |
145 | + private javax.swing.JPanel jPanel1; | |
146 | + private javax.swing.JPanel jPanel2; | |
147 | + private javax.swing.JPanel jPanel3; | |
148 | + private javax.swing.JScrollPane jScrollPane1; | |
149 | + private javax.swing.JSeparator jSeparator2; | |
150 | + private javax.swing.JButton okButton; | |
151 | + private javax.swing.JButton selectallButton; | |
152 | + private javax.swing.JButton unselectallButton; | |
153 | + // End of variables declaration//GEN-END:variables | |
154 | + private DataView myview =null; | |
155 | + public boolean OkforExport = false; | |
161 | 156 | } |
@@ -1,7 +1,3 @@ | ||
1 | -/* | |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | 1 | package net.atomique.ksar; |
6 | 2 | |
7 | 3 | import java.util.HashMap; |
@@ -12,153 +8,152 @@ | ||
12 | 8 | * |
13 | 9 | * @author Max |
14 | 10 | */ |
15 | -public abstract class OSParser extends AllParser { | |
11 | +public abstract class OSParser extends AllParser{ | |
16 | 12 | |
17 | - public OSParser(){ | |
18 | - } | |
13 | + protected Map<String,Object> ListofGraph = new HashMap<>(); | |
19 | 14 | |
20 | - public void init(KSar hissar, String header){ | |
21 | - String [] s = header.split("\\s+"); | |
22 | - mysar = hissar; | |
23 | - ParserName = s[0]; | |
24 | - myosconfig = GlobalOptions.getOSinfo(s[0]); | |
25 | - parse_header(header); | |
26 | - } | |
27 | - | |
28 | - public OSParser(KSar hissar,String header) { | |
29 | - init(hissar, header); | |
30 | - } | |
15 | + protected String lastStat = null; | |
16 | + protected Object currentStatObj = null; | |
17 | + //List graphlist = new ArrayList(); | |
31 | 18 | |
32 | - public OSConfig get_OSConfig() { | |
33 | - return myosconfig; | |
34 | - } | |
19 | + protected String ostype = null; | |
20 | + protected String hostname = null; | |
21 | + protected String osversion = null; | |
22 | + protected String kernel = null; | |
23 | + protected String cputype = null; | |
24 | + protected String macaddress = null; | |
25 | + protected String memory = null; | |
26 | + protected String nbdisk = null; | |
27 | + protected String nbcpu = null; | |
28 | + protected String ent = null; | |
29 | + protected String detect = null; | |
30 | + protected String original_line = null; | |
31 | + // for graph | |
35 | 32 | |
33 | + public OSParser(){ | |
34 | + } | |
36 | 35 | |
37 | - public void setHostname(String s) { | |
38 | - Hostname = s; | |
39 | - } | |
36 | + @Override | |
37 | + public void init(KSar hissar, String header){ | |
38 | + String [] s = header.split("\\s+"); | |
39 | + mysar = hissar; | |
40 | + parserName = s[0]; | |
41 | + osConfig = GlobalOptions.getOSinfo(s[0]); | |
42 | + parse_header(header); | |
43 | + } | |
44 | + private void _init_(KSar hissar, String header){init(hissar, header);} | |
45 | + public OSParser(KSar hissar,String header){ | |
46 | + _init_(hissar, header); | |
47 | + } | |
40 | 48 | |
41 | - public void setOSversion(String s) { | |
42 | - OSversion = s; | |
43 | - } | |
49 | + public OSConfig get_OSConfig(){ | |
50 | + return osConfig; | |
51 | + } | |
44 | 52 | |
45 | - public void setKernel(String s) { | |
46 | - Kernel = s; | |
47 | - } | |
53 | + public void setHostname(String s){ | |
54 | + hostname = s; | |
55 | + } | |
48 | 56 | |
49 | - public void setCpuType(String s) { | |
50 | - CpuType = s; | |
51 | - } | |
57 | + public void setOSversion(String s){ | |
58 | + osversion = s; | |
59 | + } | |
52 | 60 | |
53 | - | |
61 | + public void setKernel(String s){ | |
62 | + kernel = s; | |
63 | + } | |
54 | 64 | |
55 | - public void setMacAddress(String s) { | |
56 | - MacAddress = s; | |
57 | - } | |
65 | + public void setCpuType(String s){ | |
66 | + cputype = s; | |
67 | + } | |
58 | 68 | |
59 | - public void setMemory(String s) { | |
60 | - Memory = s; | |
61 | - } | |
69 | + public void setMacAddress(String s){ | |
70 | + macaddress = s; | |
71 | + } | |
62 | 72 | |
63 | - public void setNBDisk(String s) { | |
64 | - NBDisk = s; | |
65 | - } | |
73 | + public void setMemory(String s){ | |
74 | + memory = s; | |
75 | + } | |
66 | 76 | |
67 | - public void setNBCpu(String s) { | |
68 | - NBCpu = s; | |
69 | - } | |
77 | + public void setNBDisk(String s){ | |
78 | + nbdisk = s; | |
79 | + } | |
70 | 80 | |
71 | - public void setENT(String s) { | |
72 | - ENT = s; | |
73 | - } | |
81 | + public void setNBCpu(String s){ | |
82 | + nbcpu = s; | |
83 | + } | |
74 | 84 | |
85 | + public void setENT(String s){ | |
86 | + ent = s; | |
87 | + } | |
88 | + | |
75 | 89 | @Override |
76 | - public String getInfo() { | |
77 | - StringBuilder tmpstr = new StringBuilder(); | |
78 | - tmpstr.append("OS Type: ").append(ostype); | |
79 | - if (OSversion != null) { | |
80 | - tmpstr.append("OS Version: ").append(OSversion).append("\n"); | |
81 | - } | |
82 | - if (Kernel != null) { | |
83 | - tmpstr.append("Kernel Release: ").append(Kernel).append("\n"); | |
84 | - } | |
85 | - if (CpuType != null) { | |
86 | - tmpstr.append("CPU Type: ").append(CpuType).append("\n"); | |
87 | - } | |
88 | - if (Hostname != null) { | |
89 | - tmpstr.append("Hostname: ").append(Hostname).append("\n"); | |
90 | - } | |
91 | - if (MacAddress != null) { | |
92 | - tmpstr.append("Mac Address: ").append(MacAddress).append("\n"); | |
93 | - } | |
94 | - if (Memory != null) { | |
95 | - tmpstr.append("Memory: ").append(Memory).append("\n"); | |
96 | - } | |
97 | - if (NBDisk != null) { | |
98 | - tmpstr.append("Number of disks: ").append(NBDisk).append("\n"); | |
99 | - } | |
100 | - if (NBCpu != null) { | |
101 | - tmpstr.append("Number of CPU: ").append(NBCpu).append("\n"); | |
102 | - } | |
103 | - if (ENT != null) { | |
104 | - tmpstr.append("Ent: ").append(ENT).append("\n"); | |
105 | - } | |
106 | - if (sarStartDate != null) { | |
107 | - tmpstr.append("Start of SAR: ").append(sarStartDate).append("\n"); | |
108 | - } | |
109 | - if (sarEndDate != null) { | |
110 | - tmpstr.append("End of SAR: ").append(sarEndDate).append("\n"); | |
111 | - } | |
90 | + public String getInfo(){ | |
91 | + StringBuilder tmpstr = new StringBuilder(); | |
92 | + tmpstr.append("OS Type: ").append(ostype); | |
93 | + if(osversion != null){ | |
94 | + tmpstr.append("OS Version: ").append(osversion).append("\n"); | |
95 | + } | |
96 | + if(kernel != null){ | |
97 | + tmpstr.append("Kernel Release: ").append(kernel).append("\n"); | |
98 | + } | |
99 | + if(cputype != null){ | |
100 | + tmpstr.append("CPU Type: ").append(cputype).append("\n"); | |
101 | + } | |
102 | + if(hostname != null){ | |
103 | + tmpstr.append("Hostname: ").append(hostname).append("\n"); | |
104 | + } | |
105 | + if(macaddress != null){ | |
106 | + tmpstr.append("Mac Address: ").append(macaddress).append("\n"); | |
107 | + } | |
108 | + if(memory != null){ | |
109 | + tmpstr.append("Memory: ").append(memory).append("\n"); | |
110 | + } | |
111 | + if(nbdisk != null){ | |
112 | + tmpstr.append("Number of disks: ").append(nbdisk).append("\n"); | |
113 | + } | |
114 | + if(nbcpu != null){ | |
115 | + tmpstr.append("Number of CPU: ").append(nbcpu).append("\n"); | |
116 | + } | |
117 | + if(ent != null){ | |
118 | + tmpstr.append("Ent: ").append(ent).append("\n"); | |
119 | + } | |
120 | + if(sarStartDate != null){ | |
121 | + tmpstr.append("Start of SAR: ").append(sarStartDate).append("\n"); | |
122 | + } | |
123 | + if(sarEndDate != null){ | |
124 | + tmpstr.append("End of SAR: ").append(sarEndDate).append("\n"); | |
125 | + } | |
112 | 126 | |
113 | - tmpstr.append("\n"); | |
127 | + tmpstr.append("\n"); | |
114 | 128 | |
115 | - return tmpstr.toString(); | |
116 | - } | |
129 | + return tmpstr.toString(); | |
130 | + } | |
117 | 131 | |
118 | - public String getOriginal_line() { | |
119 | - return original_line; | |
120 | - } | |
132 | + public String getOriginal_line(){ | |
133 | + return original_line; | |
134 | + } | |
121 | 135 | |
122 | - public void setOriginal_line(String original_line) { | |
123 | - this.original_line = original_line; | |
124 | - } | |
136 | + public void setOriginal_line(String original_line){ | |
137 | + this.original_line = original_line; | |
138 | + } | |
125 | 139 | |
126 | - public String gethostName() { | |
127 | - return Hostname; | |
128 | - } | |
140 | + public String gethostName(){ | |
141 | + return hostname; | |
142 | + } | |
129 | 143 | |
130 | - public String getOstype() { | |
131 | - return ostype; | |
132 | - } | |
144 | + public String getOstype(){ | |
145 | + return ostype; | |
146 | + } | |
133 | 147 | |
134 | - public void setOstype(String ostype) { | |
135 | - this.ostype = ostype; | |
136 | - } | |
148 | + public void setOstype(String ostype){ | |
149 | + this.ostype = ostype; | |
150 | + } | |
137 | 151 | |
138 | 152 | @Override |
139 | - public void updateUITitle() { | |
140 | - if ( mysar.getDataView() != null) { | |
141 | - mysar.getDataView().setTitle(Hostname + " from "+ startofgraph + " to " + endofgraph); | |
142 | - } | |
143 | - } | |
153 | + public void updateUITitle(){ | |
154 | + if( mysar.getDataView() != null){ | |
155 | + mysar.getDataView().setTitle(hostname + " from "+ startofgraph + " to " + endofgraph); | |
156 | + } | |
157 | + } | |
144 | 158 | |
145 | - protected Map<String,Object> ListofGraph = new HashMap<String, Object>(); | |
146 | - | |
147 | - protected String lastStat = null; | |
148 | - protected Object currentStatObj = null; | |
149 | - //List graphlist = new ArrayList(); | |
150 | - | |
151 | - protected String ostype = null; | |
152 | - protected String Hostname = null; | |
153 | - protected String OSversion = null; | |
154 | - protected String Kernel = null; | |
155 | - protected String CpuType = null; | |
156 | - protected String MacAddress = null; | |
157 | - protected String Memory = null; | |
158 | - protected String NBDisk = null; | |
159 | - protected String NBCpu = null; | |
160 | - protected String ENT = null; | |
161 | - protected String Detect = null; | |
162 | - protected String original_line=null; | |
163 | - // for graph | |
164 | 159 | } |
@@ -1,8 +1,3 @@ | ||
1 | -/* | |
2 | - * To change this template, choose Tools | Templates | |
3 | - * and open the template in the editor. | |
4 | - */ | |
5 | - | |
6 | 1 | package net.atomique.ksar; |
7 | 2 | |
8 | 3 | import java.io.BufferedReader; |
@@ -18,23 +13,23 @@ | ||
18 | 13 | |
19 | 14 | private static VersionNumber instance = new VersionNumber(); |
20 | 15 | |
21 | - public static VersionNumber getInstance() { | |
16 | + public static VersionNumber getInstance(){ | |
22 | 17 | return instance; |
23 | 18 | } |
24 | 19 | |
25 | - VersionNumber() { | |
20 | + VersionNumber(){ | |
26 | 21 | StringBuilder tmpstr = new StringBuilder(); |
27 | 22 | BufferedReader reader = null; |
28 | - try { | |
23 | + try{ | |
29 | 24 | InputStream is = this.getClass().getResourceAsStream("/kSar.version"); |
30 | 25 | InputStreamReader isr = new InputStreamReader(is); |
31 | 26 | reader = new BufferedReader(isr); |
32 | 27 | String line = ""; |
33 | - while ((line = reader.readLine()) != null) { | |
28 | + while((line = reader.readLine()) != null){ | |
34 | 29 | tmpstr.append(line); |
35 | 30 | } |
36 | 31 | reader.close(); |
37 | - } catch (IOException e) { | |
32 | + }catch(IOException e){ | |
38 | 33 | System.err.println("Unable to read Current version"); |
39 | 34 | return; |
40 | 35 | } |
@@ -42,9 +37,9 @@ | ||
42 | 37 | return; |
43 | 38 | } |
44 | 39 | |
45 | - public void setVersionNumber(String version) { | |
40 | + public void setVersionNumber(String version){ | |
46 | 41 | String tmp[]= version.split("\\."); |
47 | - if ( tmp.length != 3) { | |
42 | + if( tmp.length != 3){ | |
48 | 43 | return; |
49 | 44 |