Browse Source

initial release

pull/2/head
Seil0 4 years ago
parent
commit
c3a3398112
41 changed files with 1475 additions and 0 deletions
  1. +9
    -0
      .classpath
  2. +3
    -0
      .gitignore
  3. +23
    -0
      .project
  4. +11
    -0
      .settings/org.eclipse.jdt.core.prefs
  5. BIN
      bin/Homeflix_Icon_64x64.png
  6. BIN
      bin/Homeflix_Poster.png
  7. BIN
      bin/application/DBController$1.class
  8. BIN
      bin/application/DBController.class
  9. +15
    -0
      bin/application/HomeFlix-Local_de_DE.properties
  10. +15
    -0
      bin/application/HomeFlix-Local_en_US.properties
  11. BIN
      bin/application/Main.class
  12. +37
    -0
      bin/application/MainWindow.fxml
  13. BIN
      bin/application/MainWindowController$1.class
  14. BIN
      bin/application/MainWindowController$2$1.class
  15. BIN
      bin/application/MainWindowController$2$2.class
  16. BIN
      bin/application/MainWindowController$2$3.class
  17. BIN
      bin/application/MainWindowController$2$4.class
  18. BIN
      bin/application/MainWindowController$2$5.class
  19. BIN
      bin/application/MainWindowController$2$6.class
  20. BIN
      bin/application/MainWindowController$2.class
  21. BIN
      bin/application/MainWindowController$3.class
  22. BIN
      bin/application/MainWindowController$4.class
  23. BIN
      bin/application/MainWindowController$5.class
  24. BIN
      bin/application/MainWindowController$6.class
  25. BIN
      bin/application/MainWindowController.class
  26. +1
    -0
      bin/application/application.css
  27. BIN
      bin/application/uiData.class
  28. BIN
      bin/menu_icon_black.png
  29. +8
    -0
      build.fxbuild
  30. +10
    -0
      config.xml
  31. BIN
      src/Homeflix_Icon_64x64.png
  32. BIN
      src/Homeflix_Poster.png
  33. +216
    -0
      src/application/DBController.java
  34. +15
    -0
      src/application/HomeFlix-Local_de_DE.properties
  35. +15
    -0
      src/application/HomeFlix-Local_en_US.properties
  36. +148
    -0
      src/application/Main.java
  37. +37
    -0
      src/application/MainWindow.fxml
  38. +854
    -0
      src/application/MainWindowController.java
  39. +1
    -0
      src/application/application.css
  40. +57
    -0
      src/application/uiData.java
  41. BIN
      src/menu_icon_black.png

+ 9
- 0
.classpath View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.fx.ide.jdt.core.JAVAFX_CONTAINER"/>
<classpathentry kind="lib" path="C:/Users/Jannik/workspace/Project HomeFlix/jfoenix.jar"/>
<classpathentry kind="lib" path="C:/Users/Jannik/workspace/Project HomeFlix/minimal-json-0.9.4.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

+ 3
- 0
.gitignore View File

@ -45,3 +45,6 @@ $RECYCLE.BIN/
Network Trash Folder
Temporary Items
.apdisk
ProjectHomeFlix.jar
jfoenix.jar
minimal-json-0.9.4.jar

+ 23
- 0
.project View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Project HomeFlix</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

+ 11
- 0
.settings/org.eclipse.jdt.core.prefs View File

@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8

BIN
bin/Homeflix_Icon_64x64.png View File

Before After
Width: 64  |  Height: 64  |  Size: 24 KiB

BIN
bin/Homeflix_Poster.png View File

Before After
Width: 300  |  Height: 444  |  Size: 30 KiB

BIN
bin/application/DBController$1.class View File


BIN
bin/application/DBController.class View File


+ 15
- 0
bin/application/HomeFlix-Local_de_DE.properties View File

@ -0,0 +1,15 @@
# HomeFlix-Local_de_DE.properties German Local
info = Info
settings = Einstellungen
play = play
openFolder = Ordner \u00F6ffnen
chooseFolder = Ordner auswählen
fontSize = Schriftgr\u00F6\u00DFe:
checkUpdates = Auf Update pr\u00FCfen
autoUpdate = beim Start nach Updates suchen:
version = Version:
columnName = Name
columnRating = Bewertung
columnDatName = Datei Name
errorUpdate = Es ist ein Fehler aufgetreten! \n Um Hilfe zu erhalten besuchen Sie \nwww.kellerkinder.xyz oder support@kellerkinder.xyz
infoText = \nMaintainer: seilo@kellerkinder.xyz und \nhendrik.schutter@coptersicht.de \n(c) 2016 Kellerkinder www.kellerkinder.xyz

+ 15
- 0
bin/application/HomeFlix-Local_en_US.properties View File

@ -0,0 +1,15 @@
# HomeFlix-Local_en_US.properties US-English Local and default
info = Info
settings = Settings
play = play
openFolder = open Folder
chooseFolder = choose Directory
fontSize = font size:
checkUpdates = check for updates
autoUpdate = check at startup for updates:
version = Version:
columnName = Name
columnRating = Rating
columnDatName = File Name
errorUpdate = An error has occurred! \n To get help, visit \n nwww.kellerkinder.xyz or support@kellerkinder.xyz
infoText = \nMaintainer: seilo@kellerkinder.xyz and \nhendrik.schutter@coptersicht.de \n(c) 2016 Kellerkinder www.kellerkinder.xyz

BIN
bin/application/Main.class View File


+ 37
- 0
bin/application/MainWindow.fxml View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import com.jfoenix.controls.JFXButton?>
<?import com.jfoenix.controls.JFXTextArea?>
<?import com.jfoenix.controls.JFXTextField?>
<?import javafx.scene.control.TreeTableView?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>
<?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">
<children>
<VBox fx:id="topVBox" prefHeight="32.0" prefWidth="800.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<JFXButton fx:id="menubtn" onAction="#menubtnclicked" prefHeight="32.0" prefWidth="67.0" text="Menu" />
</children>
</VBox>
<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" />
<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" />
<JFXButton fx:id="playbtn" layoutX="690.0" layoutY="363.0" onAction="#playbtnclicked" prefHeight="25.0" prefWidth="198.0" text="play" AnchorPane.bottomAnchor="212.0" AnchorPane.rightAnchor="12.0">
<font>
<Font name="System Bold" size="14.0" />
</font></JFXButton>
<JFXButton fx:id="openfolderbtn" layoutX="690.0" layoutY="404.0" onAction="#openfolderbtnclicked" prefHeight="25.0" prefWidth="198.0" text="open Folder" AnchorPane.bottomAnchor="171.0" AnchorPane.rightAnchor="12.0">
<font>
<Font name="System Bold" size="14.0" />
</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">
<font>
<Font name="Arial" size="12.0" />
</font></JFXTextField>
<ImageView fx:id="image1" fitHeight="297.0" fitWidth="198.0" layoutX="481.0" layoutY="46.0" pickOnBounds="true" preserveRatio="true" AnchorPane.rightAnchor="12.0" AnchorPane.topAnchor="44.0" />
<JFXButton fx:id="returnBtn" layoutX="690.0" layoutY="443.0" onAction="#returnBtnclicked" prefHeight="25.0" prefWidth="90.0" text="&lt;&lt;" AnchorPane.bottomAnchor="132.0" AnchorPane.rightAnchor="120.0" />
<JFXButton fx:id="forwardBtn" layoutX="798.0" layoutY="443.0" onAction="#forwardBtnclicked" prefHeight="25.0" prefWidth="90.0" text="&gt;&gt;" AnchorPane.bottomAnchor="132.0" AnchorPane.rightAnchor="12.0" />
</children>
</AnchorPane>

BIN
bin/application/MainWindowController$1.class View File


BIN
bin/application/MainWindowController$2$1.class View File


BIN
bin/application/MainWindowController$2$2.class View File


BIN
bin/application/MainWindowController$2$3.class View File


BIN
bin/application/MainWindowController$2$4.class View File


BIN
bin/application/MainWindowController$2$5.class View File


BIN
bin/application/MainWindowController$2$6.class View File


BIN
bin/application/MainWindowController$2.class View File


BIN
bin/application/MainWindowController$3.class View File


BIN
bin/application/MainWindowController$4.class View File


BIN
bin/application/MainWindowController$5.class View File


BIN
bin/application/MainWindowController$6.class View File


BIN
bin/application/MainWindowController.class View File


+ 1
- 0
bin/application/application.css View File

@ -0,0 +1 @@
/* JavaFX CSS - Leave this comment until you have at least create one rule which uses -fx-Property */

BIN
bin/application/uiData.class View File


BIN
bin/menu_icon_black.png View File

Before After
Width: 30  |  Height: 30  |  Size: 14 KiB

+ 8
- 0
build.fxbuild View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="ASCII"?>
<anttasks:AntTask xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:anttasks="http://org.eclipse.fx.ide.jdt/1.0" buildDirectory="${project}/build">
<deploy>
<application name="Project HomeFlix"/>
<info/>
</deploy>
<signjar/>
</anttasks:AntTask>

+ 10
- 0
config.xml View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<comment>Project HomeFlix settings</comment>
<entry key="color">ee3523</entry>
<entry key="autoUpdate">0</entry>
<entry key="size">12.0</entry>
<entry key="local">1</entry>
<entry key="path">C:\Users\Jannik\Videos\Beispielfilme</entry>
</properties>

BIN
src/Homeflix_Icon_64x64.png View File

Before After
Width: 64  |  Height: 64  |  Size: 24 KiB

BIN
src/Homeflix_Poster.png View File

Before After
Width: 300  |  Height: 444  |  Size: 30 KiB

+ 216
- 0
src/application/DBController.java View File

@ -0,0 +1,216 @@
package application;
import java.sql.Connection; //für Datenbank
import java.sql.DriverManager; //für Datenbank
import java.sql.PreparedStatement; //für Datenbank
import java.sql.ResultSet; //für Datenbank
import java.sql.SQLException; //für Datenbank
import java.sql.Statement; //für Datenbank
import java.io.File;//für Dateien einlesen
class DBController {
@SuppressWarnings("unused")
private MainWindowController mainWindowController;
private static final DBController dbcontroller = new DBController();
private static Connection connection;
private static final String DB_PATH = System.getProperty("user.dir") + "/" + "Homeflix.db"; // der Pfad der Datenbank-Datei
private String path;
File f;
File file[]; //ArrayList für die Dateien
static {
try {
Class.forName("org.sqlite.JDBC"); //Datenbanktreiber
} catch (ClassNotFoundException e) {
System.err.println("Fehler beim Laden des JDBC-Treibers");
e.printStackTrace();
}
}
public static void main(String input) {
DBController datenbank = DBController.getInstance(); //neues Datenbank-Objekt wird erstellt
datenbank.setPath(input); // Pfad zuweisen
datenbank.f = new File(datenbank.getPath()); // für Datenbank-Datei einlesen
datenbank.file = datenbank.f.listFiles(); // für Datenbank-Datei einlesen
datenbank.verbindeDatenbank();
datenbank.fuelleDatenbank();
//datenbank.defavorisieren("Frozen");
//datenbank.favorisieren("Frozen");
//datenbank.ausgebenTitel();
//System.out.println("Pfad: " + datenbank.getPfad("Frozen"));
//System.out.println("Bewertung: " + datenbank.getFavStatus("Frozen"));
}
DBController(){
}
private static DBController getInstance(){
return dbcontroller;
}
// Die Datenbak wird mit Hilfe des JDBC-Treibers eingebunden
public void verbindeDatenbank() {
try {
if (connection != null)
return;
System.out.println("Erstelle Verbindung zur Datenbank...");
connection = DriverManager.getConnection("jdbc:sqlite:" + DB_PATH);
if (!connection.isClosed())
System.out.println("...Verbindung hergestellt");
} catch (SQLException e) {
throw new RuntimeException(e);
}
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
try {
if (!connection.isClosed() && connection != null) {
connection.close();
if (connection.isClosed())
System.out.println("Verbindung getrennt");
}
} catch (SQLException e) {
e.printStackTrace();
}
}
});
}
// Die Dateien werden in die Datenbank geschrieben
public void fuelleDatenbank() {
try {
System.out.println("Erstelle Einträge");
Statement stmt = connection.createStatement();
stmt.executeUpdate("DROP TABLE IF EXISTS filme;");
stmt.executeUpdate("CREATE TABLE filme (titel, pfad, bewertung);"); // Tabelle "filme" und die Spalten "titel", "pfad", "bewertung" erstellen
PreparedStatement ps = connection.prepareStatement("INSERT INTO filme VALUES (?, ?, ?);"); // SQL Befehl
//System.out.println(file.length);
for(int i=0;i!=file.length;i++) // Geht alle Dateien im Verzeichniss durch
{
//System.out.println(file[i].getName());
ps.setString(1, ohneEndung(file[i].getName())); // definiert Name als String in der ersten Spalte
ps.setString(2,file[i].getName()); // definiert Pfad als String in der zweiten Spalte
ps.setInt(3, 0); // definiert Bewertung als Integer in der dritten Spalte
ps.addBatch(); // fügt den Eintrag hinzu
}
connection.setAutoCommit(false);
ps.executeBatch(); // scheibt alle Einträge in die Datenbank
connection.setAutoCommit(true);
//connection.close();
} catch (SQLException e) {
System.err.println("Konnte nicht ausgeführt werden");
e.printStackTrace();
}
}
public void ausgeben(){
System.out.println("Einträge ausgeben");
try {
Statement stmt = connection.createStatement();
mainWindowController = new MainWindowController();
ResultSet rs = stmt.executeQuery("SELECT * FROM filme;");
while (rs.next()) {
// MainWindowController mainWindowController = new MainWindowController();
}
//rs.close();
// mainWindowController.initTabel();
} catch (SQLException e) {
System.err.println("Konnte nicht ausgeführt werden");
e.printStackTrace();
}
}
// Kontroll Methode, ob ein Film wirklich in der Datenbank ist
public String getTitel(String name){
try {
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT titel, pfad FROM filme WHERE titel = '"+name+"';" );
return rs.getString("titel");
} catch (SQLException e) {
System.err.println("Konnte nicht ausgeführt werden");
e.printStackTrace();
}
return "Error 404";
}
// gibt den Pfad eines bestimmten Films
public String getPfad(String name){
try {
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT titel, pfad FROM filme WHERE titel = '"+name+"';" ); //SQL Befehl
return rs.getString("pfad");
} catch (SQLException e) {
System.err.println("Konnte nicht ausgeführt werden");
e.printStackTrace();
}
return "Error 404";
}
// gibt die Favorisierung eines bestimmten Films
public boolean getFavStatus(String name){
try {
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT titel, bewertung FROM filme WHERE titel = '"+name+"';" ); //SQL Befehl
System.out.println(rs.getInt("bewertung"));
if((rs.getInt("bewertung")) == 1){
return true;
}
else{
return false;
}
} catch (SQLException e) {
System.err.println("Konnte nicht ausgeführt werden");
e.printStackTrace();
return false;
}
}
// setzt die Defavorisierung eines bestimmten Films
public void defavorisieren(String name){
System.out.println("setze Bewertung");
try {
Statement stmt = connection.createStatement();
String sql = ("UPDATE filme SET bewertung=0 WHERE titel='"+name+"';"); //SQL Befehl
stmt.executeUpdate(sql);
connection.setAutoCommit(false);
connection.setAutoCommit(true);
} catch (SQLException e) {
System.err.println("Konnte nicht ausgeführt werden");
e.printStackTrace();
}
}
// setzt die Favorisierung eines bestimmten Films
public void favorisieren(String name){
System.out.println("setze Bewertung");
try {
Statement stmt = connection.createStatement();
String sql = ("UPDATE filme SET bewertung=1 WHERE titel='"+name+"';"); //SQL Befehl
stmt.executeUpdate(sql);
connection.setAutoCommit(false);
connection.setAutoCommit(true);
} catch (SQLException e) {
System.err.println("Konnte nicht ausgeführt werden");
e.printStackTrace();
}
}
//entfernt die Endung
private static String ohneEndung (String str) {
if (str == null) return null;
int pos = str.lastIndexOf(".");
if (pos == -1) return str;
return str.substring(0, pos);
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path.replace("\\", "\\\\");
}
}

+ 15
- 0
src/application/HomeFlix-Local_de_DE.properties View File

@ -0,0 +1,15 @@
# HomeFlix-Local_de_DE.properties German Local
info = Info
settings = Einstellungen
play = play
openFolder = Ordner \u00F6ffnen
chooseFolder = Ordner auswählen
fontSize = Schriftgr\u00F6\u00DFe:
checkUpdates = Auf Update pr\u00FCfen
autoUpdate = beim Start nach Updates suchen:
version = Version:
columnName = Name
columnRating = Bewertung
columnDatName = Datei Name
errorUpdate = Es ist ein Fehler aufgetreten! \n Um Hilfe zu erhalten besuchen Sie \nwww.kellerkinder.xyz oder support@kellerkinder.xyz
infoText = \nMaintainer: seilo@kellerkinder.xyz und \nhendrik.schutter@coptersicht.de \n(c) 2016 Kellerkinder www.kellerkinder.xyz

+ 15
- 0
src/application/HomeFlix-Local_en_US.properties View File

@ -0,0 +1,15 @@
# HomeFlix-Local_en_US.properties US-English Local and default
info = Info
settings = Settings
play = play
openFolder = open Folder
chooseFolder = choose Directory
fontSize = font size:
checkUpdates = check for updates
autoUpdate = check at startup for updates:
version = Version:
columnName = Name
columnRating = Rating
columnDatName = File Name
errorUpdate = An error has occurred! \n To get help, visit \n nwww.kellerkinder.xyz or support@kellerkinder.xyz
infoText = \nMaintainer: seilo@kellerkinder.xyz and \nhendrik.schutter@coptersicht.de \n(c) 2016 Kellerkinder www.kellerkinder.xyz

+ 148
- 0
src/application/Main.java View File

@ -0,0 +1,148 @@
/**
* Project HomeFlix
*
* Copyright 2016 <admin@kellerkinder>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*/
package application;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Optional;
import java.util.Properties;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.ButtonType;
import javafx.scene.image.Image;
import javafx.scene.layout.AnchorPane;
import javafx.scene.paint.Color;
import javafx.stage.DirectoryChooser;
import javafx.stage.Stage;
public class Main extends Application {
public Stage primaryStage;
private String path;
private String color = "ee3523";
private String autoUpdate = "0";
private double size = 12;
private int local = 0;
Properties props = new Properties();
private MainWindowController mainWindowController;
@Override
public void start(Stage primaryStage) {
this.primaryStage = primaryStage;
mainWindow();
}
public void mainWindow(){
File file = new File("config.xml");
try {
FXMLLoader loader = new FXMLLoader(Main.class.getResource("MainWindow.fxml"));
AnchorPane pane = loader.load();
primaryStage.setMinHeight(600.00);
primaryStage.setMinWidth(900.00);
primaryStage.setResizable(false);
primaryStage.setTitle("Project HomeFlix");
primaryStage.getIcons().add(new Image(Main.class.getResourceAsStream("/Homeflix_Icon_64x64.png"))); //fügt Anwendungsicon hinzu
mainWindowController = loader.getController(); //verknüpfung von FXMLController und Controller Klasse
mainWindowController.setAutoUpdate(autoUpdate); //setzt autoupdate
mainWindowController.setMain(this); //aufruf setMain
//prüft ob config.xml vorhanden, wenn nicht hole Pfad und schreibe Daten in Controller
if (file.exists() != true) {
mainWindowController.setPath(firstStart());
mainWindowController.setColor(color);
mainWindowController.setSize(size);
mainWindowController.setAutoUpdate(autoUpdate);
mainWindowController.setLoaclUI(local);
mainWindowController.saveSettings();
Runtime.getRuntime().exec("java -jar ProjectHomeFlix.jar"); //starte neu um Bugs zu verhindern
System.exit(0); //beendet sich selbst
}else{
loadSettings();
}
mainWindowController.applyColor(); //setzt die Theme Farbe
mainWindowController.cbLocal.getSelectionModel().select(mainWindowController.getLocal()); //setzt local
mainWindowController.mainColor.setValue(Color.valueOf(mainWindowController.getColor()));
mainWindowController.loadData(); //läd die Daten im Controller
Scene scene = new Scene(pane); //neue Scen um inhalt der stage anzuzeigen
primaryStage.setScene(scene);
primaryStage.show(); //zeige scene
} catch (IOException e) {
// Auto-generated catch block
e.printStackTrace();
}
}
//methode für den erstmaligen Start
private String firstStart(){
Alert alert = new Alert(AlertType.CONFIRMATION); //neuer alert mit filechooser
alert.setTitle("Project HomeFlix");
alert.setHeaderText("Es ist kein Stammverzeichniss für Filme angegeben!");
alert.setContentText("Stammverzeichniss angeben?");
Optional<ButtonType> result = alert.showAndWait();
if (result.get() == ButtonType.OK){
DirectoryChooser directoryChooser = new DirectoryChooser();
File selectedDirectory =
directoryChooser.showDialog(primaryStage);
path = selectedDirectory.getAbsolutePath();
} else {
path = "";
}
return path;
}
//lädt die einstellungen aus der XML
public void loadSettings(){
File configFile = new File("config.xml");
try {
InputStream inputStream = new FileInputStream(configFile);
props.loadFromXML(inputStream);
path = props.getProperty("path");
color = props.getProperty("color");
autoUpdate = props.getProperty("autoUpdate");
size = Double.parseDouble(props.getProperty("size"));
local = Integer.parseInt(props.getProperty("local"));
inputStream.close();
} catch (IOException e) {
// Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
}

+ 37
- 0
src/application/MainWindow.fxml View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import com.jfoenix.controls.JFXButton?>
<?import com.jfoenix.controls.JFXTextArea?>
<?import com.jfoenix.controls.JFXTextField?>
<?import javafx.scene.control.TreeTableView?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>
<?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">
<children>
<VBox fx:id="topVBox" prefHeight="32.0" prefWidth="800.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<JFXButton fx:id="menubtn" onAction="#menubtnclicked" prefHeight="32.0" prefWidth="67.0" text="Menu" />
</children>
</VBox>
<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" />
<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" />
<JFXButton fx:id="playbtn" layoutX="690.0" layoutY="363.0" onAction="#playbtnclicked" prefHeight="25.0" prefWidth="198.0" text="play" AnchorPane.bottomAnchor="212.0" AnchorPane.rightAnchor="12.0">
<font>
<Font name="System Bold" size="14.0" />
</font></JFXButton>
<JFXButton fx:id="openfolderbtn" layoutX="690.0" layoutY="404.0" onAction="#openfolderbtnclicked" prefHeight="25.0" prefWidth="198.0" text="open Folder" AnchorPane.bottomAnchor="171.0" AnchorPane.rightAnchor="12.0">
<font>
<Font name="System Bold" size="14.0" />
</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">
<font>
<Font name="Arial" size="12.0" />
</font></JFXTextField>
<ImageView fx:id="image1" fitHeight="297.0" fitWidth="198.0" layoutX="481.0" layoutY="46.0" pickOnBounds="true" preserveRatio="true" AnchorPane.rightAnchor="12.0" AnchorPane.topAnchor="44.0" />
<JFXButton fx:id="returnBtn" layoutX="690.0" layoutY="443.0" onAction="#returnBtnclicked" prefHeight="25.0" prefWidth="90.0" text="&lt;&lt;" AnchorPane.bottomAnchor="132.0" AnchorPane.rightAnchor="120.0" />
<JFXButton fx:id="forwardBtn" layoutX="798.0" layoutY="443.0" onAction="#forwardBtnclicked" prefHeight="25.0" prefWidth="90.0" text="&gt;&gt;" AnchorPane.bottomAnchor="132.0" AnchorPane.rightAnchor="12.0" />
</children>
</AnchorPane>

+ 854
- 0
src/application/MainWindowController.java View File

@ -0,0 +1,854 @@
/**
* Project HomeFlix
*
* Copyright 2016 <admin@kellerkinder>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*/
package application;
import java.awt.Desktop;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.math.BigInteger;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.Locale;
import java.util.Properties;
import java.util.ResourceBundle;
import java.util.Scanner;
import com.eclipsesource.json.Json;
import com.eclipsesource.json.JsonObject;
import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXColorPicker;
import com.jfoenix.controls.JFXDialog;
import com.jfoenix.controls.JFXSlider;
import com.jfoenix.controls.JFXTextArea;
import com.jfoenix.controls.JFXTextField;
import com.jfoenix.controls.JFXToggleButton;
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.beans.property.ReadOnlyStringWrapper;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.geometry.Insets;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Label;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeTableColumn;
import javafx.scene.control.TreeTableColumn.CellDataFeatures;
import javafx.scene.control.TreeTableView;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.stage.DirectoryChooser;
public class MainWindowController {
@FXML
private AnchorPane anpane;
@FXML
private AnchorPane settingsan = new AnchorPane();
@FXML
private VBox topVBox;
@FXML
private VBox menuBox = new VBox();
@FXML
private VBox settingsBox = new VBox();
@FXML
private TreeTableView<uiData> treeTableViewfilm;
@FXML
private JFXTextArea ta1;
@FXML
private JFXButton menubtn;
@FXML
private JFXButton playbtn;
@FXML
private JFXButton openfolderbtn;
@FXML
private JFXButton returnBtn;
@FXML
private JFXButton forwardBtn;
@FXML
private JFXButton infoBtn = new JFXButton("Info");
@FXML
private JFXButton demoBtn = new JFXButton("Beheben");
@FXML
private JFXButton settingsBtn = new JFXButton("Settings");
@FXML
private JFXButton updateBtn = new JFXButton("Auf Update prüfen");
@FXML
private JFXButton directoryBtn = new JFXButton("Ordner auswählen");
@FXML
private JFXToggleButton autoupdateBtn = new JFXToggleButton();
@FXML
public JFXTextField tfPfad = new JFXTextField();
@FXML
private JFXTextField tfsearch;
@FXML
public JFXColorPicker mainColor = new JFXColorPicker();
@FXML
public ChoiceBox<String> cbLocal = new ChoiceBox<String>();
@FXML
public JFXSlider sl1 = new JFXSlider();
@FXML
private JFXDialog dialog = new JFXDialog();
@FXML
private Label versionlbl = new Label();
@FXML
private Label sizelbl = new Label("Schriftgröße:");
@FXML
private Label aulbl = new Label("beim starten nach Updates suchen:");
@FXML
private ImageView image1;
@FXML
TreeItem<uiData> root = new TreeItem<>(new uiData(1.0, "filme","1"));
@FXML
TreeTableColumn<uiData, Double> columnRating = new TreeTableColumn<>("Bewertung");
@FXML
TreeTableColumn<uiData, String> columnName = new TreeTableColumn<>("Name");
@FXML
TreeTableColumn<uiData, String> columnDatName = new TreeTableColumn<>("Datei Name");
private boolean menutrue = false; //merker für menubtn (öffnen oder schließen)
private boolean settingstrue = false;
private String version = "0.3.5";
private String versionURL = "https://raw.githubusercontent.com/Seil0/Project-HomeFlix/master/version";
private String downloadLink = "";
private String updateDataURL = "https://raw.githubusercontent.com/Seil0/Project-HomeFlix/master/ProjectHomeFlix.jar";
private String errorUpdate;
private String infoText;
private String aktVersion;
private String path;
private String color;
private String Name;
private String datPath;
private String autoUpdate;
private double size;
private int last;
private int selected;
private int next;
private int local;
private File selectedFolder;
private ResourceBundle bundle;
private ObservableList<uiData> newDaten = FXCollections.observableArrayList();
private ObservableList<uiData> filterData = FXCollections.observableArrayList();
private ObservableList<String> locals = FXCollections.observableArrayList("english", "deutsch");
private Image imHF = new Image("Homeflix_Poster.png");
private ImageView menu_icon_black = new ImageView(new Image("menu_icon_black.png"));
// private ImageView menu_icon_white = new ImageView(new Image("menu_icon_white.png"));
private DirectoryChooser directoryChooser = new DirectoryChooser();
Properties props = new Properties();
//wenn menubtn clicked
/**
* TODO fix directory bug under linux
* TODO change value of Text-color change
* TODO menu icon white
*/
@FXML
private void menubtnclicked(){
if(menutrue == false){
anpane.getChildren().addAll(menuBox);
//infobtn clicked
infoBtn.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent event) {
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("Info");
alert.setHeaderText("Project HomeFlix");
alert.setContentText(infoText);
alert.showAndWait();
}
});
//setteingsbtn clicked, deklarieren der actions der Objekte die bei settingsbtn angezeigt werden
settingsBtn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event){
if(settingstrue == false){
anpane.getChildren().addAll(settingsBox);
tfPfad.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent event){
setPath(tfPfad.getText());
saveSettings();
}
});
directoryBtn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event){
selectedFolder = directoryChooser.showDialog(null);
if(selectedFolder == null){
System.out.println("No Directory selected");
}else{
setPath(selectedFolder.getAbsolutePath());
saveSettings();
tfPfad.setText(getPath());
try {
Runtime.getRuntime().exec("java -jar ProjectHomeFlix.jar"); //starte neu
System.exit(0); //beendet sich selbst
} catch (IOException e) {
System.out.println("es ist ein Fehler aufgetreten");
e.printStackTrace();
}
}
}
});
mainColor.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent event){
editColor(mainColor.getValue().toString());
applyColor();
}
});
sl1.valueProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> ov,Number old_val, Number new_val) {
setSize(sl1.getValue());
ta1.setFont(Font.font("System", size));
saveSettings();
}
});
//updater
updateBtn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event){
update();
}
});
autoupdateBtn.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent event) {
if(autoUpdate.equals("0")){
setAutoUpdate("1");
saveSettings();
}else{
setAutoUpdate("0");
saveSettings();
}
}
});
settingstrue = true;
}else{
anpane.getChildren().removeAll(settingsBox);
setPath(tfPfad.getText());
saveSettings();
settingstrue = false;
}
}
});
//demoBtn clicked
demoBtn.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent event) {
/**
* TODO DBController
*/
// loadData();
}
});
menutrue = true;
}else{
anpane.getChildren().removeAll(menuBox);
menutrue = false;
}
if(settingstrue == true){
anpane.getChildren().removeAll(settingsBox);
setPath(tfPfad.getText());
saveSettings();
settingstrue = false;
}
}
@FXML
private void playbtnclicked(){
try {
Desktop.getDesktop().open(new File(getPath()+"\\"+ datPath)); //öffnt die aktuell ausgewählte Datei
} catch (IOException e) {
// Auto-generated catch block
e.printStackTrace();
}
}
@FXML
private void openfolderbtnclicked(){
try {
Desktop.getDesktop().open(new File(getPath())); //öffnet den aktuellen Pfad
} catch (IOException e) {
// Auto-generated catch block
e.printStackTrace();
}
}
@FXML
private void returnBtnclicked(){
treeTableViewfilm.getSelectionModel().select(last);
}
@FXML
private void forwardBtnclicked(){
treeTableViewfilm.getSelectionModel().select(next);
}
//"Main" Methode die beim start von der Klasse Main aufgerufen wird, initialiesirung der einzellnen UI-Objekte
@SuppressWarnings({ "static-access"})
public void setMain(Main main) {
loadSettings();
initTabel();
infoBtn.setPrefWidth(130);
infoBtn.setPrefHeight(32);
infoBtn.setFont(Font.font("System", FontWeight.BOLD, 15));
settingsBtn.setPrefWidth(130);
settingsBtn.setPrefHeight(32);
settingsBtn.setFont(Font.font("System", FontWeight.BOLD, 15));
demoBtn.setPrefWidth(130);
demoBtn.setPrefHeight(32);
demoBtn.setFont(Font.font("System", FontWeight.BOLD, 15));
demoBtn.setDisable(false);
menubtn.setText("");
menubtn.setMaxSize(32, 32);
tfPfad.setPrefWidth(250);
tfPfad.setPromptText("Pfad");
tfPfad.setText(getPath());
sl1.setMaxWidth(250);
sl1.setMin(2);
sl1.setMax(48);
sl1.setValue(getSize());
cbLocal.setItems(locals);
updateBtn.setFont(Font.font("System", 12));
directoryBtn.setFont(Font.font("System", 12));
directoryBtn.setMaxSize(180, 25);
if(autoUpdate.equals("1")){
autoupdateBtn.setSelected(true);
update();
}else{
autoupdateBtn.setSelected(false);
}
versionlbl.setText("Version: "+version);
menuBox.setSpacing(2.5); //Zeilenabstand
menuBox.setPadding(new Insets(2.5,0,0,2.5)); // abstand zum Rand
menuBox.getChildren().addAll(infoBtn, settingsBtn,demoBtn);
menuBox.setFillWidth(true);
AnchorPane.setTopAnchor(menuBox, 33d);
AnchorPane.setBottomAnchor(menuBox, 0d);
settingsBox.setStyle("-fx-background-color: #FFFFFF;");
settingsBox.getChildren().add(settingsan);
settingsan.getChildren().addAll(tfPfad, directoryBtn, mainColor, sizelbl, sl1, cbLocal, updateBtn, aulbl, autoupdateBtn, versionlbl);
settingsan.setTopAnchor(tfPfad, 5d);
settingsan.setLeftAnchor(tfPfad, 5d);
settingsan.setTopAnchor(directoryBtn, 5d);
settingsan.setLeftAnchor(directoryBtn, 260d);
settingsan.setTopAnchor(mainColor, 40d);
settingsan.setLeftAnchor(mainColor, 5d);
settingsan.setTopAnchor(sizelbl, 75d);
settingsan.setLeftAnchor(sizelbl, 5d);
settingsan.setTopAnchor(sl1, 110d);
settingsan.setLeftAnchor(sl1, 5d);
settingsan.setTopAnchor(cbLocal, 145d);
settingsan.setLeftAnchor(cbLocal, 5d);
settingsan.setTopAnchor(updateBtn, 180d);
settingsan.setLeftAnchor(updateBtn, 5d);
settingsan.setTopAnchor(aulbl, 215d);
settingsan.setLeftAnchor(aulbl, 5d);
settingsan.setTopAnchor(autoupdateBtn, 230d);
settingsan.setLeftAnchor(autoupdateBtn, 5d);
settingsan.setTopAnchor(versionlbl, 280d);
settingsan.setLeftAnchor(versionlbl, 5d);
AnchorPane.setTopAnchor(settingsBox, 34d);
AnchorPane.setRightAnchor(settingsBox, 0d);
AnchorPane.setBottomAnchor(settingsBox, 0d);
AnchorPane.setLeftAnchor(settingsBox, 130d);
ta1.setWrapText(true);
ta1.setEditable(false);
ta1.setFont(Font.font("System", getSize()));
image1.setImage(imHF);
tfsearch.textProperty().addListener(new ChangeListener<String>() {
@SuppressWarnings("unchecked")
@Override
public void changed(ObservableValue<? extends String> observable,String oldValue, String newValue) {
int counter = newDaten.size();
filterData.removeAll(filterData);
root.getChildren().remove(0,root.getChildren().size());
for(int i = 0; i < counter; i++){
if(newDaten.get(i).getFilmName().toLowerCase().contains(tfsearch.getText().toLowerCase())){
filterData.add(newDaten.get(i));
}
}
for(int i = 0; i < filterData.size(); i++){
root.getChildren().addAll(new TreeItem<uiData>(filterData.get(i))); //fügt daten zur Rootnode hinzu
}
}
});
cbLocal.getSelectionModel().selectedIndexProperty()
.addListener(new ChangeListener<Number>() {
public void changed(ObservableValue<? extends Number> ov, Number value, Number new_value) {
setLocal(new_value.intValue());
setLoaclUI(local);
saveSettings();
}
});
}
//initialisierung der TreeTabelView
@SuppressWarnings("unchecked")
private void initTabel(){
root.setExpanded(true);
columnRating.setMaxWidth(120);
columnName.setMaxWidth(240);
columnDatName.setMaxWidth(0);
treeTableViewfilm.setRoot(root);
treeTableViewfilm.setColumnResizePolicy( TreeTableView.CONSTRAINED_RESIZE_POLICY );
treeTableViewfilm.setShowRoot(false);
//inhalt in Zelle schreiben
columnName.setCellValueFactory((CellDataFeatures<uiData, String> p) ->
new ReadOnlyStringWrapper(p.getValue().getValue().getFilmName()));
columnRating.setCellValueFactory((CellDataFeatures<uiData, Double> p) ->
new ReadOnlyObjectWrapper<Double>(p.getValue().getValue().getFilmBewertung()));
columnDatName.setCellValueFactory((CellDataFeatures<uiData, String> p) ->
new ReadOnlyStringWrapper(p.getValue().getValue().getDataName()));
treeTableViewfilm.getColumns().addAll(columnName, columnRating, columnDatName);
//Changelistener für TreeTable
treeTableViewfilm.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Object>() {
@Override
public void changed(ObservableValue<?> observable, Object oldVal, Object newVal) {
// last = selected; //für autoplay
selected = treeTableViewfilm.getSelectionModel().getSelectedIndex(); // holt aktuelles Item
last = selected - 1;
next = selected + 1;
Name = columnName.getCellData(selected); // holt Namen des Aktuelle Items aus der ColumnName
datPath = columnDatName.getCellData(selected); // holt den aktuellen Datei Pfad aus der ColumnDatName
ta1.setText(""); // löscht Text in ta1
apiAbfrage(Name); // startet die api abfrage
ta1.positionCaret(0); // setzt die startposition des Cursors in
// ta1
}
});
treeTableViewfilm.getColumns().get(2).setVisible(false); //blendet die Column mit den Dateinamen aus (wichtig um sie abzuspielen)
}
//prüft auf Update und füht es gegebenenfalls aus
private void update(){
System.out.println("check for updates ...");
try {
URL url = new URL(versionURL); //URL der Datei mit aktueller Versionsnummer
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
aktVersion = in.readLine(); //schreibt inputstream in String
in.close();
} catch (IOException e1) {
// Auto-generated catch block
e1.printStackTrace();
}
System.out.println("Version: "+version+", Update: "+aktVersion);
//vergleicht die Versionsnummern, bei aktversion > version wird ein Update durchgrführt
int iversion = Integer.parseInt(version.replace(".", ""));
int iaktVersion = Integer.parseInt(aktVersion.replace(".", ""));
if(iversion >= iaktVersion){
updateBtn.setText("kein Update verfügbar");
System.out.println("kein Update verfügbar");
}else{
updateBtn.setText("Update verfügbar");
System.out.println("Update verfügbar");
try {
URL website;
URL downloadURL = new URL(downloadLink);
BufferedReader in = new BufferedReader(new InputStreamReader(downloadURL.openStream()));
//updateDataURL = in.readLine();
website = new URL(updateDataURL); //Update URL
ReadableByteChannel rbc = Channels.newChannel(website.openStream()); //öffnet neuen Stream/Channel
FileOutputStream fos = new FileOutputStream("ProjectHomeFlix.jar"); //neuer fileoutputstram für ProjectHomeFLix.jar
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); //holt datei von 0 bis max größe
fos.close(); //schließt den fos (extrem wichtig!)
Runtime.getRuntime().exec("java -jar ProjectHomeFlix.jar"); //starte neu
System.exit(0); //beendet sich selbst
} catch (IOException e) {
//Falls ein Fehler auftritt (ungetestet)
e.printStackTrace();
Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("Error");
alert.setHeaderText("");
alert.setContentText(errorUpdate);
alert.showAndWait();
e.printStackTrace();
}
}
}
//lädt die Daten im angegeben Ordner in newDaten
public void loadData(){
if(getPath().equals("")||getPath().equals(null)){
System.out.println("Kein Pfad angegeben"); //falls der Pfad null oder "" ist
}else{
String[] entries = new File(getPath()).list();
for(int i = 0; i < entries.length; i++){
String titel = ohneEndung(entries[i]);
String data = entries[i];
newDaten.add(new uiData(5.0, titel ,data));
}
for(int i = 0; i < newDaten.size(); i++){
root.getChildren().add(new TreeItem<uiData>(newDaten.get(i))); //fügt daten zur Rootnode hinzu
}
}
}
//entfernt die Endung vom String
private String ohneEndung (String str) {
if (str == null) return null;
int pos = str.lastIndexOf(".");
if (pos == -1) return str;
return str.substring(0, pos);
}
//setzt die Farben für die UI-Elemente
public void applyColor(){
String style = "-fx-background-color: #"+getColor()+";";
String btnStyle = "-fx-button-type: RAISED; -fx-background-color: #"+getColor()+"; -fx-text-fill: BLACK;";
String btnStylewhite = "-fx-button-type: RAISED; -fx-background-color: #"+getColor()+"; -fx-text-fill: WHITE;";
BigInteger icolor = new BigInteger(getColor(),16);
BigInteger ccolor = new BigInteger("78909cff",16);
menuBox.setStyle(style);
topVBox.setStyle(style);
tfsearch.setFocusColor(Color.valueOf(getColor()));
tfPfad.setFocusColor(Color.valueOf(getColor()));
if(icolor.compareTo(ccolor) == -1){
settingsBtn.setStyle("-fx-text-fill: WHITE;");
infoBtn.setStyle("-fx-text-fill: WHITE;");
demoBtn.setStyle("-fx-text-fill: WHITE;");
directoryBtn.setStyle(btnStylewhite);
updateBtn.setStyle(btnStylewhite);
playbtn.setStyle(btnStylewhite);
openfolderbtn.setStyle(btnStylewhite);
returnBtn.setStyle(btnStylewhite);
forwardBtn.setStyle(btnStylewhite);
//TODO menubtn.setGraphic(menu_icon_white);
menubtn.setGraphic(menu_icon_black);
}else{
settingsBtn.setStyle("-fx-text-fill: BLACK;");
infoBtn.setStyle("-fx-text-fill: BLACK;");
demoBtn.setStyle("-fx-text-fill: BLACK;");
directoryBtn.setStyle(btnStyle);
updateBtn.setStyle(btnStyle);
playbtn.setStyle(btnStyle);
openfolderbtn.setStyle(btnStyle);
returnBtn.setStyle(btnStyle);
forwardBtn.setStyle(btnStyle);
menubtn.setGraphic(menu_icon_black);
}
}
public void setLoaclUI(int local){
switch(local){
case 0: bundle = ResourceBundle.getBundle("application.HomeFlix-Local", Locale.US); //us_english
break;
case 1: bundle = ResourceBundle.getBundle("application.HomeFlix-Local", Locale.GERMAN); //german
break;
default:bundle = ResourceBundle.getBundle("application.HomeFlix-Local", Locale.US); //default local
break;
}
settingsBtn.setText(bundle.getString("settings"));
infoBtn.setText(bundle.getString("info"));
playbtn.setText(bundle.getString("play"));
openfolderbtn.setText(bundle.getString("openFolder"));
sizelbl.setText(bundle.getString("fontSize"));
updateBtn.setText(bundle.getString("checkUpdates"));
aulbl.setText(bundle.getString("autoUpdate"));
versionlbl.setText(bundle.getString("version")+" "+version);
columnName.setText(bundle.getString("columnName"));
columnRating.setText(bundle.getString("columnRating"));
columnDatName.setText(bundle.getString("columnDatName"));
errorUpdate = bundle.getString("errorUpdate");
infoText = bundle.getString("version")+" "+version+bundle.getString("infoText");
}
//speichert die Einstellungen
public void saveSettings(){
File configFile = new File("config.xml"); //neue Datei "config.xml"
try {
props.setProperty("path", getPath()); //setzt pfad in propselement
props.setProperty("color", getColor());
props.setProperty("autoUpdate", getAutoUpdate());
props.setProperty("size", getSize().toString());
props.setProperty("local", Integer.toString(getLocal()));
OutputStream outputStream = new FileOutputStream(configFile); //neuer outputstream
props.storeToXML(outputStream, "Project HomeFlix settings");
outputStream.close();
} catch (IOException e) {
System.out.println("An error has occurred!");
e.printStackTrace();
}
}
//lädt die Einstellungen
public void loadSettings(){
File configFile = new File("config.xml");
try {
InputStream inputStream = new FileInputStream(configFile);
props.loadFromXML(inputStream);
path = props.getProperty("path"); //setzt Propselement in Pfad
color = props.getProperty("color");
size = Double.parseDouble(props.getProperty("size"));
autoUpdate = props.getProperty("autoUpdate");
local = Integer.parseInt(props.getProperty("local"));
inputStream.close();
} catch (IOException e) {
System.out.println("An error has occurred!");
e.printStackTrace();
}
}
//getter Und setter
public void setColor(String input){
this.color = input;
}
public String getColor(){
return color;
}
//entfernt 0x von dem rückgabe wert des Colorpickers
private void editColor(String input){
StringBuilder sb = new StringBuilder(input);
sb.delete(0, 2);
this.color = sb.toString();
saveSettings();
}
public void setPath(String input){
this.path = input;
}
public String getPath(){
return path;
}
public void setSize(Double input){
this.size = input;
}
public Double getSize(){
return size;
}
public void setAutoUpdate(String input){
this.autoUpdate = input;
}
public String getAutoUpdate(){
return autoUpdate;
}
public void setLocal(int input){
this.local = input;
}
public int getLocal(){
return local;
}
//methode der API-Abfrage
@SuppressWarnings("deprecation")
private void apiAbfrage(String input){
URL url = null;
Scanner sc = null;
String apiurl = "https://www.omdbapi.com/?"; //API URL
String moviename = null;
String dataurl = null;
String retdata = null;
InputStream is = null;
DataInputStream dis = null;
try {
// hohlen des Filmtitels
sc = new Scanner(System.in);
moviename = input;
// für keinen oder "" Filmtitel
if (moviename == null || moviename.equals("")) {
System.out.println("No movie found");
}
//entfernen ungewolter leerzeichen
moviename = moviename.trim();
// ersetzen der Leerzeichen durch + für api-abfrage
moviename = moviename.replace(" ", "+");
//URL wird zusammengestellt abfragetypen: http,json,xml (muss json sein um späteres trennen zu ermöglichen)
dataurl = apiurl + "t=" + moviename + "&plot=full&r=json";
url = new URL(dataurl);
is = url.openStream();
dis = new DataInputStream(is);
// lesen der Daten aus dem Antwort Stream
while ((retdata = dis.readLine()) != null) {
//retdata in json object parsen und anschließend das json Objekt "zerschneiden"
System.out.println(retdata);
JsonObject object = Json.parse(retdata).asObject();
String titel = object.getString("Title", "");
String year = object.getString("Year", "");
String rated = object.getString("Rated", "");
String released = object.getString("Released", "");
String runtime = object.getString("Runtime", "");
String genre = object.getString("Genre", "");
String director = object.getString("Director", "");
String writer = object.getString("Writer", "");
String actors = object.getString("Actors", "");
String plot = object.getString("Plot", "");
String language = object.getString("Language", "");
String country = object.getString("Country", "");
String awards = object.getString("Awards", "");
String posterURL = object.getString("Poster", "");
String metascore = object.getString("Metascore", "");
String imdbRating = object.getString("imdbRating", "");
@SuppressWarnings("unused")
String imdbVotes = object.getString("imdbVotes", "");
@SuppressWarnings("unused")
String imdbID = object.getString("imdbID", "");
String type = object.getString("Type", "");
String response = object.getString("Response", "");
if(response.equals("False")){
ta1.appendText("Kein Film mit diesem Titel gefunden!");
Image im2 = new Image("http://publicdomainvectors.org/photos/jean_victor_balin_cross.png");
image1.setImage(im2);
}else{
//ausgabe des Textes in ta1 in jeweils neuer Zeile
ta1.appendText("Titel: "+titel+"\n");
ta1.appendText("Jahr: "+ year+"\n");
ta1.appendText("Einstufung: "+rated+"\n");
ta1.appendText("Veröffentlicht am: "+released+"\n");
ta1.appendText("Laufzeit: "+runtime+"\n");
ta1.appendText("Genre: "+genre+"\n");
ta1.appendText("Regisseur: "+director+"\n");
ta1.appendText("Autor: "+writer+"\n");
ta1.appendText("Schauspieler: "+actors+"\n");
ta1.appendText("Beschreibung: "+plot+"\n");
ta1.appendText("Original Sprache: "+language+"\n");
ta1.appendText("Produktionsland: "+country+"\n");
ta1.appendText("Auszeichnungen: "+awards+"\n");
ta1.appendText("Metascore: "+metascore+"\n");
ta1.appendText("imdb Bewertung: "+imdbRating+"\n");
ta1.appendText("Type: "+type+"\n");
Image im1 = new Image(posterURL);
image1.setImage(im1);
}
}
} catch (Exception e) {
System.out.println(e);
} finally {
try {
//schließt datainputStream, InputStream,Scanner
if (dis != null) {
dis.close();
}
if (is != null) {
is.close();
}
if (sc != null) {
sc.close();
}
} catch (Exception e2) {
;
}
}
}
}

+ 1
- 0
src/application/application.css View File

@ -0,0 +1 @@
/* JavaFX CSS - Leave this comment until you have at least create one rule which uses -fx-Property */

+ 57
- 0
src/application/uiData.java View File

@ -0,0 +1,57 @@
package application;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
public class uiData {
private DoubleProperty filmBewertung = new SimpleDoubleProperty();
private StringProperty filmName = new SimpleStringProperty();
private StringProperty dataName = new SimpleStringProperty();
//uiData ist der Typ der Daten in der TreeTabelView
public uiData (final Double filmBewertung, final String filmName, final String dataName) {
this.filmBewertung.set(filmBewertung);
this.filmName.set(filmName);
this.dataName.set(dataName);
}
public Double getFilmBewertung() {
return filmBewertung.get();
}
public String getFilmName() {
return filmName.get();
}
public String getDataName() {
return dataName.get();
}
public void setFilmBewertung(Double filmBewertung) {
this.filmBewertung.set(filmBewertung);
}
public void setFilmName(String filmName) {
this.filmName.set(filmName);
}
public void setDataName(StringProperty dataName) {
this.dataName = dataName;
}
public DoubleProperty FilmBewertungProperty(){
return filmBewertung;
}
public StringProperty FilmNameProperty(){
return filmName;
}
public StringProperty DataNameProperty(){
return dataName;
}
}

BIN
src/menu_icon_black.png View File

Before After
Width: 30  |  Height: 30  |  Size: 14 KiB

Loading…
Cancel
Save