|
@@ -67,6 +67,11 @@ public class Controller {
|
|
|
@FXML
|
|
|
MenuBar menuPane;
|
|
|
|
|
|
+ @FXML
|
|
|
+ Label deleteMovieButton;
|
|
|
+ @FXML
|
|
|
+ Label editMovieButton;
|
|
|
+
|
|
|
@FXML
|
|
|
TextField userTextBox;
|
|
|
@FXML
|
|
@@ -136,20 +141,26 @@ public class Controller {
|
|
|
|
|
|
workParams = new ConnectionParams("connection.properties");
|
|
|
if (!workParams.initilized())
|
|
|
- //TODO this is temporaly handler
|
|
|
+ //TODO this is temporal handler
|
|
|
System.out.println(workParams.getInitilizeErrCause().toString());
|
|
|
else {
|
|
|
my_connector = new DataBaseConnector();
|
|
|
my_connector.initConnection(workParams);
|
|
|
}
|
|
|
|
|
|
+ System.out.println(my_connector.granted("USAGE"));
|
|
|
+ System.out.println(my_connector.granted("INSERT"));
|
|
|
+ System.out.println(my_connector.granted("UPDATE"));
|
|
|
+ System.out.println(my_connector.granted("DELETE"));
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public void loadPosters()
|
|
|
{
|
|
|
//detailsPane.setMinWidth(300);
|
|
|
//get movies array
|
|
|
- if (my_connector.initialized()) {
|
|
|
+ if (my_connector.initialized() & my_connector.granted("USAGE")) {
|
|
|
movies = my_connector.getMovies();
|
|
|
labelsMovies = new Label[movies.length];
|
|
|
|
|
@@ -235,6 +246,32 @@ public class Controller {
|
|
|
//moviesGrid.setPrefWidth(browserPane.getWidth());
|
|
|
//moviesGrid.setPrefHeight(browserPane.getHeight());
|
|
|
//loadPosters();
|
|
|
+ if (my_connector.granted("DELETE")) {
|
|
|
+ deleteMovieButton.setDisable(false);
|
|
|
+ deleteMovieButton.setOpacity(1);
|
|
|
+ deleteMovieButton.setOnMouseClicked(ed -> {
|
|
|
+ System.out.println("delete");
|
|
|
+ });
|
|
|
+
|
|
|
+ } else {
|
|
|
+ deleteMovieButton.setDisable(true);
|
|
|
+ deleteMovieButton.setOpacity(0);
|
|
|
+ deleteMovieButton.setOnMouseClicked(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (my_connector.granted("UPDATE")) {
|
|
|
+ editMovieButton.setDisable(false);
|
|
|
+ editMovieButton.setOpacity(1);
|
|
|
+ editMovieButton.setOnMouseClicked(ed -> {
|
|
|
+ System.out.println("edit");
|
|
|
+ });
|
|
|
+
|
|
|
+ } else {
|
|
|
+ editMovieButton.setDisable(true);
|
|
|
+ editMovieButton.setOpacity(0);
|
|
|
+ editMovieButton.setOnMouseClicked(null);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
gridResize();
|
|
|
//button.setText(Double.toString(browserPane.getWidth()));
|
|
@@ -368,12 +405,15 @@ public class Controller {
|
|
|
controller = loader.getController();
|
|
|
//controller.initialize(parent);
|
|
|
if(controller.newArgLogin(userTextBox.getText(), passTextBox.getText())) {
|
|
|
+ controller.loadPosters();
|
|
|
+ controller.closeDetails();
|
|
|
stage.close();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Text errorMessage = new Text("Incorrect login or password!");
|
|
|
errorMessage.setStyle("-fx-font-size: 14; -fx-fill: #FF0000;");
|
|
|
+ errorTextBox.getChildren().clear();
|
|
|
errorTextBox.getChildren().add(errorMessage);
|
|
|
}
|
|
|
//System.out.println("LoginForm closed");
|
|
@@ -399,17 +439,10 @@ public class Controller {
|
|
|
setUserName(user);
|
|
|
return my_connector.initialized();
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- ConnectionParams defaultParams = new ConnectionParams("connection.properties");
|
|
|
- setUserName("Guest");
|
|
|
- my_connector.initConnection(defaultParams);
|
|
|
- }
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- public void setUserName(String name)
|
|
|
- {
|
|
|
+ public void setUserName(String name){
|
|
|
userLabel.setText("Logged in as " + name);
|
|
|
}
|
|
|
}
|