report page added
This commit is contained in:
parent
8fc11ec111
commit
0697eca5d9
|
|
@ -7,6 +7,7 @@ import static com.r0r5chach.CompetitorList.createErrorLog;
|
||||||
import com.r0r5chach.controllers.Controller;
|
import com.r0r5chach.controllers.Controller;
|
||||||
import com.r0r5chach.controllers.EditController;
|
import com.r0r5chach.controllers.EditController;
|
||||||
import com.r0r5chach.controllers.MainController;
|
import com.r0r5chach.controllers.MainController;
|
||||||
|
import com.r0r5chach.controllers.ReportController;
|
||||||
import com.r0r5chach.controllers.ViewController;
|
import com.r0r5chach.controllers.ViewController;
|
||||||
|
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
|
|
@ -21,9 +22,12 @@ public class Manager extends Application {
|
||||||
public static Stage stage;
|
public static Stage stage;
|
||||||
private static CompetitorList competitors;
|
private static CompetitorList competitors;
|
||||||
|
|
||||||
|
private static Controller controller;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage stage) throws IOException {
|
public void start(Stage stage) throws IOException {
|
||||||
competitors = createList();
|
competitors = createList();
|
||||||
|
controller = null;
|
||||||
scene = new Scene(loadFXML("main"), 640, 480);
|
scene = new Scene(loadFXML("main"), 640, 480);
|
||||||
Manager.stage = stage;
|
Manager.stage = stage;
|
||||||
Manager.stage.setScene(scene);
|
Manager.stage.setScene(scene);
|
||||||
|
|
@ -47,7 +51,10 @@ public class Manager extends Application {
|
||||||
public static Parent loadFXML(String fxml) throws IOException {
|
public static Parent loadFXML(String fxml) throws IOException {
|
||||||
FXMLLoader fxmlLoader = new FXMLLoader(Manager.class.getResource(fxml + ".fxml"));
|
FXMLLoader fxmlLoader = new FXMLLoader(Manager.class.getResource(fxml + ".fxml"));
|
||||||
Parent root = fxmlLoader.load();
|
Parent root = fxmlLoader.load();
|
||||||
Controller controller;
|
if (controller != null) {
|
||||||
|
competitors = controller.getCompetitors();
|
||||||
|
}
|
||||||
|
|
||||||
switch(fxml) {
|
switch(fxml) {
|
||||||
case "main":
|
case "main":
|
||||||
controller = fxmlLoader.<MainController>getController();
|
controller = fxmlLoader.<MainController>getController();
|
||||||
|
|
@ -61,6 +68,11 @@ public class Manager extends Application {
|
||||||
controller = fxmlLoader.<ViewController>getController();
|
controller = fxmlLoader.<ViewController>getController();
|
||||||
controller.setCompetitors(competitors);
|
controller.setCompetitors(competitors);
|
||||||
break;
|
break;
|
||||||
|
case "pages/report":
|
||||||
|
controller = fxmlLoader.<ReportController>getController();
|
||||||
|
controller.setCompetitors(competitors);
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@ import javafx.application.Platform;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
import javafx.scene.Parent;
|
import javafx.scene.Parent;
|
||||||
|
import javafx.scene.control.Tab;
|
||||||
|
import javafx.scene.control.TabPane;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
|
|
||||||
public class Controller implements Initializable {
|
public class Controller implements Initializable {
|
||||||
|
|
@ -22,33 +24,40 @@ public class Controller implements Initializable {
|
||||||
@FXML
|
@FXML
|
||||||
protected AnchorPane viewTab;
|
protected AnchorPane viewTab;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
protected AnchorPane reportTab;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
protected TabPane tabs;
|
||||||
|
|
||||||
protected CompetitorList competitors;
|
protected CompetitorList competitors;
|
||||||
protected ArrayList<Integer> competitorIds;
|
protected ArrayList<Integer> competitorIds;
|
||||||
|
|
||||||
public void setCompetitors(CompetitorList competitors) {
|
|
||||||
this.competitors = competitors;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL location, ResourceBundle resources) {
|
public void initialize(URL location, ResourceBundle resources) {
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
loadCompetitors();
|
loadCompetitors();
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
public void setCompetitors(CompetitorList competitors) {
|
||||||
protected void getEditTab() throws IOException {
|
this.competitors = competitors;
|
||||||
Parent root = Manager.loadFXML("pages/edit");
|
}
|
||||||
editTab.getChildren().clear();
|
|
||||||
editTab.getChildren().add(root);
|
public CompetitorList getCompetitors() {
|
||||||
|
return competitors;
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
protected void getViewTab() throws IOException {
|
protected void getTab() throws IOException {
|
||||||
Parent root = Manager.loadFXML("pages/view");
|
Parent root = null;
|
||||||
viewTab.getChildren().clear();
|
Tab tab = tabs.getSelectionModel().getSelectedItem();
|
||||||
viewTab.getChildren().add(root);
|
switch(tab.getText().toLowerCase()) {
|
||||||
|
case "view" -> root = Manager.loadFXML("pages/view");
|
||||||
|
case "edit" -> root = Manager.loadFXML("pages/edit");
|
||||||
|
case "report" -> root = Manager.loadFXML("pages/report");
|
||||||
|
}
|
||||||
|
tab.setContent(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void loadCompetitors(){
|
protected void loadCompetitors(){
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
package com.r0r5chach.controllers;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
import javafx.application.Platform;
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.control.ListView;
|
||||||
|
import javafx.scene.control.TextArea;
|
||||||
|
|
||||||
|
public class ReportController extends Controller {
|
||||||
|
@FXML
|
||||||
|
private ListView<Integer> competitorList;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private TextArea outputArea;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(URL url, ResourceBundle rb) {
|
||||||
|
Platform.runLater(() -> {
|
||||||
|
loadCompetitors();
|
||||||
|
competitorList.setItems(FXCollections.observableList(competitorIds));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private void shortDetailsPress() {
|
||||||
|
Integer item = competitorList.getSelectionModel().getSelectedItem();
|
||||||
|
outputArea.clear();
|
||||||
|
if (item != null) {
|
||||||
|
outputArea.setText(competitors.getCompetitors().get(competitorIds.indexOf(item)).getShortDetails());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
outputArea.setText("Select A Competitor");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private void fullDetailsPress() {
|
||||||
|
Integer item = competitorList.getSelectionModel().getSelectedItem();
|
||||||
|
if (item != null) {
|
||||||
|
outputArea.clear();
|
||||||
|
outputArea.setText(competitors.getCompetitors().get(competitorIds.indexOf(item)).getFullDetails());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
outputArea.setText("Select A Competitor");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -7,20 +7,20 @@
|
||||||
|
|
||||||
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.r0r5chach.controllers.MainController">
|
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.r0r5chach.controllers.MainController">
|
||||||
<children>
|
<children>
|
||||||
<TabPane tabClosingPolicy="UNAVAILABLE">
|
<TabPane fx:id="tabs" tabClosingPolicy="UNAVAILABLE">
|
||||||
<tabs>
|
<tabs>
|
||||||
<Tab onSelectionChanged="#getEditTab" text="Edit">
|
<Tab onSelectionChanged="#getTab" text="Edit">
|
||||||
<content>
|
<content>
|
||||||
<AnchorPane fx:id="editTab" />
|
<AnchorPane fx:id="editTab" />
|
||||||
</content></Tab>
|
</content></Tab>
|
||||||
<Tab onSelectionChanged="#getViewTab" text="View">
|
<Tab onSelectionChanged="#getTab" text="View">
|
||||||
<content>
|
<content>
|
||||||
<AnchorPane fx:id="viewTab" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" />
|
<AnchorPane fx:id="viewTab" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" />
|
||||||
</content>
|
</content>
|
||||||
</Tab>
|
</Tab>
|
||||||
<Tab text="Report">
|
<Tab onSelectionChanged="#getTab" text="Report">
|
||||||
<content>
|
<content>
|
||||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
|
<AnchorPane fx:id="reportTab" />
|
||||||
</content>
|
</content>
|
||||||
</Tab>
|
</Tab>
|
||||||
</tabs>
|
</tabs>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.geometry.Insets?>
|
||||||
|
<?import javafx.scene.control.Button?>
|
||||||
|
<?import javafx.scene.control.ListView?>
|
||||||
|
<?import javafx.scene.control.SplitPane?>
|
||||||
|
<?import javafx.scene.control.TextArea?>
|
||||||
|
<?import javafx.scene.layout.ColumnConstraints?>
|
||||||
|
<?import javafx.scene.layout.GridPane?>
|
||||||
|
<?import javafx.scene.layout.RowConstraints?>
|
||||||
|
|
||||||
|
<SplitPane dividerPositions="0.3060200668896321" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.r0r5chach.controllers.ReportController">
|
||||||
|
<items>
|
||||||
|
<ListView fx:id="competitorList" />
|
||||||
|
<GridPane>
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints maxHeight="379.0" minHeight="10.0" prefHeight="341.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints maxHeight="199.0" minHeight="19.0" prefHeight="57.0" vgrow="SOMETIMES" />
|
||||||
|
</rowConstraints>
|
||||||
|
<children>
|
||||||
|
<TextArea fx:id="outputArea" GridPane.columnSpan="2147483647" />
|
||||||
|
<Button mnemonicParsing="false" onAction="#shortDetailsPress" text="Generate Short Details" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="TOP">
|
||||||
|
<GridPane.margin>
|
||||||
|
<Insets top="15.0" />
|
||||||
|
</GridPane.margin>
|
||||||
|
</Button>
|
||||||
|
<Button mnemonicParsing="false" onAction="#fullDetailsPress" text="Generate Full Details" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="TOP">
|
||||||
|
<GridPane.margin>
|
||||||
|
<Insets top="15.0" />
|
||||||
|
</GridPane.margin>
|
||||||
|
</Button>
|
||||||
|
</children>
|
||||||
|
</GridPane>
|
||||||
|
</items>
|
||||||
|
</SplitPane>
|
||||||
Loading…
Reference in New Issue