Skip to content

Commit

Permalink
Merge 887f473 into 7670c75
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinMgt authored May 25, 2023
2 parents 7670c75 + 887f473 commit e281361
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
6 changes: 6 additions & 0 deletions src/main/java/components/comparison/ComparisonView.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@
import application.history.HistoryManager;
import components.comparison.controllers.ComparisonTableController;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.collections.ObservableList;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyCodeCombination;
import javafx.scene.input.KeyCombination;
import javafx.stage.Stage;
import utils.GlobalVariables;

Expand All @@ -33,10 +37,12 @@ public void start(Stage stage) throws IOException {
fxmlLoader.setResources(Configuration.langBundle);
Parent root = fxmlLoader.load();
Scene scene = new Scene(root);
controller.setShortcuts();
root.getStylesheets().add(Objects.requireNonNull(getClass().getResource("/css/application.css")).toExternalForm());
stage.setScene(scene);
GlobalVariables.getGlobalVariables().setComparisonState(true);
GlobalVariables.getGlobalVariables().setId(startingId);
stage.show();

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import javafx.geometry.Orientation;
import javafx.scene.Node;
import javafx.scene.control.*;
import javafx.scene.control.MenuItem;
import javafx.scene.control.skin.TableColumnHeader;
import javafx.scene.input.ContextMenuEvent;
import javafx.scene.input.KeyCode;
Expand All @@ -27,8 +28,6 @@
import persistency.newSaveSystem.SConcreteCategory;
import persistency.newSaveSystem.SMoment;

//import javax.swing.event.ChangeListener;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.IOException;
import java.net.URL;
Expand All @@ -40,8 +39,8 @@
public class ComparisonTableController implements Initializable {

private @FXML VBox table;
public @FXML MenuItem undo;
public @FXML MenuItem redo;
public @FXML MenuItem undoC;
public @FXML MenuItem redoC;
private ComparisonTable comparisonTable;
private final ObservableList<String> selectionInterviews;

Expand All @@ -67,21 +66,21 @@ public ComparisonTableController(ObservableList<String> selectionInterviews) {

@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
final KeyCodeCombination keyCombUNDO = new KeyCodeCombination(KeyCode.Z, KeyCombination.SHORTCUT_DOWN);
/*final KeyCodeCombination keyCombUNDO = new KeyCodeCombination(KeyCode.Z, KeyCombination.SHORTCUT_DOWN);
final KeyCodeCombination keyCombREDO = new KeyCodeCombination(KeyCode.Y, KeyCombination.SHORTCUT_DOWN);
//set the undo method to the undo keyCombination
this.undoC.setAccelerator(keyCombUNDO);
redoC.setAccelerator(keyCombREDO);*/
table.requestFocus();
fillTable(this.selectionInterviews);
Platform.runLater(() -> {
//bindUndoRedoButtons(false);
bindScroll();
setColumnsSizesToBiggest();
//bindUndoRedoButtons(true);

//set the undo method to the undo keyCombination
this.undo.setAccelerator(keyCombUNDO);
redo.setAccelerator(keyCombREDO);
});

/*
this.table.setOnKeyPressed(event -> {
if (keyCombUNDO.match(event)) {
undo();
Expand All @@ -90,10 +89,17 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
redo();
event.consume(); // Prevent the event from being processed further
}
});
});*/

}

public void setShortcuts(){
final KeyCodeCombination keyCombUNDO = new KeyCodeCombination(KeyCode.Z, KeyCombination.SHORTCUT_DOWN);
final KeyCodeCombination keyCombREDO = new KeyCodeCombination(KeyCode.Y, KeyCombination.SHORTCUT_DOWN);
undoC.setAccelerator(keyCombUNDO);
redoC.setAccelerator(keyCombREDO);
}


///////////////////////////// CREATE TABLE /////////////////////////////
//remplit la table avec les données
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/views/Comparison/ComparisonView.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<MenuItem fx:id="excelExportButton" mnemonicParsing="false" onAction="#exportToExcel" text="%export_to_excel"/>
</Menu>
<Menu mnemonicParsing="false" text="%edit">
<MenuItem fx:id="undo" mnemonicParsing="false" onAction="#undo" text="%undo"/>
<MenuItem fx:id="redo" mnemonicParsing="false" onAction="#redo" text="%redo"/>
<MenuItem fx:id="undoC" mnemonicParsing="false" onAction="#undo" text="%undo"/>
<MenuItem fx:id="redoC" mnemonicParsing="false" onAction="#redo" text="%redo"/>
</Menu>
</MenuBar>
<padding>
Expand Down

0 comments on commit e281361

Please sign in to comment.