finished dbcontroller and favourites

pre releas version of Project HomeFlix for version 0.5 plasma cow
This commit is contained in:
Seil0 2017-02-04 16:15:47 +01:00
parent 93822bb013
commit 3a73d84bfb
14 changed files with 73 additions and 90 deletions

Binary file not shown.

View File

@ -17,10 +17,10 @@
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<AnchorPane fx:id="anpane" prefHeight="600.0" prefWidth="900.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.MainWindowController"> <AnchorPane fx:id="anpane" prefHeight="600.0" prefWidth="950.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.MainWindowController">
<children> <children>
<TreeTableView fx:id="treeTableViewfilm" layoutX="14.0" layoutY="88.0" prefHeight="400.0" prefWidth="360.0" AnchorPane.bottomAnchor="12.0" AnchorPane.leftAnchor="12.0" AnchorPane.topAnchor="88.0" /> <TreeTableView fx:id="treeTableViewfilm" layoutX="14.0" layoutY="88.0" prefHeight="400.0" prefWidth="360.0" AnchorPane.bottomAnchor="12.0" AnchorPane.leftAnchor="12.0" AnchorPane.rightAnchor="553.0" AnchorPane.topAnchor="88.0" />
<JFXTextArea fx:id="ta1" layoutX="385.0" layoutY="42.0" maxWidth="503.0" minWidth="275.0" prefHeight="546.0" prefWidth="293.0" AnchorPane.bottomAnchor="12.0" AnchorPane.leftAnchor="385.0" AnchorPane.rightAnchor="222.0" AnchorPane.topAnchor="44.0" /> <JFXTextArea fx:id="ta1" layoutX="385.0" layoutY="42.0" maxWidth="503.0" minWidth="275.0" prefHeight="546.0" prefWidth="293.0" AnchorPane.bottomAnchor="12.0" AnchorPane.leftAnchor="410.0" AnchorPane.rightAnchor="222.0" AnchorPane.topAnchor="44.0" />
<JFXButton fx:id="playbtn" contentDisplay="CENTER" layoutX="690.0" layoutY="363.0" onAction="#playbtnclicked" prefHeight="25.0" prefWidth="198.0" AnchorPane.bottomAnchor="212.0" AnchorPane.rightAnchor="12.0"> <JFXButton fx:id="playbtn" contentDisplay="CENTER" layoutX="690.0" layoutY="363.0" onAction="#playbtnclicked" prefHeight="25.0" prefWidth="198.0" AnchorPane.bottomAnchor="212.0" AnchorPane.rightAnchor="12.0">
<font> <font>
<Font name="System Bold" size="14.0" /> <Font name="System Bold" size="14.0" />
@ -29,7 +29,7 @@
<font> <font>
<Font name="System Bold" size="14.0" /> <Font name="System Bold" size="14.0" />
</font></JFXButton> </font></JFXButton>
<JFXTextField fx:id="tfsearch" layoutX="12.0" layoutY="44.0" maxWidth="477.0" minWidth="359.0" prefHeight="31.0" prefWidth="359.0" promptText="Suche ..." AnchorPane.leftAnchor="12.0" AnchorPane.topAnchor="44.0"> <JFXTextField fx:id="tfsearch" layoutX="12.0" layoutY="44.0" maxWidth="477.0" minWidth="359.0" prefHeight="31.0" prefWidth="359.0" promptText="Suche ..." AnchorPane.leftAnchor="12.0" AnchorPane.rightAnchor="553.0" AnchorPane.topAnchor="44.0">
<font> <font>
<Font name="Arial" size="12.0" /> <Font name="Arial" size="12.0" />
</font></JFXTextField> </font></JFXTextField>

Binary file not shown.

View File

@ -34,9 +34,9 @@ public class DBController {
} }
private MainWindowController mainWindowController; private MainWindowController mainWindowController;
private String DB_PATH = System.getProperty("user.home") + "\\Documents\\HomeFlix" + "\\" + "Homeflix.db"; // der Pfad der Datenbank-Datei private String DB_PATH = System.getProperty("user.home") + "\\Documents\\HomeFlix" + "\\" + "Homeflix.db"; //path to database file
private ImageView favorite_black = new ImageView(new Image("recources/icons/ic_favorite_black_18dp_1x.png")); private Image favorite_black = 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 Image favorite_border_black = new Image("recources/icons/ic_favorite_border_black_18dp_1x.png");
private List<String> filmsdbAll = new ArrayList<String>(); private List<String> filmsdbAll = new ArrayList<String>();
private List<String> filmsdbLocal = new ArrayList<String>(); private List<String> filmsdbLocal = new ArrayList<String>();
private List<String> filmsdbStream = new ArrayList<String>(); private List<String> filmsdbStream = new ArrayList<String>();
@ -53,9 +53,9 @@ public class DBController {
// create a database connection // create a database connection
connection = DriverManager.getConnection("jdbc:sqlite:" + DB_PATH); connection = DriverManager.getConnection("jdbc:sqlite:" + DB_PATH);
// Statement statement = connection.createStatement(); // Statement statement = connection.createStatement();
// statement.setQueryTimeout(30); // set timeout to 30 sec. TODO don't know wath to do with this // statement.setQueryTimeout(30); // set timeout to 30 sec. TODO don't know what to do with this
connection.setAutoCommit(false); //Autocommit to false -> manual commit is active connection.setAutoCommit(false); //AutoCommit to false -> manual commit is active
// fuelleDatenbank(); // fuelleDatenbank();
} catch (SQLException e) { } catch (SQLException e) {
// if the error message is "out of memory", it probably means no database file is found // if the error message is "out of memory", it probably means no database file is found
@ -142,17 +142,17 @@ public class DBController {
ps = connection.prepareStatement("insert into film_local values (?, ?, ?, ?)"); ps = connection.prepareStatement("insert into film_local values (?, ?, ?, ?)");
psS = connection.prepareStatement("insert into film_streaming values (?, ?, ?, ?, ?, ?, ?, ?)"); psS = connection.prepareStatement("insert into film_streaming values (?, ?, ?, ?, ?, ?, ?, ?)");
for(int j=0;j!=entries.length;j++) // Geht alle Dateien im Verzeichniss durch for(int j=0;j!=entries.length;j++) //goes through all the files in the directory
{ {
ps.setInt(1, 0); // definiert Bewertung als Integer in der dritten Spalte ps.setInt(1, 0); //rating as integer 1. column
ps.setString(2, cutOffEnd(entries[j])); // definiert Name als String in der ersten Spalte ps.setString(2, cutOffEnd(entries[j])); //name as String without ending 2. column
ps.setString(3,entries[j]); // definiert Pfad als String in der zweiten Spalte ps.setString(3,entries[j]); //path as String 3. column
ps.setString(4, "favorite_border_black"); ps.setString(4, "favorite_border_black");
ps.addBatch(); // fügt den Eintrag hinzu ps.addBatch(); // add command to prepared statement
} }
if(mainWindowController.getStreamingPath().equals("")||mainWindowController.getStreamingPath().equals(null)){ if(mainWindowController.getStreamingPath().equals("")||mainWindowController.getStreamingPath().equals(null)){
System.out.println("Kein Pfad angegeben"); //falls der Pfad null oder "" ist System.out.println("Kein Pfad angegeben"); //if path == null or ""
}else{ }else{
for(int i=0; i< mainWindowController.streamingData.size(); i++){ for(int i=0; i< mainWindowController.streamingData.size(); i++){
String fileNamea = mainWindowController.getStreamingPath()+"/"+mainWindowController.streamingData.get(i).getStreamUrl(); String fileNamea = mainWindowController.getStreamingPath()+"/"+mainWindowController.streamingData.get(i).getStreamUrl();
@ -168,14 +168,14 @@ public class DBController {
psS.setString(6, item.asObject().getString("titel","")); psS.setString(6, item.asObject().getString("titel",""));
psS.setString(7, item.asObject().getString("streamUrl", "")); psS.setString(7, item.asObject().getString("streamUrl", ""));
psS.setString(8, "favorite_border_black"); psS.setString(8, "favorite_border_black");
psS.addBatch(); // fügt den Eintrag hinzu psS.addBatch(); // add command to prepared statement
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }
ps.executeBatch(); // scheibt alle Einträge in die Datenbank ps.executeBatch(); //execute statement to write entries into table
psS.executeBatch(); psS.executeBatch();
connection.commit(); connection.commit();
ps.close(); ps.close();
@ -208,7 +208,11 @@ public class DBController {
Statement stmt = connection.createStatement(); Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM film_local"); ResultSet rs = stmt.executeQuery("SELECT * FROM film_local");
while (rs.next()) { while (rs.next()) {
mainWindowController.newDaten.add(new streamUiData(1, 1, 1, rs.getDouble(1), "1", rs.getString(2), rs.getString(3), favorite_border_black)); if(rs.getString(4).equals("favorite_black")){
mainWindowController.newDaten.add( new streamUiData(1, 1, 1, rs.getDouble(1), "1", rs.getString(2), rs.getString(3), new ImageView(favorite_black)));
}else{
mainWindowController.newDaten.add( new streamUiData(1, 1, 1, rs.getDouble(1), "1", rs.getString(2), rs.getString(3), new ImageView(favorite_border_black)));
}
} }
stmt.close(); stmt.close();
rs.close(); rs.close();
@ -216,7 +220,11 @@ public class DBController {
//load streaming Data TODO check if there are streaming data before loading -> maybe there is an issue now //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;"); rs = stmt.executeQuery("SELECT * FROM film_streaming;");
while (rs.next()) { 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), favorite_border_black)); if(rs.getString(8).equals("favorite_black")){
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), new ImageView(favorite_black)));
}else{
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), new ImageView(favorite_border_black)));
}
} }
stmt.close(); stmt.close();
rs.close(); rs.close();
@ -227,7 +235,7 @@ public class DBController {
System.out.println("<==========finished loading sql==========>"); System.out.println("<==========finished loading sql==========>");
} }
//refreshs the data in mainWindowController.newDaten and mainWindowController.streamData //Refreshes the data in mainWindowController.newDaten and mainWindowController.streamData
//TODO it seems that there is an issue at the moment with streaming refreshing wrong entry if there is more than one with the same name //TODO it seems that there is an issue at the moment with streaming refreshing wrong entry if there is more than one with the same name
void refresh(String name,int i) throws SQLException{ void refresh(String name,int i) throws SQLException{
System.out.println("refresh ..."); System.out.println("refresh ...");
@ -237,9 +245,9 @@ public class DBController {
stmt = connection.createStatement(); stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM film_local WHERE titel = '"+name+"';" ); ResultSet rs = stmt.executeQuery("SELECT * FROM film_local WHERE titel = '"+name+"';" );
if(rs.getString(4).equals("favorite_black")){ 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)); mainWindowController.newDaten.set(i, new streamUiData(1, 1, 1, rs.getDouble(1), "1", rs.getString(2), rs.getString(3), new ImageView(favorite_black)));
}else{ }else{
mainWindowController.newDaten.set(i, new streamUiData(1, 1, 1, rs.getDouble(1), "1", rs.getString(2), rs.getString(3), favorite_border_black)); mainWindowController.newDaten.set(i, new streamUiData(1, 1, 1, rs.getDouble(1), "1", rs.getString(2), rs.getString(3), new ImageView(favorite_border_black)));
} }
stmt.close(); stmt.close();
rs.close(); rs.close();
@ -248,9 +256,9 @@ public class DBController {
stmt = connection.createStatement(); stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM film_streaming WHERE titel = '"+name+"';" ); ResultSet rs = stmt.executeQuery("SELECT * FROM film_streaming WHERE titel = '"+name+"';" );
if(rs.getString(8).equals("favorite_black")){ 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)); 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), new ImageView(favorite_black)));
}else{ }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)); 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), new ImageView(favorite_border_black)));
} }
stmt.close(); stmt.close();
rs.close(); rs.close();
@ -287,7 +295,7 @@ public class DBController {
} }
private void checkAddEntry() throws SQLException, FileNotFoundException, IOException{ //müssen noch alphabetisch sortiert werden private void checkAddEntry() throws SQLException, FileNotFoundException, IOException{ //TODO sort alphabetical
System.out.println("checking for entrys to add to DB ..."); System.out.println("checking for entrys to add to DB ...");
String[] entries = new File(mainWindowController.getPath()).list(); String[] entries = new File(mainWindowController.getPath()).list();
Statement stmt = connection.createStatement(); Statement stmt = connection.createStatement();

View File

@ -17,10 +17,10 @@
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<AnchorPane fx:id="anpane" prefHeight="600.0" prefWidth="900.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.MainWindowController"> <AnchorPane fx:id="anpane" prefHeight="600.0" prefWidth="950.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.MainWindowController">
<children> <children>
<TreeTableView fx:id="treeTableViewfilm" layoutX="14.0" layoutY="88.0" prefHeight="400.0" prefWidth="360.0" AnchorPane.bottomAnchor="12.0" AnchorPane.leftAnchor="12.0" AnchorPane.topAnchor="88.0" /> <TreeTableView fx:id="treeTableViewfilm" layoutX="14.0" layoutY="88.0" prefHeight="400.0" prefWidth="360.0" AnchorPane.bottomAnchor="12.0" AnchorPane.leftAnchor="12.0" AnchorPane.rightAnchor="553.0" AnchorPane.topAnchor="88.0" />
<JFXTextArea fx:id="ta1" layoutX="385.0" layoutY="42.0" maxWidth="503.0" minWidth="275.0" prefHeight="546.0" prefWidth="293.0" AnchorPane.bottomAnchor="12.0" AnchorPane.leftAnchor="385.0" AnchorPane.rightAnchor="222.0" AnchorPane.topAnchor="44.0" /> <JFXTextArea fx:id="ta1" layoutX="385.0" layoutY="42.0" maxWidth="503.0" minWidth="275.0" prefHeight="546.0" prefWidth="293.0" AnchorPane.bottomAnchor="12.0" AnchorPane.leftAnchor="410.0" AnchorPane.rightAnchor="222.0" AnchorPane.topAnchor="44.0" />
<JFXButton fx:id="playbtn" contentDisplay="CENTER" layoutX="690.0" layoutY="363.0" onAction="#playbtnclicked" prefHeight="25.0" prefWidth="198.0" AnchorPane.bottomAnchor="212.0" AnchorPane.rightAnchor="12.0"> <JFXButton fx:id="playbtn" contentDisplay="CENTER" layoutX="690.0" layoutY="363.0" onAction="#playbtnclicked" prefHeight="25.0" prefWidth="198.0" AnchorPane.bottomAnchor="212.0" AnchorPane.rightAnchor="12.0">
<font> <font>
<Font name="System Bold" size="14.0" /> <Font name="System Bold" size="14.0" />
@ -29,7 +29,7 @@
<font> <font>
<Font name="System Bold" size="14.0" /> <Font name="System Bold" size="14.0" />
</font></JFXButton> </font></JFXButton>
<JFXTextField fx:id="tfsearch" layoutX="12.0" layoutY="44.0" maxWidth="477.0" minWidth="359.0" prefHeight="31.0" prefWidth="359.0" promptText="Suche ..." AnchorPane.leftAnchor="12.0" AnchorPane.topAnchor="44.0"> <JFXTextField fx:id="tfsearch" layoutX="12.0" layoutY="44.0" maxWidth="477.0" minWidth="359.0" prefHeight="31.0" prefWidth="359.0" promptText="Suche ..." AnchorPane.leftAnchor="12.0" AnchorPane.rightAnchor="553.0" AnchorPane.topAnchor="44.0">
<font> <font>
<Font name="Arial" size="12.0" /> <Font name="Arial" size="12.0" />
</font></JFXTextField> </font></JFXTextField>

View File

@ -182,9 +182,10 @@ public class MainWindowController {
private boolean menutrue = false; //saves the position of menubtn (opened or closed) private boolean menutrue = false; //saves the position of menubtn (opened or closed)
private boolean settingstrue = false; private boolean settingstrue = false;
private boolean streamingSettingsTrue = false; private boolean streamingSettingsTrue = false;
private String version = "0.4.0"; private int hashA = -2055934614;
private String buildNumber = "104"; private String version = "0.4.99";
private String versionName = "glowing bucket"; private String buildNumber = "110";
private String versionName = "plasma cow (pre Release)";
private String buildURL = "https://raw.githubusercontent.com/Seil0/Project-HomeFlix/master/updates/buildNumber.txt"; private String buildURL = "https://raw.githubusercontent.com/Seil0/Project-HomeFlix/master/updates/buildNumber.txt";
private String downloadLink = "https://raw.githubusercontent.com/Seil0/Project-HomeFlix/master/updates/downloadLink.txt"; private String downloadLink = "https://raw.githubusercontent.com/Seil0/Project-HomeFlix/master/updates/downloadLink.txt";
private File dir = new File(System.getProperty("user.home") + "/Documents/HomeFlix"); private File dir = new File(System.getProperty("user.home") + "/Documents/HomeFlix");
@ -250,8 +251,6 @@ public class MainWindowController {
private ImageView skip_next_black = new ImageView(new Image("recources/icons/ic_skip_next_black_18dp_1x.png")); 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_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")); private ImageView play_arrow_black = new ImageView(new Image("recources/icons/ic_play_arrow_black_18dp_1x.png"));
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 DirectoryChooser directoryChooser = new DirectoryChooser(); private DirectoryChooser directoryChooser = new DirectoryChooser();
private ContextMenu menu = new ContextMenu(); private ContextMenu menu = new ContextMenu();
private MenuItem like = new MenuItem("like"); private MenuItem like = new MenuItem("like");
@ -262,7 +261,6 @@ public class MainWindowController {
private apiQuery ApiQuery; private apiQuery ApiQuery;
DBController dbController; DBController dbController;
//wenn menubtn clicked
/** /**
* TODO change value of Text-color change * TODO change value of Text-color change
*/ */
@ -303,7 +301,6 @@ public class MainWindowController {
System.out.println(output); System.out.println(output);
input.close(); input.close();
} catch (IOException e1) { } catch (IOException e1) {
// Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();
} }
if(output.contains("which: no vlc")||output == ""){ if(output.contains("which: no vlc")||output == ""){
@ -335,7 +332,7 @@ public class MainWindowController {
} }
}else if(mode.equals("streaming")){ }else if(mode.equals("streaming")){
try { try {
Desktop.getDesktop().browse(new URI(datPath)); //opens the streaming url in browser (other option?) Desktop.getDesktop().browse(new URI(datPath)); //opens the streaming url in browser (TODO other option?)
} catch (URISyntaxException | IOException e) { } catch (URISyntaxException | IOException e) {
showErrorMsg(errorOpenStream, (IOException) e); showErrorMsg(errorOpenStream, (IOException) e);
} }
@ -350,7 +347,7 @@ public class MainWindowController {
@FXML @FXML
private void openfolderbtnclicked(){ private void openfolderbtnclicked(){
try { try {
Desktop.getDesktop().open(new File(getPath())); //öffnet den aktuellen Pfad Desktop.getDesktop().open(new File(getPath())); //open path when button is clicked
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -393,7 +390,7 @@ public class MainWindowController {
} }
/** /**
* TODO zusätzliche infos über die dateien * TODO additional info about the "streaming.json"
*/ */
@FXML @FXML
private void streamingSettingsBtnclicked(){ private void streamingSettingsBtnclicked(){
@ -424,7 +421,7 @@ public class MainWindowController {
addDataUI(); addDataUI();
settingsAnchor.setVisible(false); settingsAnchor.setVisible(false);
streamingSettingsAnchor.setVisible(false); streamingSettingsAnchor.setVisible(false);
sideMenuSlideOut(); //disables sidemenu sideMenuSlideOut(); //disables side-menu
menutrue = false; menutrue = false;
settingstrue = false; settingstrue = false;
streamingSettingsTrue = false; streamingSettingsTrue = false;
@ -432,7 +429,6 @@ public class MainWindowController {
@FXML @FXML
private void debugBtnclicked(){ private void debugBtnclicked(){
newDaten.get(selected).setImage(favorite_black);
//for testing //for testing
} }
@ -508,7 +504,7 @@ public class MainWindowController {
} }
//"Main" Methode die beim start von der Klasse Main aufgerufen wird, initialiesirung der einzellnen UI-Objekte //"Main" Method called in Main.java main() when starting, initialize some UI elements
public void setMain(Main main) { public void setMain(Main main) {
Updater = new updater(this); Updater = new updater(this);
ApiQuery = new apiQuery(this); ApiQuery = new apiQuery(this);
@ -519,15 +515,16 @@ public class MainWindowController {
initActions(); initActions();
System.out.println("Mode: "+mode); //TODO debugging System.out.println("Mode: "+mode); //TODO debugging
// if(ratingSortType == "DESCENDING"){ //TODO not fully implemented yet //TODO implement sort for rating and alphabetical sort for name after new title was added
// if(ratingSortType == "DESCENDING"){
// columnRating.setSortType(TreeTableColumn.SortType.DESCENDING); // columnRating.setSortType(TreeTableColumn.SortType.DESCENDING);
// }else{ // }else{
// columnRating.setSortType(TreeTableColumn.SortType.ASCENDING); // columnRating.setSortType(TreeTableColumn.SortType.ASCENDING);
// } // }
debugBtn.setDisable(false); //debugging btn for tests debugBtn.setDisable(true); //debugging btn for tests
debugBtn.setVisible(true); debugBtn.setVisible(false);
tfPath.setText(getPath()); tfPath.setText(getPath());
@ -550,7 +547,7 @@ public class MainWindowController {
ta1.setFont(Font.font("System", getSize())); ta1.setFont(Font.font("System", getSize()));
} }
//initialisierung der Tabellen für filme(beide Modi) und Streaming-Settings //Initialize the tables (treeTableViewfilm and tableViewStreamingdata)
@SuppressWarnings({ "unchecked"}) @SuppressWarnings({ "unchecked"})
private void initTabel(){ private void initTabel(){
@ -565,31 +562,8 @@ public class MainWindowController {
treeTableViewfilm.setRoot(root); treeTableViewfilm.setRoot(root);
treeTableViewfilm.setColumnResizePolicy( TreeTableView.CONSTRAINED_RESIZE_POLICY ); treeTableViewfilm.setColumnResizePolicy( TreeTableView.CONSTRAINED_RESIZE_POLICY );
treeTableViewfilm.setShowRoot(false); treeTableViewfilm.setShowRoot(false);
//inhalt in Zelle schreiben
// columnTitel.setCellValueFactory((CellDataFeatures<streamUiData, String> p) ->
// new ReadOnlyStringWrapper(p.getValue().getValue().getTitel()));
//
// columnRating.setCellValueFactory((CellDataFeatures<streamUiData, Double> p) ->
// new ReadOnlyObjectWrapper<Double>(p.getValue().getValue().getRating()));
//
// columnStreamUrl.setCellValueFactory((CellDataFeatures<streamUiData, String> p) ->
// new ReadOnlyStringWrapper(p.getValue().getValue().getStreamUrl()));
//
// columnResolution.setCellValueFactory((CellDataFeatures<streamUiData, String> p) ->
// new ReadOnlyStringWrapper(p.getValue().getValue().getResolution()));
//
// columnYear.setCellValueFactory((CellDataFeatures<streamUiData, Integer> p) ->
// new ReadOnlyObjectWrapper(p.getValue().getValue().getYear()));
//
// columnSeason.setCellValueFactory((CellDataFeatures<streamUiData, Integer> p) ->
// new ReadOnlyObjectWrapper(p.getValue().getValue().getSeason()));
//
// columnEpisode.setCellValueFactory((CellDataFeatures<streamUiData, Integer> p) ->
// new ReadOnlyObjectWrapper(p.getValue().getValue().getEpisode()));
//write content into cell
//write content into cell (new)
columnTitel.setCellValueFactory(cellData -> cellData.getValue().getValue().titelProperty()); columnTitel.setCellValueFactory(cellData -> cellData.getValue().getValue().titelProperty());
columnRating.setCellValueFactory(cellData -> cellData.getValue().getValue().imageProperty()); columnRating.setCellValueFactory(cellData -> cellData.getValue().getValue().imageProperty());
columnStreamUrl.setCellValueFactory(cellData -> cellData.getValue().getValue().streamUrlProperty()); columnStreamUrl.setCellValueFactory(cellData -> cellData.getValue().getValue().streamUrlProperty());
@ -599,21 +573,21 @@ public class MainWindowController {
columnEpisode.setCellValueFactory(cellData -> cellData.getValue().getValue().episodeProperty().asObject()); columnEpisode.setCellValueFactory(cellData -> cellData.getValue().getValue().episodeProperty().asObject());
treeTableViewfilm.getColumns().addAll(columnTitel, columnRating, columnStreamUrl, columnResolution, columnYear, columnSeason, columnEpisode); 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) treeTableViewfilm.getColumns().get(2).setVisible(false); //hide columnStreamUrl (column with file path important for the player)
//Changelistener r TreeTable //Changelistener for TreeTable
treeTableViewfilm.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Object>() { treeTableViewfilm.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Object>() {
@Override @Override
public void changed(ObservableValue<?> observable, Object oldVal, Object newVal) { public void changed(ObservableValue<?> observable, Object oldVal, Object newVal) {
// last = selected; //für autoplay // last = selected; //for auto-play
selected = treeTableViewfilm.getSelectionModel().getSelectedIndex(); // holt aktuelles Item selected = treeTableViewfilm.getSelectionModel().getSelectedIndex(); //get selected item
last = selected - 1; last = selected - 1;
next = selected + 1; next = selected + 1;
Name = columnTitel.getCellData(selected); // holt Namen des Aktuelle Items aus der ColumnName Name = columnTitel.getCellData(selected); //get name of selected item
datPath = columnStreamUrl.getCellData(selected); // holt den aktuellen Datei Pfad aus der ColumnDatName datPath = columnStreamUrl.getCellData(selected); //get file path of selected item
ta1.setText(""); // löscht Text in ta1 ta1.setText(""); //delete text in ta1
ApiQuery.startQuery(Name); // startet die api abfrage ApiQuery.startQuery(Name); // start api query
ta1.positionCaret(0); // setzt die startposition des Cursors in ta1 ta1.positionCaret(0); //set cursor position in ta1
} }
}); });
@ -649,7 +623,7 @@ public class MainWindowController {
for(int i = 0; i < filterData.size(); i++){ for(int i = 0; i < filterData.size(); i++){
root.getChildren().addAll(new TreeItem<streamUiData>(filterData.get(i))); //fügt daten zur Rootnode hinzu root.getChildren().addAll(new TreeItem<streamUiData>(filterData.get(i))); //fügt daten zur Rootnode hinzu
} }
if(tfsearch.getText().equals("Notflix_glowing_cow")){ if(tfsearch.getText().hashCode() == hashA){
setColor("000000"); setColor("000000");
applyColor(); applyColor();
} }
@ -730,24 +704,24 @@ public class MainWindowController {
void addDataUI(){ void addDataUI(){
if(mode.equals("local")){ if(mode.equals("local")){
for(int i = 0; i < newDaten.size(); i++){ for(int i = 0; i < newDaten.size(); i++){
root.getChildren().add(new TreeItem<streamUiData>(newDaten.get(i))); //fügt daten zur Rootnode hinzu root.getChildren().add(new TreeItem<streamUiData>(newDaten.get(i))); //add data to root-node
} }
columnRating.setMaxWidth(80); columnRating.setMaxWidth(90);
columnTitel.setMaxWidth(280); columnTitel.setMaxWidth(290);
treeTableViewfilm.getColumns().get(3).setVisible(false); treeTableViewfilm.getColumns().get(3).setVisible(false);
treeTableViewfilm.getColumns().get(4).setVisible(false); treeTableViewfilm.getColumns().get(4).setVisible(false);
treeTableViewfilm.getColumns().get(5).setVisible(false); treeTableViewfilm.getColumns().get(5).setVisible(false);
treeTableViewfilm.getColumns().get(6).setVisible(false); treeTableViewfilm.getColumns().get(6).setVisible(false);
}else if(mode.equals("streaming")){ }else if(mode.equals("streaming")){
for(int i = 0; i < streamData.size(); i++){ for(int i = 0; i < streamData.size(); i++){
root.getChildren().add(new TreeItem<streamUiData>(streamData.get(i))); //fügt daten zur Rootnode hinzu root.getChildren().add(new TreeItem<streamUiData>(streamData.get(i))); //add data to root-node
} }
columnTitel.setMaxWidth(150); columnTitel.setMaxWidth(150);
columnResolution.setMaxWidth(65); columnResolution.setMaxWidth(65);
columnRating.setMaxWidth(52.5); columnRating.setMaxWidth(50);
columnYear.setMaxWidth(40); columnYear.setMaxWidth(43);
columnSeason.setMaxWidth(52.5); columnSeason.setMaxWidth(42);
columnEpisode.setMaxWidth(0); //disabled for ui size reasons columnEpisode.setMaxWidth(44);
treeTableViewfilm.getColumns().get(3).setVisible(true); treeTableViewfilm.getColumns().get(3).setVisible(true);
treeTableViewfilm.getColumns().get(4).setVisible(true); treeTableViewfilm.getColumns().get(4).setVisible(true);
treeTableViewfilm.getColumns().get(5).setVisible(true); treeTableViewfilm.getColumns().get(5).setVisible(true);
@ -831,7 +805,7 @@ public class MainWindowController {
//das solte weg kann aber hier bleiben wicht ist dass es zum selben zeitpunkt wie aply color ausgeführt wird //das solte weg kann aber hier bleiben wicht ist dass es zum selben zeitpunkt wie aply color ausgeführt wird
if(mode.equals("local")){ if(mode.equals("local")){
switchBtn.setText("streaming"); //TODO translate switchBtn.setText("streaming");
}else if(mode.equals("streaming")){ }else if(mode.equals("streaming")){
switchBtn.setText("local"); switchBtn.setText("local");
} }

View File

@ -122,6 +122,7 @@ public class apiQuery{
} }
} catch (Exception e) { } catch (Exception e) {
mainWindowController.ta1.setText(e.toString());
System.out.println(e); System.out.println(e);
} finally { } finally {
//closes datainputStream, InputStream,Scanner if not already done //closes datainputStream, InputStream,Scanner if not already done