实现config.xml功能

裁判机的编译器配置读写改在config.xml中实现
This commit is contained in:
Jered Ye 2024-01-15 14:38:26 +08:00
parent 7e549c1059
commit 05802a9524
9 changed files with 109 additions and 21 deletions

8
.gitignore vendored
View File

@ -12,3 +12,11 @@ clientUpdater/dist/README.TXT
Common/dist/Common.jar Common/dist/Common.jar
Judger/dist/Judger.jar Judger/dist/Judger.jar
Judger/dist/lib/Common.jar Judger/dist/lib/Common.jar
*.class
*.properties
*.html
*.cpp
*.jar
*.class
*.zip
*.jar

63
JuderUI/config.xml Normal file
View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<languages>
<language id="C++" alias="c++,c,cpp,CPP,C">
<compiler name="MinGW">
<path>K:\Dev-Cpp\MinGW64\bin</path>
<compileCmd>g++.exe -Wall -g -std=c++14 -c $sourceFile$ -o $objFile$</compileCmd>
<!-- g++.exe -Wall -g -std=c++14 -c D:\prog_old\test\main.cpp -o obj\Debug\main.o-->
<linkCmd>g++.exe -o $exeFile$ $objFile$ -O1</linkCmd>
<!-- g++.exe -o bin\Debug\test.exe obj\Debug\main.o -O1-->
<runCmd>"$exeFile$"</runCmd>
</compiler>
<compiler name="MSVC">
<path>C:/MinGW/bin/</path>
<compileCmd>g++.exe -Wall -g -std=c++14 -c $sourceFile$ -o $objFile$</compileCmd>
<!-- g++.exe -Wall -g -std=c++14 -c D:\prog_old\test\main.cpp -o obj\Debug\main.o-->
<linkCmd>g++.exe -o $exeFile$ $objFile$ -O1</linkCmd>
<!-- g++.exe -o bin\Debug\test.exe obj\Debug\main.o -O1-->
<runCmd>msvc</runCmd>
</compiler>
</language>
<language id="Java" alias="java,JAVA">
<compiler name="JDK8">
<path>C:/JDK8/bin</path>
<compileCmd>g++.exe -Wall -g -std=c++14 -c $sourceFile$ -o $objFile$</compileCmd>
<!-- g++.exe -Wall -g -std=c++14 -c D:\prog_old\test\main.cpp -o obj\Debug\main.o-->
<linkCmd>g++.exe -o $exeFile$ $objFile$ -O1</linkCmd>
<!-- g++.exe -o bin\Debug\test.exe obj\Debug\main.o -O1-->
<runCmd>"$compilerPath$ java -cp $sourceFile$\output\$exeFile$"</runCmd>
</compiler>
<compiler name="JDK9">
<path>C:/MinGW/bin/</path>
<compileCmd>g++.exe -Wall -g -std=c++14 -c $sourceFile$ -o $objFile$</compileCmd>
<!-- g++.exe -Wall -g -std=c++14 -c D:\prog_old\test\main.cpp -o obj\Debug\main.o-->
<linkCmd>g++.exe -o $exeFile$ $objFile$ -O1</linkCmd>
<!-- g++.exe -o bin\Debug\test.exe obj\Debug\main.o -O1-->
<runCmd>
</runCmd>
</compiler>
</language>
<language id="Python" alias="python,PYTHON">
<compiler name="Python2">
<path>C:/MinGW/bin/</path>
<compileCmd>g++.exe -Wall -g -std=c++14 -c $sourceFile$ -o $objFile$</compileCmd>
<!-- g++.exe -Wall -g -std=c++14 -c D:\prog_old\test\main.cpp -o obj\Debug\main.o-->
<linkCmd>g++.exe -o $exeFile$ $objFile$ -O1</linkCmd>
<!-- g++.exe -o bin\Debug\test.exe obj\Debug\main.o -O1-->
<runCmd>$exeFile$</runCmd>
</compiler>
<compiler name="Python3">
<path>C:/MinGW/bin/</path>
<compileCmd>g++.exe -Wall -g -std=c++14 -c $sourceFile$ -o $objFile$</compileCmd>
<!-- g++.exe -Wall -g -std=c++14 -c D:\prog_old\test\main.cpp -o obj\Debug\main.o-->
<linkCmd>g++.exe -o $exeFile$ $objFile$ -O1</linkCmd>
<!-- g++.exe -o bin\Debug\test.exe obj\Debug\main.o -O1-->
<runCmd>
</runCmd>
</compiler>
</language>
<!-- sourceFile-->
<!-- objFile-->
<!-- exeFile-->
<language id="VB" />
</languages>

Binary file not shown.

View File

@ -108,8 +108,9 @@ public class Control {
//设置停止文本 //设置停止文本
public static void setStoptxt() { public static void setStoptxt() {
runflag = 0; //设置线程状态关闭 runflag = 0; //设置线程状态关闭
mainFrame.buttonCompilersConfig.setEnabled(true);//恢复编译器配置按钮 // mainFrame.buttonCompilersConfig.setEnabled(true);//恢复编译器配置按钮
mainFrame.buttonCompilersConfig1.setEnabled(true); // mainFrame.buttonCompilersConfig1.setEnabled(true);
mainFrame.jButton2.setEnabled(true);//设置编辑配置文件
mainFrame.jLabel14.setText("已关闭 ");//更新UI状态 mainFrame.jLabel14.setText("已关闭 ");//更新UI状态
} }

View File

@ -134,8 +134,8 @@
<Component id="buttonCompilersConfig" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="buttonCompilersConfig" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="distributorIP" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="distributorIP" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonCompilersConfig1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jButton2" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="jButton2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonCompilersConfig1" alignment="1" max="32767" attributes="0"/>
</Group> </Group>
<Group type="103" alignment="1" groupAlignment="3" attributes="0"> <Group type="103" alignment="1" groupAlignment="3" attributes="0">
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
@ -184,6 +184,7 @@
<Component class="javax.swing.JButton" name="buttonCompilersConfig"> <Component class="javax.swing.JButton" name="buttonCompilersConfig">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="C/C++&#x7f16;&#x8bd1;&#x5668;&#x914d;&#x7f6e;"/> <Property name="text" type="java.lang.String" value="C/C++&#x7f16;&#x8bd1;&#x5668;&#x914d;&#x7f6e;"/>
<Property name="enabled" type="boolean" value="false"/>
</Properties> </Properties>
<Events> <Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonCompilersConfigActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonCompilersConfigActionPerformed"/>
@ -510,6 +511,7 @@
<Component class="javax.swing.JButton" name="buttonCompilersConfig1"> <Component class="javax.swing.JButton" name="buttonCompilersConfig1">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="JAVA&#x7f16;&#x8bd1;&#x5668;&#x914d;&#x7f6e;"/> <Property name="text" type="java.lang.String" value="JAVA&#x7f16;&#x8bd1;&#x5668;&#x914d;&#x7f6e;"/>
<Property name="enabled" type="boolean" value="false"/>
</Properties> </Properties>
<Events> <Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonCompilersConfig1ActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonCompilersConfig1ActionPerformed"/>
@ -520,11 +522,14 @@
</Component> </Component>
<Component class="javax.swing.JButton" name="jButton2"> <Component class="javax.swing.JButton" name="jButton2">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="&#x67e5;&#x770b;&#x914d;&#x7f6e;&#x6587;&#x4ef6;"/> <Property name="text" type="java.lang.String" value="&#x7f16;&#x8f91;&#x914d;&#x7f6e;&#x6587;&#x4ef6;"/>
</Properties> </Properties>
<Events> <Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/>
</Events> </Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
</Component> </Component>
</SubComponents> </SubComponents>
</Container> </Container>

View File

@ -15,6 +15,8 @@ import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.xml.namespace.QName; import javax.xml.namespace.QName;
import share.gui.NewCompileSetting; import share.gui.NewCompileSetting;
@ -124,6 +126,7 @@ public class MainFrame extends javax.swing.JFrame {
}); });
buttonCompilersConfig.setText("C/C++编译器配置"); buttonCompilersConfig.setText("C/C++编译器配置");
buttonCompilersConfig.setEnabled(false);
buttonCompilersConfig.addActionListener(new java.awt.event.ActionListener() { buttonCompilersConfig.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonCompilersConfigActionPerformed(evt); buttonCompilersConfigActionPerformed(evt);
@ -265,13 +268,14 @@ public class MainFrame extends javax.swing.JFrame {
}); });
buttonCompilersConfig1.setText("JAVA编译器配置"); buttonCompilersConfig1.setText("JAVA编译器配置");
buttonCompilersConfig1.setEnabled(false);
buttonCompilersConfig1.addActionListener(new java.awt.event.ActionListener() { buttonCompilersConfig1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonCompilersConfig1ActionPerformed(evt); buttonCompilersConfig1ActionPerformed(evt);
} }
}); });
jButton2.setText("²é¿´ÅäÖÃÎļþ"); jButton2.setText("编辑配置文件");
jButton2.addActionListener(new java.awt.event.ActionListener() { jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt); jButton2ActionPerformed(evt);
@ -338,8 +342,8 @@ public class MainFrame extends javax.swing.JFrame {
.addComponent(buttonCompilersConfig) .addComponent(buttonCompilersConfig)
.addComponent(distributorIP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(distributorIP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3) .addComponent(jLabel3)
.addComponent(buttonCompilersConfig1) .addComponent(jButton2)
.addComponent(jButton2)) .addComponent(buttonCompilersConfig1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4) .addComponent(jLabel4)
.addComponent(distributorPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addComponent(distributorPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
@ -410,13 +414,18 @@ public class MainFrame extends javax.swing.JFrame {
}//GEN-LAST:event_buttonStopActionPerformed }//GEN-LAST:event_buttonStopActionPerformed
private void buttonCompilersConfigActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCompilersConfigActionPerformed private void buttonCompilersConfigActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCompilersConfigActionPerformed
JOptionPane.showMessageDialog(this, "请直接在配置文件中修改!");
NewCompileSetting cConfig = new NewCompileSetting("c", this, true); // NewCompileSetting cConfig = new NewCompileSetting("c", this, true);
cConfig.setVisible(true); // cConfig.setVisible(true);
Config.freshConfig(); // Config.freshConfig();
}//GEN-LAST:event_buttonCompilersConfigActionPerformed }//GEN-LAST:event_buttonCompilersConfigActionPerformed
private void button_StartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_StartActionPerformed private void button_StartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_StartActionPerformed
try {
LangSelector.init();
} catch (Exception ex) {
Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
}//刷新配置文件
if (!checkForCompile()) { if (!checkForCompile()) {
return; return;
} }
@ -426,9 +435,9 @@ public class MainFrame extends javax.swing.JFrame {
if (Control.startJudgerForNet(ip, Integer.parseInt(port))) { if (Control.startJudgerForNet(ip, Integer.parseInt(port))) {
this.jLabel14.setText("- -"); this.jLabel14.setText("- -");
//线程开始后不允许编辑编译器 //线程开始后不允许编辑编译器
this.buttonCompilersConfig.setEnabled(false); // this.buttonCompilersConfig.setEnabled(false);
this.buttonCompilersConfig1.setEnabled(false); // this.buttonCompilersConfig1.setEnabled(false);
this.jButton2.setEnabled(false);//设置编辑配置文件
Control.setRunStatus(); Control.setRunStatus();
this.button_Start.setEnabled(false); this.button_Start.setEnabled(false);
this.buttonStop.setEnabled(true); this.buttonStop.setEnabled(true);
@ -455,8 +464,8 @@ public class MainFrame extends javax.swing.JFrame {
//弹窗设置保存 //弹窗设置保存
JOptionPane.showMessageDialog(this, "请先配置C语言编译器"); JOptionPane.showMessageDialog(this, "请先配置C语言编译器");
NewCompileSetting window = new NewCompileSetting("c", this, true); // NewCompileSetting window = new NewCompileSetting("c", this, true);
window.setVisible(true); // window.setVisible(true);
return false; return false;
} }
@ -464,8 +473,8 @@ public class MainFrame extends javax.swing.JFrame {
if (tmp == null || "".equals(tmp) || !FileFinder.isExistFile(tmp + File.separator + "javac.exe")) { if (tmp == null || "".equals(tmp) || !FileFinder.isExistFile(tmp + File.separator + "javac.exe")) {
JOptionPane.showMessageDialog(this, "请先配置Java编译器"); JOptionPane.showMessageDialog(this, "请先配置Java编译器");
NewCompileSetting window = new NewCompileSetting("java", this, true); // NewCompileSetting window = new NewCompileSetting("java", this, true);
window.setVisible(true); // window.setVisible(true);
return false; return false;
} }
return true; return true;
@ -487,8 +496,9 @@ public class MainFrame extends javax.swing.JFrame {
private void buttonCompilersConfig1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCompilersConfig1ActionPerformed private void buttonCompilersConfig1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCompilersConfig1ActionPerformed
// TODO add your handling code here: // TODO add your handling code here:
NewCompileSetting javaConfig = new NewCompileSetting("java", this, true); JOptionPane.showMessageDialog(this, "请直接在配置文件中修改!");
javaConfig.setVisible(true); // NewCompileSetting javaConfig = new NewCompileSetting("java", this, true);
// javaConfig.setVisible(true);
}//GEN-LAST:event_buttonCompilersConfig1ActionPerformed }//GEN-LAST:event_buttonCompilersConfig1ActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
@ -497,6 +507,7 @@ public class MainFrame extends javax.swing.JFrame {
try { try {
// 打开文件 // 打开文件
desktop.open(new File(LangSelector.getConfigPath())); desktop.open(new File(LangSelector.getConfigPath()));
// desktop.open(FileFinder.findFile("ConfigEditor.exe")));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -585,7 +596,7 @@ public class MainFrame extends javax.swing.JFrame {
private javax.swing.JTextField distributorIP; private javax.swing.JTextField distributorIP;
private javax.swing.JTextField distributorPort; private javax.swing.JTextField distributorPort;
private javax.swing.JButton jButton1; private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2; javax.swing.JButton jButton2;
private javax.swing.JCheckBox jCheckBox1; private javax.swing.JCheckBox jCheckBox1;
javax.swing.JComboBox<String> jComboBox1; javax.swing.JComboBox<String> jComboBox1;
javax.swing.JLabel jLabel14; javax.swing.JLabel jLabel14;