Skip to content

Commit 4c3817e

Browse files
committed
#178: improve layouts
1 parent 96ecef5 commit 4c3817e

File tree

4 files changed

+75
-47
lines changed

4 files changed

+75
-47
lines changed

src/main/java/de/doubleslash/keeptime/view/ExternalProjectsSyncController.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ protected void updateItem(TableRow item, boolean empty) {
169169
});
170170
mappingTableView.setEditable(true);
171171
shouldSyncColumn.setEditable(true);
172-
shouldSyncColumn.setPrefWidth(50);
173172

174173
TableColumn<TableRow, List<Project>> projectColumn = new TableColumn<>("Project");
175174
projectColumn.setCellValueFactory(data -> new SimpleObjectProperty(data.getValue().mapping.projects()));
@@ -196,7 +195,6 @@ private HBox createRow(Color color, String text) {
196195
return new HBox(5, circle, label);
197196
}
198197
});
199-
projectColumn.setPrefWidth(100);
200198

201199
TableColumn<TableRow, TableRow> timeColumn = new TableColumn<>("Time");
202200
timeColumn.setCellValueFactory(data -> new SimpleObjectProperty<>(data.getValue())); // Placeholder property
@@ -249,7 +247,6 @@ protected void updateItem(TableRow item, boolean empty) {
249247
}
250248
}
251249
});
252-
timeColumn.setPrefWidth(125);
253250

254251
TableColumn<TableRow, TableRow> notesColumn = new TableColumn<>("Notes");
255252
notesColumn.setCellValueFactory(data -> new SimpleObjectProperty<>(data.getValue())); // Placeholder property
@@ -321,13 +318,20 @@ protected void updateItem(TableRow item, boolean empty) {
321318
}
322319
}
323320
});
324-
notesColumn.setPrefWidth(350);
325321

326322
TableColumn<TableRow, String> syncColumn = new TableColumn<>("Sync Status");
327323
syncColumn.setCellValueFactory(data -> data.getValue().syncStatus);
324+
325+
shouldSyncColumn.setPrefWidth(50);
326+
projectColumn.setPrefWidth(100);
327+
timeColumn.setPrefWidth(125);
328+
notesColumn.prefWidthProperty().bind(mappingTableView.widthProperty().subtract(525+17));
328329
syncColumn.setPrefWidth(250);
330+
329331
mappingTableView.getColumns().addAll(shouldSyncColumn, projectColumn, timeColumn, notesColumn, syncColumn);
330332
mappingTableView.setSelectionModel(null);
333+
mappingTableView.getColumns().forEach(column -> column.setSortable(false));
334+
331335

332336
saveButton.setOnAction((ae) -> {
333337
LOG.debug("New mappings to be synced '{}'.", "TODO");

src/main/java/de/doubleslash/keeptime/view/MapExternalProjectsController.java

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ public class MapExternalProjectsController {
6363
@FXML
6464
private Button cancelButton;
6565

66-
@FXML
67-
private CheckBox filterOnlyWorkCheckBox;
68-
6966
@FXML
7067
private ComboBox<HeimatTask> addNewProjectComboBox;
7168

@@ -120,21 +117,12 @@ private void initialize() {
120117
}).toList();
121118

122119
final ObservableList<ProjectMapping> observableMappings = FXCollections.observableArrayList(projectMappings);
123-
final FilteredList<ProjectMapping> value = new FilteredList<>(observableMappings);
124-
filterOnlyWorkCheckBox.selectedProperty().addListener(((observable, oldValue, newValue) -> {
125-
if (Boolean.TRUE.equals(newValue))
126-
value.setPredicate(pm -> pm.getProject().isWork());
127-
else
128-
value.setPredicate(null);
129-
}));
130-
filterOnlyWorkCheckBox.setSelected(true);
131-
120+
final FilteredList<ProjectMapping> value = new FilteredList<>(observableMappings, pm->pm.getProject().isWork());
132121
mappingTableView.setItems(value);
133122

134123
// KeepTime Project column
135124
TableColumn<ProjectMapping, String> keepTimeColumn = new TableColumn<>("KeepTime Project");
136125
keepTimeColumn.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().project.getName()));
137-
keepTimeColumn.setPrefWidth(200);
138126

139127
// External Project column with dropdown
140128
externalProjects.add(0, null); // option to clear selection
@@ -191,7 +179,10 @@ protected void updateItem(HeimatTask item, boolean empty) {
191179
}
192180
}
193181
});
194-
externalColumn.setPrefWidth(400);
182+
183+
double scrollbarWidth = 17; // Approximate width of a vertical scrollbar
184+
keepTimeColumn.prefWidthProperty().bind(mappingTableView.widthProperty().subtract(scrollbarWidth).multiply(.4));
185+
externalColumn.prefWidthProperty().bind(mappingTableView.widthProperty().subtract(scrollbarWidth).multiply(.6));
195186

196187
mappingTableView.getColumns().addAll(keepTimeColumn, externalColumn);
197188

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

33
<?import javafx.scene.control.Button?>
4-
<?import javafx.scene.control.CheckBox?>
54
<?import javafx.scene.control.ComboBox?>
65
<?import javafx.scene.control.DatePicker?>
7-
<?import javafx.scene.control.Label?>
86
<?import javafx.scene.control.TableView?>
97
<?import javafx.scene.layout.AnchorPane?>
8+
<?import javafx.scene.layout.HBox?>
109

11-
<AnchorPane prefHeight="600.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.doubleslash.keeptime.view.MapExternalProjectsController">
10+
<AnchorPane prefHeight="600.0" prefWidth="700.0" style="-fx-background-color: white;" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.doubleslash.keeptime.view.MapExternalProjectsController">
1211
<children>
13-
<TableView fx:id="mappingTableView" layoutY="50.0" prefHeight="500.0" prefWidth="600.0" />
14-
<Label text="Map projects" />
15-
<Button fx:id="saveButton" layoutX="429.0" layoutY="555.0" mnemonicParsing="false" text="Save" />
16-
<Button fx:id="cancelButton" layoutX="500.0" layoutY="555.0" mnemonicParsing="false" text="Cancel" />
17-
<CheckBox fx:id="filterOnlyWorkCheckBox" layoutX="14.0" layoutY="21.0" mnemonicParsing="false" text="Only Work items" />
18-
<ComboBox fx:id="addNewProjectComboBox" layoutX="14.0" layoutY="555.0" prefHeight="25.0" prefWidth="210.0" />
19-
<Button fx:id="addNewProjectButton" layoutX="234.0" layoutY="555.0" mnemonicParsing="false" text="Import project" />
20-
<DatePicker fx:id="tasksForDateDatePicker" layoutX="412.0" layoutY="17.0" />
12+
<TableView fx:id="mappingTableView" layoutY="50.0" prefHeight="500.0" prefWidth="600.0" AnchorPane.bottomAnchor="40.0" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0" AnchorPane.topAnchor="40.0" />
13+
<HBox layoutX="429.0" layoutY="555.0" spacing="5.0" AnchorPane.bottomAnchor="5.0" AnchorPane.rightAnchor="5.0">
14+
<children>
15+
<Button fx:id="saveButton" mnemonicParsing="false" text="Save" />
16+
<Button fx:id="cancelButton" mnemonicParsing="false" text="Cancel" />
17+
</children>
18+
</HBox>
19+
<HBox layoutX="5.0" layoutY="564.0" spacing="5.0" AnchorPane.leftAnchor="5.0" AnchorPane.topAnchor="5.0">
20+
<children>
21+
<ComboBox fx:id="addNewProjectComboBox" prefHeight="25.0" prefWidth="210.0" />
22+
<Button fx:id="addNewProjectButton" mnemonicParsing="false" text="Import project" />
23+
</children>
24+
</HBox>
25+
<DatePicker fx:id="tasksForDateDatePicker" layoutX="371.0" layoutY="16.0" AnchorPane.rightAnchor="5.0" AnchorPane.topAnchor="5.0" />
2126
</children>
2227
</AnchorPane>

src/main/resources/layouts/externalProjectSync.fxml

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,59 @@
55
<?import javafx.scene.control.Label?>
66
<?import javafx.scene.control.TableView?>
77
<?import javafx.scene.layout.AnchorPane?>
8+
<?import javafx.scene.layout.HBox?>
89
<?import javafx.scene.layout.StackPane?>
910
<?import javafx.scene.layout.VBox?>
1011
<?import javafx.scene.text.Font?>
1112

12-
<StackPane xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.doubleslash.keeptime.view.ExternalProjectsSyncController">
13+
<StackPane style="-fx-background-color: white;" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.doubleslash.keeptime.view.ExternalProjectsSyncController">
1314
<children>
1415
<AnchorPane fx:id="pane" prefHeight="600.0" prefWidth="1000.0">
1516
<children>
16-
<TableView fx:id="mappingTableView" layoutY="50.0" prefHeight="603.0" prefWidth="1112.0" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0" />
17-
<Label text="Sync dialog">
18-
<font>
19-
<Font name="System Bold" size="15.0" />
20-
</font>
21-
</Label>
22-
<Button fx:id="saveButton" layoutX="987.0" layoutY="722.0" mnemonicParsing="false" text="Save" />
23-
<Button fx:id="cancelButton" layoutX="1058.0" layoutY="722.0" mnemonicParsing="false" text="Cancel" />
24-
<Label layoutX="14.0" layoutY="21.0" text="Syncing day" />
25-
<Label fx:id="dayOfSyncLabel" layoutX="104.0" layoutY="21.0" text="01.01.2025" />
26-
<Label layoutX="37.0" layoutY="665.0" text="New Heimat time:" />
27-
<Label fx:id="sumTimeLabel" layoutX="189.0" layoutY="665.0" text="08:45" />
28-
<Hyperlink fx:id="externalSystemLink" layoutX="29.0" layoutY="723.0" text="Open day in HEIMAT" />
29-
<Label layoutX="282.0" layoutY="665.0" text="KeepTime time:" />
30-
<Label fx:id="keepTimeTimeLabel" layoutX="402.0" layoutY="665.0" text="08:45" />
31-
<Label layoutX="38.0" layoutY="692.0" text="Current Heimat time:" />
32-
<Label fx:id="heimatTimeLabel" layoutX="189.0" layoutY="692.0" text="08:45" />
17+
<TableView fx:id="mappingTableView" layoutY="50.0" prefHeight="603.0" prefWidth="1112.0" AnchorPane.bottomAnchor="55.0" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0" AnchorPane.topAnchor="35.0" />
18+
<HBox layoutX="987.0" layoutY="722.0" spacing="5.0" AnchorPane.bottomAnchor="5.0" AnchorPane.rightAnchor="5.0">
19+
<children>
20+
<Button fx:id="saveButton" mnemonicParsing="false" text="Save" />
21+
<Button fx:id="cancelButton" mnemonicParsing="false" text="Cancel" />
22+
</children>
23+
</HBox>
24+
<HBox spacing="20.0" AnchorPane.leftAnchor="5.0" AnchorPane.topAnchor="5.0">
25+
<children>
26+
<HBox spacing="5.0">
27+
<children>
28+
<Label text="Syncing day" />
29+
<Label fx:id="dayOfSyncLabel" text="01.01.2025" />
30+
</children>
31+
</HBox>
32+
<HBox spacing="5.0">
33+
<children>
34+
<Label text="KeepTime work time:" />
35+
<Label fx:id="keepTimeTimeLabel" text="08:45" />
36+
</children>
37+
</HBox>
38+
</children>
39+
</HBox>
40+
<HBox layoutX="37.0" layoutY="665.0" spacing="50.0" AnchorPane.bottomAnchor="5.0" AnchorPane.leftAnchor="5.0">
41+
<children>
42+
<VBox spacing="5.0">
43+
<children>
44+
<HBox spacing="5.0">
45+
<children>
46+
<Label text="New Heimat time:" />
47+
<Label fx:id="sumTimeLabel" alignment="CENTER_RIGHT" contentDisplay="RIGHT" text="08:45" />
48+
</children>
49+
</HBox>
50+
<HBox spacing="5.0">
51+
<children>
52+
<Label text="Current Heimat time:" />
53+
<Label fx:id="heimatTimeLabel" text="08:45" />
54+
</children>
55+
</HBox>
56+
</children>
57+
</VBox>
58+
</children>
59+
</HBox>
60+
<Hyperlink fx:id="externalSystemLink" layoutX="29.0" layoutY="723.0" text="Open day in HEIMAT" AnchorPane.rightAnchor="5.0" AnchorPane.topAnchor="5.0" />
3361
</children>
3462
</AnchorPane>
3563
<VBox fx:id="loadingScreen" alignment="CENTER" spacing="10.0" visible="false">

0 commit comments

Comments
 (0)