cleaned up DataTypes
This commit is contained in:
Jannik 2017-06-16 23:35:56 +02:00
parent 4ce6c06d2f
commit fe88271c90
13 changed files with 37 additions and 22 deletions

2
bin/.gitignore vendored
View File

@ -1,3 +1 @@
/application/ /application/
/datatypes/
/resources/

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -25,7 +25,6 @@ import java.math.BigInteger;
import java.sql.SQLException; import java.sql.SQLException;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Optional; import java.util.Optional;
import java.util.Properties; import java.util.Properties;
@ -43,7 +42,8 @@ import com.jfoenix.controls.JFXTreeTableView;
import com.jfoenix.transitions.hamburger.HamburgerBackArrowBasicTransition; import com.jfoenix.transitions.hamburger.HamburgerBackArrowBasicTransition;
import datatypes.SmmdbApiDataType; import datatypes.SmmdbApiDataType;
import datatypes.courseTableDataType; import datatypes.UIROMDataType;
import datatypes.CourseTableDataType;
import javafx.animation.FadeTransition; import javafx.animation.FadeTransition;
import javafx.animation.ParallelTransition; import javafx.animation.ParallelTransition;
import javafx.animation.TranslateTransition; import javafx.animation.TranslateTransition;
@ -148,22 +148,22 @@ public class MainWindowController {
@FXML @FXML
private JFXTreeTableView<courseTableDataType> courseTreeTable = new JFXTreeTableView<courseTableDataType>(); private JFXTreeTableView<CourseTableDataType> courseTreeTable = new JFXTreeTableView<CourseTableDataType>();
@FXML @FXML
TreeItem<courseTableDataType> root = new TreeItem<>(new courseTableDataType("",0,0,0)); TreeItem<CourseTableDataType> root = new TreeItem<>(new CourseTableDataType("",0,0,0));
@FXML @FXML
private JFXTreeTableColumn<courseTableDataType, String> titleColumn = new JFXTreeTableColumn<>("title"); private JFXTreeTableColumn<CourseTableDataType, String> titleColumn = new JFXTreeTableColumn<>("title");
@FXML @FXML
private JFXTreeTableColumn<courseTableDataType, Integer> starsColumn = new JFXTreeTableColumn<>("stars"); private JFXTreeTableColumn<CourseTableDataType, Integer> starsColumn = new JFXTreeTableColumn<>("stars");
@FXML @FXML
private JFXTreeTableColumn<courseTableDataType, Integer> downloadsColumn = new JFXTreeTableColumn<>("downloads"); private JFXTreeTableColumn<CourseTableDataType, Integer> downloadsColumn = new JFXTreeTableColumn<>("downloads");
@FXML @FXML
private JFXTreeTableColumn<courseTableDataType, Integer> idColumn = new JFXTreeTableColumn<>("id"); private JFXTreeTableColumn<CourseTableDataType, Integer> idColumn = new JFXTreeTableColumn<>("id");
Main main; Main main;
dbController dbController; dbController dbController;
@ -198,7 +198,7 @@ public class MainWindowController {
private File fileLinux = new File(dirLinux + "/config.xml"); private File fileLinux = new File(dirLinux + "/config.xml");
File pictureCacheWin = new File(dirWin+"/picture_cache"); File pictureCacheWin = new File(dirWin+"/picture_cache");
File pictureCacheLinux = new File(dirLinux+"/picture_cache"); File pictureCacheLinux = new File(dirLinux+"/picture_cache");
private ObservableList<uiDataType> games = FXCollections.observableArrayList(); private ObservableList<UIROMDataType> games = FXCollections.observableArrayList();
ObservableList<SmmdbApiDataType> courses = FXCollections.observableArrayList(); ObservableList<SmmdbApiDataType> courses = FXCollections.observableArrayList();
Properties props = new Properties(); Properties props = new Properties();
Properties gameProps = new Properties(); Properties gameProps = new Properties();
@ -494,7 +494,14 @@ public class MainWindowController {
selected = courseTreeTable.getSelectionModel().getSelectedIndex(); //get selected item selected = courseTreeTable.getSelectionModel().getSelectedIndex(); //get selected item
id = idColumn.getCellData(selected); //get name of selected item id = idColumn.getCellData(selected); //get name of selected item
//TODO show additional information and download option for (int i = 0; i < courses.size(); i++) {
if (courses.get(i).getId() == id) {
//TODO show additional information and download option
System.out.println(i);
}
}
System.out.println(id + "; " + selected); System.out.println(id + "; " + selected);
} }
@ -556,10 +563,10 @@ public class MainWindowController {
//add query response to courseTreeTable //add query response to courseTreeTable
for(int i = 0; i < courses.size(); i++){ for(int i = 0; i < courses.size(); i++){
courseTableDataType helpCourse = new courseTableDataType(courses.get(i).getTitle(), courses.get(i).getDownloads(), CourseTableDataType helpCourse = new CourseTableDataType(courses.get(i).getTitle(), courses.get(i).getDownloads(),
courses.get(i).getStars(), courses.get(i).getId()); courses.get(i).getStars(), courses.get(i).getId());
root.getChildren().add(new TreeItem<courseTableDataType>(helpCourse)); //add data to root-node root.getChildren().add(new TreeItem<CourseTableDataType>(helpCourse)); //add data to root-node
} }
} }
@ -825,6 +832,7 @@ public class MainWindowController {
selectedGameTitleID = titleID; selectedGameTitleID = titleID;
selectedGameTitle = title; selectedGameTitle = title;
//underling selected Label
lastGameLabel.setStyle("-fx-underline: false;"); lastGameLabel.setStyle("-fx-underline: false;");
games.get(selectedUIDataIndex).getLabel().setStyle("-fx-underline: true;"); games.get(selectedUIDataIndex).getLabel().setStyle("-fx-underline: true;");
lastGameLabel = games.get(selectedUIDataIndex).getLabel(); lastGameLabel = games.get(selectedUIDataIndex).getLabel();
@ -865,7 +873,7 @@ public class MainWindowController {
} }
}); });
games.add(new uiDataType(VBox, gameTitleLabel, gameBtn, titleID, romPath)); games.add(new UIROMDataType(VBox, gameTitleLabel, gameBtn, titleID, romPath));
} }
//add all games to the UI (only called on startup) //add all games to the UI (only called on startup)

View File

@ -96,7 +96,7 @@ public class dbController {
System.out.println("games database loaded successfull"); System.out.println("games database loaded successfull");
} }
//creating database, if db has 0 entries search for all .rpx files in the roms directory and add them //creating database, if database has 0 entries search for all .rpx files in the roms directory and add them
void createRomDatabase() { void createRomDatabase() {
try { try {
Statement stmt = connection.createStatement(); Statement stmt = connection.createStatement();

View File

@ -1,3 +1,6 @@
/**
* Datatype used in the TreeTableview for
*/
package datatypes; package datatypes;
import com.jfoenix.controls.datamodels.treetable.RecursiveTreeObject; import com.jfoenix.controls.datamodels.treetable.RecursiveTreeObject;
@ -7,14 +10,14 @@ import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty; import javafx.beans.property.StringProperty;
public class courseTableDataType extends RecursiveTreeObject<courseTableDataType> { public class CourseTableDataType extends RecursiveTreeObject<CourseTableDataType> {
public final StringProperty title; public final StringProperty title;
public final IntegerProperty downloads; public final IntegerProperty downloads;
public final IntegerProperty stars; public final IntegerProperty stars;
public final IntegerProperty id; public final IntegerProperty id;
public courseTableDataType(String title, int downloads, int stars, int id) { public CourseTableDataType(String title, int downloads, int stars, int id) {
this.title = new SimpleStringProperty(title); this.title = new SimpleStringProperty(title);
this.downloads = new SimpleIntegerProperty(downloads); this.downloads = new SimpleIntegerProperty(downloads);
this.stars = new SimpleIntegerProperty(stars); this.stars = new SimpleIntegerProperty(stars);

View File

@ -1,3 +1,6 @@
/**
* Datatype used for the smmdbapi query
*/
package datatypes; package datatypes;
import javafx.beans.property.IntegerProperty; import javafx.beans.property.IntegerProperty;

View File

@ -1,4 +1,7 @@
package application; /**
* Datatype used for UI ROM elements
*/
package datatypes;
import com.jfoenix.controls.JFXButton; import com.jfoenix.controls.JFXButton;
@ -8,15 +11,15 @@ import javafx.beans.property.StringProperty;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
public class uiDataType { public class UIROMDataType {
private final SimpleObjectProperty<VBox> vBox = new SimpleObjectProperty<>(); private final SimpleObjectProperty<VBox> vBox = new SimpleObjectProperty<>();
private final SimpleObjectProperty<Label> label = new SimpleObjectProperty<>(); private final SimpleObjectProperty<Label> label = new SimpleObjectProperty<>();
private final SimpleObjectProperty<JFXButton> button = new SimpleObjectProperty<>(); private final SimpleObjectProperty<JFXButton> button = new SimpleObjectProperty<>();
private final StringProperty titleID = new SimpleStringProperty(); private final StringProperty titleID = new SimpleStringProperty();
private final StringProperty romPath = new SimpleStringProperty(); private final StringProperty romPath = new SimpleStringProperty();
public uiDataType (final VBox vBox, final Label label, final JFXButton button, final String titleID, final String romPath){ public UIROMDataType (final VBox vBox, final Label label, final JFXButton button, final String titleID, final String romPath){
this.vBox.set(vBox); this.vBox.set(vBox);
this.label.set(label); this.label.set(label);
this.button.set(button); this.button.set(button);