77import cn .rocket .deksrt .util .Student ;
88import cn .rocket .deksrt .util .StudentList ;
99import cn .rocket .deksrt .util .Util ;
10+ import com .jfoenix .controls .JFXButton ;
1011import javafx .application .Application ;
1112import javafx .fxml .FXMLLoader ;
1213import javafx .scene .Parent ;
1314import 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 ;
1422import javafx .stage .Stage ;
23+ import javafx .stage .StageStyle ;
1524import org .apache .poi .openxml4j .exceptions .InvalidFormatException ;
1625import org .apache .poi .openxml4j .opc .OPCPackage ;
1726import 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\t py\t boarding" );
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}
0 commit comments