Skip to content

Commit

Permalink
++edit gets to the right page
Browse files Browse the repository at this point in the history
  • Loading branch information
bopojoe committed Dec 31, 2017
1 parent 5819d80 commit aeaa47f
Show file tree
Hide file tree
Showing 12 changed files with 167 additions and 31 deletions.
3 changes: 3 additions & 0 deletions src/project/Controller/ControllerAdd.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,7 @@ private void handleButtonAction(ActionEvent event) throws IOException {
stage.setScene(scene);
stage.show();
}



}
41 changes: 34 additions & 7 deletions src/project/Controller/ControllerResults.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import javafx.scene.Parent;
import javafx.scene.Scene;
import project.Movie;
import project.MovieList;

import java.io.IOException;
import java.net.URL;
Expand All @@ -30,13 +31,13 @@ public class ControllerResults implements Initializable {
private Label exit;

@FXML
private Button btn1;
private Button btn1, changeBtn;
@FXML
private Button btn2;
@FXML
private Label year1, runtime1, plot1, url1, mTitle1, name1 ,age1, gender1, nationality1;
@FXML
private TextField year2, runtime2, plot2, url2, mTitle2;
private TextField year2, runtime2, plot2, url2, mTitle2, sName, sAge, sGender, sNationality;


@FXML
Expand All @@ -47,6 +48,23 @@ private void handleClose(MouseEvent event) {
}
}

@FXML
private void handleButtonChange(ActionEvent event) throws IOException {
Movie movie = ControllerSearchMovie.savedMovie;
MovieList.removeMovie(movie);
String title = this.mTitle2.getText();
int year = Integer.parseInt(this.year2.getText());
int runtime = Integer.parseInt(this.runtime2.getText());
String plot = this.plot2.getText();
String url = this.url2.getText();
MovieList.addMovie(title, year, runtime, plot, url);

Stage stage = (Stage) changeBtn.getScene().getWindow();
// do what you have to do
stage.close();

}

public void handle(ActionEvent event){

}
Expand Down Expand Up @@ -81,14 +99,15 @@ public void initialize(URL location, ResourceBundle resources) {
String title = ControllerSearchMovie.savedMovie.getTitle();
String plot = ControllerSearchMovie.savedMovie.getPlot();
String url = ControllerSearchMovie.savedMovie.getImgUrl();
try {
try{
mTitle1.setText(title);
plot1.setText(plot);
url1.setText(url);
year1.setText(year);
runtime1.setText(runt);
} catch (NullPointerException e) {test = true;}
if (test){

mTitle2.setText(title);
plot2.setText(plot);
url2.setText(url);
Expand All @@ -100,10 +119,18 @@ public void initialize(URL location, ResourceBundle resources) {
String age = Integer.toString(ControllerSearchActor.savedActor.getAge());
String gender = ControllerSearchActor.savedActor.getGender();
String nationality = ControllerSearchActor.savedActor.getNationality();
name1.setText(name);
age1.setText(age);
gender1.setText(gender);
nationality1.setText(nationality);
try {
name1.setText(name);
age1.setText(age);
gender1.setText(gender);
nationality1.setText(nationality);
}catch (NullPointerException e) {test = true;}
if (test) {
sName.setText(name);
sAge.setText(age);
sGender.setText(gender);
sNationality.setText(nationality);
}
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/project/Controller/ControllerSearch.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private void handleButtonAction(ActionEvent event) throws IOException {
private void handleButtonActor(ActionEvent event) throws IOException {
Parent root;
Stage stage;
stage = (Stage) btn2.getScene().getWindow();
stage = (Stage) btn22.getScene().getWindow();
root = FXMLLoader.load(getClass().getResource("../View/EditActor.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
Expand Down
81 changes: 79 additions & 2 deletions src/project/Controller/ControllerSearchActor.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import project.IODriver;
import project.LinkedList;
import project.Main;
import project.Actor;

import java.io.IOException;

Expand Down Expand Up @@ -90,7 +89,7 @@ private void handleButtonOne(ActionEvent event) throws IOException {
private void handleButtonTwo(ActionEvent event) throws IOException {
int age;
if (sAge != null) {
boolean check = Main.parceCheck(sAge.getText());
boolean check = Main.parseCheck(sAge.getText());
if (check) {
age = Integer.parseInt(sAge.getText());
if (age != 0) {
Expand Down Expand Up @@ -146,4 +145,82 @@ private void multiList(LinkedList.DataLink data) throws IOException {
data = data.nextDataLink;
}
}

private void multiListEdit(LinkedList.DataLink data) throws IOException {
while(data.nextDataLink!=null){
savedActor = (Actor)data.nextDataLink.data;
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("../View/EditActorResult.fxml"));
Parent root1 = (Parent) fxmlLoader.load();
Stage stage = new Stage();
stage.setTitle("Better IMDB");
stage.setScene(new Scene(root1));
stage.getIcons().add(new Image("@../../home-page.png"));
stage.show();
data = data.nextDataLink;
}
}



@FXML
private void handleButtonName(ActionEvent event) throws IOException {
String name;
if (sName != null) {
name = sName.getText();
LinkedList<Actor> returnedActorList = IODriver.nameSearch(name);
LinkedList.DataLink head = returnedActorList.header;
multiListEdit(head);} else {
System.out.println("Please Enter a valid search for name");
}


}

@FXML
private void handleButtonAge(ActionEvent event) throws IOException {
int age;
if (sAge != null) {
boolean check = Main.parseCheck(sAge.getText());
if (check) {
age = Integer.parseInt(sAge.getText());
if (age != 0) {
LinkedList<Actor> returnedActorList = IODriver.ageSearch(age);
LinkedList.DataLink head = returnedActorList.header;
multiListEdit(head);} else {
System.out.println("Please Enter a number for year ie. 1998");
}
} else {
System.out.println("Please Enter a number for year ie. 1998");
}

}

}

@FXML
private void handleButtonGender(ActionEvent event) throws IOException {
String gender;
if (sGender != null) {
gender = sGender.getText();
LinkedList<Actor> returnedActorList = IODriver.genderSearch(gender);
LinkedList.DataLink head = returnedActorList.header;
multiListEdit(head);} else {
System.out.println("Please Enter a valid search for gender");
}


}

@FXML
private void handleButtonNat(ActionEvent event) throws IOException {
String nat;
if (sNationality != null) {
nat = sNationality.getText();
LinkedList<Actor> returnedActorList = IODriver.natSearch(nat);
LinkedList.DataLink head = returnedActorList.header;
multiListEdit(head);} else {
System.out.println("Please Enter a valid search for nationality");
}

}
}
27 changes: 24 additions & 3 deletions src/project/Controller/ControllerSearchMovie.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private void handleButtonNine(ActionEvent event) throws IOException {
int runtime;

if (sRuntime != null) {
boolean check = Main.parceCheck(sRuntime.getText());
boolean check = Main.parseCheck(sRuntime.getText());
if (check) {
runtime = Integer.parseInt(sRuntime.getText());
if (runtime != 0) {
Expand All @@ -82,7 +82,7 @@ private void handleButtonNine(ActionEvent event) throws IOException {
private void handleButtonEight(ActionEvent event) throws IOException {
int year;
if (sYear != null) {
boolean check = Main.parceCheck(sYear.getText());
boolean check = Main.parseCheck(sYear.getText());
if (check) {
year = Integer.parseInt(sYear.getText());
if (year != 0) {
Expand Down Expand Up @@ -155,14 +155,35 @@ private void handleButtonTitle(ActionEvent event) throws IOException {

@FXML
private void handleButtonyear(ActionEvent event) throws IOException {
int year;
if (sYear != null) {
boolean check = Main.parseCheck(sYear.getText());
if (check) {
year = Integer.parseInt(sYear.getText());
if (year != 0) {
LinkedList<Movie> returnedMovieList = IODriver.yearSearch(year);
LinkedList.DataLink head = returnedMovieList.header;
multiListEdit(head);} else {
System.out.println("Please Enter a number for year ie. 1998");
}
} else {
System.out.println("Please Enter a number for year ie. 1998");
}


}
}

@FXML
private void handleButtonRuntime(ActionEvent event) throws IOException {
if (sRuntime != null) {
String title = sRuntime.getText();
LinkedList<Movie> returnedMovieList = IODriver.titleSearch(title);
LinkedList.DataLink head = returnedMovieList.header;
multiListEdit(head);


}

}

}
Expand Down
4 changes: 3 additions & 1 deletion src/project/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.ToolBar;
import javafx.scene.image.Image;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.*;
Expand Down Expand Up @@ -38,6 +39,7 @@ public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("View/Start.fxml"));
// stage.initStyle(StageStyle.UNDECORATED);
// stage.initStyle(StageStyle.TRANSPARENT);

root.setOnMousePressed(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
Expand Down Expand Up @@ -74,7 +76,7 @@ else if (e.getSource() == btnScene1)
stage.setScene(scene2);
}

public static boolean parceCheck(String V) {
public static boolean parseCheck(String V) {

boolean parsable = true;
try {
Expand Down
5 changes: 1 addition & 4 deletions src/project/Movie.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,5 @@ public String toString() {
String str = "Movie info: [name:"+getTitle()+", "+"Year:"+getYear()+", "+"Film Length: "+getRunningTime()+", "+"Plot: "+getPlot()+", "+"Film Img Url: "+getImgUrl()+"] \n";
return str;
}
@Override
public int hashCode(){
return this.toString().hashCode();
}

}
19 changes: 14 additions & 5 deletions src/project/MovieList.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,23 @@ public static void addMovie(String title, int year, int runningTime, String plot


//Kevin Power 20075681
public void removeMovie(Movie toRemoveMovie){
LinkedList<Movie> internalList = runtimeHashlist[toRemoveMovie.hashCode()];
if (internalList != null){
internalList.remove(toRemoveMovie);
public static void removeMovie(Movie movie){
int runtime = movie.getRunningTime();
int year = movie.getYear();
String title = movie.getTitle();
int rtHash = runtime % runtimeHashlist.length;
int yearHash = year %yearHashlist.length;
int titleHash =Math.abs(title.hashCode())%titleHashlist.length;
LinkedList<Movie> runList = runtimeHashlist[rtHash];
LinkedList<Movie> yearList = yearHashlist[yearHash];
LinkedList<Movie> titleList = titleHashlist[titleHash];
runList.remove(movie);
yearList.remove(movie);
titleList.remove(movie);
}
}

}




Expand Down
10 changes: 5 additions & 5 deletions src/project/View/EditActor.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" onMouseClicked="#handleClose" prefHeight="400.0" prefWidth="700.0" style="-fx-background-color: #1C1F25" xmlns="http://javafx.com/javafx/8.0.121" xmlns:fx="http://javafx.com/fxml/1" fx:controller="project.Controller.ControllerAdd">
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" onMouseClicked="#handleClose" prefHeight="400.0" prefWidth="700.0" style="-fx-background-color: #1C1F25" xmlns="http://javafx.com/javafx/8.0.121" xmlns:fx="http://javafx.com/fxml/1" fx:controller="project.Controller.ControllerSearchActor">
<children>
<Label fx:id="exit" layoutX="677.0" onMousePressed="#handleClose" prefHeight="35.0" prefWidth="18.0" text="X" textFill="#e52019dc">
<font>
Expand Down Expand Up @@ -38,13 +38,13 @@
</VBox>
<VBox layoutX="434.0" layoutY="128.0" prefHeight="200.0" prefWidth="100.0">
<children>
<Button fx:id="btn1" mnemonicParsing="false" text="Search" />
<Button fx:id="btn1" mnemonicParsing="false" onAction="#handleButtonName" text="Search" />
<Separator prefHeight="32.0" prefWidth="200.0" visible="false" />
<Button fx:id="btn2" prefHeight="25.0" prefWidth="52.0" text="Search" />
<Button fx:id="btn2" onAction="#handleButtonAge" prefHeight="25.0" prefWidth="52.0" text="Search" />
<Separator prefHeight="32.0" prefWidth="200.0" visible="false" />
<Button fx:id="btn3" text="Search" />
<Button fx:id="btn3" onAction="#handleButtonGender" text="Search" />
<Separator prefHeight="32.0" prefWidth="200.0" visible="false" />
<Button fx:id="btn4" contentDisplay="CENTER" text="Search" />
<Button fx:id="btn4" contentDisplay="CENTER" onAction="#handleButtonNat" text="Search" />
</children>
</VBox>
<Button fx:id="btn5" layoutX="14.0" layoutY="361.0" mnemonicParsing="false" onAction="#handleButtonAction" text="Back" />
Expand Down
2 changes: 1 addition & 1 deletion src/project/View/EditActorResult.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>

<AnchorPane prefHeight="400.0" prefWidth="700.0" style="-fx-background-color: #1C1F25" xmlns="http://javafx.com/javafx/8.0.121" xmlns:fx="http://javafx.com/fxml/1" fx:controller="project.Controller.ControllerSearchActor">
<AnchorPane prefHeight="400.0" prefWidth="700.0" style="-fx-background-color: #1C1F25" xmlns="http://javafx.com/javafx/8.0.121" xmlns:fx="http://javafx.com/fxml/1" fx:controller="project.Controller.ControllerResults">

<children>
<Label fx:id="exit" layoutX="677.0" onMousePressed="#handleClose" prefHeight="35.0" prefWidth="18.0" text="X" textFill="#e52019dc">
Expand Down
2 changes: 1 addition & 1 deletion src/project/View/EditMovieResult.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</Label>
<AnchorPane layoutX="266.0" layoutY="312.0" prefHeight="51.0" prefWidth="165.0" style="-fx-background-color: #1C1F25">
<children>
<Button fx:id="btn1" alignment="CENTER" layoutX="14.0" layoutY="4.0" mnemonicParsing="false" onAction="#handleButtonAction" prefHeight="36.0" prefWidth="137.0" text="Submit" />
<Button fx:id="changeBtn" alignment="CENTER" layoutX="14.0" layoutY="4.0" mnemonicParsing="false" onAction="#handleButtonChange" prefHeight="36.0" prefWidth="137.0" text="Submit" />
</children></AnchorPane>
<Label layoutX="248.0" layoutY="36.0" text="Edit Movie Results" textFill="#e52019dc">
<font>
Expand Down
2 changes: 1 addition & 1 deletion src/project/View/SearchActor.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@
<Button fx:id="btn4" contentDisplay="CENTER" onAction="#handleButtonFour" text="Search" />
</children>
</VBox>
<Button fx:id="btn5" layoutX="43.0" layoutY="76.0" mnemonicParsing="false" onAction="#handleButtonAction" text="Back" />
<Button fx:id="btn5" layoutX="14.0" layoutY="361.0" mnemonicParsing="false" onAction="#handleButtonAction" text="Back" />
</children>
</AnchorPane>

0 comments on commit aeaa47f

Please sign in to comment.