added a search bar for smmdb courses

* added a search bar for the smmdbcourse table
* fixed some wrong Anschors at the smmdb Anchorpane
This commit is contained in:
Jannik 2017-12-11 10:31:23 +01:00
parent 75d8e6b525
commit e92a43a37e
2 changed files with 43 additions and 7 deletions

View File

@ -152,6 +152,9 @@ public class MainWindowController {
@FXML @FXML
private JFXTextField romTextField; private JFXTextField romTextField;
@FXML
private JFXTextField courseSearchTextFiled;
@FXML @FXML
private TextFlow smmdbTextFlow; private TextFlow smmdbTextFlow;
@ -291,6 +294,7 @@ public class MainWindowController {
private ObservableList<String> smmIDs = FXCollections.observableArrayList("fe31b7f2", "44fc5929"); // TODO add more IDs private ObservableList<String> smmIDs = FXCollections.observableArrayList("fe31b7f2", "44fc5929"); // TODO add more IDs
private ObservableList<UIROMDataType> games = FXCollections.observableArrayList(); private ObservableList<UIROMDataType> games = FXCollections.observableArrayList();
ObservableList<SmmdbApiDataType> courses = FXCollections.observableArrayList(); ObservableList<SmmdbApiDataType> courses = FXCollections.observableArrayList();
ObservableList<SmmdbApiDataType> filteredCourses = FXCollections.observableArrayList();
ArrayList<Text> courseText = new ArrayList<Text>(); ArrayList<Text> courseText = new ArrayList<Text>();
ArrayList<Text> nameText = new ArrayList<Text>(); ArrayList<Text> nameText = new ArrayList<Text>();
Properties props = new Properties(); Properties props = new Properties();
@ -361,9 +365,9 @@ public class MainWindowController {
applyColor(); applyColor();
// initialize courseTable // initialize courseTable
titleColumn.setPrefWidth(160); titleColumn.setPrefWidth(185);
timeColumn.setPrefWidth(127); timeColumn.setPrefWidth(112);
starsColumn.setPrefWidth(100); starsColumn.setPrefWidth(90);
courseTreeTable.setRoot(root); courseTreeTable.setRoot(root);
courseTreeTable.setShowRoot(false); courseTreeTable.setShowRoot(false);
@ -611,6 +615,32 @@ public class MainWindowController {
} }
}); });
courseSearchTextFiled.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
filteredCourses.removeAll(filteredCourses);
root.getChildren().remove(0, root.getChildren().size());
for (int i = 0; i < courses.size(); i++) {
if (courses.get(i).getTitle().toLowerCase()
.contains(courseSearchTextFiled.getText().toLowerCase())) {
// add data from courses to filteredCourses where title contains search input
filteredCourses.add(courses.get(i));
}
}
for (int i = 0; i < filteredCourses.size(); i++) {
CourseTableDataType helpCourse = new CourseTableDataType(filteredCourses.get(i).getTitle(),
filteredCourses.get(i).getId(), filteredCourses.get(i).getTime(),
filteredCourses.get(i).getStars());
root.getChildren().add(new TreeItem<CourseTableDataType>(helpCourse)); // add data to root-node
}
}
});
// Change-listener for TreeTable // Change-listener for TreeTable
courseTreeTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Object>() { courseTreeTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Object>() {
@Override @Override
@ -887,6 +917,11 @@ public class MainWindowController {
} }
saveSettings(); saveSettings();
} }
@FXML
void courseSearchTextFiledAction(ActionEvent event) {
// not in use
}
@FXML @FXML
void smmdbDownloadBtnAction(ActionEvent event) { void smmdbDownloadBtnAction(ActionEvent event) {

View File

@ -147,19 +147,20 @@
</ScrollPane> </ScrollPane>
<AnchorPane fx:id="smmdbAnchorPane" style="-fx-background-color: white;" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="175.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="38.0"> <AnchorPane fx:id="smmdbAnchorPane" style="-fx-background-color: white;" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="175.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="38.0">
<children> <children>
<JFXTreeTableView fx:id="courseTreeTable" layoutX="14.0" layoutY="14.0" prefHeight="537.0" prefWidth="405.0" AnchorPane.bottomAnchor="14.0" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="14.0" /> <JFXTextField fx:id="courseSearchTextFiled" layoutX="14.0" layoutY="14.0" onAction="#courseSearchTextFiledAction" prefHeight="25.0" prefWidth="405.0" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="14.0" />
<JFXTreeTableView fx:id="courseTreeTable" layoutX="14.0" layoutY="53.0" prefHeight="494.0" prefWidth="405.0" AnchorPane.bottomAnchor="14.0" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="53.0" />
<ImageView fx:id="smmdbImageView" fitHeight="150.0" fitWidth="267.0" layoutX="436.0" layoutY="14.0" pickOnBounds="true" preserveRatio="true" AnchorPane.leftAnchor="436.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="14.0" /> <ImageView fx:id="smmdbImageView" fitHeight="150.0" fitWidth="267.0" layoutX="436.0" layoutY="14.0" pickOnBounds="true" preserveRatio="true" AnchorPane.leftAnchor="436.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="14.0" />
<ScrollPane fx:id="smmdbScrollPane" layoutX="436.0" layoutY="181.0" prefHeight="290.0" prefWidth="267.0" AnchorPane.bottomAnchor="91.0" AnchorPane.leftAnchor="436.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="181.0"> <ScrollPane fx:id="smmdbScrollPane" layoutX="436.0" layoutY="181.0" prefHeight="290.0" prefWidth="267.0" AnchorPane.bottomAnchor="91.0" AnchorPane.leftAnchor="436.0" AnchorPane.rightAnchor="14.0">
<content> <content>
<TextFlow fx:id="smmdbTextFlow" maxWidth="265.0" prefWidth="265.0" /> <TextFlow fx:id="smmdbTextFlow" maxWidth="265.0" prefWidth="265.0" />
</content> </content>
</ScrollPane> </ScrollPane>
<JFXButton fx:id="smmdbDownloadBtn" buttonType="RAISED" layoutX="436.0" layoutY="479.0" onAction="#smmdbDownloadBtnAction" prefHeight="38.0" prefWidth="267.0" text="download" AnchorPane.bottomAnchor="45.0" AnchorPane.leftAnchor="436.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="479.0"> <JFXButton fx:id="smmdbDownloadBtn" buttonType="RAISED" layoutX="436.0" layoutY="479.0" onAction="#smmdbDownloadBtnAction" prefHeight="38.0" prefWidth="267.0" text="download" AnchorPane.bottomAnchor="45.0" AnchorPane.leftAnchor="436.0" AnchorPane.rightAnchor="14.0">
<font> <font>
<Font name="System Bold" size="14.0" /> <Font name="System Bold" size="14.0" />
</font> </font>
</JFXButton> </JFXButton>
<Label fx:id="helpLbl" layoutX="436.0" layoutY="538.0" prefHeight="17.0" prefWidth="267.0" text="please help me improving this! click me!"> <Label fx:id="helpLbl" layoutX="436.0" layoutY="538.0" prefHeight="17.0" prefWidth="267.0" text="please help me improving this! click me!" AnchorPane.bottomAnchor="14.0" AnchorPane.leftAnchor="436.0" AnchorPane.rightAnchor="14.0">
<font> <font>
<Font size="14.0" /> <Font size="14.0" />
</font> </font>