Skip to content

Commit 887fa97

Browse files
committed
#178: use styling for buttons
1 parent 85eb0ba commit 887fa97

File tree

12 files changed

+73
-48
lines changed

12 files changed

+73
-48
lines changed

src/main/java/de/doubleslash/keeptime/common/Resources.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ public enum RESOURCE {
8181

8282
SVG_ROTATE_ICON("/svgs/rotate-solid.svg"),
8383

84-
ICON_MAIN("/icons/icon.png")
84+
ICON_MAIN("/icons/icon.png"),
8585

86+
/** CSS **/
87+
CSS_BUTTONS("/css/buttons.css")
8688
;
8789

8890
String resourceLocation;

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package de.doubleslash.keeptime.view;
1818

1919
import de.doubleslash.keeptime.common.ColorHelper;
20+
import de.doubleslash.keeptime.common.Resources;
2021
import de.doubleslash.keeptime.controller.Controller;
2122
import de.doubleslash.keeptime.controller.HeimatController;
2223
import de.doubleslash.keeptime.model.Model;
@@ -170,7 +171,7 @@ protected void updateItem(HeimatTask item, boolean empty) {
170171
&& mapping.getHeimatTask().id() == ht.id());
171172
return !alreadyMapped;
172173
}).toList();
173-
List<HeimatTask> selectedItems = showMultiSelectDialog(externalProjectsObservableList, unmappedHeimatTasks);
174+
List<HeimatTask> selectedItems = showMultiSelectDialog(externalProjects, unmappedHeimatTasks);
174175
for (HeimatTask toBeCreatedHeimatTask : selectedItems) {
175176
final int sortIndex = model.getAvailableProjects().size();
176177
final Project project = controller.addNewProject(
@@ -193,7 +194,7 @@ protected void updateItem(HeimatTask item, boolean empty) {
193194
}
194195
}
195196

196-
private List<HeimatTask> showMultiSelectDialog(final ObservableList<HeimatTask> externalProjectsObservableList,
197+
private List<HeimatTask> showMultiSelectDialog(final List<HeimatTask> externalProjects,
197198
List<HeimatTask> unmappedHeimatTasks) {
198199
Dialog<List<HeimatTask>> dialog = new Dialog<>();
199200
dialog.setTitle("Import HEIMAT projects");
@@ -222,9 +223,10 @@ protected void updateItem(HeimatTask item, boolean empty) {
222223
}
223224
});
224225
listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
225-
listView.setItems(externalProjectsObservableList);
226+
listView.setItems(FXCollections.observableArrayList(externalProjects));
226227

227-
Button selectAllUnmappedButton = new Button("Select All Unmapped");
228+
Button selectAllUnmappedButton = new Button("Select unmapped projects (" + unmappedHeimatTasks.size() + ")");
229+
selectAllUnmappedButton.getStyleClass().add("secondary-button");
228230
selectAllUnmappedButton.setOnAction(e -> {
229231
listView.getSelectionModel().clearSelection();
230232
for (HeimatTask ht : unmappedHeimatTasks) {
@@ -236,18 +238,22 @@ protected void updateItem(HeimatTask item, boolean empty) {
236238
VBox content = new VBox(10, selectAllUnmappedButton, listView);
237239
dialog.getDialogPane().setContent(content);
238240
final List<HeimatTask> emptyList = List.of();
239-
// Handle result when OK is clicked
240241
dialog.setResultConverter(dialogButton -> {
241242
if (dialogButton == okButtonType) {
242243
return listView.getSelectionModel().getSelectedItems().stream().toList();
243244
}
244-
return emptyList; // Cancel was clicked
245+
return emptyList; // cancel was clicked
245246
});
246247

247248
Button okButton = (Button) dialog.getDialogPane().lookupButton(okButtonType);
248-
okButton.setText("Import (0)"); // Initial state
249+
okButton.setText("Import (0)");
250+
okButton.setPrefWidth(100);
251+
okButton.getStyleClass().add("primary-button");
252+
Button dialogCancelButton = (Button) dialog.getDialogPane().lookupButton(cancelButtonType);
253+
dialogCancelButton.getStyleClass().add("secondary-button");
254+
dialog.getDialogPane().getStylesheets().add(Resources.getResource(Resources.RESOURCE.CSS_BUTTONS).toExternalForm());
255+
249256

250-
// Listen for selection changes and update button text
251257
listView.getSelectionModel().getSelectedItems().addListener((ListChangeListener<HeimatTask>) change -> {
252258
int selectedCount = listView.getSelectionModel().getSelectedItems().size();
253259
okButton.setText("Import (" + selectedCount + ")");

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,10 @@ private GridPane setUpEditProjectGridPane(final Project p, final Dialog<Project>
380380
return null;
381381
});
382382

383+
dialog.getDialogPane().lookupButton(ButtonType.OK).getStyleClass().add("primary-button");
384+
dialog.getDialogPane().lookupButton(ButtonType.CANCEL).getStyleClass().add("secondary-button");
385+
dialog.getDialogPane().getStylesheets().add(Resources.getResource(Resources.RESOURCE.CSS_BUTTONS).toExternalForm());
386+
383387
return grid;
384388
}
385389

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,9 @@ private GridPane setUpAddNewProjectGridPane(final Dialog<Project> dialog) {
502502
final ManageProjectController manageProjectController = loader.getController();
503503

504504
dialog.getDialogPane().lookupButton(ButtonType.OK).disableProperty().bind(manageProjectController.formValidProperty().not());
505+
dialog.getDialogPane().lookupButton(ButtonType.OK).getStyleClass().add("primary-button");
506+
dialog.getDialogPane().lookupButton(ButtonType.CANCEL).getStyleClass().add("secondary-button");
507+
dialog.getDialogPane().getStylesheets().add(Resources.getResource(Resources.RESOURCE.CSS_BUTTONS).toExternalForm());
505508

506509
dialogResultConverter(dialog, manageProjectController);
507510

src/main/resources/css/application.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,4 @@
9191
.list-view .scroll-bar:vertical .increment-button:hover,
9292
.list-view .scroll-bar:vertical .decrement-button:hover {
9393
-fx-background-color: transparent;
94-
}
94+
}

src/main/resources/css/buttons.css

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.primary-button {
2+
-fx-background-color: #00759e;
3+
-fx-text-fill: white;
4+
5+
-fx-background-radius: 5px;
6+
-fx-border-radius: 5px;
7+
-fx-border-width: 1px;
8+
-fx-border-color: #00759e;
9+
}
10+
11+
.secondary-button {
12+
-fx-background-color: transparent;
13+
-fx-text-fill: #00759e;
14+
15+
-fx-background-radius: 5px;
16+
-fx-border-radius: 5px;
17+
-fx-border-width: 1px;
18+
-fx-border-color: #00759e;
19+
}

src/main/resources/css/settingsv2.css

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@
66
-fx-padding: 0 0 5 0;
77
}
88

9-
.saveCancelHboxBorder{
10-
11-
-fx-border-color: lightgrey;
12-
-fx-border-style: solid hidden hidden hidden;
13-
-fx-padding: 2px;
14-
-fx-spacing: 15px;
15-
}
169
.tab-pane > .tab-header-area > .headers-region > .tab > .tab-container {
1710
-fx-rotate: 90;
1811
}
@@ -43,12 +36,7 @@
4336
{
4437
-fx-background-color: #eaeaea;
4538
}
46-
.button{
47-
-fx-background-color: white;
48-
-fx-border-color: lightgrey;
49-
-fx-border-radius: 2 2 2 2;
5039

51-
}
5240
.button:hover{
5341
-fx-border-color: grey;
5442
}

src/main/resources/layouts/externalProjectMapping.fxml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
<?import javafx.scene.layout.AnchorPane?>
77
<?import javafx.scene.layout.HBox?>
88

9-
<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">
9+
<AnchorPane prefHeight="600.0" prefWidth="700.0" style="-fx-background-color: white;" stylesheets="@../css/buttons.css" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.doubleslash.keeptime.view.MapExternalProjectsController">
1010
<children>
1111
<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" />
1212
<HBox layoutX="429.0" layoutY="555.0" spacing="5.0" AnchorPane.bottomAnchor="5.0" AnchorPane.rightAnchor="5.0">
1313
<children>
14-
<Button fx:id="saveButton" mnemonicParsing="false" text="Save" />
15-
<Button fx:id="cancelButton" mnemonicParsing="false" text="Cancel" />
14+
<Button fx:id="saveButton" mnemonicParsing="false" styleClass="primary-button" text="Save" />
15+
<Button fx:id="cancelButton" mnemonicParsing="false" styleClass="secondary-button" text="Cancel" />
1616
</children>
1717
</HBox>
1818
<HBox layoutX="5.0" layoutY="564.0" spacing="5.0" AnchorPane.leftAnchor="5.0" AnchorPane.topAnchor="5.0">
1919
<children>
20-
<Button fx:id="addNewProjectButton" mnemonicParsing="false" text="Import project(s)" />
20+
<Button fx:id="addNewProjectButton" mnemonicParsing="false" styleClass="secondary-button" text="Import project(s)..." />
2121
</children>
2222
</HBox>
2323
<DatePicker fx:id="tasksForDateDatePicker" layoutX="371.0" layoutY="16.0" AnchorPane.rightAnchor="5.0" AnchorPane.topAnchor="5.0" />

src/main/resources/layouts/externalProjectSync.fxml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<?import javafx.scene.layout.VBox?>
1212
<?import javafx.scene.text.Font?>
1313

14-
<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">
14+
<StackPane style="-fx-background-color: white;" stylesheets="@../css/buttons.css" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.doubleslash.keeptime.view.ExternalProjectsSyncController">
1515
<children>
1616
<AnchorPane fx:id="pane" prefHeight="600.0" prefWidth="1000.0">
1717
<children>
@@ -54,13 +54,13 @@
5454
<HBox spacing="5.0">
5555
<children>
5656
<ComboBox fx:id="heimatTaskComboBox" prefHeight="25.0" prefWidth="254.0" />
57-
<Button fx:id="addHeimatTaskButton" mnemonicParsing="false" prefHeight="25.0" text="Add" />
57+
<Button fx:id="addHeimatTaskButton" mnemonicParsing="false" prefHeight="25.0" styleClass="secondary-button" text="Add" />
5858
</children>
5959
</HBox>
6060
<HBox alignment="TOP_RIGHT" spacing="5.0">
6161
<children>
62-
<Button fx:id="saveButton" mnemonicParsing="false" text="Save" />
63-
<Button fx:id="cancelButton" mnemonicParsing="false" text="Cancel" />
62+
<Button fx:id="saveButton" mnemonicParsing="false" styleClass="primary-button" text="Save" />
63+
<Button fx:id="cancelButton" mnemonicParsing="false" styleClass="secondary-button" text="Cancel" />
6464
</children>
6565
</HBox>
6666
</children>

src/main/resources/layouts/manage-project.fxml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<?import javafx.scene.layout.RowConstraints?>
1515
<?import javafx.scene.layout.VBox?>
1616

17-
<GridPane fx:id="grid" hgap="5.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" vgap="5.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.doubleslash.keeptime.view.ManageProjectController">
17+
<GridPane fx:id="grid" hgap="5.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" stylesheets="@../css/buttons.css" vgap="5.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.doubleslash.keeptime.view.ManageProjectController">
1818
<columnConstraints>
1919
<ColumnConstraints hgrow="SOMETIMES" />
2020
<ColumnConstraints hgrow="SOMETIMES" />
@@ -39,7 +39,7 @@
3939
<HBox spacing="5.0" GridPane.columnIndex="1" GridPane.rowIndex="4">
4040
<children>
4141
<ColorPicker fx:id="textFillColorPicker" />
42-
<Button fx:id="randomColorButton" mnemonicParsing="false" text="Random" />
42+
<Button fx:id="randomColorButton" mnemonicParsing="false" styleClass="secondary-button" text="Random" />
4343
</children>
4444
</HBox>
4545
<CheckBox fx:id="isWorkCheckBox" mnemonicParsing="false" selected="true" GridPane.columnIndex="1" GridPane.rowIndex="5" />

0 commit comments

Comments
 (0)