diff --git a/bin/.gitignore b/bin/.gitignore index a4b7045..94b23b3 100644 --- a/bin/.gitignore +++ b/bin/.gitignore @@ -1,3 +1,3 @@ /application/ -/dataTypes/ /datatypes/ +/resources/ diff --git a/bin/application/MainWindow.fxml b/bin/application/MainWindow.fxml index ca3010e..90a6ba3 100644 --- a/bin/application/MainWindow.fxml +++ b/bin/application/MainWindow.fxml @@ -5,6 +5,7 @@ + @@ -82,7 +83,10 @@ - + + + + diff --git a/bin/application/MainWindowController$1.class b/bin/application/MainWindowController$1.class index cc32e0b..ab9d404 100644 Binary files a/bin/application/MainWindowController$1.class and b/bin/application/MainWindowController$1.class differ diff --git a/bin/application/MainWindowController$2.class b/bin/application/MainWindowController$2.class index 500c251..7803ef7 100644 Binary files a/bin/application/MainWindowController$2.class and b/bin/application/MainWindowController$2.class differ diff --git a/bin/application/MainWindowController$3.class b/bin/application/MainWindowController$3.class index 9bf613a..2a06cb1 100644 Binary files a/bin/application/MainWindowController$3.class and b/bin/application/MainWindowController$3.class differ diff --git a/bin/application/MainWindowController$4.class b/bin/application/MainWindowController$4.class index 9c182b2..64fb60f 100644 Binary files a/bin/application/MainWindowController$4.class and b/bin/application/MainWindowController$4.class differ diff --git a/bin/application/MainWindowController$5.class b/bin/application/MainWindowController$5.class index 4b94679..5049c3d 100644 Binary files a/bin/application/MainWindowController$5.class and b/bin/application/MainWindowController$5.class differ diff --git a/bin/application/MainWindowController$6.class b/bin/application/MainWindowController$6.class index 2880dcb..7ebf0e1 100644 Binary files a/bin/application/MainWindowController$6.class and b/bin/application/MainWindowController$6.class differ diff --git a/bin/application/MainWindowController$7.class b/bin/application/MainWindowController$7.class index 2fcf99d..2adbfee 100644 Binary files a/bin/application/MainWindowController$7.class and b/bin/application/MainWindowController$7.class differ diff --git a/bin/application/MainWindowController.class b/bin/application/MainWindowController.class index b609179..f901824 100644 Binary files a/bin/application/MainWindowController.class and b/bin/application/MainWindowController.class differ diff --git a/src/application/MainWindow.fxml b/src/application/MainWindow.fxml index ca3010e..90a6ba3 100644 --- a/src/application/MainWindow.fxml +++ b/src/application/MainWindow.fxml @@ -5,6 +5,7 @@ + @@ -82,7 +83,10 @@ - + + + + diff --git a/src/application/MainWindowController.java b/src/application/MainWindowController.java index 5d667d8..0c54a2a 100644 --- a/src/application/MainWindowController.java +++ b/src/application/MainWindowController.java @@ -38,12 +38,17 @@ import com.jfoenix.controls.JFXColorPicker; import com.jfoenix.controls.JFXHamburger; import com.jfoenix.controls.JFXTextField; import com.jfoenix.controls.JFXToggleButton; +import com.jfoenix.controls.JFXTreeTableColumn; +import com.jfoenix.controls.JFXTreeTableView; import com.jfoenix.transitions.hamburger.HamburgerBackArrowBasicTransition; import datatypes.SmmdbApiDataType; +import datatypes.courseTableDataType; import javafx.animation.FadeTransition; import javafx.animation.ParallelTransition; import javafx.animation.TranslateTransition; +import javafx.beans.value.ChangeListener; +import javafx.beans.value.ObservableValue; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.event.ActionEvent; @@ -58,6 +63,7 @@ import javafx.scene.control.Label; import javafx.scene.control.MenuItem; import javafx.scene.control.ScrollPane; import javafx.scene.control.TextInputDialog; +import javafx.scene.control.TreeItem; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.input.MouseEvent; @@ -140,6 +146,25 @@ public class MainWindowController { @FXML private HBox topHBox; + + @FXML + private JFXTreeTableView courseTreeTable = new JFXTreeTableView(); + + @FXML + TreeItem root = new TreeItem<>(new courseTableDataType("",0,0,0)); + + @FXML + private JFXTreeTableColumn titleColumn = new JFXTreeTableColumn<>("title"); + + @FXML + private JFXTreeTableColumn starsColumn = new JFXTreeTableColumn<>("stars"); + + @FXML + private JFXTreeTableColumn downloadsColumn = new JFXTreeTableColumn<>("downloads"); + + @FXML + private JFXTreeTableColumn idColumn = new JFXTreeTableColumn<>("id"); + Main main; dbController dbController; SmmdbApiQuery smmdbApiQuery; @@ -147,6 +172,7 @@ public class MainWindowController { private boolean menuTrue = false; private boolean settingsTrue = false; private boolean playTrue = false; + private boolean smmdbTrue = false; private boolean fullscreen; private boolean cloudSync; private String cloudService = ""; //set cloud provider (at the moment only GoogleDrive, Dropbox is planed) @@ -163,6 +189,8 @@ public class MainWindowController { private int yPos = 17; private int xPosHelper; private int selectedUIDataIndex; + private int selected; + private int id; private DirectoryChooser directoryChooser = new DirectoryChooser(); private File dirWin = new File(System.getProperty("user.home") + "/Documents/cemu_UI"); private File dirLinux = new File(System.getProperty("user.home") + "/cemu_UI"); @@ -197,6 +225,7 @@ public class MainWindowController { smmdbApiQuery = new SmmdbApiQuery(); } + @SuppressWarnings("unchecked") //FIXME SuppressWarnings void initUI(){ cemuTextField.setText(cemuPath); romTextField.setText(romPath); @@ -204,8 +233,24 @@ public class MainWindowController { fullscreenToggleBtn.setSelected(isFullscreen()); cloudSyncToggleBtn.setSelected(isCloudSync()); edit.setDisable(true); - smmdbBtn.setDisable(false); //TODO applyColor(); + + //initialize courseTable + titleColumn.setPrefWidth(150); + starsColumn.setPrefWidth(85); + downloadsColumn.setPrefWidth(115); + + courseTreeTable.setRoot(root); + courseTreeTable.setShowRoot(false); + courseTreeTable.setEditable(false); + + titleColumn.setCellValueFactory(cellData -> cellData.getValue().getValue().title); + starsColumn.setCellValueFactory(cellData -> cellData.getValue().getValue().stars.asObject()); + downloadsColumn.setCellValueFactory(cellData -> cellData.getValue().getValue().downloads.asObject()); + idColumn.setCellValueFactory(cellData -> cellData.getValue().getValue().id.asObject()); + + courseTreeTable.getColumns().setAll(titleColumn, downloadsColumn, starsColumn, idColumn); + courseTreeTable.getColumns().get(3).setVisible(false); //hide idColumn (important) } void initActions() { @@ -213,26 +258,31 @@ public class MainWindowController { HamburgerBackArrowBasicTransition burgerTask = new HamburgerBackArrowBasicTransition(menuHam); menuHam.addEventHandler(MouseEvent.MOUSE_PRESSED, (e)->{ - if(playTrue){ + if (playTrue) { playBtnSlideOut(); } - if(menuTrue == false){ - sideMenuSlideIn(); - burgerTask.setRate(1.0); - burgerTask.play(); - menuTrue = true; - }else{ + if (menuTrue){ sideMenuSlideOut(); burgerTask.setRate(-1.0); burgerTask.play(); menuTrue = false; + }else{ + sideMenuSlideIn(); + burgerTask.setRate(1.0); + burgerTask.play(); + menuTrue = true; } - if(settingsTrue == true){ + if (settingsTrue) { settingsAnchorPane.setVisible(false); // setPath(tfPath.getText()); saveSettings(); settingsTrue = false; } + if (smmdbTrue) { + smmdbAnchorPane.setVisible(false); + smmdbTrue = false; + } + }); edit.setOnAction(new EventHandler() { @@ -248,7 +298,7 @@ public class MainWindowController { alert.initOwner(main.primaryStage); alert.showAndWait(); }else{ - System.out.println("show edit window TODO!"); //TODO + System.out.println("show edit window TODO!"); //TODO show edit window } } }); @@ -434,6 +484,20 @@ public class MainWindowController { } } }); + + //Change-listener for TreeTable + courseTreeTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() { + @Override + public void changed(ObservableValue observable, Object oldVal, Object newVal){ + // last = selected; //for auto-play + selected = courseTreeTable.getSelectionModel().getSelectedIndex(); //get selected item + id = idColumn.getCellData(selected); //get name of selected item + + //TODO show additional information and download option + + System.out.println(id + "; " + selected); + } + }); System.out.println("initializing Actions done!"); } @@ -474,13 +538,28 @@ public class MainWindowController { @FXML void smmdbBtnAction() { - //TODO show TODO smmdbAnchorPane - + //show smmdbAnchorPane + if (smmdbTrue) { + smmdbAnchorPane.setVisible(false); + smmdbTrue = false; + } else { + smmdbAnchorPane.setVisible(true); + smmdbTrue = true; + } + //start query ArrayList courses = new ArrayList<>(smmdbApiQuery.startQuery()); System.out.println("size: " + courses.size()); System.out.println(courses.get(3).getNintendoid()); + + //add query response to courseTreeTable + for(int i = 0; i < courses.size(); i++){ + courseTableDataType helpCourse = new courseTableDataType(courses.get(i).getTitle(), courses.get(i).getDownloads(), + courses.get(i).getStars(), courses.get(i).getId()); + + root.getChildren().add(new TreeItem(helpCourse)); //add data to root-node + } } @FXML diff --git a/src/datatypes/courseTableDataType.java b/src/datatypes/courseTableDataType.java new file mode 100644 index 0000000..f5c8fc3 --- /dev/null +++ b/src/datatypes/courseTableDataType.java @@ -0,0 +1,23 @@ +package datatypes; + +import com.jfoenix.controls.datamodels.treetable.RecursiveTreeObject; + +import javafx.beans.property.IntegerProperty; +import javafx.beans.property.SimpleIntegerProperty; +import javafx.beans.property.SimpleStringProperty; +import javafx.beans.property.StringProperty; + +public class courseTableDataType extends RecursiveTreeObject { + + public final StringProperty title; + public final IntegerProperty downloads; + public final IntegerProperty stars; + public final IntegerProperty id; + + public courseTableDataType(String title, int downloads, int stars, int id) { + this.title = new SimpleStringProperty(title); + this.downloads = new SimpleIntegerProperty(downloads); + this.stars = new SimpleIntegerProperty(stars); + this.id = new SimpleIntegerProperty(id); + } +}