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:
parent
75d8e6b525
commit
e92a43a37e
|
@ -153,6 +153,9 @@ public class MainWindowController {
|
|||
@FXML
|
||||
private JFXTextField romTextField;
|
||||
|
||||
@FXML
|
||||
private JFXTextField courseSearchTextFiled;
|
||||
|
||||
@FXML
|
||||
private TextFlow smmdbTextFlow;
|
||||
|
||||
|
@ -291,6 +294,7 @@ public class MainWindowController {
|
|||
private ObservableList<String> smmIDs = FXCollections.observableArrayList("fe31b7f2", "44fc5929"); // TODO add more IDs
|
||||
private ObservableList<UIROMDataType> games = FXCollections.observableArrayList();
|
||||
ObservableList<SmmdbApiDataType> courses = FXCollections.observableArrayList();
|
||||
ObservableList<SmmdbApiDataType> filteredCourses = FXCollections.observableArrayList();
|
||||
ArrayList<Text> courseText = new ArrayList<Text>();
|
||||
ArrayList<Text> nameText = new ArrayList<Text>();
|
||||
Properties props = new Properties();
|
||||
|
@ -361,9 +365,9 @@ public class MainWindowController {
|
|||
applyColor();
|
||||
|
||||
// initialize courseTable
|
||||
titleColumn.setPrefWidth(160);
|
||||
timeColumn.setPrefWidth(127);
|
||||
starsColumn.setPrefWidth(100);
|
||||
titleColumn.setPrefWidth(185);
|
||||
timeColumn.setPrefWidth(112);
|
||||
starsColumn.setPrefWidth(90);
|
||||
|
||||
courseTreeTable.setRoot(root);
|
||||
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
|
||||
courseTreeTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Object>() {
|
||||
@Override
|
||||
|
@ -888,6 +918,11 @@ public class MainWindowController {
|
|||
saveSettings();
|
||||
}
|
||||
|
||||
@FXML
|
||||
void courseSearchTextFiledAction(ActionEvent event) {
|
||||
// not in use
|
||||
}
|
||||
|
||||
@FXML
|
||||
void smmdbDownloadBtnAction(ActionEvent event) {
|
||||
String downloadUrl = "http://smmdb.ddns.net/api/downloadcourse?id=" + id + "&type=zip";
|
||||
|
|
|
@ -147,19 +147,20 @@
|
|||
</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">
|
||||
<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" />
|
||||
<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>
|
||||
<TextFlow fx:id="smmdbTextFlow" maxWidth="265.0" prefWidth="265.0" />
|
||||
</content>
|
||||
</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 name="System Bold" size="14.0" />
|
||||
</font>
|
||||
</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 size="14.0" />
|
||||
</font>
|
||||
|
|
Loading…
Reference in New Issue