diff options
-rw-r--r-- | src/cppcheckplus/control/MyContorlUtil.java | 132 | ||||
-rw-r--r-- | src/cppcheckplus/control/UIFrame.java | 148 | ||||
-rw-r--r-- | src/cppcheckplus/control/menubar.xml | 17 | ||||
-rw-r--r-- | src/toolsconfig/ToolsConfig.java | 4 | ||||
-rw-r--r-- | src/toolsconfig/clangTidy.java | 2 | ||||
-rw-r--r-- | src/toolsconfig/cppcheck.java | 8 | ||||
-rw-r--r-- | src/toolsconfig/flawfinder.java | 9 |
7 files changed, 130 insertions, 190 deletions
diff --git a/src/cppcheckplus/control/MyContorlUtil.java b/src/cppcheckplus/control/MyContorlUtil.java index a43d570..e7e3d07 100644 --- a/src/cppcheckplus/control/MyContorlUtil.java +++ b/src/cppcheckplus/control/MyContorlUtil.java | |||
@@ -35,6 +35,7 @@ import javax.swing.Icon; | |||
35 | import javax.swing.ImageIcon; | 35 | import javax.swing.ImageIcon; |
36 | import javax.swing.JLabel; | 36 | import javax.swing.JLabel; |
37 | import javax.swing.JMenuItem; | 37 | import javax.swing.JMenuItem; |
38 | import javax.swing.JOptionPane; | ||
38 | import javax.swing.UIManager; | 39 | import javax.swing.UIManager; |
39 | import javax.swing.plaf.FontUIResource; | 40 | import javax.swing.plaf.FontUIResource; |
40 | import javax.xml.parsers.DocumentBuilder; | 41 | import javax.xml.parsers.DocumentBuilder; |
@@ -47,6 +48,7 @@ import org.w3c.dom.Document; | |||
47 | import org.w3c.dom.Element; | 48 | import org.w3c.dom.Element; |
48 | import org.w3c.dom.Node; | 49 | import org.w3c.dom.Node; |
49 | import org.w3c.dom.NodeList; | 50 | import org.w3c.dom.NodeList; |
51 | import toolsconfig.ToolsConfig; | ||
50 | import toolsconfig.ToolsRegistry; | 52 | import toolsconfig.ToolsRegistry; |
51 | 53 | ||
52 | 54 | ||
@@ -270,38 +272,43 @@ public class MyContorlUtil { | |||
270 | public static MyMenuBar loadMenuBar(String xml, ActionListener action) { | 272 | public static MyMenuBar loadMenuBar(String xml, ActionListener action) { |
271 | MyMenuBar menuBar = null; | 273 | MyMenuBar menuBar = null; |
272 | try { | 274 | try { |
275 | // 初始化XML解析器 | ||
273 | DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); | 276 | DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); |
274 | DocumentBuilder db = dbf.newDocumentBuilder(); | 277 | DocumentBuilder db = dbf.newDocumentBuilder(); |
278 | // 解析XML文件 | ||
275 | Document doc = db.parse(MyContorlUtil.getXMLFile(xml)); | 279 | Document doc = db.parse(MyContorlUtil.getXMLFile(xml)); |
276 | Element root = doc.getDocumentElement(); | 280 | Element root = doc.getDocumentElement(); |
277 | NodeList rootMenus = root.getChildNodes(); | 281 | NodeList rootMenus = root.getChildNodes(); |
278 | if (rootMenus != null) { | 282 | if (rootMenus == null) { |
279 | menuBar = new MyMenuBar(); | 283 | return null; |
280 | for (int i = 0; i < rootMenus.getLength(); i++) { | 284 | } |
281 | org.w3c.dom.Node menu = rootMenus.item(i); | 285 | |
282 | if (menu.getNodeType() == Node.ELEMENT_NODE) { | 286 | menuBar = new MyMenuBar(); |
283 | if (menu.getNodeName().equalsIgnoreCase("menu")) { | 287 | // 遍历 |
284 | String text = | 288 | for (int i = 0; i < rootMenus.getLength(); i++) { |
285 | MyContorlUtil.getStringAttribute(menu, "text"); | 289 | org.w3c.dom.Node menu = rootMenus.item(i); |
286 | MyRootMenu rootMenu = new MyRootMenu(); | 290 | if (menu.getNodeType() == Node.ELEMENT_NODE) { |
287 | rootMenu.setText(text); | 291 | if (menu.getNodeName().equalsIgnoreCase("menu")) { |
288 | menuBar.add(rootMenu); | 292 | // 菜单一级节点 |
289 | processMenuItem(menu, rootMenu, action); | 293 | String text = |
290 | } | 294 | MyContorlUtil.getStringAttribute(menu, "text"); |
291 | if (menu.getNodeName().equalsIgnoreCase("logo")) { | 295 | MyRootMenu rootMenu = new MyRootMenu(); |
292 | String tooltip = | 296 | rootMenu.setText(text); // 以text作为菜单名 |
293 | MyContorlUtil.getStringAttribute(menu, | 297 | menuBar.add(rootMenu); |
294 | "tooltip"); | 298 | processMenuItem(menu, rootMenu, action); |
295 | String imageURL = | 299 | } else if (menu.getNodeName().equalsIgnoreCase("logo")) { |
296 | MyContorlUtil.getStringAttribute(menu, "image"); | 300 | // 总菜单栏的logo |
297 | menuBar.add(Box.createGlue()); | 301 | String tooltip = |
298 | JLabel label = new JLabel( | 302 | MyContorlUtil.getStringAttribute(menu, "tooltip"); |
299 | MyContorlUtil.getImageIcon(imageURL)); | 303 | String imageURL = |
300 | label.setBorder( | 304 | MyContorlUtil.getStringAttribute(menu, "image"); |
301 | BorderFactory.createEmptyBorder(0, 5, 0, 5)); | 305 | menuBar.add(Box.createGlue()); |
302 | label.setToolTipText(tooltip); | 306 | JLabel label = |
303 | menuBar.add(label); | 307 | new JLabel(MyContorlUtil.getImageIcon(imageURL)); |
304 | } | 308 | label.setBorder( |
309 | BorderFactory.createEmptyBorder(0, 5, 0, 5)); | ||
310 | label.setToolTipText(tooltip); | ||
311 | menuBar.add(label); | ||
305 | } | 312 | } |
306 | } | 313 | } |
307 | } | 314 | } |
@@ -366,44 +373,59 @@ public class MyContorlUtil { | |||
366 | } catch (Exception ex) { | 373 | } catch (Exception ex) { |
367 | ex.printStackTrace(); | 374 | ex.printStackTrace(); |
368 | } | 375 | } |
369 | |||
370 | } | 376 | } |
371 | 377 | ||
372 | public static void loadToolsRoad(String xml, UIFrame main) { | 378 | public static void loadToolsRoad(String xml, UIFrame ui, |
379 | ActionListener action) { | ||
373 | try { | 380 | try { |
374 | DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); | 381 | DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); |
375 | DocumentBuilder db = dbf.newDocumentBuilder(); | 382 | DocumentBuilder db = dbf.newDocumentBuilder(); |
376 | Document doc = db.parse(MyContorlUtil.getXMLFile(xml)); | 383 | Document doc = db.parse(MyContorlUtil.getXMLFile(xml)); |
377 | Element root = doc.getDocumentElement(); | 384 | Element root = doc.getDocumentElement(); |
378 | NodeList tools = root.getChildNodes(); | 385 | NodeList tools = root.getChildNodes(); |
379 | if (tools != null) { | 386 | |
380 | for (int i = 0; i < tools.getLength(); i++) { | 387 | MyRootMenu checkBar = new MyRootMenu(); |
381 | org.w3c.dom.Node menu = tools.item(i); | 388 | String toolName, filePath, para; |
382 | if (menu.getNodeType() == Node.ELEMENT_NODE) { | 389 | MyMenuItem menuItem; |
383 | if (menu.getNodeName().equalsIgnoreCase("tool")) { | 390 | if (tools == null) { |
384 | String toolName = | 391 | // 弹窗提示 |
385 | MyContorlUtil.getStringAttribute(menu, | 392 | JOptionPane.showMessageDialog(null, "Error: 工具配置文件未找到", |
386 | "toolName"); | 393 | "提示", 2); |
387 | String filePath = | 394 | return; |
388 | MyContorlUtil.getStringAttribute(menu, | 395 | } |
389 | "filePath"); | 396 | for (int i = 0; i < tools.getLength(); i++) { |
390 | String para = | 397 | org.w3c.dom.Node menu = tools.item(i); |
391 | MyContorlUtil.getStringAttribute(menu, "para"); | 398 | if (menu.getNodeType() != Node.ELEMENT_NODE || |
392 | 399 | !menu.getNodeName().equalsIgnoreCase("tool")) { | |
393 | try { | 400 | continue; |
394 | Class<?> clazz = | 401 | } |
395 | Class.forName("toolsconfig." + toolName); | 402 | toolName = MyContorlUtil.getStringAttribute(menu, "toolName"); |
396 | Object obj = clazz.getDeclaredConstructor() | 403 | filePath = MyContorlUtil.getStringAttribute(menu, "filePath"); |
397 | .newInstance(); | 404 | para = MyContorlUtil.getStringAttribute(menu, "para"); |
398 | ToolsRegistry.getTool(toolName) | 405 | |
399 | .init(filePath, para, main); | 406 | ToolsConfig tool = ToolsRegistry.getTool(toolName); |
400 | } catch (Exception e) { | 407 | if (tool != null) { |
401 | e.printStackTrace(); | 408 | tool.init(filePath, para, ui); |
402 | } | 409 | continue; |
403 | } | ||
404 | } | ||
405 | } | 410 | } |
411 | try { | ||
412 | Class<?> clazz = Class.forName("toolsconfig." + toolName); | ||
413 | Object obj = clazz.getDeclaredConstructor().newInstance(); | ||
414 | ToolsRegistry.getTool(toolName).init(filePath, para, ui); | ||
415 | } catch (Exception e) { | ||
416 | e.printStackTrace(); | ||
417 | } | ||
418 | menuItem = new MyMenuItem(); | ||
419 | menuItem.setText(toolName); | ||
420 | menuItem.setToolTipText(toolName); | ||
421 | menuItem.setActionCommand(toolName); | ||
422 | |||
423 | menuItem.addActionListener(action); | ||
424 | checkBar.add(menuItem); | ||
406 | } | 425 | } |
426 | |||
427 | checkBar.setText("检测工具"); | ||
428 | ui.mymenubar.add(checkBar, 1); | ||
407 | } catch (Exception ex) { | 429 | } catch (Exception ex) { |
408 | ex.printStackTrace(); | 430 | ex.printStackTrace(); |
409 | } | 431 | } |
diff --git a/src/cppcheckplus/control/UIFrame.java b/src/cppcheckplus/control/UIFrame.java index bb15707..499d056 100644 --- a/src/cppcheckplus/control/UIFrame.java +++ b/src/cppcheckplus/control/UIFrame.java | |||
@@ -34,19 +34,19 @@ import javax.swing.JTextArea; | |||
34 | import javax.swing.event.ListSelectionEvent; | 34 | import javax.swing.event.ListSelectionEvent; |
35 | import javax.swing.event.ListSelectionListener; | 35 | import javax.swing.event.ListSelectionListener; |
36 | import javax.swing.plaf.TabbedPaneUI; | 36 | import javax.swing.plaf.TabbedPaneUI; |
37 | import toolsconfig.ToolsConfig; | ||
37 | import toolsconfig.ToolsRegistry; | 38 | import toolsconfig.ToolsRegistry; |
38 | 39 | ||
39 | |||
40 | // 构造界面 | 40 | // 构造界面 |
41 | public class UIFrame extends JFrame { | 41 | public class UIFrame extends JFrame { |
42 | public final MyMenuBar mymenubar; | ||
42 | // XML配置文件路径 | 43 | // XML配置文件路径 |
43 | private final String menuBarXML; | 44 | private final String menuBarXML = "cppcheckplus/control/menubar.xml"; |
44 | private final String outlookPanelXML; | 45 | private final String outlookPanelXML = "cppcheckplus/control/outlook.xml"; |
45 | private final String settingsXML; | 46 | private final String settingsXML = "toolsconfig/settings.xml"; |
46 | private final String stdclangXML; | 47 | private final String stdclangXML = "cppcheckplus/control/stdclang.xml"; |
47 | // 界面组件 | 48 | // 界面组件 |
48 | private final MyContentPanel contentPanel; | 49 | private final MyContentPanel contentPanel; |
49 | private final MyMenuBar menubar; | ||
50 | private final JFileChooser jfc = new JFileChooser();// 文件选择器 | 50 | private final JFileChooser jfc = new JFileChooser();// 文件选择器 |
51 | private final JFileChooser jfsettings = new JFileChooser();// 配置设定 | 51 | private final JFileChooser jfsettings = new JFileChooser();// 配置设定 |
52 | private final String projectPath; | 52 | private final String projectPath; |
@@ -57,50 +57,39 @@ public class UIFrame extends JFrame { | |||
57 | public creatTable ct = new creatTable(); // 生成表格 | 57 | public creatTable ct = new creatTable(); // 生成表格 |
58 | public TextArea textCheck;// 显示检查进度输出 | 58 | public TextArea textCheck;// 显示检查进度输出 |
59 | private MyOutlookPanel outlookPanel; | 59 | private MyOutlookPanel outlookPanel; |
60 | private MyTabPanel1 footTabPanel; | 60 | private MyTabPanel1 footTabPanel; // 底部标签页 |
61 | private MyShortcutPanel shortcutPanel; | 61 | private MyShortcutPanel shortcutPanel; |
62 | private MyTree tree; | 62 | private MyTree tree; |
63 | private MyTextPanel1 testPanel; | 63 | private MyTextPanel1 testPanel; |
64 | private ViewPanel viewPanel; | 64 | private ViewPanel viewPanel; |
65 | // 显示代码和检查进程的文本区域 | ||
66 | private JTextArea textCode;// 显示代码内容 | 65 | private JTextArea textCode;// 显示代码内容 |
67 | // 文件操作相关 | 66 | |
68 | private File result; // 存储打开的文件 | ||
69 | private File report; // 导出报告时选择的文件 | 67 | private File report; // 导出报告时选择的文件 |
70 | private File dir; // 存储打开的目录 | ||
71 | 68 | ||
72 | // 构造函数:初始化各个组件,加载配置文件,建立界面布局 | ||
73 | public UIFrame() { | 69 | public UIFrame() { |
74 | projectPath = System.getProperty("user.dir"); | 70 | projectPath = System.getProperty("user.dir"); |
75 | // 文件选择器初始目录 | 71 | // 文件选择器初始目录 |
76 | jfc.setCurrentDirectory(new File("d://")); | 72 | jfc.setCurrentDirectory(new File("d://")); |
77 | jfsettings.setCurrentDirectory(new File("d://")); | 73 | jfsettings.setCurrentDirectory(new File("d://")); |
78 | 74 | ||
79 | // 配置文件路径 | ||
80 | menuBarXML = "cppcheckplus/control/menubar.xml"; | ||
81 | outlookPanelXML = "cppcheckplus/control/outlook.xml"; | ||
82 | settingsXML = "toolsconfig/settings.xml"; | ||
83 | stdclangXML = "cppcheckplus/control/stdclang.xml"; | ||
84 | |||
85 | MyContorlUtil.loadToolsRoad(settingsXML, this);// 加载工具路径设置到当前对象中 | ||
86 | ct.initSTDClang(stdclangXML);// 设置clang配置 | 75 | ct.initSTDClang(stdclangXML);// 设置clang配置 |
87 | 76 | ||
88 | // 加载菜单栏,注册事件监听 | 77 | // 加载菜单栏,注册事件监听 |
89 | menubar = MyContorlUtil.loadMenuBar(menuBarXML, new ActionListener() { | 78 | mymenubar = MyContorlUtil.loadMenuBar(menuBarXML, new ActionListener() { |
90 | public void actionPerformed(ActionEvent e) { | 79 | public void actionPerformed(ActionEvent e) { |
91 | String command = e.getActionCommand(); | 80 | String command = e.getActionCommand(); |
81 | File res = null; | ||
92 | switch (command) { | 82 | switch (command) { |
93 | case "onMenuOpen": | 83 | case "onMenuOpen": |
94 | // 打开文件 | ||
95 | jfc.setFileSelectionMode(JFileChooser.FILES_ONLY); | 84 | jfc.setFileSelectionMode(JFileChooser.FILES_ONLY); |
96 | if (jfc.showOpenDialog(null) == | 85 | if (jfc.showOpenDialog(null) == |
97 | JFileChooser.CANCEL_OPTION) { | 86 | JFileChooser.CANCEL_OPTION) { |
98 | return; | 87 | return; |
99 | } | 88 | } |
100 | result = jfc.getSelectedFile();// result为选择到的文件 | 89 | res = jfc.getSelectedFile(); |
101 | src = result.getAbsolutePath(); | 90 | src = res.getAbsolutePath(); |
102 | // 读取文件内容并显示到代码区 | 91 | textCode.setText( |
103 | textCode.setText(FileTools.readFile(result)); | 92 | FileTools.readFile(res)); // 读取文件内容并显示到代码区 |
104 | // 如果代码标签页不存在,则创建一个 | 93 | // 如果代码标签页不存在,则创建一个 |
105 | if (!centerTabPanel.isSelectTabComponents("代码")) { | 94 | if (!centerTabPanel.isSelectTabComponents("代码")) { |
106 | centerTabPanel.addTab("代码", testCode); | 95 | centerTabPanel.addTab("代码", testCode); |
@@ -114,14 +103,15 @@ public class UIFrame extends JFrame { | |||
114 | JFileChooser.CANCEL_OPTION) { | 103 | JFileChooser.CANCEL_OPTION) { |
115 | return; | 104 | return; |
116 | } | 105 | } |
117 | dir = jfc.getSelectedFile();// 选择到的目录 | 106 | res = jfc.getSelectedFile(); |
118 | src = dir.getAbsolutePath(); | 107 | src = res.getAbsolutePath(); |
119 | tree.setRootDir(dir);// 更新目录树 | 108 | tree.setRootDir(res);// 更新目录树 |
120 | break; | 109 | break; |
121 | case "onMenuSave": | 110 | case "onMenuSave": |
122 | // 保存文件 | 111 | if (res != null && res.isFile()) { |
123 | if (result != null) { | 112 | FileTools.writeFile(res, textCode.getText()); |
124 | FileTools.writeFile(result, textCode.getText()); | 113 | JOptionPane.showMessageDialog(null, "保存成功", |
114 | "提示", 2); | ||
125 | } | 115 | } |
126 | break; | 116 | break; |
127 | case "onMenuClose": | 117 | case "onMenuClose": |
@@ -148,51 +138,10 @@ public class UIFrame extends JFrame { | |||
148 | if (r == JFileChooser.APPROVE_OPTION) { | 138 | if (r == JFileChooser.APPROVE_OPTION) { |
149 | report = dialog.getSelectedFile(); | 139 | report = dialog.getSelectedFile(); |
150 | FileTools.writeFile(report, ct.results); | 140 | FileTools.writeFile(report, ct.results); |
151 | } else { | 141 | JOptionPane.showMessageDialog(null, "导出成功", |
152 | JOptionPane.showMessageDialog(null, "路径错误", | ||
153 | "提示", 2); | 142 | "提示", 2); |
154 | } | ||
155 | break; | ||
156 | case "onCppcheck": | ||
157 | // cppcheck检查 | ||
158 | if (src != null && src.length() != 0) { | ||
159 | new Thread() { | ||
160 | public void run() { | ||
161 | ToolsRegistry.executeTool("cppcheck", src); | ||
162 | viewResult("cppcheck"); | ||
163 | } | ||
164 | }.start(); | ||
165 | } else { | 143 | } else { |
166 | JOptionPane.showMessageDialog(null, "目标路径错误", | 144 | JOptionPane.showMessageDialog(null, "路径错误", |
167 | "提示", 2); | ||
168 | } | ||
169 | break; | ||
170 | case "onClang": | ||
171 | // clang/clang-tidy检查 | ||
172 | if (src != null && src.length() != 0) { | ||
173 | new Thread() { | ||
174 | public void run() { | ||
175 | ToolsRegistry.executeTool("clangTidy", src); | ||
176 | viewResult("clangTidy"); | ||
177 | } | ||
178 | }.start(); | ||
179 | } else { | ||
180 | JOptionPane.showMessageDialog(null, "目标路径错误", | ||
181 | "提示", 2); | ||
182 | } | ||
183 | break; | ||
184 | case "onFlawfinder": | ||
185 | // flawfinder检查 | ||
186 | if (src != null && src.length() != 0) { | ||
187 | new Thread() { | ||
188 | public void run() { | ||
189 | ToolsRegistry.executeTool("flawfinder", | ||
190 | src); | ||
191 | viewResult("flawfinder"); | ||
192 | } | ||
193 | }.start(); | ||
194 | } else { | ||
195 | JOptionPane.showMessageDialog(null, "目标路径错误", | ||
196 | "提示", 2); | 145 | "提示", 2); |
197 | } | 146 | } |
198 | break; | 147 | break; |
@@ -240,37 +189,28 @@ public class UIFrame extends JFrame { | |||
240 | viewPanel.update(ct.results); | 189 | viewPanel.update(ct.results); |
241 | } | 190 | } |
242 | break; | 191 | break; |
243 | case "onSetCppcheckRoad": | 192 | default: |
244 | // cppcheck路径 | 193 | System.out.println("未知命令"); |
245 | jfsettings.setFileSelectionMode( | ||
246 | JFileChooser.FILES_ONLY); | ||
247 | if (jfsettings.showOpenDialog(null) == | ||
248 | JFileChooser.CANCEL_OPTION) { | ||
249 | return; | ||
250 | } else { | ||
251 | File cppcheckFile = jfsettings.getSelectedFile(); | ||
252 | String cppcheckPathTemp = | ||
253 | cppcheckFile.getAbsolutePath(); | ||
254 | MyContorlUtil.fixSettingPath(settingsXML, | ||
255 | "cppcheck", cppcheckPathTemp); | ||
256 | // changedpathcpp = true; | ||
257 | } | ||
258 | break; | 194 | break; |
259 | case "onSetFlawfinderRoad": | 195 | } |
260 | // flawfinder路径 | 196 | } |
261 | jfsettings.setFileSelectionMode( | 197 | }); |
262 | JFileChooser.FILES_ONLY); | 198 | |
263 | if (jfsettings.showOpenDialog(null) == | 199 | MyContorlUtil.loadToolsRoad(settingsXML, this, new ActionListener() { |
264 | JFileChooser.CANCEL_OPTION) { | 200 | @Override |
265 | return;// 撤销则返回 | 201 | public void actionPerformed(ActionEvent e) { |
202 | String toolName = e.getActionCommand(); | ||
203 | if (src != null && src.length() != 0) { | ||
204 | new Thread() { | ||
205 | public void run() { | ||
206 | ct.clearall(); | ||
207 | ToolsRegistry.executeTool(toolName, src); | ||
208 | viewResult(toolName); | ||
266 | } | 209 | } |
267 | File flawfinderFile = jfsettings.getSelectedFile(); | 210 | }.start(); |
268 | String flawfinderPathTemp = | 211 | } else { |
269 | flawfinderFile.getAbsolutePath(); | 212 | JOptionPane.showMessageDialog(null, "目标路径错误", "提示", |
270 | MyContorlUtil.fixSettingPath(settingsXML, "flawfinder", | 213 | 2); |
271 | flawfinderPathTemp); | ||
272 | // changedpathflaw = true; | ||
273 | break; | ||
274 | } | 214 | } |
275 | } | 215 | } |
276 | }); | 216 | }); |
@@ -293,7 +233,7 @@ public class UIFrame extends JFrame { | |||
293 | setIconImage(MyContorlUtil.getImage("control/images/logo2.png")); | 233 | setIconImage(MyContorlUtil.getImage("control/images/logo2.png")); |
294 | setContentPane(contentPanel); | 234 | setContentPane(contentPanel); |
295 | // 菜单栏在最上方 | 235 | // 菜单栏在最上方 |
296 | contentPanel.add(menubar, "North"); | 236 | contentPanel.add(mymenubar, "North"); |
297 | 237 | ||
298 | // 除却菜单栏之外的面板 | 238 | // 除却菜单栏之外的面板 |
299 | //JPanel centerPane = new JPanel(new BorderLayout()); | 239 | //JPanel centerPane = new JPanel(new BorderLayout()); |
diff --git a/src/cppcheckplus/control/menubar.xml b/src/cppcheckplus/control/menubar.xml index f2d2f19..0aae26b 100644 --- a/src/cppcheckplus/control/menubar.xml +++ b/src/cppcheckplus/control/menubar.xml | |||
@@ -1,28 +1,19 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <menubar> | 2 | <menubar> |
3 | <menu text="件"> | 3 | <menu text="辑"> |
4 | <menuitem text="打开文件" tooltip="可以打开你的代码" icon="control/images/toolbar/update.png" action="onMenuOpen"/> | 4 | <menuitem text="打开文件" tooltip="可以打开你的代码" icon="control/images/toolbar/update.png" action="onMenuOpen"/> |
5 | <menuitem text="选择路径" tooltip="选取工程或者项目路径" icon="control/images/toolbar/add.png" action="onMenuLoad"/> | 5 | <menuitem text="选择路径" tooltip="选取工程或者项目路径" icon="control/images/toolbar/add.png" action="onMenuLoad"/> |
6 | <menuitem text="保存文件" tooltip="可以保存你的代码" icon="control/images/toolbar/email.png" action="onMenuSave"/> | 6 | <menuitem text="保存文件" tooltip="可以保存你的代码" icon="control/images/toolbar/email.png" action="onMenuSave"/> |
7 | <menuitem text="关闭" tooltip="退出程序" icon="control/images/toolbar/right.png" action="onMenuClose"/> | ||
8 | </menu> | ||
9 | <menu text="编辑"> | ||
10 | <menuitem text="清理工作区" tooltip="clean" icon="control/images/toolbar/home.png" action="onMenuClean"/> | ||
11 | <menuitem text="导出检查结果" tooltip="选取工程或者项目路径" icon="control/images/toolbar/print.png" action="onMenuExport"/> | 7 | <menuitem text="导出检查结果" tooltip="选取工程或者项目路径" icon="control/images/toolbar/print.png" action="onMenuExport"/> |
12 | <menuitem text="cppcheck" tooltip="用cppcheck检查代码" icon="control/images/toolbar/message.png" action="onCppcheck"/> | 8 | <menuitem text="清理工作区" tooltip="clean" icon="control/images/toolbar/home.png" action="onMenuClean"/> |
13 | <menuitem text="Clang" tooltip="用Clang检查代码" icon="control/images/toolbar/message.png" action="onClang"/> | 9 | <menuitem text="关闭" tooltip="退出程序" icon="control/images/toolbar/right.png" action="onMenuClose"/> |
14 | <menuitem text="flawfinder" tooltip="用flawfinder检查代码" icon="control/images/toolbar/message.png" action="onFlawfinder"/> | ||
15 | </menu> | 10 | </menu> |
16 | <menu text="设置"> | 11 | <menu text="设置"> |
17 | <menu text="结果筛选"> | 12 | <menu text="结果筛选"> |
18 | <menuitem text="按照类别筛选" tooltip="结果按缺陷类别排序" icon="control/images/email.png" action="onOrderType"/> | 13 | <menuitem text="按照类别筛选" tooltip="结果按缺陷类别排序" icon="control/images/email.png" action="onOrderType"/> |
19 | <menuitem text="按照级别筛选" tooltip="结果按缺陷等级排序" icon="control/images/email.png" action="onOrderLevel"/> | 14 | <menuitem text="按照级别筛选" tooltip="结果按缺陷等级排序" icon="control/images/email.png" action="onOrderLevel"/> |
20 | <menuitem text="按照文件筛选" tooltip="结果按文件排序" icon="control/images/email.png" action="onOrderFile"/> | 15 | <menuitem text="按照文件筛选" tooltip="结果按文件排序" icon="control/images/email.png" action="onOrderFile"/> |
21 | </menu> | 16 | </menu> |
22 | <menu text="初始文件设置"> | ||
23 | <menuitem text="设置Cppcheck路径" tooltip="设置Cppcheck路径" icon="control/images/email.png" action="onSetCppcheckRoad"/> | ||
24 | <menuitem text="设置flawfinder路径" tooltip="设置flawfinder路径" icon="control/images/email.png" action="onSetFlawfinderRoad"/> | ||
25 | </menu> | ||
26 | </menu> | 17 | </menu> |
27 | 18 | ||
28 | <menu text="帮助"> | 19 | <menu text="帮助"> |
diff --git a/src/toolsconfig/ToolsConfig.java b/src/toolsconfig/ToolsConfig.java index 7d55fb2..fc1b6a0 100644 --- a/src/toolsconfig/ToolsConfig.java +++ b/src/toolsconfig/ToolsConfig.java | |||
@@ -14,9 +14,9 @@ public abstract class ToolsConfig { | |||
14 | protected String params; | 14 | protected String params; |
15 | protected UIFrame uiFrame; | 15 | protected UIFrame uiFrame; |
16 | protected TextArea result; | 16 | protected TextArea result; |
17 | protected String name; | 17 | public String name; |
18 | 18 | ||
19 | public abstract void execute(String src); | 19 | protected abstract void execute(String src); |
20 | 20 | ||
21 | public void init(String path, String params, UIFrame uiFrame) { | 21 | public void init(String path, String params, UIFrame uiFrame) { |
22 | this.path = path; | 22 | this.path = path; |
diff --git a/src/toolsconfig/clangTidy.java b/src/toolsconfig/clangTidy.java index 8186603..6e3cb59 100644 --- a/src/toolsconfig/clangTidy.java +++ b/src/toolsconfig/clangTidy.java | |||
@@ -15,7 +15,7 @@ public class clangTidy extends ToolsConfig { | |||
15 | } | 15 | } |
16 | 16 | ||
17 | @Override | 17 | @Override |
18 | public void execute(String src) { | 18 | protected void execute(String src) { |
19 | // clang-tidy 检查 | 19 | // clang-tidy 检查 |
20 | Runtime runtime = Runtime.getRuntime(); | 20 | Runtime runtime = Runtime.getRuntime(); |
21 | Process p = null; | 21 | Process p = null; |
diff --git a/src/toolsconfig/cppcheck.java b/src/toolsconfig/cppcheck.java index d36c11f..ca3be27 100644 --- a/src/toolsconfig/cppcheck.java +++ b/src/toolsconfig/cppcheck.java | |||
@@ -13,13 +13,7 @@ public class cppcheck extends ToolsConfig { | |||
13 | } | 13 | } |
14 | 14 | ||
15 | @Override | 15 | @Override |
16 | public void execute(String src) { | 16 | protected void execute(String src) { |
17 | // FIXME:这段代码原因不详,十分令人疑惑 | ||
18 | // if (changedpathcpp) { | ||
19 | // MyContorlUtil.loadToolsRoad(settingsXML, this); | ||
20 | // changedpathcpp = false; | ||
21 | // } | ||
22 | |||
23 | // 路径未配置,直接返回 | 17 | // 路径未配置,直接返回 |
24 | if (path == null) { | 18 | if (path == null) { |
25 | return; | 19 | return; |
diff --git a/src/toolsconfig/flawfinder.java b/src/toolsconfig/flawfinder.java index 0528eb6..bb953ea 100644 --- a/src/toolsconfig/flawfinder.java +++ b/src/toolsconfig/flawfinder.java | |||
@@ -12,13 +12,7 @@ public class flawfinder extends ToolsConfig { | |||
12 | } | 12 | } |
13 | 13 | ||
14 | @Override | 14 | @Override |
15 | public void execute(String src) { | 15 | protected void execute(String src) { |
16 | // flawfinder | ||
17 | // if (changedpathflaw) { | ||
18 | // MyContorlUtil.loadToolsRoad(settingsXML, this); | ||
19 | // changedpathflaw = false; | ||
20 | // } | ||
21 | |||
22 | if (path == null) { | 16 | if (path == null) { |
23 | return; | 17 | return; |
24 | } | 18 | } |
@@ -27,7 +21,6 @@ public class flawfinder extends ToolsConfig { | |||
27 | Runtime runtime2 = Runtime.getRuntime(); | 21 | Runtime runtime2 = Runtime.getRuntime(); |
28 | Process p2 = null; | 22 | Process p2 = null; |
29 | try { | 23 | try { |
30 | |||
31 | // 两个参数数组,一个是csv格式,一个是传入的参数 | 24 | // 两个参数数组,一个是csv格式,一个是传入的参数 |
32 | String[] arguments = | 25 | String[] arguments = |
33 | new String[] {"python", path, "--csv", src}; | 26 | new String[] {"python", path, "--csv", src}; |