From e0e208919033dd3798c7047c3fb862faf751d9a7 Mon Sep 17 00:00:00 2001 From: GAM Date: Thu, 11 Mar 2021 04:44:31 +0100 Subject: [PATCH] timeControl instead of format --- db/db_init.sql | 120 +++++++++--------- .../application/data/entity/GameInfo.java | 16 +-- .../data/service/ChessComService.java | 2 +- .../application/views/results/MatchView.java | 17 ++- .../views/results/MatchdayView.java | 2 +- .../views/results/ResultsView.java | 18 +-- 6 files changed, 94 insertions(+), 81 deletions(-) diff --git a/db/db_init.sql b/db/db_init.sql index 867ead1..afd0455 100644 --- a/db/db_init.sql +++ b/db/db_init.sql @@ -41,7 +41,7 @@ CREATE TABLE "game" ( CREATE TABLE "game_info" ( "id" SERIAL PRIMARY KEY, - "format" int, + "time_control" varchar, "url" varchar ); @@ -357,136 +357,136 @@ INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 9, 5, 26); INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 7, 13, 26); INSERT INTO "match" ("player1", "player2", "matchday") VALUES (14, 2, 26); -INSERT INTO "game_info" (format, url) VALUES (10, 'https://www.chess.com/live/game/8722014513'); +INSERT INTO "game_info" (time_control, url)VALUES ('600', 'https://www.chess.com/live/game/8722014513'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=2 AND player2=9 AND matchday=1), TRUE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8722014513')); -INSERT INTO "game_info" (format, url) VALUES (10, 'https://www.chess.com/live/game/8723231941'); +INSERT INTO "game_info" (time_control, url)VALUES ('600', 'https://www.chess.com/live/game/8723231941'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=2 AND player2=9 AND matchday=1), FALSE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8723231941')); -INSERT INTO "game_info" (format, url) VALUES (5, 'https://www.chess.com/live/game/8724907847'); +INSERT INTO "game_info" (time_control, url)VALUES ('300', 'https://www.chess.com/live/game/8724907847'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=2 AND player2=9 AND matchday=1), TRUE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8724907847')); -INSERT INTO "game_info" (format, url) VALUES (5, 'https://www.chess.com/live/game/8725036665'); +INSERT INTO "game_info" (time_control, url)VALUES ('300', 'https://www.chess.com/live/game/8725036665'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=2 AND player2=9 AND matchday=1), FALSE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8725036665')); -INSERT INTO "game_info" (format, url) VALUES (3, 'https://www.chess.com/live/game/8725614379'); +INSERT INTO "game_info" (time_control, url)VALUES ('180', 'https://www.chess.com/live/game/8725614379'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=2 AND player2=9 AND matchday=1), TRUE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8725614379')); -INSERT INTO "game_info" (format, url) VALUES (3, 'https://www.chess.com/live/game/8726184583'); +INSERT INTO "game_info" (time_control, url)VALUES ('180', 'https://www.chess.com/live/game/8726184583'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=2 AND player2=9 AND matchday=1), FALSE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8726184583')); -INSERT INTO "game_info" (format, url) VALUES (10, 'https://www.chess.com/live/game/8616485043'); +INSERT INTO "game_info" (time_control, url)VALUES ('600', 'https://www.chess.com/live/game/8616485043'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=14 AND player2=7 AND matchday=1), TRUE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8616485043')); -INSERT INTO "game_info" (format, url) VALUES (10, 'https://www.chess.com/live/game/8618149677'); +INSERT INTO "game_info" (time_control, url)VALUES ('600', 'https://www.chess.com/live/game/8618149677'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=14 AND player2=7 AND matchday=1), FALSE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8618149677')); -INSERT INTO "game_info" (format, url) VALUES (5, 'https://www.chess.com/live/game/8702757001'); +INSERT INTO "game_info" (time_control, url)VALUES ('300', 'https://www.chess.com/live/game/8702757001'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=14 AND player2=7 AND matchday=1), FALSE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8702757001')); -INSERT INTO "game_info" (format, url) VALUES (5, 'https://www.chess.com/live/game/8705204521'); +INSERT INTO "game_info" (time_control, url)VALUES ('300', 'https://www.chess.com/live/game/8705204521'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=14 AND player2=7 AND matchday=1), TRUE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8705204521')); -INSERT INTO "game_info" (format, url) VALUES (3, 'https://www.chess.com/live/game/8705796221'); +INSERT INTO "game_info" (time_control, url)VALUES ('180', 'https://www.chess.com/live/game/8705796221'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=14 AND player2=7 AND matchday=1), FALSE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8705796221')); -INSERT INTO "game_info" (format, url) VALUES (3, 'https://www.chess.com/live/game/8706438057'); +INSERT INTO "game_info" (time_control, url)VALUES ('180', 'https://www.chess.com/live/game/8706438057'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=14 AND player2=7 AND matchday=1), TRUE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8706438057')); -INSERT INTO "game_info" (format, url) VALUES (10, 'https://www.chess.com/live/game/8617630129'); +INSERT INTO "game_info" (time_control, url)VALUES ('600', 'https://www.chess.com/live/game/8617630129'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=10 AND player2=4 AND matchday=1), TRUE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8617630129')); -INSERT INTO "game_info" (format, url) VALUES (10, 'https://www.chess.com/live/game/8618225533'); +INSERT INTO "game_info" (time_control, url)VALUES ('600', 'https://www.chess.com/live/game/8618225533'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=10 AND player2=4 AND matchday=1), FALSE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8618225533')); -INSERT INTO "game_info" (format, url) VALUES (5, 'https://www.chess.com/live/game/8619306585'); +INSERT INTO "game_info" (time_control, url)VALUES ('300', 'https://www.chess.com/live/game/8619306585'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=10 AND player2=4 AND matchday=1), TRUE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8619306585')); -INSERT INTO "game_info" (format, url) VALUES (5, 'https://www.chess.com/live/game/8619471075'); +INSERT INTO "game_info" (time_control, url)VALUES ('300', 'https://www.chess.com/live/game/8619471075'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=10 AND player2=4 AND matchday=1), FALSE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8619471075')); -INSERT INTO "game_info" (format, url) VALUES (3, 'https://www.chess.com/live/game/8620078695'); +INSERT INTO "game_info" (time_control, url)VALUES ('180', 'https://www.chess.com/live/game/8620078695'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=10 AND player2=4 AND matchday=1), TRUE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8620078695')); -INSERT INTO "game_info" (format, url) VALUES (3, 'https://www.chess.com/live/game/8620568591'); +INSERT INTO "game_info" (time_control, url)VALUES ('180', 'https://www.chess.com/live/game/8620568591'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=10 AND player2=4 AND matchday=1), FALSE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8620568591')); - -INSERT INTO "game_info" (format, url) VALUES (10, 'https://www.chess.com/live/game/8504667551'); + +INSERT INTO "game_info" (time_control, url)VALUES ('600', 'https://www.chess.com/live/game/8504667551'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=13 AND player2=6 AND matchday=1), TRUE, 0, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8504667551')); - -INSERT INTO "game_info" (format, url) VALUES (10, 'https://www.chess.com/live/game/8505882389'); + +INSERT INTO "game_info" (time_control, url)VALUES ('600', 'https://www.chess.com/live/game/8505882389'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=13 AND player2=6 AND matchday=1), FALSE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8505882389')); - -INSERT INTO "game_info" (format, url) VALUES (5, 'https://www.chess.com/live/game/8507004247'); + +INSERT INTO "game_info" (time_control, url)VALUES ('300', 'https://www.chess.com/live/game/8507004247'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=13 AND player2=6 AND matchday=1), TRUE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8507004247')); - -INSERT INTO "game_info" (format, url) VALUES (5, 'https://www.chess.com/live/game/8507617133'); + +INSERT INTO "game_info" (time_control, url)VALUES ('300', 'https://www.chess.com/live/game/8507617133'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=13 AND player2=6 AND matchday=1), FALSE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8507617133')); - -INSERT INTO "game_info" (format, url) VALUES (3, 'https://www.chess.com/live/game/8508203475'); + +INSERT INTO "game_info" (time_control, url)VALUES ('180', 'https://www.chess.com/live/game/8508203475'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=13 AND player2=6 AND matchday=1), TRUE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8508203475')); - -INSERT INTO "game_info" (format, url) VALUES (3, 'https://www.chess.com/live/game/8508297031'); + +INSERT INTO "game_info" (time_control, url)VALUES ('180', 'https://www.chess.com/live/game/8508297031'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=13 AND player2=6 AND matchday=1), FALSE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8508297031')); -INSERT INTO "game_info" (format, url) VALUES (10, 'https://www.chess.com/live/game/8624735639'); +INSERT INTO "game_info" (time_control, url)VALUES ('600', 'https://www.chess.com/live/game/8624735639'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=11 AND player2=8 AND matchday=1), FALSE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8624735639')); -INSERT INTO "game_info" (format, url) VALUES (10, 'https://www.chess.com/live/game/8625353555'); +INSERT INTO "game_info" (time_control, url)VALUES ('600', 'https://www.chess.com/live/game/8625353555'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=11 AND player2=8 AND matchday=1), TRUE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8625353555')); -INSERT INTO "game_info" (format, url) VALUES (5, 'https://www.chess.com/live/game/8625963087'); +INSERT INTO "game_info" (time_control, url)VALUES ('300', 'https://www.chess.com/live/game/8625963087'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=11 AND player2=8 AND matchday=1), FALSE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8625963087')); -INSERT INTO "game_info" (format, url) VALUES (5, 'https://www.chess.com/live/game/8853361491'); +INSERT INTO "game_info" (time_control, url)VALUES ('300', 'https://www.chess.com/live/game/8853361491'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=11 AND player2=8 AND matchday=1), TRUE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8853361491')); -INSERT INTO "game_info" (format, url) VALUES (3, 'https://www.chess.com/live/game/8853455035'); +INSERT INTO "game_info" (time_control, url)VALUES ('180', 'https://www.chess.com/live/game/8853455035'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=11 AND player2=8 AND matchday=1), FALSE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8853455035')); -INSERT INTO "game_info" (format, url) VALUES (3, 'https://www.chess.com/live/game/8854002505'); +INSERT INTO "game_info" (time_control, url)VALUES ('180', 'https://www.chess.com/live/game/8854002505'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=11 AND player2=8 AND matchday=1), TRUE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8854002505')); -INSERT INTO "game_info" (format, url) VALUES (10, 'https://www.chess.com/live/game/8858219835'); +INSERT INTO "game_info" (time_control, url)VALUES ('600', 'https://www.chess.com/live/game/8858219835'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=12 AND player2=1 AND matchday=1), FALSE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8858219835')); - -INSERT INTO "game_info" (format, url) VALUES (10, 'https://www.chess.com/live/game/8859375675'); + +INSERT INTO "game_info" (time_control, url)VALUES ('600', 'https://www.chess.com/live/game/8859375675'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=12 AND player2=1 AND matchday=1), TRUE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8859375675')); - -INSERT INTO "game_info" (format, url) VALUES (5, 'https://www.chess.com/live/game/8859976305'); + +INSERT INTO "game_info" (time_control, url)VALUES ('300', 'https://www.chess.com/live/game/8859976305'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=12 AND player2=1 AND matchday=1), FALSE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8859976305')); - -INSERT INTO "game_info" (format, url) VALUES (5, 'https://www.chess.com/live/game/8860591347'); + +INSERT INTO "game_info" (time_control, url)VALUES ('300', 'https://www.chess.com/live/game/8860591347'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=12 AND player2=1 AND matchday=1), TRUE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8860591347')); - -INSERT INTO "game_info" (format, url) VALUES (3, 'https://www.chess.com/live/game/8860675419'); + +INSERT INTO "game_info" (time_control, url)VALUES ('180', 'https://www.chess.com/live/game/8860675419'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=12 AND player2=1 AND matchday=1), FALSE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8860675419')); - -INSERT INTO "game_info" (format, url) VALUES (3, 'https://www.chess.com/live/game/8861228997'); + +INSERT INTO "game_info" (time_control, url)VALUES ('180', 'https://www.chess.com/live/game/8861228997'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=12 AND player2=1 AND matchday=1), TRUE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8861228997')); - -INSERT INTO "game_info" (format, url) VALUES (10, 'https://www.chess.com/live/game/8877523129'); + +INSERT INTO "game_info" (time_control, url)VALUES ('600', 'https://www.chess.com/live/game/8877523129'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=5 AND player2=3 AND matchday=1), FALSE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8877523129')); - -INSERT INTO "game_info" (format, url) VALUES (10, 'https://www.chess.com/live/game/8878652939'); + +INSERT INTO "game_info" (time_control, url)VALUES ('600', 'https://www.chess.com/live/game/8878652939'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=5 AND player2=3 AND matchday=1), TRUE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8878652939')); - -INSERT INTO "game_info" (format, url) VALUES (5, 'https://www.chess.com/live/game/8879853665'); + +INSERT INTO "game_info" (time_control, url)VALUES ('300', 'https://www.chess.com/live/game/8879853665'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=5 AND player2=3 AND matchday=1), FALSE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8879853665')); - -INSERT INTO "game_info" (format, url) VALUES (5, 'https://www.chess.com/live/game/8880469509'); + +INSERT INTO "game_info" (time_control, url)VALUES ('300', 'https://www.chess.com/live/game/8880469509'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=5 AND player2=3 AND matchday=1), TRUE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8880469509')); - -INSERT INTO "game_info" (format, url) VALUES (3, 'https://www.chess.com/live/game/8881562307'); + +INSERT INTO "game_info" (time_control, url)VALUES ('180', 'https://www.chess.com/live/game/8881562307'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=5 AND player2=3 AND matchday=1), FALSE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8881562307')); - -INSERT INTO "game_info" (format, url) VALUES (3, 'https://www.chess.com/live/game/8881610243'); + +INSERT INTO "game_info" (time_control, url)VALUES ('180', 'https://www.chess.com/live/game/8881610243'); INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=5 AND player2=3 AND matchday=1), TRUE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8881610243')); diff --git a/src/main/java/com/example/application/data/entity/GameInfo.java b/src/main/java/com/example/application/data/entity/GameInfo.java index ff9dec7..4c73968 100644 --- a/src/main/java/com/example/application/data/entity/GameInfo.java +++ b/src/main/java/com/example/application/data/entity/GameInfo.java @@ -9,7 +9,7 @@ public class GameInfo { private Integer id; private String url; private Game game; - private Integer format; + private String timeControl; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @@ -33,13 +33,13 @@ public class GameInfo { } @Basic - @Column(name = "format", nullable = false) - public Integer getFormat() { - return format; + @Column(name = "time_control", nullable = false) + public String getTimeControl() { + return timeControl; } - public void setFormat(Integer format) { - this.format = format; + public void setTimeControl(String format) { + this.timeControl = format; } @Override @@ -47,12 +47,12 @@ public class GameInfo { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; GameInfo that = (GameInfo) o; - return Objects.equals(id, that.id) && Objects.equals(url, that.url) && Objects.equals(format, that.format); + return Objects.equals(id, that.id) && Objects.equals(url, that.url) && Objects.equals(timeControl, that.timeControl); } @Override public int hashCode() { - return Objects.hash(id, url, format); + return Objects.hash(id, url, timeControl); } @OneToOne(mappedBy = "gameInfo") diff --git a/src/main/java/com/example/application/data/service/ChessComService.java b/src/main/java/com/example/application/data/service/ChessComService.java index 5268025..56f3007 100644 --- a/src/main/java/com/example/application/data/service/ChessComService.java +++ b/src/main/java/com/example/application/data/service/ChessComService.java @@ -72,7 +72,7 @@ public class ChessComService { game.setGameInfo(gameInfo); gameInfo.setUrl(chessComGame.getUrl()); - gameInfo.setFormat(Integer.parseInt(chessComGame.getTimeControl())/60); // TODO: change gameinfo.format in database to reflect this! + gameInfo.setTimeControl(chessComGame.getTimeControl()); gameInfo.setGame(game); return game; // important: match is not set here! diff --git a/src/main/java/com/example/application/views/results/MatchView.java b/src/main/java/com/example/application/views/results/MatchView.java index 0c8829a..68ace45 100644 --- a/src/main/java/com/example/application/views/results/MatchView.java +++ b/src/main/java/com/example/application/views/results/MatchView.java @@ -6,19 +6,30 @@ import com.vaadin.flow.component.html.Label; public class MatchView extends Div { + private final ResultsView parent; private final Navigation navigation; private final Label label = new Label(); // private final ChessComService chessComService; // private final PlayerService playerService; -// public ResultsViewRight(@Autowired ChessComService chessComService, @Autowired PlayerService playerService) { - public MatchView(Navigation navigation) { + // public ResultsViewRight(@Autowired ChessComService chessComService, @Autowired PlayerService playerService) { + public MatchView(Navigation navigation, ResultsView resultsView) { + this.parent = resultsView; this.navigation = navigation; - navigation.addRunnableToBeRunAfterMatchSelection(()-> label.setText(navigation.getSelectedMatch().toString())); + navigation.addRunnableToBeRunAfterMatchSelection(() -> label.setText(navigation.getSelectedMatch().toString())); + navigation.addRunnableToBeRunAfterMatchSelection(this::configureSplit); add(label); // this.chessComService = chessComService; // this.playerService = playerService; } + private void configureSplit() { + navigation.getSelectedMatch().ifPresentOrElse( + match -> parent.enableSplit(), + parent::disableSplit + ); + + } + } diff --git a/src/main/java/com/example/application/views/results/MatchdayView.java b/src/main/java/com/example/application/views/results/MatchdayView.java index 258bc0a..8df81e7 100644 --- a/src/main/java/com/example/application/views/results/MatchdayView.java +++ b/src/main/java/com/example/application/views/results/MatchdayView.java @@ -50,7 +50,7 @@ public class MatchdayView extends VerticalLayout { // LAYOUT // //////////// - protected void configureContentLayout() { + private void configureContentLayout() { setWidthFull(); setHeightFull(); setAlignItems(FlexComponent.Alignment.CENTER); diff --git a/src/main/java/com/example/application/views/results/ResultsView.java b/src/main/java/com/example/application/views/results/ResultsView.java index fd4936a..4a5e36b 100644 --- a/src/main/java/com/example/application/views/results/ResultsView.java +++ b/src/main/java/com/example/application/views/results/ResultsView.java @@ -31,33 +31,35 @@ public class ResultsView extends Div implements HasUrlParameter { this.navigation.setAutoselectSeason(true); this.navigation.setAutoselectMatchday(true); this.matchdayView = new MatchdayView(navigation, matchService); - this.matchView = new MatchView(navigation); + this.matchView = new MatchView(navigation, this); addClassName("results-view"); configureLayout(); -// disableSplit(); - enableSplit(); + disableSplit(); +// enableSplit(); } public void enableSplit() { removeAll(); add(splitLayout); + splitLayout.addToPrimary(matchdayView); + splitLayout.addToSecondary(matchView); + splitLayout.setWidthFull(); + splitLayout.setHeightFull(); + splitLayout.setSplitterPosition(50); } public void disableSplit() { removeAll(); add(matchdayView); + matchdayView.setWidthFull(); + matchdayView.setHeightFull(); } private void configureLayout() { setWidthFull(); setHeightFull(); - - splitLayout.addToPrimary(matchdayView); - splitLayout.addToSecondary(matchView); - splitLayout.setWidthFull(); - splitLayout.setHeightFull(); } @Override