diff --git a/bin/application/DBController.class b/bin/application/DBController.class index e947aed..d674821 100644 Binary files a/bin/application/DBController.class and b/bin/application/DBController.class differ diff --git a/bin/application/MainWindowController$1.class b/bin/application/MainWindowController$1.class index 1b2b0b0..03a46a6 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 a05efd9..eb38fce 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 88c48b3..b52778e 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 5eb9631..9d64b28 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 74053a8..8d32ae5 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 29c4ca8..d56c5fa 100644 Binary files a/bin/application/MainWindowController$6.class and b/bin/application/MainWindowController$6.class differ diff --git a/bin/application/MainWindowController.class b/bin/application/MainWindowController.class index f221118..ac7d7ab 100644 Binary files a/bin/application/MainWindowController.class and b/bin/application/MainWindowController.class differ diff --git a/bin/application/streamUiData.class b/bin/application/streamUiData.class index d0821f1..034c7a2 100644 Binary files a/bin/application/streamUiData.class and b/bin/application/streamUiData.class differ diff --git a/src/application/DBController.java b/src/application/DBController.java index f6d0c2c..47f3f6e 100644 --- a/src/application/DBController.java +++ b/src/application/DBController.java @@ -24,6 +24,9 @@ import com.eclipsesource.json.JsonArray; import com.eclipsesource.json.JsonObject; import com.eclipsesource.json.JsonValue; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; + public class DBController { public DBController(MainWindowController m) { @@ -32,6 +35,8 @@ public class DBController { private MainWindowController mainWindowController; private String DB_PATH = System.getProperty("user.home") + "\\Documents\\HomeFlix" + "\\" + "Homeflix.db"; // der Pfad der Datenbank-Datei + private ImageView favorite_black = new ImageView(new Image("recources/icons/ic_favorite_black_18dp_1x.png")); + private ImageView favorite_border_black = new ImageView(new Image("recources/icons/ic_favorite_border_black_18dp_1x.png")); private List filmsdbAll = new ArrayList(); private List filmsdbLocal = new ArrayList(); private List filmsdbStream = new ArrayList(); @@ -68,15 +73,15 @@ public class DBController { } void createDatabase() { - System.out.println("<=====starting loading sql=====>"); + System.out.println("<==========starting loading sql==========>"); PreparedStatement ps; PreparedStatement psS; try { Statement stmt = connection.createStatement(); - stmt.executeUpdate("create table if not exists film_local (rating, titel, streamUrl)"); - stmt.executeUpdate("create table if not exists film_streaming (year, season, episode, rating, resolution, titel, streamUrl)"); + stmt.executeUpdate("create table if not exists film_local (rating, titel, streamUrl, favIcon)"); + stmt.executeUpdate("create table if not exists film_streaming (year, season, episode, rating, resolution, titel, streamUrl, favIcon)"); stmt.close(); } catch (SQLException e1) { e1.printStackTrace(); @@ -134,14 +139,15 @@ public class DBController { System.out.println("creating entries ..."); try{ - ps = connection.prepareStatement("insert into film_local values (?, ?, ?)"); - psS = connection.prepareStatement("insert into film_streaming values (?, ?, ?, ?, ?, ?, ?)"); + ps = connection.prepareStatement("insert into film_local values (?, ?, ?, ?)"); + psS = connection.prepareStatement("insert into film_streaming values (?, ?, ?, ?, ?, ?, ?, ?)"); for(int j=0;j!=entries.length;j++) // Geht alle Dateien im Verzeichniss durch { ps.setInt(1, 0); // definiert Bewertung als Integer in der dritten Spalte ps.setString(2, cutOffEnd(entries[j])); // definiert Name als String in der ersten Spalte ps.setString(3,entries[j]); // definiert Pfad als String in der zweiten Spalte + ps.setString(4, "favorite_border_black"); ps.addBatch(); // fügt den Eintrag hinzu } @@ -161,6 +167,7 @@ public class DBController { psS.setString(5, item.asObject().getString("resolution", "")); psS.setString(6, item.asObject().getString("titel","")); psS.setString(7, item.asObject().getString("streamUrl", "")); + psS.setString(8, "favorite_border_black"); psS.addBatch(); // fügt den Eintrag hinzu } } catch (IOException e) { @@ -201,7 +208,7 @@ public class DBController { Statement stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM film_local"); while (rs.next()) { - mainWindowController.newDaten.add(new streamUiData(1, 1, 1, rs.getDouble(1), "1", rs.getString(2), rs.getString(3))); + mainWindowController.newDaten.add(new streamUiData(1, 1, 1, rs.getDouble(1), "1", rs.getString(2), rs.getString(3), favorite_border_black)); } stmt.close(); rs.close(); @@ -209,7 +216,7 @@ public class DBController { //load streaming Data TODO check if there are streaming data before loading -> maybe there is an issue now rs = stmt.executeQuery("SELECT * FROM film_streaming;"); while (rs.next()) { - mainWindowController.streamData.add(new streamUiData(rs.getInt(1), rs.getInt(2), rs.getInt(3), rs.getDouble(4), rs.getString(5), rs.getString(6), rs.getString(7))); + mainWindowController.streamData.add(new streamUiData(rs.getInt(1), rs.getInt(2), rs.getInt(3), rs.getDouble(4), rs.getString(5), rs.getString(6), rs.getString(7), favorite_border_black)); } stmt.close(); rs.close(); @@ -217,7 +224,7 @@ public class DBController { System.err.println("Ups! an error occured!"); e.printStackTrace(); } - System.out.println("<=====finished loading sql=====>"); + System.out.println("<==========finished loading sql==========>"); } //refreshs the data in mainWindowController.newDaten and mainWindowController.streamData @@ -229,14 +236,22 @@ public class DBController { try { stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM film_local WHERE titel = '"+name+"';" ); - mainWindowController.newDaten.set(i, new streamUiData(1, 1, 1, rs.getDouble(1), "1", rs.getString(2), rs.getString(3))); + if(rs.getString(4).equals("favorite_black")){ + mainWindowController.newDaten.set(i, new streamUiData(1, 1, 1, rs.getDouble(1), "1", rs.getString(2), rs.getString(3), favorite_black)); + }else{ + mainWindowController.newDaten.set(i, new streamUiData(1, 1, 1, rs.getDouble(1), "1", rs.getString(2), rs.getString(3), favorite_border_black)); + } stmt.close(); rs.close(); } catch (SQLException e) { try { stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM film_streaming WHERE titel = '"+name+"';" ); - mainWindowController.streamData.set(i,new streamUiData(rs.getInt(1), rs.getInt(2), rs.getInt(3), rs.getDouble(4), rs.getString(5), rs.getString(6), rs.getString(7))); + if(rs.getString(8).equals("favorite_black")){ + mainWindowController.streamData.set(i,new streamUiData(rs.getInt(1), rs.getInt(2), rs.getInt(3), rs.getDouble(4), rs.getString(5), rs.getString(6), rs.getString(7), favorite_black)); + }else{ + mainWindowController.streamData.set(i,new streamUiData(rs.getInt(1), rs.getInt(2), rs.getInt(3), rs.getDouble(4), rs.getString(5), rs.getString(6), rs.getString(7), favorite_border_black)); + } stmt.close(); rs.close(); } catch (SQLException e1) { @@ -276,13 +291,13 @@ public class DBController { System.out.println("checking for entrys to add to DB ..."); String[] entries = new File(mainWindowController.getPath()).list(); Statement stmt = connection.createStatement(); - PreparedStatement ps = connection.prepareStatement("insert into film_streaming values (?, ?, ?, ?, ?, ?, ?)");; + PreparedStatement ps = connection.prepareStatement("insert into film_streaming values (?, ?, ?, ?, ?, ?, ?, ?)");; int i=0; for(int a=0; a root = new TreeItem<>(new streamUiData(1, 1, 1, 5.0,"1", "filme","1")); + TreeItem root = new TreeItem<>(new streamUiData(1, 1, 1, 5.0,"1", "filme","1", imv1)); @FXML - TreeTableColumn columnRating = new TreeTableColumn<>("Bewertung"); + TreeTableColumn columnRating = new TreeTableColumn<>("Rating"); @FXML - TreeTableColumn columnTitel = new TreeTableColumn<>("Name"); + TreeTableColumn columnTitel = new TreeTableColumn<>("Titel"); @FXML - TreeTableColumn columnStreamUrl = new TreeTableColumn<>("Datei Name"); + TreeTableColumn columnStreamUrl = new TreeTableColumn<>("File Name"); @FXML - TreeTableColumn columnResolution = new TreeTableColumn<>("Auflösung"); + TreeTableColumn columnResolution = new TreeTableColumn<>("Resolution"); @FXML - TreeTableColumn columnYear = new TreeTableColumn<>("Jahr"); + TreeTableColumn columnYear = new TreeTableColumn<>("Year"); @FXML - TreeTableColumn columnSeason = new TreeTableColumn<>("Staffel"); + TreeTableColumn columnSeason = new TreeTableColumn<>("Season"); @FXML TreeTableColumn columnEpisode = new TreeTableColumn<>("Episode"); @FXML - private TreeItem streamingRoot =new TreeItem<>(new streamUiData(1 ,1 ,1 ,1.0 ,"1" ,"filme" ,"1")); + private TreeItem streamingRoot =new TreeItem<>(new streamUiData(1 ,1 ,1 ,1.0 ,"1" ,"filme" ,"1", imv1)); @FXML private TableColumn dataNameColumn = new TableColumn<>("Datei Name"); @FXML @@ -252,9 +250,7 @@ public class MainWindowController { private ImageView skip_next_black = new ImageView(new Image("recources/icons/ic_skip_next_black_18dp_1x.png")); private ImageView play_arrow_white = new ImageView(new Image("recources/icons/ic_play_arrow_white_18dp_1x.png")); private ImageView play_arrow_black = new ImageView(new Image("recources/icons/ic_play_arrow_black_18dp_1x.png")); - @SuppressWarnings("unused") private ImageView favorite_black = new ImageView(new Image("recources/icons/ic_favorite_black_18dp_1x.png")); - @SuppressWarnings("unused") private ImageView favorite_border_black = new ImageView(new Image("recources/icons/ic_favorite_border_black_18dp_1x.png")); private DirectoryChooser directoryChooser = new DirectoryChooser(); private ContextMenu menu = new ContextMenu(); @@ -436,6 +432,7 @@ public class MainWindowController { @FXML private void debugBtnclicked(){ + newDaten.get(selected).setImage(favorite_black); //for testing } @@ -529,8 +526,8 @@ public class MainWindowController { // columnRating.setSortType(TreeTableColumn.SortType.ASCENDING); // } - debugBtn.setDisable(true); //debugging btn for tests - debugBtn.setVisible(false); + debugBtn.setDisable(false); //debugging btn for tests + debugBtn.setVisible(true); tfPath.setText(getPath()); @@ -554,41 +551,52 @@ public class MainWindowController { } //initialisierung der Tabellen für filme(beide Modi) und Streaming-Settings - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({ "unchecked"}) private void initTabel(){ //filmtabelle - columnRating.setMaxWidth(120); - columnTitel.setMaxWidth(240); + columnRating.setMaxWidth(80); + columnTitel.setMaxWidth(260); columnStreamUrl.setMaxWidth(0); - dataNameColumn.setPrefWidth(130); + dataNameColumn.setPrefWidth(150); dataNameEndColumn.setPrefWidth(170); + columnRating.setStyle("-fx-alignment: CENTER;"); treeTableViewfilm.setRoot(root); treeTableViewfilm.setColumnResizePolicy( TreeTableView.CONSTRAINED_RESIZE_POLICY ); treeTableViewfilm.setShowRoot(false); //inhalt in Zelle schreiben - columnTitel.setCellValueFactory((CellDataFeatures p) -> - new ReadOnlyStringWrapper(p.getValue().getValue().getTitel())); - - columnRating.setCellValueFactory((CellDataFeatures p) -> - new ReadOnlyObjectWrapper(p.getValue().getValue().getRating())); +// columnTitel.setCellValueFactory((CellDataFeatures p) -> +// new ReadOnlyStringWrapper(p.getValue().getValue().getTitel())); +// +// columnRating.setCellValueFactory((CellDataFeatures p) -> +// new ReadOnlyObjectWrapper(p.getValue().getValue().getRating())); +// +// columnStreamUrl.setCellValueFactory((CellDataFeatures p) -> +// new ReadOnlyStringWrapper(p.getValue().getValue().getStreamUrl())); +// +// columnResolution.setCellValueFactory((CellDataFeatures p) -> +// new ReadOnlyStringWrapper(p.getValue().getValue().getResolution())); +// +// columnYear.setCellValueFactory((CellDataFeatures p) -> +// new ReadOnlyObjectWrapper(p.getValue().getValue().getYear())); +// +// columnSeason.setCellValueFactory((CellDataFeatures p) -> +// new ReadOnlyObjectWrapper(p.getValue().getValue().getSeason())); +// +// columnEpisode.setCellValueFactory((CellDataFeatures p) -> +// new ReadOnlyObjectWrapper(p.getValue().getValue().getEpisode())); - columnStreamUrl.setCellValueFactory((CellDataFeatures p) -> - new ReadOnlyStringWrapper(p.getValue().getValue().getStreamUrl())); - columnResolution.setCellValueFactory((CellDataFeatures p) -> - new ReadOnlyStringWrapper(p.getValue().getValue().getResolution())); - - columnYear.setCellValueFactory((CellDataFeatures p) -> - new ReadOnlyObjectWrapper(p.getValue().getValue().getYear())); - - columnSeason.setCellValueFactory((CellDataFeatures p) -> - new ReadOnlyObjectWrapper(p.getValue().getValue().getSeason())); - - columnEpisode.setCellValueFactory((CellDataFeatures p) -> - new ReadOnlyObjectWrapper(p.getValue().getValue().getEpisode())); + //write content into cell (new) + columnTitel.setCellValueFactory(cellData -> cellData.getValue().getValue().titelProperty()); + columnRating.setCellValueFactory(cellData -> cellData.getValue().getValue().imageProperty()); + columnStreamUrl.setCellValueFactory(cellData -> cellData.getValue().getValue().streamUrlProperty()); + columnResolution.setCellValueFactory(cellData -> cellData.getValue().getValue().resolutionProperty()); + columnYear.setCellValueFactory(cellData -> cellData.getValue().getValue().yearProperty().asObject()); + columnSeason.setCellValueFactory(cellData -> cellData.getValue().getValue().seasonProperty().asObject()); + columnEpisode.setCellValueFactory(cellData -> cellData.getValue().getValue().episodeProperty().asObject()); treeTableViewfilm.getColumns().addAll(columnTitel, columnRating, columnStreamUrl, columnResolution, columnYear, columnSeason, columnEpisode); treeTableViewfilm.getColumns().get(2).setVisible(false); //blendet die Column mit den Dateinamen aus (wichtig um sie abzuspielen) @@ -724,8 +732,8 @@ public class MainWindowController { for(int i = 0; i < newDaten.size(); i++){ root.getChildren().add(new TreeItem(newDaten.get(i))); //fügt daten zur Rootnode hinzu } - columnRating.setMaxWidth(120); - columnTitel.setMaxWidth(240); + columnRating.setMaxWidth(80); + columnTitel.setMaxWidth(280); treeTableViewfilm.getColumns().get(3).setVisible(false); treeTableViewfilm.getColumns().get(4).setVisible(false); treeTableViewfilm.getColumns().get(5).setVisible(false); @@ -756,7 +764,7 @@ public class MainWindowController { if(entries[i].endsWith(".json")){ String titel = ohneEndung(entries[i]); String data = entries[i]; - streamingData.add(new streamUiData(1,1,1,5.0,"1",titel ,data)); + streamingData.add(new streamUiData(1,1,1,5.0,"1",titel ,data, imv1)); } } for(int i = 0; i < streamingData.size(); i++){ diff --git a/src/application/streamUiData.java b/src/application/streamUiData.java index 429d246..8f801c5 100644 --- a/src/application/streamUiData.java +++ b/src/application/streamUiData.java @@ -4,21 +4,24 @@ import javafx.beans.property.DoubleProperty; import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleDoubleProperty; import javafx.beans.property.SimpleIntegerProperty; +import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; +import javafx.scene.image.ImageView; public class streamUiData { - private IntegerProperty year = new SimpleIntegerProperty(); - private IntegerProperty season = new SimpleIntegerProperty(); - private IntegerProperty episode = new SimpleIntegerProperty(); - private DoubleProperty rating = new SimpleDoubleProperty(); - private StringProperty resolution = new SimpleStringProperty(); - private StringProperty titel = new SimpleStringProperty(); - private StringProperty streamUrl = new SimpleStringProperty(); + private final IntegerProperty year = new SimpleIntegerProperty(); + private final IntegerProperty season = new SimpleIntegerProperty(); + private final IntegerProperty episode = new SimpleIntegerProperty(); + private final DoubleProperty rating = new SimpleDoubleProperty(); + private final StringProperty resolution = new SimpleStringProperty(); + private final StringProperty titel = new SimpleStringProperty(); + private final StringProperty streamUrl = new SimpleStringProperty(); + private final SimpleObjectProperty image = new SimpleObjectProperty<>(); //uiData ist der Typ der Daten in der TreeTabelView - public streamUiData (final int year, final int season, final int episode, final double rating, final String resolution, final String titel, final String streamUrl) { + public streamUiData (final int year, final int season, final int episode, final double rating, final String resolution, final String titel, final String streamUrl, final ImageView image) { this.year.set(year); this.season.set(season); this.episode.set(episode); @@ -26,63 +29,7 @@ public class streamUiData { this.resolution.set(resolution); this.titel.set(titel); this.streamUrl.set(streamUrl); - } - - public int getYear() { - return year.get(); - } - - public int getSeason() { - return season.get(); - } - - public int getEpisode() { - return episode.get(); - } - - public double getRating() { - return rating.get(); - } - - public String getResolution() { - return resolution.get(); - } - - public String getTitel() { - return titel.get(); - } - - public String getStreamUrl() { - return streamUrl.get(); - } - - - public void setYear(int year) { - this.year.set(year); - } - - public void setSeason(int season) { - this.season.set(season); - } - - public void setEpisode(int season) { - this.episode.set(season); - } - - public void setRating(int rating) { - this.rating.set(rating); - } - - public void setResolution(String resolution) { - this.resolution.set(resolution); - } - - public void setTitel(String titel) { - this.titel.set(titel); - } - - public void setStreamUrl(StringProperty streamUrl) { - this.streamUrl = streamUrl; + this.image.set(image); } public IntegerProperty yearProperty(){ @@ -112,4 +59,74 @@ public class streamUiData { public StringProperty streamUrlProperty(){ return streamUrl; } + + public SimpleObjectProperty imageProperty(){ + return image; + } + + + public final int getYear() { + return yearProperty().get(); + } + + public final int getSeason() { + return seasonProperty().get(); + } + + public final int getEpisode() { + return episodeProperty().get(); + } + + public final double getRating() { + return ratingProperty().get(); + } + + public final String getResolution() { + return resolutionProperty().get(); + } + + public final String getTitel() { + return titelProperty().get(); + } + + public final String getStreamUrl() { + return streamUrlProperty().get(); + } + + public final ImageView getImage() { + return imageProperty().get(); + } + + + public final void setYear(int year) { + yearProperty().set(year); + } + + public final void setSeason(int season) { + seasonProperty().set(season); + } + + public final void setEpisode(int season) { + episodeProperty().set(season); + } + + public final void setRating(int rating) { + ratingProperty().set(rating); + } + + public final void setResolution(String resolution) { + resolutionProperty().set(resolution); + } + + public final void setTitel(String titel) { + titelProperty().set(titel); + } + + public final void setStreamUrl(String streamUrl) { + streamUrlProperty().set(streamUrl); + } + + public final void setImage(ImageView image) { + imageProperty().set(image); + } }