Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit bc66941

Browse files
committed
21- prepare to release, fix small bugs
1 parent 05d2555 commit bc66941

File tree

7 files changed

+44
-15
lines changed

7 files changed

+44
-15
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121

2222
## 注意事项
2323

24-
1. 在程序里看到这份文档时,程序已在程序文件的目录下创建了**导入学生**的表格。 请根据指示在表格中填入名字、拼音(**全部小写,不能有空格**)、是否住校,至少2名学生。 然后关闭窗口,重新打开程序。
24+
1. 在程序里看到这份文档时,程序已在程序文件的目录下创建了**导入学生**的表格。 请根据指示在表格中填入名字、拼音(**全部小写,不能有空格,每个学生都要有**)、是否住校,至少2名学生。 然后关闭窗口,重新打开程序。
25+
程序完全启动后,模板表格可以删除。
2526
2. **请不要导入原先的表格!已做更改!(删除了第8行)**
2627
3. 导入导出界面可以用回车代表点击确定
2728
4. 出现任何bug,请在Github上发issue(或私信)(可通过主界面左下角版权按钮直达)

src/cn/rocket/deksrt/main/Entry.java

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,20 @@
77
import cn.rocket.deksrt.util.Student;
88
import cn.rocket.deksrt.util.StudentList;
99
import cn.rocket.deksrt.util.Util;
10+
import com.jfoenix.controls.JFXButton;
1011
import javafx.application.Application;
1112
import javafx.fxml.FXMLLoader;
1213
import javafx.scene.Parent;
1314
import javafx.scene.Scene;
15+
import javafx.scene.image.Image;
16+
import javafx.scene.image.ImageView;
17+
import javafx.scene.layout.AnchorPane;
18+
import javafx.scene.layout.Background;
19+
import javafx.scene.layout.BackgroundFill;
20+
import javafx.scene.paint.Paint;
21+
import javafx.scene.text.Font;
1422
import javafx.stage.Stage;
23+
import javafx.stage.StageStyle;
1524
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
1625
import org.apache.poi.openxml4j.opc.OPCPackage;
1726
import org.apache.poi.ss.usermodel.Cell;
@@ -34,8 +43,14 @@ public class Entry extends Application {
3443
public void start(Stage primaryStage) throws Exception {
3544
GlobalVariables.mainS = primaryStage;
3645
// File propertiesFile = new File(GlobalVariables.env+"config.properties");
37-
if (!importStuInfo())
38-
System.out.println("errors:" + scanStuInfo());
46+
if (!importStuInfo()) {
47+
String errors = scanStuInfo();
48+
if (errors == null) {
49+
showIntroduction(primaryStage);
50+
return;
51+
} else
52+
System.out.println("errors:" + errors);
53+
}
3954
exportStuInfo();
4055

4156
Parent root = FXMLLoader.load(Objects.requireNonNull(
@@ -45,7 +60,23 @@ public void start(Stage primaryStage) throws Exception {
4560
primaryStage.setResizable(false);
4661
primaryStage.setScene(new Scene(root));
4762
primaryStage.show();
63+
}
4864

65+
private void showIntroduction(Stage primaryStage) {
66+
JFXButton btn = new JFXButton("关闭");
67+
btn.setButtonType(JFXButton.ButtonType.RAISED);
68+
btn.setTextFill(Paint.valueOf("white"));
69+
btn.setFont(Font.font(25));
70+
btn.setOnAction(event -> primaryStage.close());
71+
btn.setBackground(new Background(new BackgroundFill(Paint.valueOf("dodgerblue"), null, null)));
72+
AnchorPane pane = new AnchorPane();
73+
AnchorPane.setTopAnchor(btn, 100.0);
74+
AnchorPane.setRightAnchor(btn, 100.0);
75+
pane.setPrefSize(970, 700);
76+
pane.getChildren().addAll(new ImageView(new Image(GlobalVariables.INTRODUCTION)), btn);
77+
primaryStage.setScene(new Scene(pane));
78+
primaryStage.initStyle(StageStyle.UNDECORATED);
79+
primaryStage.show();
4980
}
5081

5182
/**
@@ -61,7 +92,7 @@ private String scanStuInfo() throws IOException, InvalidFormatException {
6192
if (!infoXlsx.exists()) {
6293
assert in != null;
6394
Files.copy(in, infoXlsx.toPath());
64-
System.exit(99);
95+
return null;
6596
} else {
6697
OPCPackage opcPackage = OPCPackage.open(infoXlsx);
6798
XSSFWorkbook wb = new XSSFWorkbook(opcPackage);
@@ -71,19 +102,16 @@ private String scanStuInfo() throws IOException, InvalidFormatException {
71102
Sheet sheet = wb.getSheetAt(0);
72103
DataFormatter df = new DataFormatter();
73104

74-
Student queue;
75105
String name;
76106
String pinyin;
77107
boolean boarding;
78108
for (int row = 1; row <= 52; row++) {
79109
Row r = sheet.getRow(row);
80110
if (r == null)
81111
continue;
82-
83112
Cell c0 = r.getCell(0, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL);
84113
Cell c1 = r.getCell(1, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL);
85114
Cell c2 = r.getCell(2, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL);
86-
87115
if (c0 != null) {
88116
if (c1 == null || !Util.validatePinyin((pinyin = df.formatCellValue(c1)))) {
89117
errors.append("B").append(row + 1).append(",");
@@ -108,16 +136,15 @@ private String scanStuInfo() throws IOException, InvalidFormatException {
108136
if (!stuIn.add(new Student(name, pinyin.toLowerCase(), boarding)))
109137
errors.append(c0.getAddress()).append(",");
110138
}
111-
if (stuIn.size() == 0) {
112-
System.err.println("No names in input file!");
139+
if (stuIn.size() < 2) {
140+
System.err.println("Too less names in input file!");
113141
System.exit(100);
114142
}
115143
System.out.println("name\tpy\tboarding");
116144
for (Student student : stuIn)
117145
System.out.println(student);
118146
wb.close();
119147
}
120-
121148
return errors.length() != 0 ? errors.deleteCharAt(errors.length() - 1).toString() : "";
122149
}
123150

@@ -201,7 +228,6 @@ public static void main(String[] args) {
201228
stuInfoFile.delete();
202229
}
203230

204-
205231
launch(args);
206232
}
207233
}

src/cn/rocket/deksrt/main/GlobalVariables.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ class GlobalVariables {
2525
static final String STUDENT_INFO = ENV + "student.info";
2626
static final String RESOURCE_PATH = "/cn/rocket/deksrt/resource/";
2727
static final String STU_INFO_TEMPLATE_P = RESOURCE_PATH + "templateOfStuInfo.xlsx";
28-
static final String MAIN_WINDOW_FXML = RESOURCE_PATH + "MainWindow.fxml";
2928
static final String TABLE_TEMPLATE_P = RESOURCE_PATH + "templateOfTable.xlsx";
29+
static final String MAIN_WINDOW_FXML = RESOURCE_PATH + "MainWindow.fxml";
30+
static final String FOLDER_ICON = RESOURCE_PATH + "folder.png";
31+
static final String INTRODUCTION = RESOURCE_PATH + "introduction.png";
3032

3133
static final String GIVE_UP_LAYOUT_WARNING = "是否放弃当前布局?";
3234
}

src/cn/rocket/deksrt/main/IEportDialog.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
import com.jfoenix.controls.JFXTextField;
99
import javafx.fxml.FXML;
1010
import javafx.scene.control.Label;
11+
import javafx.scene.image.Image;
1112
import javafx.scene.image.ImageView;
1213
import javafx.scene.input.KeyCode;
1314
import javafx.scene.input.KeyEvent;
1415
import javafx.stage.FileChooser;
1516
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
1617

1718
import java.io.*;
18-
import java.net.URL;
1919

2020
/**
2121
* @author Rocket
@@ -38,9 +38,8 @@ public class IEportDialog {
3838
@FXML
3939
void initialize() {
4040
iodTxtF.setText("");
41-
URL iconU = IEportDialog.class.getResource("/cn/rocket/deksrt/resource/folder.png");
4241
iconBtn.setText("");
43-
iconBtn.setGraphic(new ImageView(String.valueOf(iconU)));
42+
iconBtn.setGraphic(new ImageView(new Image(GlobalVariables.FOLDER_ICON)));
4443
}
4544

4645
@FXML

src/cn/rocket/deksrt/main/MainWindow.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ private void updateTable(int x, int y) {
461461
JFXButton btn = btns[y][x];
462462
Student stu = students[y][x];
463463
if (stu == null) {
464+
btn.setTextFill(Paint.valueOf("black"));
464465
btn.setText("");
465466
} else {
466467
btn.setText(stu.getName());
66.5 KB
Loading
626 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)