|
@@ -65,16 +65,37 @@ public class BrowserController extends Controller {
|
|
|
Label editMovieButton;
|
|
|
|
|
|
@FXML
|
|
|
- TextField userTextBox;
|
|
|
+ TextField userTextBox;
|
|
|
@FXML
|
|
|
- TextField passTextBox;
|
|
|
+ TextField passTextBox;
|
|
|
@FXML
|
|
|
- TextFlow errorTextBox;
|
|
|
+ TextFlow errorTextBox;
|
|
|
@FXML
|
|
|
- Label userLabel;
|
|
|
+ Label userLabel;
|
|
|
@FXML
|
|
|
Polyline resizerPoly;
|
|
|
|
|
|
+ @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
|
|
|
+ TextField actorTextBox;
|
|
|
+ @FXML
|
|
|
+ TextField roleTextBox;
|
|
|
+
|
|
|
Map<Label, Movie> map;
|
|
|
Label[] labelsMovies;
|
|
|
Movie[] movies;
|
|
@@ -94,7 +115,7 @@ public class BrowserController extends Controller {
|
|
|
int detailsWidth = 300;
|
|
|
int filterWidth = 300;
|
|
|
|
|
|
- public void initialize(Stage primaryStage){
|
|
|
+ public void initialize(Stage primaryStage) {
|
|
|
prepare();
|
|
|
stage = primaryStage;
|
|
|
|
|
@@ -126,7 +147,7 @@ public class BrowserController extends Controller {
|
|
|
@Override
|
|
|
public void handle(MouseEvent event) {
|
|
|
|
|
|
- primaryStage.setWidth(event.getScreenX() + xOffset);
|
|
|
+ primaryStage.setWidth(event.getScreenX() + xOffset);
|
|
|
primaryStage.setHeight(event.getScreenY() + yOffset);
|
|
|
}
|
|
|
});
|
|
@@ -149,8 +170,7 @@ public class BrowserController extends Controller {
|
|
|
|
|
|
}
|
|
|
|
|
|
- public void loadPosters()
|
|
|
- {
|
|
|
+ public void loadPosters() {
|
|
|
if (my_connector.initialized() & my_connector.granted("INSERT")) {
|
|
|
addMenu.setDisable(false);
|
|
|
} else
|
|
@@ -193,8 +213,46 @@ public class BrowserController extends Controller {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void returnMessage()
|
|
|
- {
|
|
|
+ public void loadPosters(Movie[] filteredMovies) {
|
|
|
+ //detailsPane.setMinWidth(300);
|
|
|
+ //get movies array
|
|
|
+ if (my_connector.initialized() & (my_connector.granted("USAGE") || my_connector.granted("SELECT"))) {
|
|
|
+ movies = filteredMovies;
|
|
|
+ labelsMovies = new Label[movies.length];
|
|
|
+
|
|
|
+ map = new LinkedHashMap<Label, Movie>();
|
|
|
+ //
|
|
|
+ for (int i = 0; i < movies.length; i++) {
|
|
|
+ labelsMovies[i] = new Label();
|
|
|
+ ImageView image = new ImageView(movies[i].cover());
|
|
|
+
|
|
|
+ map.put(labelsMovies[i], movies[i]);
|
|
|
+
|
|
|
+ image.setFitHeight(imageHeight);
|
|
|
+ image.setFitWidth(imageWidth);
|
|
|
+ labelsMovies[i].setGraphic(image);
|
|
|
+ GridPane.setValignment(labelsMovies[i], VPos.TOP);
|
|
|
+ GridPane.setHalignment(labelsMovies[i], HPos.CENTER);
|
|
|
+ Label movie = labelsMovies[i];
|
|
|
+ labelsMovies[i].setOnMouseClicked(e -> {
|
|
|
+ openDetails(movie);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ //moviesGrid.setPrefWidth(scrollPane.getWidth());
|
|
|
+ //clear old data in grid
|
|
|
+ moviesGrid.getChildren().clear();
|
|
|
+ //moviesGrid.setAlignment(Pos.CENTER);
|
|
|
+ //fill grid by movies
|
|
|
+ //moviesGrid.addRow(0, labelsMovies[0], labelsMovies[1]);
|
|
|
+ //moviesGrid.minHeight(moviesGrid.getMinHeight() + 222);
|
|
|
+ //moviesGrid.setPrefWidth(browserPane.getWidth()-26);
|
|
|
+ //moviesGrid.setMinHeight(scrollPane.getHeight());
|
|
|
+ gridResize();
|
|
|
+ //moviesGrid.setPrefHeight(moviesGrid.getHeight());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void returnMessage() {
|
|
|
Alert alert = new Alert(AlertType.CONFIRMATION, "Are you sure you want to format your system?");
|
|
|
alert.showAndWait().ifPresent(response -> {
|
|
|
if (response == ButtonType.OK) {
|
|
@@ -203,8 +261,8 @@ public class BrowserController extends Controller {
|
|
|
}
|
|
|
|
|
|
private int detailsViewingNow;
|
|
|
- public void openDetails(Label e)
|
|
|
- {
|
|
|
+
|
|
|
+ public void openDetails(Label e) {
|
|
|
if (detailsPane.getMinWidth() < 1 || detailsViewingNow != map.get(e).id()) {
|
|
|
//detailsInfoPane = new AnchorPane();
|
|
|
//detailsPicPane.getChildren().clear();
|
|
@@ -219,10 +277,10 @@ public class BrowserController extends Controller {
|
|
|
|
|
|
//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" +
|
|
|
- "Duration: \n " + my_movie.duration() + "\n" +
|
|
|
- "Genre: \n " + my_movie.genre() + "\n" +
|
|
|
- "Description: \n " + my_movie.description());
|
|
|
+ "Year: \n " + my_movie.year() + "\n" +
|
|
|
+ "Duration: \n " + my_movie.duration() + "\n" +
|
|
|
+ "Genre: \n " + my_movie.genre() + "\n" +
|
|
|
+ "Description: \n " + my_movie.description());
|
|
|
info.setStyle("-fx-font-size: 14; -fx-fill: #9f9f9f;");
|
|
|
detailsContent.getChildren().clear();
|
|
|
detailsContent.getChildren().add(info);
|
|
@@ -237,7 +295,7 @@ public class BrowserController extends Controller {
|
|
|
image.setFitHeight(imageHeight);
|
|
|
image.setFitWidth(imageWidth);
|
|
|
|
|
|
- //movie.
|
|
|
+ //movie.
|
|
|
|
|
|
|
|
|
detailsPicPane.setImage(my_movie.cover());
|
|
@@ -251,7 +309,7 @@ public class BrowserController extends Controller {
|
|
|
double ratioY = detailsPicPane.getFitHeight() / img.getHeight();
|
|
|
|
|
|
double reducCoeff = 0;
|
|
|
- if(ratioX >= ratioY) {
|
|
|
+ if (ratioX >= ratioY) {
|
|
|
reducCoeff = ratioY;
|
|
|
} else {
|
|
|
reducCoeff = ratioX;
|
|
@@ -285,6 +343,7 @@ public class BrowserController extends Controller {
|
|
|
editMovieButton.setOpacity(1);
|
|
|
editMovieButton.setOnMouseClicked(ed -> {
|
|
|
System.out.println("edit");
|
|
|
+ openEditForm();
|
|
|
});
|
|
|
|
|
|
} else {
|
|
@@ -294,14 +353,12 @@ public class BrowserController extends Controller {
|
|
|
}
|
|
|
|
|
|
if (isOpen)
|
|
|
- gridResize(scrollPane.getWidth() , detailsPane.getMinWidth());
|
|
|
+ gridResize(scrollPane.getWidth(), detailsPane.getMinWidth());
|
|
|
else
|
|
|
gridResize((scrollPane.getWidth() - detailsPane.getMinWidth()), detailsPane.getMinWidth());
|
|
|
//button.setText(Double.toString(browserPane.getWidth()));
|
|
|
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ } else {
|
|
|
//detailsPicPane.getChildren().clear();
|
|
|
double oldDetailsWidth = detailsPane.getMinWidth();
|
|
|
detailsPane.setMinWidth(0);
|
|
@@ -318,17 +375,14 @@ public class BrowserController extends Controller {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void closeDetails()
|
|
|
- {
|
|
|
+ public void closeDetails() {
|
|
|
//detailsPicPane.getChildren().clear();
|
|
|
detailsPane.setMinWidth(1);
|
|
|
detailsPane.setPrefWidth(1);
|
|
|
}
|
|
|
|
|
|
- public void openFilter()
|
|
|
- {
|
|
|
- if (filterPane.getWidth() < 1)
|
|
|
- {
|
|
|
+ public void openFilter() {
|
|
|
+ if (filterPane.getWidth() < 1) {
|
|
|
//filterPane.maxWidth(300);
|
|
|
filterPane.setMinWidth(filterWidth);
|
|
|
filterPane.setPrefWidth(filterWidth);
|
|
@@ -341,9 +395,7 @@ public class BrowserController extends Controller {
|
|
|
//moviesGrid.setPrefHeight(browserPane.getHeight());
|
|
|
gridResize(scrollPane.getWidth() - filterPane.getWidth(), filterPane.getWidth());
|
|
|
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ } else {
|
|
|
double oldFilterWidth = filterPane.getWidth();
|
|
|
filterPane.setMinWidth(0);
|
|
|
filterPane.setPrefWidth(0);
|
|
@@ -359,8 +411,7 @@ public class BrowserController extends Controller {
|
|
|
|
|
|
}
|
|
|
|
|
|
- public void gridResize(double scrollWidth, double influencePaneWidth)
|
|
|
- {
|
|
|
+ public void gridResize(double scrollWidth, double influencePaneWidth) {
|
|
|
if (!Objects.isNull(movies)) {
|
|
|
|
|
|
moviesGrid.setAlignment(Pos.TOP_CENTER);
|
|
@@ -372,23 +423,21 @@ public class BrowserController extends Controller {
|
|
|
int rows;
|
|
|
try {
|
|
|
rows = movies.length / cols;
|
|
|
- }
|
|
|
- catch (ArithmeticException ex)
|
|
|
- {
|
|
|
- cols = (((int) (scrollWidth + influencePaneWidth)) + (int) moviesGrid.getHgap()) / (imageWidth + (int) moviesGrid.getHgap());
|
|
|
+ } catch (ArithmeticException ex) {
|
|
|
+ cols = (((int) (scrollWidth + influencePaneWidth)) + (int) moviesGrid.getHgap()) / (imageWidth + (int) moviesGrid.getHgap());
|
|
|
rows = movies.length / cols;
|
|
|
|
|
|
}
|
|
|
if (movies.length % cols != 0)
|
|
|
rows++;
|
|
|
|
|
|
- if (imageHeight * rows + (moviesGrid.getVgap()*(rows - 1)) < scrollPane.getHeight())
|
|
|
+ if (imageHeight * rows + (moviesGrid.getVgap() * (rows - 1)) < scrollPane.getHeight())
|
|
|
moviesGrid.setMinHeight(scrollPane.getHeight());
|
|
|
else
|
|
|
- moviesGrid.setMinHeight(imageHeight * rows + (moviesGrid.getVgap()*(rows - 1)));
|
|
|
+ moviesGrid.setMinHeight(imageHeight * rows + (moviesGrid.getVgap() * (rows - 1)));
|
|
|
|
|
|
- System.out.println("grid height:" + moviesGrid.getHeight() );
|
|
|
- System.out.println("scroll width:" + scrollWidth );
|
|
|
+ System.out.println("grid height:" + moviesGrid.getHeight());
|
|
|
+ System.out.println("scroll width:" + scrollWidth);
|
|
|
System.out.println("cols: " + cols);
|
|
|
System.out.println("rows: " + rows);
|
|
|
|
|
@@ -403,13 +452,12 @@ public class BrowserController extends Controller {
|
|
|
moviesGrid.getChildren().add(labelsMovies[i]);
|
|
|
|
|
|
}
|
|
|
- moviesGrid.autosize();
|
|
|
+ //moviesGrid.autosize();
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void gridResize( )
|
|
|
- {
|
|
|
+ public void gridResize() {
|
|
|
if (!Objects.isNull(movies)) {
|
|
|
|
|
|
moviesGrid.setAlignment(Pos.TOP_CENTER);
|
|
@@ -421,21 +469,19 @@ public class BrowserController extends Controller {
|
|
|
int rows;
|
|
|
try {
|
|
|
rows = movies.length / cols;
|
|
|
- }
|
|
|
- catch (ArithmeticException ex)
|
|
|
- {
|
|
|
+ } catch (ArithmeticException ex) {
|
|
|
//this is unreachable
|
|
|
- cols = (((int) scrollPane.getWidth() + 300) + (int) moviesGrid.getHgap()) / (imageWidth + (int) moviesGrid.getHgap());
|
|
|
+ cols = (((int) scrollPane.getWidth() + 300) + (int) moviesGrid.getHgap()) / (imageWidth + (int) moviesGrid.getHgap());
|
|
|
rows = movies.length / cols;
|
|
|
|
|
|
}
|
|
|
if (movies.length % cols != 0)
|
|
|
rows++;
|
|
|
|
|
|
- if (imageHeight * rows + (moviesGrid.getVgap()*(rows - 1)) < scrollPane.getHeight())
|
|
|
+ if (imageHeight * rows + (moviesGrid.getVgap() * (rows - 1)) < scrollPane.getHeight())
|
|
|
moviesGrid.setMinHeight(scrollPane.getHeight());
|
|
|
else
|
|
|
- moviesGrid.setMinHeight(imageHeight * rows + (moviesGrid.getVgap()*(rows - 1)));
|
|
|
+ moviesGrid.setMinHeight(imageHeight * rows + (moviesGrid.getVgap() * (rows - 1)));
|
|
|
|
|
|
//System.out.println("scroll width:" + scrollWidth );
|
|
|
System.out.println("cols: " + cols);
|
|
@@ -458,6 +504,7 @@ public class BrowserController extends Controller {
|
|
|
}
|
|
|
|
|
|
LogInController logInWindow;
|
|
|
+
|
|
|
public void openLoginForm() {
|
|
|
|
|
|
try {
|
|
@@ -474,7 +521,9 @@ public class BrowserController extends Controller {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
AddMovieController addWindow;
|
|
|
+
|
|
|
public void openAddForm() {
|
|
|
|
|
|
try {
|
|
@@ -483,7 +532,7 @@ public class BrowserController extends Controller {
|
|
|
addWindow = loader.getController();
|
|
|
addWindow.stage = new Stage();
|
|
|
addWindow.stage.setScene(new Scene(root, 629, 561));
|
|
|
- addWindow.stage.initStyle(StageStyle.UNDECORATED );
|
|
|
+ addWindow.stage.initStyle(StageStyle.UNDECORATED);
|
|
|
addWindow.stage.setMinWidth(629); //+16
|
|
|
addWindow.stage.setMinHeight(561); //+31+16
|
|
|
addWindow.stage.setUserData(loader);
|
|
@@ -523,6 +572,47 @@ public class BrowserController extends Controller {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ EditMovieController editWindow;
|
|
|
+
|
|
|
+ public void openEditForm() {
|
|
|
+
|
|
|
+ try {
|
|
|
+ FXMLLoader loader = new FXMLLoader(getClass().getResource("../../EditMovieWindow.fxml"));
|
|
|
+ Parent root = loader.load();
|
|
|
+ editWindow = loader.getController();
|
|
|
+ editWindow.stage = new Stage();
|
|
|
+ editWindow.stage.setScene(new Scene(root, 629, 561));
|
|
|
+ editWindow.stage.initStyle(StageStyle.UNDECORATED);
|
|
|
+ editWindow.stage.setMinWidth(629); //+16
|
|
|
+ editWindow.stage.setMinHeight(561); //+31+16
|
|
|
+ editWindow.stage.setUserData(loader);
|
|
|
+ editWindow.open(this);
|
|
|
+
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ GenreStatisticsController statsWindow;
|
|
|
+
|
|
|
+ public void openStatsForm() {
|
|
|
+
|
|
|
+ try {
|
|
|
+ FXMLLoader loader = new FXMLLoader(getClass().getResource("../../GenreStatisticsWindow.fxml"));
|
|
|
+ Parent root = loader.load();
|
|
|
+ statsWindow = loader.getController();
|
|
|
+ statsWindow.stage = new Stage();
|
|
|
+ statsWindow.stage.setScene(new Scene(root, 500, 500));
|
|
|
+ statsWindow.stage.setUserData(loader);
|
|
|
+ statsWindow.open(this);
|
|
|
+
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/*AdditionController altAddition;
|
|
|
public void openAltAddForm(){
|
|
|
try {
|
|
@@ -539,21 +629,19 @@ public class BrowserController extends Controller {
|
|
|
}
|
|
|
}
|
|
|
*/
|
|
|
- public Boolean newArgLogin(String user, String pass){
|
|
|
+ public Boolean newArgLogin(String user, String pass) {
|
|
|
|
|
|
Properties property = new Properties();
|
|
|
ConnectionParams temporalParams;
|
|
|
try {
|
|
|
FileInputStream fis = new FileInputStream("connection.properties");
|
|
|
property.load(fis);
|
|
|
- temporalParams = new ConnectionParams(property.getProperty("CONFIG_DEFAULT_HOST"), user, pass);
|
|
|
- }
|
|
|
- catch (IOException ex)
|
|
|
- {
|
|
|
- temporalParams = new ConnectionParams("127.0.0.1/moviesdb", user, pass);
|
|
|
+ temporalParams = new ConnectionParams(property.getProperty("CONFIG_DEFAULT_HOST"), user, pass);
|
|
|
+ } catch (IOException ex) {
|
|
|
+ temporalParams = new ConnectionParams("127.0.0.1/moviesdb", user, pass);
|
|
|
}
|
|
|
|
|
|
- if (my_connector.tryConnection(temporalParams)){
|
|
|
+ if (my_connector.tryConnection(temporalParams)) {
|
|
|
workParams = temporalParams;
|
|
|
my_connector.initConnection(workParams);
|
|
|
setUserName(user);
|
|
@@ -562,7 +650,29 @@ public class BrowserController extends Controller {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- public void setUserName(String name){
|
|
|
+ public void setUserName(String name) {
|
|
|
userLabel.setText("Logged in as " + name);
|
|
|
}
|
|
|
+
|
|
|
+ public int getDetailsViewingNow() {
|
|
|
+ return detailsViewingNow;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void getFilterMovies()
|
|
|
+ {
|
|
|
+ Movie filterMovie = new Movie();
|
|
|
+
|
|
|
+ filterMovie.setName(titleTextBox.getText());
|
|
|
+ filterMovie.setGenre(genreTextBox.getText());
|
|
|
+ filterMovie.setYear(yearTextBox.getText());
|
|
|
+ filterMovie.setDuration(timeTextBox.getText());
|
|
|
+ filterMovie.setStudio(studioTextBox.getText());
|
|
|
+ filterMovie.setDirector(directorTextBox.getText());
|
|
|
+ filterMovie.setRating(rateTextBox.getText());
|
|
|
+ filterMovie.setDescription(descriptionTextBox.getText());
|
|
|
+
|
|
|
+ movies = my_connector.filterMovie(filterMovie, actorTextBox.getText(), roleTextBox.getText());
|
|
|
+ loadPosters(movies);
|
|
|
+
|
|
|
+ }
|
|
|
}
|