Commit e52e74da authored by Olaf Rosendahl's avatar Olaf Rosendahl 💻 Committed by Hermann Owren Elton
Browse files

Feat/tab highlight

parent a31b5c96
......@@ -60,7 +60,7 @@ public final class PhotoViewer {
TextField tagField = new TextField();
tagField.setPromptText("Tag name");
Css.setTextField(150, 10, 14, tagField);
Css.setTextField(150, 20, 14, tagField);
Button addTagButton = new Button("Add tag");
Button closeButton = new Button("Close");
......
.button {
-fx-border-width: 1px;
-fx-border-radius: 15px;
-fx-border-color: #DDDDDD;
-fx-background-radius: 15px;
-fx-background-insets: 0;
-fx-background-color: WHITE;
}
.button:focused, .button:hover {
-fx-background-color: #00000022;
-fx-cursor: hand;
}
......@@ -15,6 +15,10 @@
-fx-cursor: hand;
}
.check-box:hover > .box, .check-box:focused > .box {
-fx-body-color: #f1f1f1;
}
.check-box > .box > .mark {
-fx-padding: 15px;
-fx-shape: "M14.596,2.055L12.455,0C9.687,2.884,6.011,6.714,5.158,7.602L2.055,4.624L0,6.765l5.242,5.037l0.003-0.004 l0.003,0.004L14.596,2.055z";
......
.choice-box {
-fx-background-color: WHITE;
-fx-border-color: #656565;
-fx-border-radius: 15px;
-fx-background-radius: 15px;
-fx-pref-width: 700;
-fx-pref-height: 20;
}
.choice-box > .label {
-fx-font-size: 17;
-fx-pref-height: 20;
}
.choice-box .context-menu {
-fx-font-size: 17;
-fx-pref-width: 325;
......
......@@ -18,15 +18,9 @@ public final class Css {
private static final String BORDER_RADIUS = "15px";
private static final String BORDER_WIDTH = "1px";
private static final String BORDER_COLOR_LIGHT = "#DDDDDD";
private static final String BORDER_COLOR_DARK = "#656565";
private static final String BOX_BACKGROUND_COLOR = "WHITE";
private static final String BOX_BACKGROUND_COLOR_HOVER = "#00000022";
private static final String FONT = "Montserrat";
private static final String PANE_STYLE = "-fx-padding: 4;-fx-border-style: solid inside;-fx-border-width: " + BORDER_WIDTH + ";-fx-border-radius: " + BORDER_RADIUS + ";-fx-border-color: " + BORDER_COLOR_LIGHT + ";-fx-background-color: " + BOX_BACKGROUND_COLOR + ";-fx-background-radius: " + BORDER_RADIUS + ";";
private static final String BUTTON_STYLE = "-fx-border-style:solid inside;-fx-border-width: " + BORDER_WIDTH + ";-fx-border-radius: " + BORDER_RADIUS + "; -fx-border-color: " + BORDER_COLOR_LIGHT + "; -fx-background-radius: " + BORDER_RADIUS + ";-fx-background-insets: 0;";
private static final String UN_HOVERED_BUTTON_STYLE = "-fx-background-color: " + BOX_BACKGROUND_COLOR + ";";
private static final String HOVERED_BUTTON_STYLE = "-fx-background-color: " + BOX_BACKGROUND_COLOR_HOVER + ";-fx-cursor: hand;";
private static final String TEXTFIELD_STYLE = "-fx-background-color: " + BOX_BACKGROUND_COLOR + ";-fx-border-color: " + BORDER_COLOR_DARK + ";-fx-border-radius: " + BORDER_RADIUS + ";-fx-background-radius: " + BORDER_RADIUS + ";";
/**
* Private constructor to hinder creation of utility class
......@@ -65,12 +59,10 @@ public final class Css {
*/
public static void setButton(int width, int height, int fontSize, Button... buttons) {
for (Button button : buttons) {
button.setStyle(BUTTON_STYLE + UN_HOVERED_BUTTON_STYLE);
button.setFont(Font.font(FONT, fontSize));
button.setPrefWidth(width);
button.setPrefHeight(height);
button.setOnMouseEntered(e -> button.setStyle(BUTTON_STYLE + HOVERED_BUTTON_STYLE));
button.setOnMouseExited(e -> button.setStyle(BUTTON_STYLE + UN_HOVERED_BUTTON_STYLE));
button.getStylesheets().add("file:src/main/App/Css/Button.css");
}
}
......@@ -82,7 +74,7 @@ public final class Css {
public static void setTagContainerButton(Button... buttons) {
for (Button button : buttons) {
button.setMaxSize(10, 10);
button.setStyle("-fx-background-color: none");
button.getStylesheets().add("file:src/main/App/Css/TagContainer.css");
}
}
......@@ -92,9 +84,7 @@ public final class Css {
* @param button An button
*/
public static void setHomeButton(Button button) {
button.setStyle("-fx-background-color: none;");
button.setOnMouseEntered(e -> button.setStyle(HOVERED_BUTTON_STYLE));
button.setOnMouseExited(e -> button.setStyle("-fx-background-color: none"));
button.getStylesheets().add("file:src/main/App/Css/HomeButton.css");
}
/**
......@@ -104,15 +94,12 @@ public final class Css {
* @param container a HBox
*/
public static void setImageContainer(Button button, HBox container) {
String imageButtonStyle = "-fx-background-radius: " + BORDER_RADIUS + " 0px 0px " + BORDER_RADIUS + ";";
button.setStyle(imageButtonStyle + UN_HOVERED_BUTTON_STYLE);
container.setStyle(PANE_STYLE + "-fx-padding: 0; -fx-border-insets: 1; -fx-background-insets: 1");
button.setOnMouseExited(action -> button.setStyle(imageButtonStyle + UN_HOVERED_BUTTON_STYLE));
button.setOnMouseEntered(action -> button.setStyle(imageButtonStyle + HOVERED_BUTTON_STYLE));
button.setAlignment(Pos.CENTER_LEFT);
button.setPrefWidth(Screen.getPrimary().getVisualBounds().getWidth());
button.setMinHeight(160);
button.setMaxHeight(160);
button.getStylesheets().add("file:src/main/App/Css/ImageContainer.css");
}
/**
......@@ -125,7 +112,7 @@ public final class Css {
*/
public static void setTextField(int width, int height, int fontSize, TextField... textFields) {
for (TextField textField : textFields) {
textField.setStyle(TEXTFIELD_STYLE);
textField.getStylesheets().add("file:src/main/App/Css/TextField.css");
textField.setPrefWidth(width);
textField.setPrefHeight(height);
textField.setFont(Font.font(FONT, fontSize));
......@@ -141,18 +128,6 @@ public final class Css {
scrollPane.setStyle("-fx-background-color:transparent;");
}
/**
* Sets styling for choice box in add to album in search scene
*
* @param choiceBox A choice box
*/
public static void setChoiceBoxAlbums(ChoiceBox choiceBox) {
choiceBox.setPrefHeight(20);
choiceBox.setPrefWidth(700);
choiceBox.setStyle("-fx-background-color: " + BOX_BACKGROUND_COLOR + ";-fx-border-color: " + BORDER_COLOR_DARK + ";" +
"-fx-border-radius: " + BORDER_RADIUS + ";-fx-background-radius: " + BORDER_RADIUS + ";");
}
/**
* Sets styling for labels
*
......@@ -187,10 +162,10 @@ public final class Css {
* @param fontSize the size of the font
* @param label label to play the transition on
*/
public static void playFeedBackLabelTransition(FeedbackType feedBackType, String labelMessage, int fontSize, Label label, int transitionDurationSeconds) {
public static void playFeedBackLabelTransition(FeedbackType feedBackType, String labelMessage, int fontSize, Label label) {
setFeedBackLabel(feedBackType, fontSize, label);
label.setText(labelMessage);
FadeTransition ft = new FadeTransition(Duration.seconds(transitionDurationSeconds), label);
FadeTransition ft = new FadeTransition(Duration.seconds(8), label);
ft.setFromValue(1);
ft.setToValue(0);
ft.play();
......
.button {
-fx-background-color: none;
-fx-background-radius: 5px;
}
.button:focused, .button:hover {
-fx-background-color: #f1f1f1;
}
.button {
-fx-background-radius: 15px 0px 0px 15px;
-fx-background-color: WHITE;
}
.button:focused, .button:hover {
-fx-background-color: #00000022;
}
......@@ -2,4 +2,8 @@
-fx-background-image: url('/Images/Search.png');
-fx-background-repeat: no-repeat;
-fx-background-position: right center;
}
#searchField:hover, #searchField:focused {
-fx-background-color: #f1f1f1;
-fx-cursor: hand;
}
\ No newline at end of file
......@@ -15,6 +15,10 @@
-fx-cursor: hand;
}
.check-box:hover > .box, .check-box:focused > .box {
-fx-body-color: #f1f1f1;
}
.check-box > .box > .mark {
-fx-padding: 5px;
-fx-shape: "M14.596,2.055L12.455,0C9.687,2.884,6.011,6.714,5.158,7.602L2.055,4.624L0,6.765l5.242,5.037l0.003-0.004 l0.003,0.004L14.596,2.055z";
......
.button {
-fx-background-color: none;
-fx-background-radius: 18px;
}
.button:focused, .button:hover {
-fx-background-color: #f1f1f1;
}
.text-field {
-fx-background-color: WHITE;
-fx-border-color: #656565;
-fx-border-radius: 15px;
-fx-background-radius: 15px;
}
.text-field:focused, .text-field:hover {
-fx-background-color: #f1f1f1;
-fx-cursor: hand;
}
......@@ -123,7 +123,7 @@ final class AlbumDetailsRoot extends SceneRoot {
SAVE_LOCATION.clear();
popupWindow.getDialogWindow().close();
} else {
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Choose file location before downloading", 13, DIALOG_FEEDBACK_LABEL, 6);
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Choose file location before downloading", 13, DIALOG_FEEDBACK_LABEL);
}
});
......@@ -250,12 +250,12 @@ final class AlbumDetailsRoot extends SceneRoot {
} catch (DocumentException e) {
FileLogger.getLogger().log(Level.FINE, e.getMessage());
FileLogger.closeHandler();
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Could not create a PDF", 13, DIALOG_FEEDBACK_LABEL, 6);
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Could not create a PDF", 13, DIALOG_FEEDBACK_LABEL);
} catch (IOException e) {
FileLogger.getLogger().log(Level.FINE, e.getMessage());
FileLogger.closeHandler();
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Could not retrieve images", 13, DIALOG_FEEDBACK_LABEL, 6);
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Could not retrieve images", 13, DIALOG_FEEDBACK_LABEL);
}
}
}
......@@ -230,7 +230,6 @@ final class AlbumsRoot extends SceneRoot {
CHOICE_BOX.getItems().clear();
CHOICE_BOX.getStyleClass().add("choice-box");
CHOICE_BOX.getStylesheets().add("file:src/main/App/Css/ChoiceBoxStyle.css");
Css.setChoiceBoxAlbums(CHOICE_BOX);
UserInfo.getUser().getAlbums().forEach(album -> {
if (!CHOICE_BOX.getItems().contains(album.getName())) {
CHOICE_BOX.getItems().add(album.getName());
......
......@@ -62,6 +62,7 @@ public final class LoginRoot extends SceneRoot {
Css.setLoadingAnimation(LOADING_ANIMATION);
//Sets functionality for the layout components
LOG_IN_BUTTON.setDefaultButton(true);
LOG_IN_BUTTON.setOnAction(e -> login());
SIGN_UP_BUTTON.setOnAction(e -> ApplicationManager.setRoot(new SignUpRoot()));
}
......@@ -78,11 +79,11 @@ public final class LoginRoot extends SceneRoot {
if (Authentication.logIn(USERNAME_FIELD.getText(), PASSWORD_FIELD.getText())) {
ApplicationManager.setRoot(new MenuRoot());
} else {
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Log in failed", 13, LOG_IN_LABEL, 6);
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Log in failed", 13, LOG_IN_LABEL);
LOADING_ANIMATION.setVisible(false);
}
} catch (ExceptionInInitializerError error) {
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Could not connect to database", 13, LOG_IN_LABEL, 6);
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Could not connect to database", 13, LOG_IN_LABEL);
LOADING_ANIMATION.setVisible(false);
FileLogger.getLogger().log(Level.FINE, error.getMessage());
FileLogger.closeHandler();
......
......@@ -181,7 +181,6 @@ final class PhotosRoot extends SceneRoot {
popupWindow.getDialogText().setText("Please select the name of the album: ");
setupChoiceBox();
Css.setChoiceBoxAlbums(CHOICE_BOX);
Button addAlbum = new Button("Add to album");
Css.setButton(500, 20, 17, addAlbum);
......@@ -231,12 +230,12 @@ final class PhotosRoot extends SceneRoot {
Album album = UserInfo.getUser().getAlbums().stream().filter(a -> a.getName().equals(albumName)).findAny().orElse(null);
ArrayList<Photo> checkedPhoto = getCheckedPhotos();
if (checkedPhoto.isEmpty()) {
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Unsuccessful: No photos were chosen", 13, FEEDBACK_LABEL, 6);
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Unsuccessful: No photos were chosen", 13, FEEDBACK_LABEL);
} else if (album == null) {
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Unsuccessful: No album were chosen", 13, FEEDBACK_LABEL, 6);
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Unsuccessful: No album were chosen", 13, FEEDBACK_LABEL);
} else {
checkedPhoto.forEach(s -> s.addAlbum(album));
Css.playFeedBackLabelTransition(FeedbackType.SUCCESSFUL, "Added to " + albumName, 13, FEEDBACK_LABEL, 6);
Css.playFeedBackLabelTransition(FeedbackType.SUCCESSFUL, "Added to " + albumName, 13, FEEDBACK_LABEL);
}
Hibernate.updateUser(UserInfo.getUser());
}
......@@ -248,7 +247,7 @@ final class PhotosRoot extends SceneRoot {
private void deleteSelectedPhotos() {
ArrayList<Photo> selectedPhotos = getCheckedPhotos();
if (selectedPhotos.isEmpty()) {
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Unsuccessful: No photos were chosen", 13, FEEDBACK_LABEL, 6);
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Unsuccessful: No photos were chosen", 13, FEEDBACK_LABEL);
} else {
boolean successfulDeleteSelectedPhotos = true;
for (Photo photo : selectedPhotos) {
......@@ -268,9 +267,9 @@ final class PhotosRoot extends SceneRoot {
}
Hibernate.updateUser(UserInfo.getUser());
if (successfulDeleteSelectedPhotos) {
Css.playFeedBackLabelTransition(FeedbackType.SUCCESSFUL, "Deleted successfully", 13, FEEDBACK_LABEL, 6);
Css.playFeedBackLabelTransition(FeedbackType.SUCCESSFUL, "Deleted successfully", 13, FEEDBACK_LABEL);
} else {
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "One or more photos could not be deleted", 13, FEEDBACK_LABEL, 6);
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "One or more photos could not be deleted", 13, FEEDBACK_LABEL);
}
}
}
......
......@@ -72,6 +72,7 @@ final class SignUpRoot extends SceneRoot {
Css.setLabel(13, USERNAME_LABEL, PASSWORD_LABEL, CONFIRM_PASSWORD_LABEL);
Css.setLoadingAnimation(LOADING_ANIMATION);
SIGN_UP_BUTTON.setDefaultButton(true);
SIGN_UP_BUTTON.setOnAction(e -> signUp());
PASSWORD_FIELD.setOnKeyTyped(e -> passwordStrengthBarEventHandling());
......@@ -91,14 +92,14 @@ final class SignUpRoot extends SceneRoot {
if (Authentication.register(USERNAME_FIELD.getText(), PASSWORD_FIELD.getText())) {
ApplicationManager.setRoot(new LoginRoot());
} else {
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Error: This username is already taken", 13, SIGN_UP_FEEDBACK_LABEL, 6);
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Error: This username is already taken", 13, SIGN_UP_FEEDBACK_LABEL);
LOADING_ANIMATION.setVisible(false);
}
} else {
LOADING_ANIMATION.setVisible(false);
}
} catch (ExceptionInInitializerError error) {
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Error: Could not connect to database", 13, SIGN_UP_FEEDBACK_LABEL, 6);
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Error: Could not connect to database", 13, SIGN_UP_FEEDBACK_LABEL);
LOADING_ANIMATION.setVisible(false);
FileLogger.getLogger().log(Level.FINE, error.getMessage());
FileLogger.closeHandler();
......@@ -185,12 +186,12 @@ final class SignUpRoot extends SceneRoot {
private boolean feedback() {
//Checks if password or username trimmed is equal to 0
if (PASSWORD_FIELD.getText().trim().length() == 0 || USERNAME_FIELD.getText().trim().length() == 0) {
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Error: Password or username is missing", 13, SIGN_UP_FEEDBACK_LABEL, 6);
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Error: Password or username is missing", 13, SIGN_UP_FEEDBACK_LABEL);
return false;
}
//Checks if password is shorter than 8 characters
if (PASSWORD_FIELD.getText().length() < 8) {
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Error: Password needs to contain 8 characters", 13, SIGN_UP_FEEDBACK_LABEL, 6);
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Error: Password needs to contain 8 characters", 13, SIGN_UP_FEEDBACK_LABEL);
return false;
}
//Checks username for illegal characters
......@@ -198,7 +199,7 @@ final class SignUpRoot extends SceneRoot {
for (int i = 0; i < USERNAME_FIELD.getText().length(); i++) {
if (!Character.isLetter(USERNAME_FIELD.getText().charAt(i)) &&
!Character.isDigit(USERNAME_FIELD.getText().charAt(i))) {
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Error: Username contains illegal character", 13, SIGN_UP_FEEDBACK_LABEL, 6);
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Error: Username contains illegal character", 13, SIGN_UP_FEEDBACK_LABEL);
return false;
}
}
......@@ -208,18 +209,18 @@ final class SignUpRoot extends SceneRoot {
for (int i = 0; i < PASSWORD_FIELD.getText().length(); i++) {
if (!Character.isLetter(PASSWORD_FIELD.getText().charAt(i)) &&
!Character.isDigit(PASSWORD_FIELD.getText().charAt(i))) {
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Error: Password contains illegal character", 13, SIGN_UP_FEEDBACK_LABEL, 6);
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Error: Password contains illegal character", 13, SIGN_UP_FEEDBACK_LABEL);
return false;
}
}
}
//Checks confirmpassword and password match
if (!PASSWORD_FIELD.getText().equals(CONFIRM_PASSWORD_FIELD.getText())) {
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Error: Your passwords don't match", 13, SIGN_UP_FEEDBACK_LABEL, 6);
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Error: Your passwords don't match", 13, SIGN_UP_FEEDBACK_LABEL);
return false;
}
Css.playFeedBackLabelTransition(FeedbackType.SUCCESSFUL, "You have been signed up!", 13, SIGN_UP_FEEDBACK_LABEL, 6);
Css.playFeedBackLabelTransition(FeedbackType.SUCCESSFUL, "You have been signed up!", 13, SIGN_UP_FEEDBACK_LABEL);
return true;
}
......
......@@ -126,7 +126,7 @@ final class UploadRoot extends SceneRoot {
*/
private boolean checkField() {
if (TITLE_FIELD.getText().trim().length() == 0 || URL_FIELD.getText().trim().length() == 0) {
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Title or URL are missing", 13, FEEDBACK_LABEL, 6);
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Title or URL are missing", 13, FEEDBACK_LABEL);
return false;
}
return true;
......@@ -156,13 +156,13 @@ final class UploadRoot extends SceneRoot {
Hibernate.updateUser(UserInfo.getUser());
TITLE_FIELD.clear();
URL_FIELD.clear();
Css.playFeedBackLabelTransition(FeedbackType.SUCCESSFUL, photo.getTitle() + " was stored", 13, FEEDBACK_LABEL, 6);
Css.playFeedBackLabelTransition(FeedbackType.SUCCESSFUL, photo.getTitle() + " was stored", 13, FEEDBACK_LABEL);
} catch (IOException ex) {
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Something went wrong when retrieving the image from the url.", 13, FEEDBACK_LABEL, 6);
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Something went wrong when retrieving the image from the url.", 13, FEEDBACK_LABEL);
FileLogger.getLogger().log(Level.FINE, ex.getMessage());
FileLogger.closeHandler();
} catch (NullPointerException ex) {
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Something went wrong when analyzing the image.", 13, FEEDBACK_LABEL, 6);
Css.playFeedBackLabelTransition(FeedbackType.ERROR, "Something went wrong when analyzing the image.", 13, FEEDBACK_LABEL);
FileLogger.getLogger().log(Level.FINE, ex.getMessage());
FileLogger.closeHandler();
} finally {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment