Skip to content

Commit

Permalink
16 fix bugs caused by incorrect import and no-name input file
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketMaDev committed Jul 8, 2021
1 parent 1b77b75 commit b35f577
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 7 deletions.
16 changes: 16 additions & 0 deletions .idea/artifacts/DeskSorting_jar.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/libraries/commons_collections4_4_42.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions DeskSorting.iml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
<orderEntry type="library" name="commons-collections4-4.4" level="project" />
<orderEntry type="library" name="jfoenix-8.0.10" level="project" />
<orderEntry type="library" name="poi-ooxml-lite-5.0.0" level="project" />
<orderEntry type="library" name="commons-collections4-4.4" level="project" />
</component>
</module>
Binary file modified out/production/DeskSorting/cn/rocket/deksrt/main/Entry.class
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@
<Font size="15.0" />
</font></Label>
</GridPane>
<JFXButton fx:id="importB" buttonType="RAISED" layoutX="40.0" layoutY="25.0" onAction="#impM" prefHeight="40.0" prefWidth="100.0" ripplerFill="BLACK" stylesheets="@style.css" text="导入..." AnchorPane.leftAnchor="40.0">
<JFXButton fx:id="importB" buttonType="RAISED" layoutX="40.0" layoutY="25.0" onAction="#impM" prefHeight="40.0" prefWidth="100.0" ripplerFill="BLACK" stylesheets="@style.css" text="导入...">
<font>
<Font size="15.0" />
</font>
</JFXButton>
<JFXButton fx:id="exportB" buttonType="RAISED" layoutX="173.0" layoutY="25.0" onAction="#expM" prefHeight="40.0" prefWidth="100.0" ripplerFill="BLACK" stylesheets="@style.css" text="导出..." AnchorPane.leftAnchor="173.0" AnchorPane.topAnchor="25.0">
<JFXButton fx:id="exportB" buttonType="RAISED" layoutX="178.0" layoutY="25.0" onAction="#expM" prefHeight="40.0" prefWidth="100.0" ripplerFill="BLACK" stylesheets="@style.css" text="导出..." AnchorPane.leftAnchor="173.0" AnchorPane.topAnchor="25.0">
<font>
<Font size="15.0" />
</font>
</JFXButton>
<JFXButton fx:id="randSort" buttonType="RAISED" layoutX="436.0" layoutY="25.0" onAction="#randM" prefHeight="40.0" prefWidth="100.0" ripplerFill="BLACK" stylesheets="@style.css" text="随机排">
<JFXButton fx:id="randSort" buttonType="RAISED" layoutX="442.0" layoutY="25.0" onAction="#randM" prefHeight="40.0" prefWidth="100.0" ripplerFill="BLACK" stylesheets="@style.css" text="随机排">
<font>
<Font size="15.0" />
</font>
Expand All @@ -72,7 +72,7 @@
<Font size="15.0" />
</font>
</JFXTextField>
<JFXCheckBox fx:id="quickSwapCB" layoutX="310.0" layoutY="25.0" onAction="#quickSwapM" prefHeight="40.0" prefWidth="100.0" stylesheets="@style.css" text="快速交换">
<JFXCheckBox fx:id="quickSwapCB" layoutX="316.0" layoutY="25.0" onAction="#quickSwapM" prefHeight="40.0" stylesheets="@style.css" text="快速交换">
<font>
<Font size="15.0" />
</font>
Expand Down
14 changes: 12 additions & 2 deletions src/cn/rocket/deksrt/main/Entry.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.*;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -38,10 +41,12 @@ public void start(Stage primaryStage) throws Exception {
}

/**
* <b>EXIT CODE 99, 100 HERE</b>
*
* @return errors in xlsx file
* @throws IOException if input a incorrect file
*/
private String scanStuInfo() throws IOException {
private String scanStuInfo() throws IOException, InvalidFormatException {
StringBuilder errors = new StringBuilder();
InputStream in = this.getClass().getResourceAsStream(GlobalVariables.stuInfoTemplateP);
File infoXlsx = new File(GlobalVariables.jarParentPath + "StuInfo.xlsx");
Expand All @@ -50,7 +55,8 @@ private String scanStuInfo() throws IOException {
Files.copy(in, infoXlsx.toPath());
System.exit(99);
} else {
Workbook wb = WorkbookFactory.create(infoXlsx);
OPCPackage opcPackage = OPCPackage.open(infoXlsx);
XSSFWorkbook wb = new XSSFWorkbook(opcPackage);
GlobalVariables.stuInfo = new StudentList<>(52);
StudentList<Student> stuIn = GlobalVariables.stuInfo;

Expand Down Expand Up @@ -95,6 +101,10 @@ private String scanStuInfo() throws IOException {
if (!stuIn.contains(queue))
stuIn.add(new Student(name, pinyin.toLowerCase(), boarding));
}
if (stuIn.size() == 0) {
System.err.println("No names in input file!");
System.exit(100);
}
System.out.println("name\tpy\tboarding");
for (Student student : stuIn)
System.out.println(student);
Expand Down
2 changes: 1 addition & 1 deletion src/cn/rocket/deksrt/main/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void initialize() throws IllegalAccessException {
iod = null;
try {
iod = FXMLLoader.load(Objects.requireNonNull(
MainWindow.class.getResource("/cn/rocket/deksrt/resource/IOportDialog.fxml")
MainWindow.class.getResource("/cn/rocket/deksrt/resource/IEportDialog.fxml")
));
} catch (IOException e) {
e.printStackTrace();
Expand Down

0 comments on commit b35f577

Please sign in to comment.