|
@@ -18,65 +18,7 @@ import java.util.List;
|
|
|
|
|
|
//For reading properties from .properties file
|
|
|
|
|
|
-public class EditMovieController extends Controller {
|
|
|
-
|
|
|
- @FXML
|
|
|
- Button addActorButton;
|
|
|
-
|
|
|
- @FXML
|
|
|
- AnchorPane borderTop;
|
|
|
-
|
|
|
- @FXML
|
|
|
- Pane borderLeft;
|
|
|
- @FXML
|
|
|
- Pane borderRight;
|
|
|
- @FXML
|
|
|
- Pane borderBottom;
|
|
|
-
|
|
|
- @FXML
|
|
|
- ScrollPane actorsGrid;
|
|
|
- @FXML
|
|
|
- VBox actorsGridAncor;
|
|
|
-
|
|
|
- @FXML
|
|
|
- TextField urlTextBox;
|
|
|
- @FXML
|
|
|
- TextField titleTextBox;
|
|
|
- @FXML
|
|
|
- TextField genreTextBox;
|
|
|
- @FXML
|
|
|
- TextArea descriptionTextBox;
|
|
|
- @FXML
|
|
|
- TextField yearTextBox;
|
|
|
- @FXML
|
|
|
- TextField timeTextBox;
|
|
|
- @FXML
|
|
|
- TextField studioTextBox;
|
|
|
- @FXML
|
|
|
- TextField directorTextBox;
|
|
|
- @FXML
|
|
|
- TextField rateTextBox;
|
|
|
-
|
|
|
- @FXML
|
|
|
- Label actorLabel;
|
|
|
- @FXML
|
|
|
- Pane actorUnderline;
|
|
|
- @FXML
|
|
|
- Label roleLabel;
|
|
|
- @FXML
|
|
|
- Pane roleUnderline;
|
|
|
- @FXML
|
|
|
- Label buttonRowAdd;
|
|
|
- @FXML
|
|
|
- Label buttonRowRem;
|
|
|
-
|
|
|
-
|
|
|
- Object caller;
|
|
|
- double xOffset;
|
|
|
- double yOffset;
|
|
|
-
|
|
|
- double basePos;
|
|
|
- double baseWidth;
|
|
|
+public class EditMovieController extends AddMovieController {
|
|
|
|
|
|
Movie editableMovie;
|
|
|
|
|
@@ -162,14 +104,19 @@ public class EditMovieController extends Controller {
|
|
|
|
|
|
urlTextBox.setText(editableMovie.getImageLink());
|
|
|
titleTextBox.setText(editableMovie.name());
|
|
|
- genreTextBox.setText(editableMovie.genre());
|
|
|
+ genreTextBox.setValue(editableMovie.genre());
|
|
|
yearTextBox.setText(editableMovie.year());
|
|
|
timeTextBox.setText(editableMovie.duration());
|
|
|
- studioTextBox.setText(editableMovie.studio());
|
|
|
- directorTextBox.setText(editableMovie.director());
|
|
|
+ studioTextBox.setValue(editableMovie.studio());
|
|
|
+ directorTextBox.setValue(editableMovie.director());
|
|
|
rateTextBox.setText(editableMovie.rating());
|
|
|
descriptionTextBox.setText(editableMovie.description());
|
|
|
|
|
|
+ studioTextBox.setItems(((BrowserController) caller).my_connector.getAllStudios());
|
|
|
+ directorTextBox.setItems(((BrowserController) caller).my_connector.getAllDirectors());
|
|
|
+ genreTextBox.setItems(((BrowserController) caller).my_connector.getAllGenres());
|
|
|
+
|
|
|
+
|
|
|
//TODO ADD ACTORS INFO
|
|
|
List<Role> Role = ((BrowserController) caller).getRolesFromConnection(editableMovie.id());
|
|
|
|
|
@@ -223,11 +170,14 @@ public class EditMovieController extends Controller {
|
|
|
Movie NewMovie = new Movie();
|
|
|
NewMovie.setCover(urlTextBox.getText());
|
|
|
NewMovie.setName(titleTextBox.getText());
|
|
|
- NewMovie.setGenre(genreTextBox.getText());
|
|
|
+ if (genreTextBox.getValue() != null)
|
|
|
+ NewMovie.setGenre(genreTextBox.getValue().toString());
|
|
|
NewMovie.setYear(yearTextBox.getText());
|
|
|
NewMovie.setDuration(timeTextBox.getText());
|
|
|
- NewMovie.setStudio(studioTextBox.getText());
|
|
|
- NewMovie.setDirector(directorTextBox.getText());
|
|
|
+ if (studioTextBox.getValue() != null)
|
|
|
+ NewMovie.setStudio(studioTextBox.getValue().toString());
|
|
|
+ if (directorTextBox.getValue() != null)
|
|
|
+ NewMovie.setDirector(directorTextBox.getValue().toString());
|
|
|
NewMovie.setRating(rateTextBox.getText());
|
|
|
NewMovie.setDescription(descriptionTextBox.getText());
|
|
|
|
|
@@ -260,54 +210,7 @@ public class EditMovieController extends Controller {
|
|
|
}
|
|
|
|
|
|
|
|
|
- private List<Role> fetchRoles(Movie targetMovie) {
|
|
|
- List<Role> roles = new ArrayList<Role>();
|
|
|
- try {
|
|
|
- //AnchorPane row = (AnchorPane) actorsGrid.getChildren().get(1);
|
|
|
|
|
|
- for (Node row : actorsGridAncor.getChildren()) {
|
|
|
- System.out.println("Type: " + row.toString());
|
|
|
- if (row instanceof AnchorPane) {
|
|
|
- // clear
|
|
|
- String name = null;
|
|
|
- String role = null;
|
|
|
- for (Node hbox : ((AnchorPane) row).getChildren()) {
|
|
|
- System.out.println("\t-Type: " + hbox.toString());
|
|
|
-
|
|
|
- if (hbox instanceof HBox)
|
|
|
- for (Node halfrow : ((HBox) hbox).getChildren()) {
|
|
|
- System.out.println("\t\t-Type: " + halfrow.toString());
|
|
|
-
|
|
|
- if (halfrow instanceof AnchorPane)
|
|
|
- for (Node part : ((AnchorPane) halfrow).getChildren()) {
|
|
|
- System.out.println("\t\t\t-Type: " + part.toString());
|
|
|
-
|
|
|
- if (part instanceof TextField) {
|
|
|
- System.out.println("\t\t\t\t Text: " + ((TextField) part).getText());
|
|
|
- if (part.getId().equals("actorName")) {
|
|
|
- name = ((TextField) part).getText();
|
|
|
- }
|
|
|
- if (part.getId().equals("actorRole")) {
|
|
|
- role = ((TextField) part).getText();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (name != "" || role != "") {
|
|
|
- Role rowRole = new Role(targetMovie.id(), name, role);
|
|
|
- roles.add(rowRole);
|
|
|
- System.out.println("Final: movieId=" + rowRole.movieId() + ", actorName=" + rowRole.actor() + ", actorRole=" + rowRole.role() + "\n");
|
|
|
- System.out.println(rowRole.movieId());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- } catch (Exception ex) {
|
|
|
- ex.printStackTrace();
|
|
|
- }
|
|
|
- return roles;
|
|
|
- }
|
|
|
|
|
|
|
|
|
private void addFilledRole(Role filledRole) {
|
|
@@ -331,11 +234,15 @@ public class EditMovieController extends Controller {
|
|
|
for (Node part : ((AnchorPane) halfrow).getChildren()) {
|
|
|
System.out.println("\t\t\t-Type: " + part.toString());
|
|
|
|
|
|
- if (part instanceof TextField) {
|
|
|
- System.out.println("\t\t\t\t Text: " + ((TextField) part).getText());
|
|
|
+ if (part instanceof ComboBox) {
|
|
|
+ //System.out.println("\t\t\t\t Text: " + ((ComboBox) part).setValue(filledRole.actor()));
|
|
|
if (part.getId().equals("actorName")) {
|
|
|
- ((TextField) part).setText(filledRole.actor());
|
|
|
+ ((ComboBox) part).setValue(filledRole.actor());
|
|
|
}
|
|
|
+ }
|
|
|
+ if (part instanceof TextField) {
|
|
|
+ System.out.println("\t\t\t\t Text: " + ((TextField) part).getText());
|
|
|
+
|
|
|
if (part.getId().equals("actorRole")) {
|
|
|
((TextField) part).setText(filledRole.role());
|
|
|
}
|