summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWe-unite <3205135446@qq.com>2025-02-19 21:04:40 +0800
committerWe-unite <3205135446@qq.com>2025-02-19 21:04:40 +0800
commit2c3ec51f24394f5f16edafd64998b504eab093f9 (patch)
tree048bd27cac35f9c53ea46a68dd475a6beca67637
parenteaba1ffa193104f90751371bfa9814552a2a6243 (diff)
downloadproject-2c3ec51f24394f5f16edafd64998b504eab093f9.tar.gz
project-2c3ec51f24394f5f16edafd64998b504eab093f9.zip
update
-rw-r--r--src/cppcheckplus/control/Main.java59
-rw-r--r--src/cppcheckplus/control/settings.xml2
2 files changed, 31 insertions, 30 deletions
diff --git a/src/cppcheckplus/control/Main.java b/src/cppcheckplus/control/Main.java
index 4c84eac..2759e2f 100644
--- a/src/cppcheckplus/control/Main.java
+++ b/src/cppcheckplus/control/Main.java
@@ -64,6 +64,7 @@ public class Main extends JFrame {
64 private final MyMenuBar menubar; 64 private final MyMenuBar menubar;
65 private final JFileChooser jfc = new JFileChooser();// 文件选择器 65 private final JFileChooser jfc = new JFileChooser();// 文件选择器
66 private final JFileChooser jfsettings = new JFileChooser();// 配置设定 66 private final JFileChooser jfsettings = new JFileChooser();// 配置设定
67 private final String projectPath;
67 public MyTabPanel tabPanel; 68 public MyTabPanel tabPanel;
68 // 编辑代码的面板 69 // 编辑代码的面板
69 public MyTextPanel testCode; 70 public MyTextPanel testCode;
@@ -101,7 +102,6 @@ public class Main extends JFrame {
101 //private static String inputResult = "inputResult.txt"; 102 //private static String inputResult = "inputResult.txt";
102 //private static String errorResult = "errorResult.txt"; 103 //private static String errorResult = "errorResult.txt";
103 private Main ui; 104 private Main ui;
104 private final String projectPath;
105 105
106 // 构造函数:初始化各个组件,加载配置文件,建立界面布局 106 // 构造函数:初始化各个组件,加载配置文件,建立界面布局
107 public Main() { 107 public Main() {
@@ -124,29 +124,28 @@ public class Main extends JFrame {
124 public void actionPerformed(ActionEvent e) { 124 public void actionPerformed(ActionEvent e) {
125 String command = e.getActionCommand(); 125 String command = e.getActionCommand();
126 switch (command) { 126 switch (command) {
127 case "OnMenuOpen": 127 case "onMenuOpen":
128 // 打开文件 128 // 打开文件
129 jfc.setFileSelectionMode(0);// 设定只能选择到文件 129 jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
130 int state = jfc.showOpenDialog(null); 130 if (jfc.showOpenDialog(null) ==
131 if (state == 1) { 131 JFileChooser.CANCEL_OPTION) {
132 return; // 撤销选择则返回 132 return;
133 } else { 133 }
134 result = jfc.getSelectedFile();// result为选择到的文件 134 result = jfc.getSelectedFile();// result为选择到的文件
135 src = result.getAbsolutePath(); 135 src = result.getAbsolutePath();
136 // 读取文件内容并显示到代码区 136 // 读取文件内容并显示到代码区
137 textCode.setText(FileTools.readFile(result)); 137 textCode.setText(FileTools.readFile(result));
138 // 如果代码标签页不存在,则创建一个 138 // 如果代码标签页不存在,则创建一个
139 if (!tabPanel.isSelectTabComponents("代码")) { 139 if (!tabPanel.isSelectTabComponents("代码")) {
140 tabPanel.addTab("代码", testCode); 140 tabPanel.addTab("代码", testCode);
141 tabPanel.isSelectTabComponents("代码"); 141 tabPanel.isSelectTabComponents("代码");
142 }
143 } 142 }
144 break; 143 break;
145 case "onMenuLoad": 144 case "onMenuLoad":
146 // 加载目录:选择目录并更新目录树 145 // 加载目录:选择目录并更新目录树
147 jfc.setFileSelectionMode(1);// 只能选择到文件夹 146 jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
148// int state = jfc.showOpenDialog(null); 147 if (jfc.showOpenDialog(null) ==
149 if (jfc.showOpenDialog(null) == 1) { 148 JFileChooser.CANCEL_OPTION) {
150 return; 149 return;
151 } 150 }
152 direct = jfc.getSelectedFile();// 选择到的目录 151 direct = jfc.getSelectedFile();// 选择到的目录
@@ -293,18 +292,19 @@ public class Main extends JFrame {
293 break; 292 break;
294 case "onSetFlawfinderRoad": 293 case "onSetFlawfinderRoad":
295 // flawfinder路径 294 // flawfinder路径
296 jfsettings.setFileSelectionMode(0);// 设定只能选择到文件 295 jfsettings.setFileSelectionMode(
296 JFileChooser.FILES_ONLY);// 设定只能选择到文件
297// int state = jfsettings.showOpenDialog(null); 297// int state = jfsettings.showOpenDialog(null);
298 if (jfsettings.showOpenDialog(null) == 1) { 298 if (jfsettings.showOpenDialog(null) ==
299 JFileChooser.CANCEL_OPTION) {
299 return;// 撤销则返回 300 return;// 撤销则返回
300 } else {
301 File flawfinderFile = jfsettings.getSelectedFile();
302 String flawfinderPathTemp =
303 flawfinderFile.getAbsolutePath();
304 MyContorlUtil.fixSettingPath(settingsXML,
305 "flawfinder", flawfinderPathTemp);
306 changedpathflaw = true;
307 } 301 }
302 File flawfinderFile = jfsettings.getSelectedFile();
303 String flawfinderPathTemp =
304 flawfinderFile.getAbsolutePath();
305 MyContorlUtil.fixSettingPath(settingsXML, "flawfinder",
306 flawfinderPathTemp);
307 changedpathflaw = true;
308 break; 308 break;
309 } 309 }
310 } 310 }
@@ -331,6 +331,7 @@ public class Main extends JFrame {
331 } 331 }
332 332
333 private void execute(String src, String para) { 333 private void execute(String src, String para) {
334 System.out.println("cppcheckPath:" + cppcheckPath);
334 if (changedpathcpp) { 335 if (changedpathcpp) {
335 MyContorlUtil.loadToolsRoad(settingsXML, this); 336 MyContorlUtil.loadToolsRoad(settingsXML, this);
336 changedpathcpp = false; 337 changedpathcpp = false;
@@ -618,6 +619,7 @@ public class Main extends JFrame {
618 } 619 }
619 620
620 private void execute3(String src, String para, String tmpFileName) { 621 private void execute3(String src, String para, String tmpFileName) {
622 System.out.println("flawfinderPath:" + flawfinderPath);
621 // flawfinder 623 // flawfinder
622 if (changedpathflaw) { 624 if (changedpathflaw) {
623 MyContorlUtil.loadToolsRoad(settingsXML, this); 625 MyContorlUtil.loadToolsRoad(settingsXML, this);
@@ -792,7 +794,6 @@ public class Main extends JFrame {
792 String command = e.getActionCommand(); 794 String command = e.getActionCommand();
793 System.out.println("Head:" + command); 795 System.out.println("Head:" + command);
794 } 796 }
795
796 }, new ListSelectionListener() { 797 }, new ListSelectionListener() {
797 @Override 798 @Override
798 public void valueChanged(ListSelectionEvent e) { 799 public void valueChanged(ListSelectionEvent e) {
diff --git a/src/cppcheckplus/control/settings.xml b/src/cppcheckplus/control/settings.xml
index 6e809a5..43efee0 100644
--- a/src/cppcheckplus/control/settings.xml
+++ b/src/cppcheckplus/control/settings.xml
@@ -1,6 +1,6 @@
1<?xml version="1.0" encoding="UTF-8" standalone="no"?><settings> 1<?xml version="1.0" encoding="UTF-8" standalone="no"?><settings>
2 <tool filePath="C:/Users/HP/Desktop/智能软件中心/软件测试小组/工具/苏佳/苏佳的代码-代码缺陷检测工具/cppcheck/bin/debug/cppcheck.exe" para="--enable=all" toolName="cppcheck"> 2 <tool filePath="C:/Users/HP/Desktop/智能软件中心/软件测试小组/工具/苏佳/苏佳的代码-代码缺陷检测工具/cppcheck/bin/debug/cppcheck.exe" para="--enable=all" toolName="cppcheck">
3 </tool> 3 </tool>
4 <tool filePath="C:/Users/HP/Desktop/智能软件中心/软件测试小组/工具/苏佳/苏佳的代码-代码缺陷检测工具/flawfinder-2.0.19/flawfinder-2.0.19/flawfinder.py" para="" toolName="flawfinder"> 4 <tool filePath="C:/Users/we-unite/Desktop/Project/Project/code/flawfinder-2.0.19/flawfinder-2.0.19/flawfinder.py" para="" toolName="flawfinder">
5 </tool> 5 </tool>
6</settings> \ No newline at end of file 6</settings> \ No newline at end of file