Browse Source

DataBaseConnector integration

toomanysugar 4 years ago
parent
commit
48983cc73b

+ 1 - 0
.idea/libraries/lib.xml

@@ -2,6 +2,7 @@
   <library name="lib">
     <CLASSES>
       <root url="file://$PROJECT_DIR$/javafx-sdk-11.0.2/lib" />
+      <root url="jar://$PROJECT_DIR$/src/com/moviesdb/mysql-connector-java-8.0.25.jar!/" />
     </CLASSES>
     <JAVADOC />
     <SOURCES>

+ 3 - 0
.idea/misc.xml

@@ -3,6 +3,9 @@
   <component name="ProjectKey">
     <option name="state" value="project://e79810c8-c5c8-43b1-b19c-90c1f4095425" />
   </component>
+  <component name="ProjectPlainTextFileTypeManager">
+    <file url="file://$PROJECT_DIR$/src/com/moviesdb/movie.hbm.xml" />
+  </component>
   <component name="ProjectRootManager" version="2" languageLevel="JDK_16" default="true" project-jdk-name="16" project-jdk-type="JavaSDK">
     <output url="file://$PROJECT_DIR$/out" />
   </component>

+ 9 - 0
JavaFxApplication.iml

@@ -8,5 +8,14 @@
     <orderEntry type="inheritedJdk" />
     <orderEntry type="sourceFolder" forTests="false" />
     <orderEntry type="library" name="lib" level="project" />
+    <orderEntry type="module-library" exported="">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/src/com/moviesdb/mysql-connector-java-8.0.25.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
   </component>
 </module>

BIN
out/production/JavaFxApplication/com/moviesdb/Controller.class


BIN
out/production/JavaFxApplication/com/moviesdb/Main.class


+ 12 - 11
src/com/moviesdb/Controller.java

@@ -15,6 +15,7 @@ import javafx.scene.control.Alert.AlertType;
 import com.moviesdb.Movie;
 import javafx.scene.text.Text;
 import javafx.scene.text.TextFlow;
+import com.moviesdb.DataBaseConnector;
 
 import java.awt.event.MouseEvent;
 import java.time.chrono.AbstractChronology;
@@ -39,16 +40,18 @@ public class Controller {
 
 
     Label[] movies;
-
     Movie my_movie;
+    DataBaseConnector my_connector;
+
+
+    public void initialize(){
+        my_connector = new DataBaseConnector();
+        my_connector.initConnection("d","1");
+    }
 
     public void loadPosters()
     {
-        my_movie = new Movie();
-        my_movie.setName("Back to the Future");
-        my_movie.setDuration("1:20");
-        my_movie.setDescription("The CSS styles for text input controls such as TextField for JavaFX 8 are defined in the modena.css stylesheet as below. Create a custom CSS stylesheet and modify the colors as you wish. Use the CSS reference guide if you need help understanding the syntax and available attributes and values.");
-        //my_movie.setCover("https://m.media-amazon.com/images/M/MV5BZmU0M2Y1OGUtZjIxNi00ZjBkLTg1MjgtOWIyNThiZWIwYjRiXkEyXkFqcGdeQXVyMTQxNzMzNDI@._V1_UX182_CR0,0,182,268_AL_.jpg");
+        detailsPane.setMinWidth(300);
         //get movies array
         movies = new Label[10];
         //change grid size for number of movies
@@ -63,7 +66,7 @@ public class Controller {
             GridPane.setHalignment(movies[i], HPos.CENTER);
             Label movie = movies[i];
             movies[i].setOnMouseClicked(e-> {
-            openDetails(movie);
+                openDetails(movie);
             });
         }
         //moviesGrid.setPrefWidth(scrollPane.getWidth());
@@ -98,6 +101,8 @@ public class Controller {
 
             detailsPane.setMinWidth(300);
 
+            my_movie= my_connector.getMovieInfo(1);
+
             //detailsContent.Text(my_movie.name() + "\n" + my_movie.year() + "\n" + my_movie.duration() + "\n" +  my_movie.genre() + "\n" + my_movie.description());
             Text info = new Text("Name:\n    " + my_movie.name() + "\n" +
                                     "Year: \n    " + my_movie.year() + "\n" +
@@ -107,10 +112,6 @@ public class Controller {
             info.setStyle("-fx-font-size: 14; -fx-fill: #9f9f9f;");
             detailsContent.getChildren().clear();
             detailsContent.getChildren().add(info);
-            //detailsContent.setText(my_movie.year());
-            //detailsContent.setText(my_movie.duration());
-            //detailsContent.setText(my_movie.genre());
-            //detailsContent.setText(my_movie.description());
 
             detailsPicPane.getChildren().clear();
             //detailsPane.setMaxWidth(300);

+ 1 - 0
src/com/moviesdb/Main.java

@@ -22,6 +22,7 @@ public class Main extends Application {
         primaryStage.setOnShown(new EventHandler<WindowEvent>() {
             @Override
             public void handle(WindowEvent event) {
+                controller.initialize();
                 controller.loadPosters();
             }
         });