Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Baptiste123D committed Feb 29, 2024
2 parents 74f3f95 + be5850e commit 640a9c4
Show file tree
Hide file tree
Showing 15 changed files with 295 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import components.schemaTree.Cell.appCommands.SchemaTreeCommandFactory;
import components.toolbox.controllers.ToolBoxControllers;
import javafx.geometry.Pos;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;
import javafx.scene.control.Tooltip;
import javafx.scene.input.KeyCode;
import javafx.util.Duration;
import models.SchemaCategory;
import models.SchemaMomentType;
import models.SchemaProperty;
import utils.ResourceLoader;
import utils.autoSuggestion.AutoSuggestionsTextField;
import utils.autoSuggestion.strategies.SuggestionStrategy;
import utils.autoSuggestion.strategies.SuggestionStrategyMoment;
Expand All @@ -23,11 +25,12 @@ public class SchemaTreeMomentTypeController extends SchemaTreeCellController {
private SchemaMomentType schemaMomentType;
private SchemaTreeCommandFactory cmdFactory;
private boolean renamingMode = false;

public static SchemaTreeMomentTypeController schemaTreeMomentTypeController;
public SchemaTreeMomentTypeController(SchemaMomentType schemaMomentType, SchemaTreeCommandFactory cmdFactory) {
super(schemaMomentType, cmdFactory);
this.schemaMomentType = schemaMomentType;
this.cmdFactory = cmdFactory;
schemaTreeMomentTypeController=this;
}

@Override
Expand Down Expand Up @@ -65,6 +68,144 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
}
});
optionsMenu.getItems().add(showButton);
addColorChange();
updateMomentTypeIcon(schemaMomentType.getColor());
}
public void c_white(){
cmdFactory.colorCommandMomentType(schemaMomentType, "ffffff").execute();
updateMomentTypeIcon("ffffff");

}
public void c_brown(){
cmdFactory.colorCommandMomentType(schemaMomentType, "b97a57").execute();
updateMomentTypeIcon("b97a57");
}
public void c_pink(){
cmdFactory.colorCommandMomentType(schemaMomentType, "ffaec9").execute();
updateMomentTypeIcon("ffaec9");

}
public void c_yellow(){
cmdFactory.colorCommandMomentType(schemaMomentType, "ffc90e").execute();
updateMomentTypeIcon("ffc90e");
}
public void c_green(){
cmdFactory.colorCommandMomentType(schemaMomentType, "b5e61d").execute();
updateMomentTypeIcon("b5e61d");
}
public void c_blue(){
cmdFactory.colorCommandMomentType(schemaMomentType, "7092be").execute();
updateMomentTypeIcon("7092be");
}
public void c_purple(){
cmdFactory.colorCommandMomentType(schemaMomentType, "8671cd").execute();
updateMomentTypeIcon("8671cd");
}
public void c_red(){

cmdFactory.colorCommandMomentType(schemaMomentType, "f15252").execute();
updateMomentTypeIcon("f15252");
}

private void addColorChange() {
Menu changeColor = new Menu(Configuration.langBundle.getString("change_color"));

MenuItem white = new MenuItem(" ");
white.setStyle("-fx-background-color: #ffffff;\n");
white.setOnAction(actionEvent -> {
cmdFactory.colorCommandMomentType(schemaMomentType, "ffffff").execute();
updateMomentTypeIcon("ffffff");
});
changeColor.getItems().add(white);

MenuItem brown = new MenuItem(" ");
brown.setStyle("-fx-background-color: #b97a57;\n");
brown.setOnAction(actionEvent -> {
cmdFactory.colorCommandMomentType(schemaMomentType, "b97a57").execute();
updateMomentTypeIcon("b97a57");
});
changeColor.getItems().add(brown);

MenuItem pink = new MenuItem(" ");
pink.setStyle("-fx-background-color: #ffaec9;\n");
pink.setOnAction(actionEvent -> {
cmdFactory.colorCommandMomentType(schemaMomentType, "ffaec9").execute();
updateMomentTypeIcon("ffaec9");
});
changeColor.getItems().add(pink);

MenuItem yellow = new MenuItem(" ");
yellow.setStyle("-fx-background-color: #ffc90e;\n");
yellow.setOnAction(actionEvent -> {
cmdFactory.colorCommandMomentType(schemaMomentType, "ffc90e").execute();
updateMomentTypeIcon("ffc90e");
});
changeColor.getItems().add(yellow);

MenuItem green = new MenuItem(" ");
green.setStyle("-fx-background-color: #b5e61d;\n");
green.setOnAction(actionEvent -> {
cmdFactory.colorCommandMomentType(schemaMomentType, "b5e61d").execute();
updateMomentTypeIcon("b5e61d");
});
changeColor.getItems().add(green);

MenuItem blue = new MenuItem(" ");
blue.setStyle("-fx-background-color: #7092be;\n");
blue.setOnAction(actionEvent -> {
cmdFactory.colorCommandMomentType(schemaMomentType, "7092be").execute();
updateMomentTypeIcon("7092be");
});
changeColor.getItems().add(blue);

MenuItem purple = new MenuItem(" ");
purple.setStyle("-fx-background-color: #8671cd;\n");
purple.setOnAction(actionEvent -> {
cmdFactory.colorCommandMomentType(schemaMomentType, "8671cd").execute();
updateMomentTypeIcon("8671cd");
});
changeColor.getItems().add(purple);

MenuItem red = new MenuItem(" ");
red.setStyle("-fx-background-color: #f15252;\n");
red.setOnAction(actionEvent -> {
cmdFactory.colorCommandMomentType(schemaMomentType, "f15252").execute();
updateMomentTypeIcon("f15252");
});
changeColor.getItems().add(red);

optionsMenu.getItems().add(changeColor);
}
public void updateMomentTypeIcon(String color) {
switch (color) {
case "ffffff":
pictureView.setImage(ResourceLoader.loadImage("toolBox_icon.png"));
break;
case "b97a57":
pictureView.setImage(ResourceLoader.loadImage("toolBox_brown.png"));
break;
case "ffaec9":
pictureView.setImage(ResourceLoader.loadImage("toolBox_pink.png"));
break;
case "ffc90e":
pictureView.setImage(ResourceLoader.loadImage("toolBox_yellow.png"));
break;
case "b5e61d":
pictureView.setImage(ResourceLoader.loadImage("toolBox_green.png"));
break;
case "7092be":
pictureView.setImage(ResourceLoader.loadImage("toolBox_blue.png"));
break;
case "8671cd":
pictureView.setImage(ResourceLoader.loadImage("toolBox_purple.png"));
break;
case "f15252":
pictureView.setImage(ResourceLoader.loadImage("toolBox_red.png"));
break;
default:
pictureView.setImage(ResourceLoader.loadImage("toolBox_icon.png"));
break;
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public void visit(SchemaProperty element) {
@Override
public void visit(SchemaMomentType element) {
resultController = new SchemaTreeMomentTypeController(element, cmdFactory);
element.setSchemaTreeMomentTypeController((SchemaTreeMomentTypeController) resultController);
}

public SchemaTreeCellController getResultController() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package components.schemaTree.Cell.appCommands;

import application.history.HistoryManager;
import components.schemaTree.Cell.modelCommands.ChangeColorSchemaMomentType;
import components.schemaTree.Cell.modelCommands.ChangeColorTreePluggable;
import models.SchemaCategory;
import models.SchemaMomentType;
import utils.command.Executable;

public class ChangeColorMomentTypesCommand implements Executable {

private SchemaMomentType momentType;
private String newColor;
private boolean userCommand;

public ChangeColorMomentTypesCommand(SchemaMomentType mt, String newColor) {
this.momentType = mt;
this.newColor = newColor;
this.userCommand = true;
}

@Override
public Object execute() {
String oldColor = momentType.getColor();
HistoryManager.addCommand(new ChangeColorSchemaMomentType(momentType, newColor, oldColor), userCommand);
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,7 @@ public RenameMomentTypesCommand renameTreeSchemaMomentTypes(SchemaMomentType ele
public ChangeColorCategoryCommand colorCommand(SchemaCategory c, String newColor) {
return new ChangeColorCategoryCommand(c, newColor);
}
public ChangeColorMomentTypesCommand colorCommandMomentType(SchemaMomentType mt, String newColor) {
return new ChangeColorMomentTypesCommand(mt, newColor);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package components.schemaTree.Cell.modelCommands;

import application.history.ModelUserActionCommand;
import models.SchemaCategory;
import models.SchemaMomentType;

public class ChangeColorSchemaMomentType extends ModelUserActionCommand{

private SchemaMomentType momentType;
private String oldColor;
private String newColor;

public ChangeColorSchemaMomentType(SchemaMomentType momentType, String newColor, String oldColor) {
this.momentType = momentType;
this.newColor = newColor;
this.oldColor = oldColor;
}

@Override
public Object execute() {
momentType.setColor(newColor);
return null;
}

@Override
public Object undo() {
momentType.setColor(oldColor);
return null;
}

}
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
package components.toolbox.controllers;

import application.configuration.Configuration;
import components.modelisationSpace.moment.appCommands.MomentCommandFactory;
import components.schemaTree.Cell.Controllers.SchemaTreeMomentTypeController;
import components.schemaTree.Cell.appCommands.SchemaTreeCommandFactory;
import components.toolbox.appCommand.RenameMomentTypesCommand;
import javafx.scene.control.MenuButton;
import javafx.scene.control.MenuItem;
import javafx.scene.control.*;
import javafx.scene.image.ImageView;
import javafx.util.Duration;
import models.SchemaMomentType;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.control.Tooltip;
import javafx.scene.input.*;
import javafx.scene.layout.BorderPane;
import models.Moment;
import models.*;
import utils.ResourceLoader;
import utils.autoSuggestion.AutoSuggestionsTextField;
import utils.autoSuggestion.strategies.SuggestionStrategyMoment;
import utils.dragAndDrop.DragStore;
Expand All @@ -31,12 +32,13 @@ public class MomentTypeController implements Initializable {
private @FXML Label momentTypeLabel;
@FXML
MenuButton optionsMenu;
private SchemaMomentType schemaMomentType;
@FXML
ImageView pictureView;
public SchemaMomentType schemaMomentType;

private boolean renamingMode = false;
private AutoSuggestionsTextField renamingField;

public MomentTypeController(Moment moment) {
public MomentTypeController(Moment moment ) {
this.schemaMomentType = new SchemaMomentType(moment, this);
}

Expand Down Expand Up @@ -67,6 +69,7 @@ public void initialize(URL url, ResourceBundle resourceBundle) {

schemaMomentType.nameProperty().addListener((observableValue, o, t1) -> updatePopUp());
schemaMomentType.categoriesProperty().addListener((observableValue, o, t1) -> updatePopUp());
addColorChange();
}

private void setupDragAndDrop() {
Expand Down Expand Up @@ -152,4 +155,67 @@ public void passInRenamingMode(boolean YoN) {
}
}
}
public void updateColor() {
momentTypeBorderPane.setStyle("-fx-background-color: #" + schemaMomentType.getColor() + ";\n");
}
private void addColorChange() {
Menu changeColor = new Menu(Configuration.langBundle.getString("change_color"));
MenuItem white = new MenuItem(" ");
white.setStyle("-fx-background-color: #ffffff;\n");
white.setOnAction(actionEvent -> {
schemaMomentType.getSchemaTreeMomentTypeController().c_white();
});
changeColor.getItems().add(white);

MenuItem brown = new MenuItem(" ");
brown.setStyle("-fx-background-color: #b97a57;\n");
brown.setOnAction(actionEvent -> {
schemaMomentType.getSchemaTreeMomentTypeController().c_brown();
});
changeColor.getItems().add(brown);

MenuItem pink = new MenuItem(" ");
pink.setStyle("-fx-background-color: #ffaec9;\n");
pink.setOnAction(actionEvent -> {
schemaMomentType.getSchemaTreeMomentTypeController().c_pink();
});
changeColor.getItems().add(pink);

MenuItem yellow = new MenuItem(" ");
yellow.setStyle("-fx-background-color: #ffc90e;\n");
yellow.setOnAction(actionEvent -> {
schemaMomentType.getSchemaTreeMomentTypeController().c_yellow();
});
changeColor.getItems().add(yellow);

MenuItem green = new MenuItem(" ");
green.setStyle("-fx-background-color: #b5e61d;\n");
green.setOnAction(actionEvent -> {
schemaMomentType.getSchemaTreeMomentTypeController().c_green();
});
changeColor.getItems().add(green);

MenuItem blue = new MenuItem(" ");
blue.setStyle("-fx-background-color: #7092be;\n");
blue.setOnAction(actionEvent -> {
schemaMomentType.getSchemaTreeMomentTypeController().c_blue();
});
changeColor.getItems().add(blue);

MenuItem purple = new MenuItem(" ");
purple.setStyle("-fx-background-color: #8671cd;\n");
purple.setOnAction(actionEvent -> {
schemaMomentType.getSchemaTreeMomentTypeController().c_purple();
});
changeColor.getItems().add(purple);

MenuItem red = new MenuItem(" ");
red.setStyle("-fx-background-color: #f15252;\n");
red.setOnAction(actionEvent -> {
schemaMomentType.getSchemaTreeMomentTypeController().c_red();
});
changeColor.getItems().add(red);

optionsMenu.getItems().add(changeColor);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ private void setupDragAndDrop() {

// permet d'être utilisé dans l'arbre à gauche pour créer un type de moment
public void addMomentTypeCommand(Moment m) {
SchemaMomentType smt = new SchemaMomentType(m, new MomentTypeController(m));
MomentTypeController momentTypeController = new MomentTypeController(m);
SchemaMomentType smt = new SchemaMomentType(m, momentTypeController);
momentTypeController.schemaMomentType=smt;
new AddSchemaMomentTypeCommand(instance, smt).execute();
}

Expand Down
Loading

0 comments on commit 640a9c4

Please sign in to comment.