Merge branch 'feature/locale' into 'main'
feature/locale See merge request cse1105/2025-2026/teams/csep-team-76!12
This commit is contained in:
commit
be82031c1e
19 changed files with 497 additions and 166 deletions
|
|
@ -53,6 +53,6 @@ public class Main extends Application {
|
||||||
var addStep = FXML.load(AddStepsCtrl.class, "client", "scenes", "AddSteps.fxml");
|
var addStep = FXML.load(AddStepsCtrl.class, "client", "scenes", "AddSteps.fxml");
|
||||||
|
|
||||||
var mainCtrl = INJECTOR.getInstance(MainCtrl.class);
|
var mainCtrl = INJECTOR.getInstance(MainCtrl.class);
|
||||||
mainCtrl.initialize(primaryStage, addName, foodpal, addIngredient, addStep);
|
mainCtrl.setup(primaryStage, addName, foodpal, addIngredient, addStep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
package client;
|
package client;
|
||||||
|
|
||||||
import client.scenes.FoodpalApplicationCtrl;
|
import client.scenes.FoodpalApplicationCtrl;
|
||||||
|
import client.utils.LocaleManager;
|
||||||
import com.google.inject.Binder;
|
import com.google.inject.Binder;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
import com.google.inject.Scopes;
|
import com.google.inject.Scopes;
|
||||||
|
|
@ -30,5 +31,7 @@ public class MyModule implements Module {
|
||||||
binder.bind(MainCtrl.class).in(Scopes.SINGLETON);
|
binder.bind(MainCtrl.class).in(Scopes.SINGLETON);
|
||||||
binder.bind(AddNameCtrl.class).in(Scopes.SINGLETON);
|
binder.bind(AddNameCtrl.class).in(Scopes.SINGLETON);
|
||||||
binder.bind(FoodpalApplicationCtrl.class).in(Scopes.SINGLETON);
|
binder.bind(FoodpalApplicationCtrl.class).in(Scopes.SINGLETON);
|
||||||
|
|
||||||
|
binder.bind(LocaleManager.class).in(Scopes.SINGLETON);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -15,33 +15,61 @@
|
||||||
*/
|
*/
|
||||||
package client.scenes;
|
package client.scenes;
|
||||||
|
|
||||||
|
import client.utils.LocaleAware;
|
||||||
|
import client.utils.LocaleManager;
|
||||||
import client.utils.ServerUtils;
|
import client.utils.ServerUtils;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import commons.Recipe;
|
import commons.Recipe;
|
||||||
import jakarta.ws.rs.WebApplicationException;
|
import jakarta.ws.rs.WebApplicationException;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.Alert;
|
import javafx.scene.control.Alert;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextField;
|
||||||
import javafx.scene.input.KeyEvent;
|
import javafx.scene.input.KeyEvent;
|
||||||
import javafx.stage.Modality;
|
import javafx.stage.Modality;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class AddIngredientCtrl {
|
public class AddIngredientCtrl implements LocaleAware {
|
||||||
|
|
||||||
private final ServerUtils server;
|
private final ServerUtils server;
|
||||||
private final MainCtrl mainCtrl;
|
private final MainCtrl mainCtrl;
|
||||||
private final FoodpalApplicationCtrl foodpalCtrl;
|
private final FoodpalApplicationCtrl foodpalCtrl;
|
||||||
|
|
||||||
|
private final LocaleManager localeManager;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public TextField ingredient;
|
public TextField ingredient;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public Button okButton;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public Button cancelButton;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public Label ingredientLabel;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public AddIngredientCtrl(ServerUtils server, MainCtrl mainCtrl, FoodpalApplicationCtrl foodpalCtrl) {
|
public AddIngredientCtrl(ServerUtils server, MainCtrl mainCtrl,
|
||||||
|
FoodpalApplicationCtrl foodpalCtrl, LocaleManager localeManager) {
|
||||||
this.mainCtrl = mainCtrl;
|
this.mainCtrl = mainCtrl;
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.foodpalCtrl = foodpalCtrl;
|
this.foodpalCtrl = foodpalCtrl;
|
||||||
|
this.localeManager = localeManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateText() {
|
||||||
|
ingredientLabel.setText(getLocaleString("add.ingredient.label"));
|
||||||
|
okButton.setText(getLocaleString("button.ok"));
|
||||||
|
cancelButton.setText(getLocaleString("button.cancel"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LocaleManager getLocaleManager() {
|
||||||
|
return localeManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancel() throws IOException, InterruptedException {
|
public void cancel() throws IOException, InterruptedException {
|
||||||
|
|
@ -83,4 +111,5 @@ public class AddIngredientCtrl {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -15,28 +15,58 @@
|
||||||
*/
|
*/
|
||||||
package client.scenes;
|
package client.scenes;
|
||||||
|
|
||||||
|
import client.utils.LocaleAware;
|
||||||
|
import client.utils.LocaleManager;
|
||||||
import client.utils.ServerUtils;
|
import client.utils.ServerUtils;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
import jakarta.ws.rs.WebApplicationException;
|
import jakarta.ws.rs.WebApplicationException;
|
||||||
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.Alert;
|
import javafx.scene.control.Alert;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextField;
|
||||||
import javafx.scene.input.KeyEvent;
|
import javafx.scene.input.KeyEvent;
|
||||||
import javafx.stage.Modality;
|
import javafx.stage.Modality;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class AddNameCtrl {
|
public class AddNameCtrl implements LocaleAware {
|
||||||
|
|
||||||
private final ServerUtils server;
|
private final ServerUtils server;
|
||||||
private final MainCtrl mainCtrl;
|
private final MainCtrl mainCtrl;
|
||||||
|
|
||||||
|
private final LocaleManager localeManager;
|
||||||
|
|
||||||
|
@FXML
|
||||||
public TextField recipeName;
|
public TextField recipeName;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public Label recipeNameLabel;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public Button cancelButton;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public Button okButton;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public AddNameCtrl(ServerUtils server, MainCtrl mainCtrl) {
|
public AddNameCtrl(ServerUtils server, MainCtrl mainCtrl, LocaleManager localeManager) {
|
||||||
this.mainCtrl = mainCtrl;
|
this.mainCtrl = mainCtrl;
|
||||||
this.server = server;
|
this.server = server;
|
||||||
|
this.localeManager = localeManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateText() {
|
||||||
|
recipeNameLabel.setText(getLocaleString("add.recipe.label"));
|
||||||
|
okButton.setText(getLocaleString("button.ok"));
|
||||||
|
cancelButton.setText(getLocaleString("button.cancel"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LocaleManager getLocaleManager() {
|
||||||
|
return localeManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancel() throws IOException, InterruptedException {
|
public void cancel() throws IOException, InterruptedException {
|
||||||
|
|
@ -78,4 +108,5 @@ public class AddNameCtrl {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -15,33 +15,60 @@
|
||||||
*/
|
*/
|
||||||
package client.scenes;
|
package client.scenes;
|
||||||
|
|
||||||
|
import client.utils.LocaleAware;
|
||||||
|
import client.utils.LocaleManager;
|
||||||
import client.utils.ServerUtils;
|
import client.utils.ServerUtils;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import commons.Recipe;
|
import commons.Recipe;
|
||||||
import jakarta.ws.rs.WebApplicationException;
|
import jakarta.ws.rs.WebApplicationException;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.Alert;
|
import javafx.scene.control.Alert;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextField;
|
||||||
import javafx.scene.input.KeyEvent;
|
import javafx.scene.input.KeyEvent;
|
||||||
import javafx.stage.Modality;
|
import javafx.stage.Modality;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class AddStepsCtrl {
|
public class AddStepsCtrl implements LocaleAware {
|
||||||
|
|
||||||
private final ServerUtils server;
|
private final ServerUtils server;
|
||||||
private final MainCtrl mainCtrl;
|
private final MainCtrl mainCtrl;
|
||||||
private final FoodpalApplicationCtrl foodpalCtrl;
|
private final FoodpalApplicationCtrl foodpalCtrl;
|
||||||
|
private final LocaleManager localeManager;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public TextField preparationStep;
|
public TextField preparationStep;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public Button okButton;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public Button cancelButton;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public Label preparationStepLabel;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public AddStepsCtrl(ServerUtils server, MainCtrl mainCtrl, FoodpalApplicationCtrl foodpalCtrl) {
|
public AddStepsCtrl(ServerUtils server, MainCtrl mainCtrl,
|
||||||
|
FoodpalApplicationCtrl foodpalCtrl, LocaleManager localeManager) {
|
||||||
this.mainCtrl = mainCtrl;
|
this.mainCtrl = mainCtrl;
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.foodpalCtrl = foodpalCtrl;
|
this.foodpalCtrl = foodpalCtrl;
|
||||||
|
this.localeManager = localeManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateText() {
|
||||||
|
preparationStepLabel.setText(getLocaleString("add.step.label"));
|
||||||
|
okButton.setText(getLocaleString("button.ok"));
|
||||||
|
cancelButton.setText(getLocaleString("button.cancel"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LocaleManager getLocaleManager() {
|
||||||
|
return localeManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancel() throws IOException, InterruptedException {
|
public void cancel() throws IOException, InterruptedException {
|
||||||
|
|
@ -83,4 +110,5 @@ public class AddStepsCtrl {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -2,24 +2,28 @@ package client.scenes;
|
||||||
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import client.utils.LocaleAware;
|
||||||
|
import client.utils.LocaleManager;
|
||||||
import client.utils.ServerUtils;
|
import client.utils.ServerUtils;
|
||||||
import commons.Recipe;
|
import commons.Recipe;
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.ListCell;
|
import javafx.scene.control.ListCell;
|
||||||
import javafx.scene.control.ListView;
|
import javafx.scene.control.ListView;
|
||||||
|
|
||||||
public class FoodpalApplicationCtrl {
|
public class FoodpalApplicationCtrl implements LocaleAware {
|
||||||
private final MainCtrl mainCtrl;
|
private final MainCtrl mainCtrl;
|
||||||
private final ServerUtils server;
|
private final ServerUtils server;
|
||||||
|
private final LocaleManager localeManager;
|
||||||
|
|
||||||
|
|
||||||
// all of these aren't used with only my part of the code
|
|
||||||
// everything in the top bar ===
|
// everything in the top bar ===
|
||||||
@FXML
|
@FXML
|
||||||
private Button flagEnButton; //already here for advanced stuff
|
private Button flagEnButton; //already here for advanced stuff
|
||||||
|
|
@ -30,19 +34,10 @@ public class FoodpalApplicationCtrl {
|
||||||
@FXML
|
@FXML
|
||||||
private Button flagPlButton; //already here for advanced stuff
|
private Button flagPlButton; //already here for advanced stuff
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Button refreshButton;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Button closeButton; //already here for advanced stuff
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Button maximizeButton; //already here for advanced stuff
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Button minimizeButton; //already here for advanced stuff
|
|
||||||
|
|
||||||
// everything in the left lane
|
// everything in the left lane
|
||||||
|
@FXML
|
||||||
|
public Label recipesLabel;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private ListView<Recipe> recipeList;
|
private ListView<Recipe> recipeList;
|
||||||
|
|
||||||
|
|
@ -52,6 +47,9 @@ public class FoodpalApplicationCtrl {
|
||||||
@FXML
|
@FXML
|
||||||
private Button removeRecipeButton;
|
private Button removeRecipeButton;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public Button cloneRecipeButton;
|
||||||
|
|
||||||
// === CENTER: RECIPE DETAILS ===
|
// === CENTER: RECIPE DETAILS ===
|
||||||
@FXML
|
@FXML
|
||||||
private Label recipeNameLabel;
|
private Label recipeNameLabel;
|
||||||
|
|
@ -59,6 +57,18 @@ public class FoodpalApplicationCtrl {
|
||||||
@FXML
|
@FXML
|
||||||
private Button editRecipeTitleButton;
|
private Button editRecipeTitleButton;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public Button removeRecipeButton2;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public Button printRecipeButton;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public Label ingredientsLabel;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public Label preparationLabel;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private ListView<String> ingredientsListView;
|
private ListView<String> ingredientsListView;
|
||||||
|
|
||||||
|
|
@ -72,13 +82,14 @@ public class FoodpalApplicationCtrl {
|
||||||
private Button addPreparationStepButton;
|
private Button addPreparationStepButton;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public FoodpalApplicationCtrl(MainCtrl mainCtrl, ServerUtils server) {
|
public FoodpalApplicationCtrl(MainCtrl mainCtrl, ServerUtils server, LocaleManager localeManager) {
|
||||||
this.mainCtrl = mainCtrl;
|
this.mainCtrl = mainCtrl;
|
||||||
this.server = server;
|
this.server = server;
|
||||||
|
this.localeManager = localeManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@Override
|
||||||
private void initialize() throws IOException, InterruptedException {
|
public void initializeComponents() {
|
||||||
// Show recipe name in the list
|
// Show recipe name in the list
|
||||||
recipeList.setCellFactory(list -> new ListCell<>() {
|
recipeList.setCellFactory(list -> new ListCell<>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -104,20 +115,56 @@ public class FoodpalApplicationCtrl {
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
// till the all the code from everyone is implemented for now to not have errors
|
@Override
|
||||||
private void showRecipeDetails(Recipe newRecipe) {
|
public void updateText() {
|
||||||
recipeNameLabel.setText(newRecipe.getName());
|
addRecipeButton.setText(getLocaleString("menu.button.add.recipe"));
|
||||||
ingredientsListView.getItems().setAll(newRecipe.getIngredients());
|
removeRecipeButton.setText(getLocaleString("menu.button.remove.recipe"));
|
||||||
preparationListView.getItems().setAll(newRecipe.getPreparationSteps());
|
cloneRecipeButton.setText(getLocaleString("menu.button.clone"));
|
||||||
|
|
||||||
|
editRecipeTitleButton.setText(getLocaleString("menu.button.edit"));
|
||||||
|
removeRecipeButton2.setText(getLocaleString("menu.button.remove.recipe"));
|
||||||
|
printRecipeButton.setText(getLocaleString("menu.button.print"));
|
||||||
|
|
||||||
|
recipesLabel.setText(getLocaleString("menu.label.recipes"));
|
||||||
|
ingredientsLabel.setText(getLocaleString("menu.label.ingredients"));
|
||||||
|
preparationLabel.setText(getLocaleString("menu.label.preparation"));
|
||||||
|
|
||||||
|
addIngredientButton.setText(getLocaleString("menu.button.add.ingredient"));
|
||||||
|
addPreparationStepButton.setText(getLocaleString("menu.button.add.step"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LocaleManager getLocaleManager() {
|
||||||
|
return localeManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
// till the all the code from everyone is implemented for now to not have errors
|
||||||
|
private void showRecipeDetails(Recipe recipe) {
|
||||||
|
if (recipe == null) {
|
||||||
|
recipeNameLabel.setText("");
|
||||||
|
ingredientsListView.getItems().clear();
|
||||||
|
preparationListView.getItems().clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
recipeNameLabel.setText(recipe.getName());
|
||||||
|
ingredientsListView.getItems().setAll(recipe.getIngredients());
|
||||||
|
preparationListView.getItems().setAll(recipe.getPreparationSteps());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Button handlers
|
// Button handlers
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void refresh() throws IOException, InterruptedException {
|
public void refresh() {
|
||||||
// TODO: someone else doing this
|
// TODO: someone else doing this
|
||||||
List<Recipe> recipes = server.getRecipes();
|
|
||||||
|
List<Recipe> recipes;
|
||||||
|
try {
|
||||||
|
recipes = server.getRecipes();
|
||||||
|
} catch (IOException | InterruptedException e) {
|
||||||
|
recipes = Collections.emptyList();
|
||||||
|
System.err.println("Failed to load recipes: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
recipeList.getItems().setAll(recipes);
|
recipeList.getItems().setAll(recipes);
|
||||||
|
|
||||||
// Select first recipe in the list by default
|
// Select first recipe in the list by default
|
||||||
|
|
@ -126,7 +173,6 @@ public class FoodpalApplicationCtrl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a recipe, by going to a different scene, there you insert the title and bam recipe created
|
* Adds a recipe, by going to a different scene, there you insert the title and bam recipe created
|
||||||
*/
|
*/
|
||||||
|
|
@ -190,22 +236,12 @@ public class FoodpalApplicationCtrl {
|
||||||
|
|
||||||
// Language buttons
|
// Language buttons
|
||||||
@FXML
|
@FXML
|
||||||
private void switchToEnglish() {
|
private void switchLocale(ActionEvent event) {
|
||||||
System.out.println("Switch language to EN");
|
Button button = (Button)event.getSource();
|
||||||
|
String lang = (String)button.getUserData();
|
||||||
|
localeManager.setLocale(Locale.of(lang));
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
|
||||||
private void switchToDutch() {
|
|
||||||
System.out.println("Switch language to NL");
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private void switchToPolish() {
|
|
||||||
System.out.println("Switch language to PL");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//without caused errors
|
|
||||||
@FXML
|
@FXML
|
||||||
private void makePrintable() {
|
private void makePrintable() {
|
||||||
System.out.println("Recipe printed");
|
System.out.println("Recipe printed");
|
||||||
|
|
@ -232,6 +268,7 @@ public class FoodpalApplicationCtrl {
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,10 @@
|
||||||
*/
|
*/
|
||||||
package client.scenes;
|
package client.scenes;
|
||||||
|
|
||||||
|
import client.utils.LocaleAware;
|
||||||
|
import client.utils.LocaleManager;
|
||||||
|
import jakarta.inject.Inject;
|
||||||
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.Parent;
|
import javafx.scene.Parent;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
@ -22,28 +26,42 @@ import javafx.util.Pair;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class MainCtrl {
|
public class MainCtrl implements LocaleAware {
|
||||||
|
private final LocaleManager localeManager;
|
||||||
|
|
||||||
|
@FXML
|
||||||
private Stage primaryStage;
|
private Stage primaryStage;
|
||||||
|
|
||||||
|
@FXML
|
||||||
private AddNameCtrl addNameCtrl;
|
private AddNameCtrl addNameCtrl;
|
||||||
private Scene addName;
|
private Scene addName;
|
||||||
|
|
||||||
|
@FXML
|
||||||
private FoodpalApplicationCtrl foodpalCtrl;
|
private FoodpalApplicationCtrl foodpalCtrl;
|
||||||
private Scene foodpal;
|
private Scene foodpal;
|
||||||
|
|
||||||
|
@FXML
|
||||||
private AddIngredientCtrl addIngredientCtrl;
|
private AddIngredientCtrl addIngredientCtrl;
|
||||||
private Scene addIngredient;
|
private Scene addIngredient;
|
||||||
|
|
||||||
|
@FXML
|
||||||
private AddStepsCtrl addStepsCtrl;
|
private AddStepsCtrl addStepsCtrl;
|
||||||
private Scene addStep;
|
private Scene addStep;
|
||||||
|
|
||||||
public void initialize(Stage primaryStage,
|
private String addNameTitle = "add.name.title";
|
||||||
Pair<AddNameCtrl, Parent> addName,
|
private String addIngredientTitle = "add.step.title";
|
||||||
Pair<FoodpalApplicationCtrl, Parent> foodpal,
|
private String addStepTitle = "add.ingredient.title";
|
||||||
Pair<AddIngredientCtrl, Parent> addIngredient,
|
|
||||||
Pair<AddStepsCtrl, Parent> addStep
|
@Inject
|
||||||
) throws IOException, InterruptedException {
|
public MainCtrl(LocaleManager localeManager) {
|
||||||
|
this.localeManager = localeManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setup(Stage primaryStage,
|
||||||
|
Pair<AddNameCtrl, Parent> addName,
|
||||||
|
Pair<FoodpalApplicationCtrl, Parent> foodpal,
|
||||||
|
Pair<AddIngredientCtrl, Parent> addIngredient,
|
||||||
|
Pair<AddStepsCtrl, Parent> addStep) throws IOException, InterruptedException {
|
||||||
|
|
||||||
this.primaryStage = primaryStage;
|
this.primaryStage = primaryStage;
|
||||||
|
|
||||||
|
|
@ -59,14 +77,26 @@ public class MainCtrl {
|
||||||
this.addStepsCtrl = addStep.getKey();
|
this.addStepsCtrl = addStep.getKey();
|
||||||
this.addStep = new Scene(addStep.getValue());
|
this.addStep = new Scene(addStep.getValue());
|
||||||
|
|
||||||
|
|
||||||
showFoodpal();
|
showFoodpal();
|
||||||
primaryStage.show();
|
primaryStage.show();
|
||||||
|
|
||||||
|
initialize(); // Initialize LocaleManager stuff manually since MainCtrl isn't loaded from FXML.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateText() {
|
||||||
|
addNameTitle = getLocaleString("add.recipe.title");
|
||||||
|
addStepTitle = getLocaleString("add.step.title");
|
||||||
|
addIngredientTitle = getLocaleString("add.ingredient.title");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LocaleManager getLocaleManager() {
|
||||||
|
return localeManager;
|
||||||
|
}
|
||||||
|
|
||||||
public void showAddName() {
|
public void showAddName() {
|
||||||
primaryStage.setTitle("Naming recipes");
|
primaryStage.setTitle(addNameTitle);
|
||||||
primaryStage.setScene(addName);
|
primaryStage.setScene(addName);
|
||||||
addName.setOnKeyPressed(e -> {
|
addName.setOnKeyPressed(e -> {
|
||||||
try {
|
try {
|
||||||
|
|
@ -77,14 +107,14 @@ public class MainCtrl {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showFoodpal() throws IOException, InterruptedException {
|
public void showFoodpal() {
|
||||||
primaryStage.setTitle("FoodPal");
|
primaryStage.setTitle("FoodPal");
|
||||||
primaryStage.setScene(foodpal);
|
primaryStage.setScene(foodpal);
|
||||||
foodpalCtrl.refresh();
|
foodpalCtrl.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showAddIngredient() {
|
public void showAddIngredient() {
|
||||||
primaryStage.setTitle("To add ingredients");
|
primaryStage.setTitle(addIngredientTitle);
|
||||||
primaryStage.setScene(addIngredient);
|
primaryStage.setScene(addIngredient);
|
||||||
addIngredient.setOnKeyPressed(e -> {
|
addIngredient.setOnKeyPressed(e -> {
|
||||||
try {
|
try {
|
||||||
|
|
@ -97,7 +127,7 @@ public class MainCtrl {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showAddSteps() {
|
public void showAddSteps() {
|
||||||
primaryStage.setTitle("To add preparation steps");
|
primaryStage.setTitle(addStepTitle);
|
||||||
primaryStage.setScene(addStep);
|
primaryStage.setScene(addStep);
|
||||||
addStep.setOnKeyPressed(e -> {
|
addStep.setOnKeyPressed(e -> {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
42
client/src/main/java/client/utils/LocaleAware.java
Normal file
42
client/src/main/java/client/utils/LocaleAware.java
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
package client.utils;
|
||||||
|
|
||||||
|
import javafx.fxml.Initializable;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
public interface LocaleAware extends Initializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates all text when locale changes.
|
||||||
|
* Must be implemented by each controller.
|
||||||
|
*/
|
||||||
|
void updateText();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the injected LocaleManager.
|
||||||
|
* Must be implemented by each controller.
|
||||||
|
*/
|
||||||
|
LocaleManager getLocaleManager();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default void initialize(URL location, ResourceBundle resources) {
|
||||||
|
updateText();
|
||||||
|
|
||||||
|
getLocaleManager().getBundleProperty().addListener((_, _, _) -> updateText());
|
||||||
|
|
||||||
|
initializeComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
default void initialize() {
|
||||||
|
initialize(null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
default String getLocaleString(String key) {
|
||||||
|
return getLocaleManager().getBundle().getString(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optional function for initialization of components. Runs after localization.
|
||||||
|
*/
|
||||||
|
default void initializeComponents() {}
|
||||||
|
}
|
||||||
47
client/src/main/java/client/utils/LocaleManager.java
Normal file
47
client/src/main/java/client/utils/LocaleManager.java
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
package client.utils;
|
||||||
|
|
||||||
|
import javafx.beans.property.ObjectProperty;
|
||||||
|
import javafx.beans.property.SimpleObjectProperty;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
public class LocaleManager {
|
||||||
|
private final ObjectProperty<Locale> currentLocale = new SimpleObjectProperty<>(Locale.ENGLISH);
|
||||||
|
private final ObjectProperty<ResourceBundle> currentBundle = new SimpleObjectProperty<>();
|
||||||
|
|
||||||
|
private static final String RESOURCE_BUNDLE_PATH = "locale/lang";
|
||||||
|
|
||||||
|
public LocaleManager() {
|
||||||
|
// TODO: Set currentLocale to config value instead of EN default.
|
||||||
|
updateBundle();
|
||||||
|
currentLocale.addListener((_, _, _) -> updateBundle());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateBundle() {
|
||||||
|
ResourceBundle bundle = ResourceBundle.getBundle(RESOURCE_BUNDLE_PATH,
|
||||||
|
currentLocale.get(),
|
||||||
|
ResourceBundle.Control.getControl(ResourceBundle.Control.FORMAT_PROPERTIES)
|
||||||
|
);
|
||||||
|
currentBundle.set(bundle);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public void setLocale(Locale locale) {
|
||||||
|
currentLocale.set(locale);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public Locale getLocale() {
|
||||||
|
return currentLocale.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public ResourceBundle getBundle() {
|
||||||
|
return currentBundle.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public ObjectProperty<ResourceBundle> getBundleProperty() {
|
||||||
|
return currentBundle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -7,9 +7,9 @@
|
||||||
|
|
||||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="94.0" prefWidth="470.0" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="client.scenes.AddIngredientCtrl">
|
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="94.0" prefWidth="470.0" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="client.scenes.AddIngredientCtrl">
|
||||||
<children>
|
<children>
|
||||||
<Button layoutX="417.0" layoutY="54.0" mnemonicParsing="false" onAction="#ok" text="Ok" />
|
<Button fx:id="okButton" layoutX="417.0" layoutY="54.0" mnemonicParsing="false" onAction="#ok" text="Ok" />
|
||||||
<Button layoutX="349.0" layoutY="54.0" mnemonicParsing="false" onAction="#cancel" text="Cancel" />
|
<Button fx:id="cancelButton" layoutX="349.0" layoutY="54.0" mnemonicParsing="false" onAction="#cancel" text="Cancel" />
|
||||||
<TextField fx:id="ingredient" layoutX="120.0" layoutY="24.0" prefHeight="18.0" prefWidth="292.0" />
|
<TextField fx:id="ingredient" layoutX="120.0" layoutY="24.0" prefHeight="18.0" prefWidth="292.0" />
|
||||||
<Label layoutX="28.0" layoutY="29.0" text="Ingredient Name" />
|
<Label fx:id="ingredientLabel" layoutX="28.0" layoutY="29.0" text="Ingredient Name" />
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
|
|
@ -7,9 +7,9 @@
|
||||||
|
|
||||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="94.0" prefWidth="470.0" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="client.scenes.AddNameCtrl">
|
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="94.0" prefWidth="470.0" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="client.scenes.AddNameCtrl">
|
||||||
<children>
|
<children>
|
||||||
<Button layoutX="417.0" layoutY="54.0" mnemonicParsing="false" onAction="#ok" text="Ok" />
|
<Button fx:id="okButton" layoutX="417.0" layoutY="54.0" mnemonicParsing="false" onAction="#ok" text="Ok" />
|
||||||
<Button layoutX="349.0" layoutY="54.0" mnemonicParsing="false" onAction="#cancel" text="Cancel" />
|
<Button fx:id="cancelButton" layoutX="349.0" layoutY="54.0" mnemonicParsing="false" onAction="#cancel" text="Cancel" />
|
||||||
<TextField fx:id="recipeName" layoutX="109.0" layoutY="24.0" prefHeight="18.0" prefWidth="292.0" />
|
<TextField fx:id="recipeName" layoutX="109.0" layoutY="24.0" prefHeight="18.0" prefWidth="292.0" />
|
||||||
<Label layoutX="28.0" layoutY="29.0" text="Recipe Name" />
|
<Label fx:id="recipeNameLabel" layoutX="28.0" layoutY="29.0" text="Recipe Name" />
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
|
|
@ -7,9 +7,9 @@
|
||||||
|
|
||||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="94.0" prefWidth="470.0" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="client.scenes.AddStepsCtrl">
|
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="94.0" prefWidth="470.0" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="client.scenes.AddStepsCtrl">
|
||||||
<children>
|
<children>
|
||||||
<Button layoutX="417.0" layoutY="54.0" mnemonicParsing="false" onAction="#ok" text="Ok" />
|
<Button fx:id="okButton" layoutX="417.0" layoutY="54.0" mnemonicParsing="false" onAction="#ok" text="Ok" />
|
||||||
<Button layoutX="349.0" layoutY="54.0" mnemonicParsing="false" onAction="#cancel" text="Cancel" />
|
<Button fx:id="cancelButton" layoutX="349.0" layoutY="54.0" mnemonicParsing="false" onAction="#cancel" text="Cancel" />
|
||||||
<TextField fx:id="preparationStep" layoutX="120.0" layoutY="24.0" prefHeight="18.0" prefWidth="292.0" />
|
<TextField fx:id="preparationStep" layoutX="120.0" layoutY="24.0" prefHeight="18.0" prefWidth="292.0" />
|
||||||
<Label layoutX="28.0" layoutY="29.0" text="Preparation step" />
|
<Label fx:id="preparationStepLabel" layoutX="28.0" layoutY="29.0" text="Preparation step" />
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
|
|
@ -23,57 +23,57 @@
|
||||||
<padding>
|
<padding>
|
||||||
<Insets bottom="10" left="10" right="10" top="10" />
|
<Insets bottom="10" left="10" right="10" top="10" />
|
||||||
</padding>
|
</padding>
|
||||||
<GridPane>
|
<GridPane>
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="198.0" minWidth="10.0" prefWidth="130.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="198.0" minWidth="10.0" prefWidth="130.0" />
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="95.0" minWidth="2.0" prefWidth="70.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="95.0" minWidth="2.0" prefWidth="70.0" />
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
<rowConstraints>
|
<rowConstraints>
|
||||||
<RowConstraints maxHeight="54.0" minHeight="10.0" prefHeight="54.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="54.0" minHeight="10.0" prefHeight="54.0" vgrow="SOMETIMES" />
|
||||||
<RowConstraints maxHeight="25.0" minHeight="6.0" prefHeight="6.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="25.0" minHeight="6.0" prefHeight="6.0" vgrow="SOMETIMES" />
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
</rowConstraints>
|
</rowConstraints>
|
||||||
<children>
|
<children>
|
||||||
|
|
||||||
<Label prefHeight="56.0" prefWidth="158.0" text="FoodPal">
|
|
||||||
<font>
|
|
||||||
<Font name="System Bold" size="29.0" />
|
|
||||||
</font>
|
|
||||||
</Label>
|
|
||||||
<ButtonBar prefHeight="40.0" prefWidth="200.0" GridPane.rowIndex="2">
|
|
||||||
<buttons>
|
|
||||||
<ToolBar prefHeight="35.0" prefWidth="123.0">
|
|
||||||
<items>
|
|
||||||
<Button fx:id="flagEnButton" minWidth="33.0" onAction="#switchToEnglish" prefHeight="25.0" prefWidth="33.0" text="EN" />
|
|
||||||
<Button fx:id="flagNlButton" onAction="#switchToDutch" text="NL" />
|
|
||||||
<Button fx:id="flagPlButton" onAction="#switchToPolish" text="PL" />
|
|
||||||
</items>
|
|
||||||
</ToolBar>
|
|
||||||
</buttons>
|
|
||||||
</ButtonBar>
|
|
||||||
</children>
|
|
||||||
</GridPane>
|
|
||||||
|
|
||||||
<Pane HBox.hgrow="ALWAYS" />
|
<Label prefHeight="56.0" prefWidth="158.0" text="FoodPal">
|
||||||
|
<font>
|
||||||
|
<Font name="System Bold" size="29.0" />
|
||||||
|
</font>
|
||||||
|
</Label>
|
||||||
|
<ButtonBar prefHeight="40.0" prefWidth="200.0" GridPane.rowIndex="2">
|
||||||
|
<buttons>
|
||||||
|
<ToolBar prefHeight="35.0" prefWidth="123.0">
|
||||||
|
<items>
|
||||||
|
<Button fx:id="flagEnButton" minWidth="33.0" onAction="#switchLocale" userData="en" prefHeight="25.0" prefWidth="33.0" text="EN" />
|
||||||
|
<Button fx:id="flagNlButton" onAction="#switchLocale" userData="nl" text="NL" />
|
||||||
|
<Button fx:id="flagPlButton" onAction="#switchLocale" userData="pl" text="PL" />
|
||||||
|
</items>
|
||||||
|
</ToolBar>
|
||||||
|
</buttons>
|
||||||
|
</ButtonBar>
|
||||||
|
</children>
|
||||||
|
</GridPane>
|
||||||
|
|
||||||
<HBox spacing="5" />
|
<Pane HBox.hgrow="ALWAYS" />
|
||||||
<GridPane prefHeight="90.0" prefWidth="114.0">
|
|
||||||
<columnConstraints>
|
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="315.0" minWidth="10.0" prefWidth="32.1666259765625" />
|
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="315.0" minWidth="10.0" prefWidth="24.8333740234375" />
|
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="173.0" minWidth="10.0" prefWidth="28.6666259765625" />
|
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="95.0" minWidth="10.0" prefWidth="34.0" />
|
|
||||||
</columnConstraints>
|
|
||||||
<rowConstraints>
|
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
|
||||||
</rowConstraints>
|
|
||||||
<children>
|
|
||||||
|
|
||||||
<Button fx:id="refreshButton" onAction="#refresh" prefHeight="25.0" prefWidth="34.0" text="⟳" GridPane.columnIndex="3" GridPane.rowIndex="2" />
|
<HBox spacing="5" />
|
||||||
</children>
|
<GridPane prefHeight="90.0" prefWidth="114.0">
|
||||||
</GridPane>
|
<columnConstraints>
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="315.0" minWidth="10.0" prefWidth="32.1666259765625" />
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="315.0" minWidth="10.0" prefWidth="24.8333740234375" />
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="173.0" minWidth="10.0" prefWidth="28.6666259765625" />
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="95.0" minWidth="10.0" prefWidth="34.0" />
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
</rowConstraints>
|
||||||
|
<children>
|
||||||
|
|
||||||
|
<Button fx:id="refreshButton" onAction="#refresh" prefHeight="25.0" prefWidth="34.0" text="⟳" GridPane.columnIndex="3" GridPane.rowIndex="2" />
|
||||||
|
</children>
|
||||||
|
</GridPane>
|
||||||
</HBox>
|
</HBox>
|
||||||
</top>
|
</top>
|
||||||
|
|
||||||
|
|
@ -84,17 +84,17 @@
|
||||||
<Insets bottom="10" left="10" right="10" top="10" />
|
<Insets bottom="10" left="10" right="10" top="10" />
|
||||||
</padding>
|
</padding>
|
||||||
|
|
||||||
<Label text="Recipes">
|
<Label fx:id="recipesLabel" text="Recipes">
|
||||||
<font>
|
<font>
|
||||||
<Font name="System Bold" size="15.0" />
|
<Font name="System Bold" size="15.0" />
|
||||||
</font></Label>
|
</font></Label>
|
||||||
|
|
||||||
<ListView fx:id="recipeList" />
|
<ListView fx:id="recipeList" />
|
||||||
|
|
||||||
<HBox spacing="10">
|
<HBox spacing="10">
|
||||||
<Button fx:id="AddRecipeButton" onAction="#addRecipe" text="Add Recipe" />
|
<Button fx:id="addRecipeButton" onAction="#addRecipe" text="Add Recipe" />
|
||||||
<Button fx:id="RemoveRecipeButton" onAction="#removeSelectedRecipe" text="Remove Recipe" />
|
<Button fx:id="removeRecipeButton" onAction="#removeSelectedRecipe" text="Remove Recipe" />
|
||||||
<Button fx:id= "CloneREcipeButton" mnemonicParsing="false" onAction="#cloneRecipe" text="Clone" />
|
<Button fx:id= "cloneRecipeButton" mnemonicParsing="false" onAction="#cloneRecipe" text="Clone" />
|
||||||
</HBox>
|
</HBox>
|
||||||
</VBox>
|
</VBox>
|
||||||
</left>
|
</left>
|
||||||
|
|
@ -109,17 +109,17 @@
|
||||||
<!-- Recipe title row -->
|
<!-- Recipe title row -->
|
||||||
<HBox spacing="10">
|
<HBox spacing="10">
|
||||||
<Label fx:id="recipeNameLabel" text="Recipe Name">
|
<Label fx:id="recipeNameLabel" text="Recipe Name">
|
||||||
<font>
|
<font>
|
||||||
<Font name="System Bold" size="14.0" />
|
<Font name="System Bold" size="14.0" />
|
||||||
</font></Label>
|
</font></Label>
|
||||||
<Button fx:id="editRecipeTitleButton" onAction="#editRecipeTitle" text="Edit" />
|
<Button fx:id="editRecipeTitleButton" onAction="#editRecipeTitle" text="Edit" />
|
||||||
<Button fx:id="RemoveRecipeButton2" mnemonicParsing="false" onAction="#removeSelectedRecipe" text="Remove Recipe" />
|
<Button fx:id="removeRecipeButton2" mnemonicParsing="false" onAction="#removeSelectedRecipe" text="Remove Recipe" />
|
||||||
<Button fx:id="printRecipe" mnemonicParsing="false" onAction="#makePrintable" text="Print Recipe" />
|
<Button fx:id="printRecipeButton" mnemonicParsing="false" onAction="#makePrintable" text="Print Recipe" />
|
||||||
</HBox>
|
</HBox>
|
||||||
|
|
||||||
<!-- Ingredients -->
|
<!-- Ingredients -->
|
||||||
<VBox spacing="10">
|
<VBox spacing="10">
|
||||||
<Label text="Ingredients">
|
<Label fx:id="ingredientsLabel" text="Ingredients">
|
||||||
<font>
|
<font>
|
||||||
<Font name="System Bold" size="14.0" />
|
<Font name="System Bold" size="14.0" />
|
||||||
</font>
|
</font>
|
||||||
|
|
@ -129,7 +129,7 @@
|
||||||
</VBox>
|
</VBox>
|
||||||
|
|
||||||
<!-- Preparation -->
|
<!-- Preparation -->
|
||||||
<Label text="Preparation">
|
<Label fx:id="preparationLabel" text="Preparation">
|
||||||
<font>
|
<font>
|
||||||
<Font name="System Bold" size="14.0" />
|
<Font name="System Bold" size="14.0" />
|
||||||
</font>
|
</font>
|
||||||
|
|
@ -137,16 +137,16 @@
|
||||||
<ListView fx:id="preparationListView" prefHeight="200.0" />
|
<ListView fx:id="preparationListView" prefHeight="200.0" />
|
||||||
<Button fx:id="addPreparationStepButton" onAction="#addPreparationStep" text="Add Step" />
|
<Button fx:id="addPreparationStepButton" onAction="#addPreparationStep" text="Add Step" />
|
||||||
<GridPane>
|
<GridPane>
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="890.6666870117188" minWidth="10.0" prefWidth="854.6666870117188" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="890.6666870117188" minWidth="10.0" prefWidth="854.6666870117188" />
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="445.3333740234375" minWidth="10.0" prefWidth="57.33331298828125" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="445.3333740234375" minWidth="10.0" prefWidth="57.33331298828125" />
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
<rowConstraints>
|
<rowConstraints>
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
</rowConstraints>
|
</rowConstraints>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
</VBox>
|
</VBox>
|
||||||
</center>
|
</center>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<?import javafx.scene.control.Button?>
|
|
||||||
<?import javafx.scene.control.TableColumn?>
|
|
||||||
<?import javafx.scene.control.TableView?>
|
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
|
||||||
|
|
||||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="client.scenes.QuoteOverviewCtrl">
|
|
||||||
<children>
|
|
||||||
<Button layoutX="503.0" layoutY="360.0" mnemonicParsing="false" onAction="#addQuote" text="Add Quote" />
|
|
||||||
<Button layoutX="431.0" layoutY="360.0" mnemonicParsing="false" onAction="#refresh" text="Refresh" />
|
|
||||||
<TableView fx:id="table" layoutX="14.0" layoutY="14.0" prefHeight="337.0" prefWidth="572.0">
|
|
||||||
<columns>
|
|
||||||
<TableColumn fx:id="colFirstName" prefWidth="113.0" text="First Name" />
|
|
||||||
<TableColumn fx:id="colLastName" prefWidth="114.0" text="Last Name" />
|
|
||||||
<TableColumn fx:id="colQuote" prefWidth="344.0" text="Quote" />
|
|
||||||
</columns>
|
|
||||||
</TableView>
|
|
||||||
</children>
|
|
||||||
</AnchorPane>
|
|
||||||
26
client/src/main/resources/locale/lang.properties
Normal file
26
client/src/main/resources/locale/lang.properties
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
add.ingredient.title=Add Ingredient
|
||||||
|
add.recipe.title=Create recipe
|
||||||
|
add.step.title=Add Step
|
||||||
|
|
||||||
|
add.ingredient.label=Ingredient
|
||||||
|
add.recipe.label=Recipe Name
|
||||||
|
add.step.label=Step
|
||||||
|
|
||||||
|
button.ok=Ok
|
||||||
|
button.cancel=Cancel
|
||||||
|
|
||||||
|
menu.label.recipes=Recipes
|
||||||
|
menu.label.ingredients=Ingredients
|
||||||
|
menu.label.preparation=Preparation
|
||||||
|
|
||||||
|
menu.button.add.recipe=Add Recipe
|
||||||
|
menu.button.add.ingredient=Add Ingredient
|
||||||
|
menu.button.add.step=Add Step
|
||||||
|
|
||||||
|
menu.button.remove.recipe=Remove Recipe
|
||||||
|
menu.button.remove.ingredient=Remove Ingredient
|
||||||
|
menu.button.remove.step=Remove Step
|
||||||
|
|
||||||
|
menu.button.edit=Edit
|
||||||
|
menu.button.clone=Clone
|
||||||
|
menu.button.print=Print recipe
|
||||||
26
client/src/main/resources/locale/lang_en.properties
Normal file
26
client/src/main/resources/locale/lang_en.properties
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
add.ingredient.title=Add Ingredient
|
||||||
|
add.recipe.title=Create recipe
|
||||||
|
add.step.title=Add Step
|
||||||
|
|
||||||
|
add.ingredient.label=Ingredient
|
||||||
|
add.recipe.label=Recipe Name
|
||||||
|
add.step.label=Step
|
||||||
|
|
||||||
|
button.ok=Ok
|
||||||
|
button.cancel=Cancel
|
||||||
|
|
||||||
|
menu.label.recipes=Recipes
|
||||||
|
menu.label.ingredients=Ingredients
|
||||||
|
menu.label.preparation=Preparation
|
||||||
|
|
||||||
|
menu.button.add.recipe=Add Recipe
|
||||||
|
menu.button.add.ingredient=Add Ingredient
|
||||||
|
menu.button.add.step=Add Step
|
||||||
|
|
||||||
|
menu.button.remove.recipe=Remove Recipe
|
||||||
|
menu.button.remove.ingredient=Remove Ingredient
|
||||||
|
menu.button.remove.step=Remove Step
|
||||||
|
|
||||||
|
menu.button.edit=Edit
|
||||||
|
menu.button.clone=Clone
|
||||||
|
menu.button.print=Print recipe
|
||||||
26
client/src/main/resources/locale/lang_nl.properties
Normal file
26
client/src/main/resources/locale/lang_nl.properties
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
add.ingredient.title=Ingredient toevoegen
|
||||||
|
add.recipe.title=Recept aanmaken
|
||||||
|
add.step.title=Stap toevoegen
|
||||||
|
|
||||||
|
add.ingredient.label=Ingredient
|
||||||
|
add.recipe.label=Receptnaam
|
||||||
|
add.step.label=Bereidingsstap
|
||||||
|
|
||||||
|
button.ok=Ok
|
||||||
|
button.cancel=Annuleren
|
||||||
|
|
||||||
|
menu.label.recipes=Recepten
|
||||||
|
menu.label.ingredients=Ingrediënten
|
||||||
|
menu.label.preparation=Bereiding
|
||||||
|
|
||||||
|
menu.button.add.recipe=Recept toevoegen
|
||||||
|
menu.button.add.ingredient=Ingrediënt toevoegen
|
||||||
|
menu.button.add.step=Stap toevoegen
|
||||||
|
|
||||||
|
menu.button.remove.recipe=Recept verwijderen
|
||||||
|
menu.button.remove.ingredient=Ingrediënt verwijderen
|
||||||
|
menu.button.remove.step=Stap verwijderen
|
||||||
|
|
||||||
|
menu.button.edit=Bewerken
|
||||||
|
menu.button.clone=Dupliceren
|
||||||
|
menu.button.print=Recept afdrukken
|
||||||
26
client/src/main/resources/locale/lang_pl.properties
Normal file
26
client/src/main/resources/locale/lang_pl.properties
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
add.ingredient.title=Dodaj składnik
|
||||||
|
add.recipe.title=Utwórz przepis
|
||||||
|
add.step.title=Dodaj instrukcję
|
||||||
|
|
||||||
|
add.ingredient.label=Składnik
|
||||||
|
add.recipe.label=Nazwa przepisu
|
||||||
|
add.step.label=Instrukcja
|
||||||
|
|
||||||
|
button.ok=Ok
|
||||||
|
button.cancel=Anuluj
|
||||||
|
|
||||||
|
menu.label.recipes=Przepisy
|
||||||
|
menu.label.ingredients=Składniki
|
||||||
|
menu.label.preparation=Przygotowanie
|
||||||
|
|
||||||
|
menu.button.add.recipe=Dodaj przepis
|
||||||
|
menu.button.add.ingredient=Dodaj składnik
|
||||||
|
menu.button.add.step=Dodaj instrukcję
|
||||||
|
|
||||||
|
menu.button.remove.recipe=Usuń przepis
|
||||||
|
menu.button.remove.ingredient=Usuń składnik
|
||||||
|
menu.button.remove.step=Usuń instrukcję
|
||||||
|
|
||||||
|
menu.button.edit=Edytuj
|
||||||
|
menu.button.clone=Duplikuj
|
||||||
|
menu.button.print=Drukuj przepis
|
||||||
|
|
@ -15,16 +15,16 @@
|
||||||
*/
|
*/
|
||||||
package client.scenes;
|
package client.scenes;
|
||||||
|
|
||||||
|
import client.utils.LocaleManager;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class MainCtrlTest {
|
public class MainCtrlTest {
|
||||||
|
|
||||||
private MainCtrl sut;
|
private MainCtrl sut;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
sut = new MainCtrl();
|
sut = new MainCtrl(new LocaleManager());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue