Skip to content

Commit 8512109

Browse files
committed
added log
1 parent d3855c2 commit 8512109

File tree

6 files changed

+37
-34
lines changed

6 files changed

+37
-34
lines changed

src/main/java/de/doubleslash/keeptime/Main.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import javafx.scene.control.Alert.AlertType;
5151
import javafx.scene.control.Label;
5252
import javafx.scene.control.TextArea;
53+
import javafx.scene.image.Image;
5354
import javafx.scene.input.KeyCode;
5455
import javafx.scene.input.KeyCodeCombination;
5556
import javafx.scene.input.KeyCombination;
@@ -240,12 +241,13 @@ private void initialiseUI(final Stage primaryStage) throws IOException {
240241
loader.setControllerFactory(springContext::getBean);
241242
mainPane = loader.load();
242243
primaryStage.initStyle(StageStyle.TRANSPARENT);
244+
primaryStage.getIcons().add(new Image(Resources.getResource(RESOURCE.ICON_MAIN).toString()));
245+
243246
// Show the scene containing the root layout.
244247
final Scene mainScene = new Scene(mainPane, Color.TRANSPARENT);
245248

246249
registerMinimizeEventlistener(mainScene, primaryStage);
247250
registerMaximizeEventlistener(mainScene, primaryStage);
248-
// Image(Resources.getResource(RESOURCE.ICON_MAIN).toString())); // TODO use an app icon
249251

250252
primaryStage.setTitle("KeepTime");
251253
primaryStage.setScene(mainScene);

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

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package de.doubleslash.keeptime.view;
22

3-
import java.util.Optional;
4-
53
import org.slf4j.Logger;
64
import org.slf4j.LoggerFactory;
75

@@ -21,7 +19,7 @@
2119
import javafx.scene.layout.GridPane;
2220
import javafx.scene.layout.VBox;
2321

24-
public class ChangeWithTimeDialog {
22+
public class ChangeWithTimeDialog extends Dialog<Integer> {
2523

2624
private static final Logger LOG = LoggerFactory.getLogger(ChangeWithTimeDialog.class);
2725
private static final String TIME_ZERO = "00:00:00";
@@ -31,7 +29,6 @@ public class ChangeWithTimeDialog {
3129
private final LongProperty activeWorkSecondsProperty;
3230
private final Project projectToChangeTo;
3331

34-
private Dialog<Integer> dialog;
3532
private boolean ctrlIsPressed = false;
3633

3734
public ChangeWithTimeDialog(final Model model, final LongProperty activeWorkSecondsProperty,
@@ -44,13 +41,12 @@ public ChangeWithTimeDialog(final Model model, final LongProperty activeWorkSeco
4441
}
4542

4643
private void setUpDialog() {
47-
dialog = new Dialog<>();
48-
dialog.setTitle("Change project with time transfer");
49-
dialog.setHeaderText("Choose the time to transfer");
50-
dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
51-
final Button okButton = (Button) dialog.getDialogPane().lookupButton(ButtonType.OK);
44+
setTitle("Change project with time transfer");
45+
setHeaderText("Choose the time to transfer");
46+
getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
47+
final Button okButton = (Button) getDialogPane().lookupButton(ButtonType.OK);
5248
okButton.setDefaultButton(true);
53-
final Button cancelButton = (Button) dialog.getDialogPane().lookupButton(ButtonType.CANCEL);
49+
final Button cancelButton = (Button) getDialogPane().lookupButton(ButtonType.CANCEL);
5450
cancelButton.setDefaultButton(false);
5551

5652
final VBox vBox = new VBox();
@@ -104,15 +100,15 @@ private void setUpDialog() {
104100
slider.valueProperty().addListener((obs, oldValue, newValue) -> updateLabelsRunnable.run());
105101
vBox.getChildren().add(grid);
106102

107-
dialog.setOnShown(de -> {
103+
setOnShown(de -> {
108104
// workaround to set focus to slider when showing the dialog
109105
// onShown is actually called before the dialog is shown
110106
Platform.runLater(slider::requestFocus);
111107
});
112108

113-
dialog.getDialogPane().setContent(vBox);
109+
getDialogPane().setContent(vBox);
114110

115-
dialog.setResultConverter(dialogButton -> {
111+
setResultConverter(dialogButton -> {
116112
if (dialogButton == ButtonType.OK) {
117113
return slider.valueProperty().intValue() * 60;
118114
}
@@ -121,16 +117,6 @@ private void setUpDialog() {
121117

122118
}
123119

124-
/**
125-
* Shows the dialog to the user.
126-
*
127-
* @return optional with the amount of seconds to transfer to the new project or null if the user does not confirm
128-
*/
129-
public Optional<Integer> showAndWait() {
130-
LOG.info("Showing dialog");
131-
return dialog.showAndWait();
132-
}
133-
134120
private Slider setupSlider() {
135121
final Slider slider = new Slider();
136122

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import javafx.scene.control.CheckBox;
4040
import javafx.scene.control.ColorPicker;
4141
import javafx.scene.control.Label;
42+
import javafx.scene.image.Image;
4243
import javafx.scene.layout.AnchorPane;
4344
import javafx.scene.layout.Region;
4445
import javafx.scene.paint.Color;
@@ -250,6 +251,7 @@ private void loadAboutStage() {
250251
aboutStage.setTitle("About KeepTime");
251252
aboutStage.setResizable(false);
252253
aboutStage.setScene(new Scene(rootAbout));
254+
aboutStage.getIcons().add(new Image(Resources.getResource(RESOURCE.ICON_MAIN).toString()));
253255
aboutStage.setOnHiding(e -> this.thisStage.setAlwaysOnTop(true));
254256
aboutStage.setOnShowing(e -> {
255257
this.thisStage.setAlwaysOnTop(false);

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,8 @@ public void changeProject(final Project newProject, final long minusSeconds) {
184184
private Stage settingsStage;
185185
private SettingsController settingsController;
186186

187-
private Stage aboutStage;
188-
private AboutController aboutController;
189-
190187
private Map<Project, Node> projectSelectionNodeMap;
191188

192-
private final boolean ctrlIsPressed = false;
193-
194189
@FXML
195190
private void initialize() {
196191

@@ -465,6 +460,7 @@ private void loadSubStages() {
465460
reportStage.setScene(reportScene);
466461
reportStage.setTitle("Report");
467462
reportStage.setResizable(false);
463+
reportStage.getIcons().add(new Image(Resources.getResource(RESOURCE.ICON_MAIN).toString()));
468464
reportStage.setOnHiding(windowEvent -> {
469465
reportStage.setAlwaysOnTop(false);
470466
this.mainStage.setAlwaysOnTop(true);
@@ -480,6 +476,7 @@ private void loadSubStages() {
480476
settingsStage.initModality(Modality.APPLICATION_MODAL);
481477
settingsStage.setTitle("Settings");
482478
settingsStage.setResizable(false);
479+
settingsStage.getIcons().add(new Image(Resources.getResource(RESOURCE.ICON_MAIN).toString()));
483480

484481
final Scene settingsScene = new Scene(settingsRoot);
485482
settingsScene.setOnKeyPressed(ke -> {
@@ -561,6 +558,8 @@ private Node addProjectToProjectList(final Project p) {
561558
changeWithTimeMenuItem.setOnAction(e -> {
562559
final ChangeWithTimeDialog changeWithTimeDialog = new ChangeWithTimeDialog(model, activeWorkSecondsProperty,
563560
p);
561+
changeWithTimeDialog.initOwner(settingsStage);
562+
564563
mainStage.setAlwaysOnTop(false);
565564
final Optional<Integer> result = changeWithTimeDialog.showAndWait();
566565
result.ifPresent(minusSeconds -> changeProject(p, minusSeconds));
@@ -576,6 +575,7 @@ private Node addProjectToProjectList(final Project p) {
576575
alert.setHeaderText("Delete project '" + p.getName() + "'.");
577576
alert.setContentText(
578577
"The project will just be hidden from display, as there may be work references to this project.");
578+
alert.initOwner(settingsStage);
579579

580580
mainStage.setAlwaysOnTop(false);
581581
final Optional<ButtonType> result = alert.showAndWait();
@@ -600,6 +600,7 @@ private Node addProjectToProjectList(final Project p) {
600600
dialog.getDialogPane().setContent(grid);
601601

602602
dialog.setResultConverter(dialogButton -> dialogButton);
603+
dialog.initOwner(settingsStage);
603604

604605
mainStage.setAlwaysOnTop(false);
605606
final Optional<ButtonType> result = dialog.showAndWait();

src/main/resources/icons/icon.png

1.07 KB
Loading

src/main/resources/layouts/about.fxml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,29 @@
2020
<?import javafx.scene.control.Hyperlink?>
2121
<?import javafx.scene.control.Label?>
2222
<?import javafx.scene.control.TableView?>
23+
<?import javafx.scene.image.Image?>
24+
<?import javafx.scene.image.ImageView?>
25+
<?import javafx.scene.layout.HBox?>
2326
<?import javafx.scene.layout.Pane?>
2427
<?import javafx.scene.shape.Line?>
2528
<?import javafx.scene.text.Font?>
2629

2730
<Pane fx:id="mainContainer" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="507.0" prefWidth="509.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.doubleslash.keeptime.view.AboutController">
2831
<children>
29-
<Label fx:id="keepTimeLabel" layoutX="197.0" layoutY="11.0" text="KeepTime">
30-
<font>
31-
<Font name="Open Sans Regular" size="26.0" />
32-
</font>
33-
</Label>
32+
<HBox alignment="CENTER_LEFT" layoutX="150.0" layoutY="14.0" spacing="10.0">
33+
<children>
34+
<ImageView fitHeight="101.0" fitWidth="86.0" pickOnBounds="true" preserveRatio="true">
35+
<image>
36+
<Image url="@../icons/icon.png" />
37+
</image>
38+
</ImageView>
39+
<Label fx:id="keepTimeLabel" text="KeepTime">
40+
<font>
41+
<Font name="Open Sans Regular" size="26.0" />
42+
</font>
43+
</Label>
44+
</children>
45+
</HBox>
3446
<Line fx:id="bigLine" endX="497.0" endY="111.0" fill="BLACK" layoutX="-23.0" layoutY="-39.0" smooth="false" startX="62.0" startY="111.0" strokeWidth="2.0" />
3547
<Label fx:id="versionLabel" layoutX="39.0" layoutY="92.0" text="Version:">
3648
<font>

0 commit comments

Comments
 (0)