Everything except window titles works with resource bundles
This commit is contained in:
parent
c53239d71e
commit
91c8469282
6 changed files with 197 additions and 100 deletions
|
|
@ -2,9 +2,11 @@ package client.scenes;
|
|||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import client.utils.LocaleAware;
|
||||
import client.utils.LocaleManager;
|
||||
import client.utils.ServerUtils;
|
||||
import commons.Recipe;
|
||||
|
|
@ -16,13 +18,11 @@ import javafx.scene.control.Label;
|
|||
import javafx.scene.control.ListCell;
|
||||
import javafx.scene.control.ListView;
|
||||
|
||||
public class FoodpalApplicationCtrl {
|
||||
public class FoodpalApplicationCtrl implements LocaleAware {
|
||||
private final MainCtrl mainCtrl;
|
||||
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 ===
|
||||
@FXML
|
||||
private Button flagEnButton; //already here for advanced stuff
|
||||
|
|
@ -33,19 +33,13 @@ public class FoodpalApplicationCtrl {
|
|||
@FXML
|
||||
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
|
||||
@FXML
|
||||
public Label recipesLabel;
|
||||
|
||||
@FXML
|
||||
private ListView<Recipe> recipeList;
|
||||
|
||||
|
|
@ -55,6 +49,9 @@ public class FoodpalApplicationCtrl {
|
|||
@FXML
|
||||
private Button removeRecipeButton;
|
||||
|
||||
@FXML
|
||||
public Button cloneRecipeButton;
|
||||
|
||||
// === CENTER: RECIPE DETAILS ===
|
||||
@FXML
|
||||
private Label recipeNameLabel;
|
||||
|
|
@ -62,6 +59,18 @@ public class FoodpalApplicationCtrl {
|
|||
@FXML
|
||||
private Button editRecipeTitleButton;
|
||||
|
||||
@FXML
|
||||
public Button removeRecipeButton2;
|
||||
|
||||
@FXML
|
||||
public Button printRecipeButton;
|
||||
|
||||
@FXML
|
||||
public Label ingredientsLabel;
|
||||
|
||||
@FXML
|
||||
public Label preparationLabel;
|
||||
|
||||
@FXML
|
||||
private ListView<String> ingredientsListView;
|
||||
|
||||
|
|
@ -81,8 +90,7 @@ public class FoodpalApplicationCtrl {
|
|||
this.localeManager = localeManager;
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void initialize() throws IOException, InterruptedException {
|
||||
public void initializeComponents() {
|
||||
// Show recipe name in the list
|
||||
recipeList.setCellFactory(list -> new ListCell<>() {
|
||||
@Override
|
||||
|
|
@ -108,20 +116,50 @@ public class FoodpalApplicationCtrl {
|
|||
refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateText() {
|
||||
addRecipeButton.setText(getLocaleString("menu.button.add.recipe"));
|
||||
removeRecipeButton.setText(getLocaleString("menu.button.remove.recipe"));
|
||||
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 newRecipe) {
|
||||
recipeNameLabel.setText(newRecipe.getName());
|
||||
ingredientsListView.getItems().setAll(newRecipe.getIngredients());
|
||||
preparationListView.getItems().setAll(newRecipe.getPreparationSteps());
|
||||
|
||||
}
|
||||
|
||||
// Button handlers
|
||||
|
||||
@FXML
|
||||
public void refresh() throws IOException, InterruptedException {
|
||||
public void refresh() {
|
||||
// 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);
|
||||
|
||||
// Select first recipe in the list by default
|
||||
|
|
@ -195,25 +233,19 @@ public class FoodpalApplicationCtrl {
|
|||
// Language buttons
|
||||
@FXML
|
||||
private void switchToEnglish() {
|
||||
System.out.println("Switch language to EN");
|
||||
localeManager.setLocale(Locale.of("en"));
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void switchToDutch() {
|
||||
System.out.println("Switch language to NL");
|
||||
localeManager.setLocale(Locale.of("nl"));
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void switchToPolish() {
|
||||
System.out.println("Switch language to PL");
|
||||
localeManager.setLocale(Locale.of("pl"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
//without caused errors
|
||||
@FXML
|
||||
private void makePrintable() {
|
||||
System.out.println("Recipe printed");
|
||||
|
|
@ -240,6 +272,7 @@ public class FoodpalApplicationCtrl {
|
|||
refresh();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -23,57 +23,57 @@
|
|||
<padding>
|
||||
<Insets bottom="10" left="10" right="10" top="10" />
|
||||
</padding>
|
||||
<GridPane>
|
||||
<columnConstraints>
|
||||
<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>
|
||||
<rowConstraints>
|
||||
<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 minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<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>
|
||||
<GridPane>
|
||||
<columnConstraints>
|
||||
<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>
|
||||
<rowConstraints>
|
||||
<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 minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
|
||||
<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="#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>
|
||||
|
||||
<HBox spacing="5" />
|
||||
<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>
|
||||
<Pane HBox.hgrow="ALWAYS" />
|
||||
|
||||
<Button fx:id="refreshButton" onAction="#refresh" prefHeight="25.0" prefWidth="34.0" text="⟳" GridPane.columnIndex="3" GridPane.rowIndex="2" />
|
||||
</children>
|
||||
</GridPane>
|
||||
<HBox spacing="5" />
|
||||
<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" />
|
||||
</children>
|
||||
</GridPane>
|
||||
</HBox>
|
||||
</top>
|
||||
|
||||
|
|
@ -84,17 +84,17 @@
|
|||
<Insets bottom="10" left="10" right="10" top="10" />
|
||||
</padding>
|
||||
|
||||
<Label text="Recipes">
|
||||
<font>
|
||||
<Font name="System Bold" size="15.0" />
|
||||
</font></Label>
|
||||
<Label fx:id="recipesLabel" text="Recipes">
|
||||
<font>
|
||||
<Font name="System Bold" size="15.0" />
|
||||
</font></Label>
|
||||
|
||||
<ListView fx:id="recipeList" />
|
||||
|
||||
<HBox spacing="10">
|
||||
<Button fx:id="AddRecipeButton" onAction="#addRecipe" text="Add Recipe" />
|
||||
<Button fx:id="RemoveRecipeButton" onAction="#removeSelectedRecipe" text="Remove Recipe" />
|
||||
<Button fx:id= "CloneREcipeButton" mnemonicParsing="false" onAction="#cloneRecipe" text="Clone" />
|
||||
<Button fx:id="addRecipeButton" onAction="#addRecipe" text="Add Recipe" />
|
||||
<Button fx:id="removeRecipeButton" onAction="#removeSelectedRecipe" text="Remove Recipe" />
|
||||
<Button fx:id= "cloneRecipeButton" mnemonicParsing="false" onAction="#cloneRecipe" text="Clone" />
|
||||
</HBox>
|
||||
</VBox>
|
||||
</left>
|
||||
|
|
@ -109,17 +109,17 @@
|
|||
<!-- Recipe title row -->
|
||||
<HBox spacing="10">
|
||||
<Label fx:id="recipeNameLabel" text="Recipe Name">
|
||||
<font>
|
||||
<Font name="System Bold" size="14.0" />
|
||||
</font></Label>
|
||||
<font>
|
||||
<Font name="System Bold" size="14.0" />
|
||||
</font></Label>
|
||||
<Button fx:id="editRecipeTitleButton" onAction="#editRecipeTitle" text="Edit" />
|
||||
<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="removeRecipeButton2" mnemonicParsing="false" onAction="#removeSelectedRecipe" text="Remove Recipe" />
|
||||
<Button fx:id="printRecipeButton" mnemonicParsing="false" onAction="#makePrintable" text="Print Recipe" />
|
||||
</HBox>
|
||||
|
||||
<!-- Ingredients -->
|
||||
<VBox spacing="10">
|
||||
<Label text="Ingredients">
|
||||
<Label fx:id="ingredientsLabel" text="Ingredients">
|
||||
<font>
|
||||
<Font name="System Bold" size="14.0" />
|
||||
</font>
|
||||
|
|
@ -129,7 +129,7 @@
|
|||
</VBox>
|
||||
|
||||
<!-- Preparation -->
|
||||
<Label text="Preparation">
|
||||
<Label fx:id="preparationLabel" text="Preparation">
|
||||
<font>
|
||||
<Font name="System Bold" size="14.0" />
|
||||
</font>
|
||||
|
|
@ -137,16 +137,16 @@
|
|||
<ListView fx:id="preparationListView" prefHeight="200.0" />
|
||||
<Button fx:id="addPreparationStepButton" onAction="#addPreparationStep" text="Add Step" />
|
||||
<GridPane>
|
||||
<columnConstraints>
|
||||
<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>
|
||||
<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>
|
||||
</GridPane>
|
||||
<columnConstraints>
|
||||
<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>
|
||||
<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>
|
||||
</GridPane>
|
||||
</VBox>
|
||||
</center>
|
||||
|
||||
|
|
|
|||
|
|
@ -8,3 +8,19 @@ 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
|
||||
|
|
|
|||
|
|
@ -4,7 +4,23 @@ add.step.title=Add Step
|
|||
|
||||
add.ingredient.label=Ingredient
|
||||
add.recipe.label=Recipe Name
|
||||
add.step.label=Preparation Step
|
||||
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
|
||||
|
|
|
|||
|
|
@ -7,4 +7,20 @@ add.recipe.label=Receptnaam
|
|||
add.step.label=Bereidingsstap
|
||||
|
||||
button.ok=Ok
|
||||
button.cancel=Annuleren
|
||||
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
|
||||
|
|
|
|||
|
|
@ -1,10 +1,26 @@
|
|||
add.ingredient.title=Dodaj sk?adnik
|
||||
add.recipe.title=Utwórz przepis
|
||||
add.ingredient.title=Dodaj składnik
|
||||
add.recipe.title=Utwórz przepis
|
||||
add.step.title=Dodaj instrukcje
|
||||
|
||||
add.ingredient.label=Sk?adnik
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue