Skip to content

Commit 6fbccae

Browse files
committed
Merge branch 'develop' into feature/PTBAS-741_mappingDialogAdjustment
# Conflicts: # src/main/java/de/doubleslash/keeptime/controller/HeimatController.java # src/main/java/de/doubleslash/keeptime/view/ExternalProjectsSyncController.java # src/main/java/de/doubleslash/keeptime/viewpopup/SearchCombobox.java # src/test/java/de/doubleslash/keeptime/controller/HeimatControllerTest.java
2 parents fd527bd + b6ded44 commit 6fbccae

File tree

8 files changed

+253
-177
lines changed

8 files changed

+253
-177
lines changed

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

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.io.StringWriter;
2222
import java.time.LocalDate;
2323
import java.util.List;
24+
import java.util.Locale;
2425
import java.util.Optional;
2526
import java.util.stream.Collectors;
2627

@@ -84,6 +85,9 @@ public class App extends Application {
8485
@Override
8586
public void init() throws Exception {
8687
LOG.info("Starting KeepTime.");
88+
89+
setLocaleToEnglish();
90+
8791
final DefaultExceptionHandler defaultExceptionHandler = new DefaultExceptionHandler();
8892
defaultExceptionHandler.register();
8993

@@ -102,6 +106,22 @@ public void init() throws Exception {
102106
model.setSpringContext(springContext);
103107
}
104108

109+
private void setLocaleToEnglish() {
110+
final Locale systemDefaultLocale = Locale.getDefault();
111+
final Locale wantedApplicationLocale = Locale.ENGLISH;
112+
113+
if (systemDefaultLocale.getLanguage().equals(wantedApplicationLocale.getLanguage())) {
114+
LOG.debug("Application locale already is '{}'. Nothing to do.", wantedApplicationLocale);
115+
return;
116+
}
117+
118+
LOG.info("Setting application locale to '{}', was '{}'.", wantedApplicationLocale, systemDefaultLocale);
119+
Locale.setDefault(wantedApplicationLocale);
120+
Locale.setDefault(Locale.Category.DISPLAY, wantedApplicationLocale);
121+
// keep system locale for format conversions (date, currency, numbers)
122+
Locale.setDefault(Locale.Category.FORMAT, systemDefaultLocale);
123+
}
124+
105125
@Override
106126
public void start(final Stage primaryStage) {
107127
LOG.info("Initialising the UI");
@@ -117,12 +137,13 @@ public void start(final Stage primaryStage) {
117137
}
118138
}
119139

120-
public static void showErrorDialogAndWait(String title, String header, String content, final Exception e, Window window) {
140+
public static void showErrorDialogAndWait(String title, String header, String content, final Exception e,
141+
Window window) {
121142
final Alert alert = new Alert(AlertType.ERROR);
122143
alert.setTitle(title);
123144
alert.setHeaderText(header);
124145
alert.setContentText(content);
125-
if(window != null) {
146+
if (window != null) {
126147
alert.initOwner(window);
127148
}
128149
final StringWriter sw = new StringWriter();

src/main/java/de/doubleslash/keeptime/controller/HeimatController.java

Lines changed: 57 additions & 52 deletions
Large diffs are not rendered by default.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Copyright 2025 doubleSlash Net Business GmbH
2+
//
3+
// This file is part of KeepTime.
4+
// KeepTime is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
package de.doubleslash.keeptime.model;
18+
19+
import java.util.ArrayList;
20+
import java.util.List;
21+
22+
/**
23+
* Represents a styled text message composed of multiple text segments. This class provides a UI-agnostic way to
24+
* represent formatted text, allowing separation of business logic from UI components.
25+
*/
26+
public class StyledMessage {
27+
28+
/**
29+
* Represents a single text segment with optional styling.
30+
*
31+
* @param text
32+
* The text content
33+
* @param bold
34+
* Whether the text should be displayed in bold
35+
*/
36+
public record TextSegment(String text, boolean bold) {
37+
public TextSegment(String text) {
38+
this(text, false);
39+
}
40+
}
41+
42+
private final List<TextSegment> segments;
43+
44+
public StyledMessage(List<TextSegment> segments) {
45+
this.segments = new ArrayList<>(segments);
46+
}
47+
48+
/**
49+
* Creates a StyledMessage from a variable number of text segments.
50+
*
51+
* @param segments
52+
* The text segments to include in the message
53+
* @return A new StyledMessage containing the provided segments
54+
*/
55+
public static StyledMessage of(TextSegment... segments) {
56+
return new StyledMessage(List.of(segments));
57+
}
58+
59+
public List<TextSegment> getSegments() {
60+
return new ArrayList<>(segments);
61+
}
62+
63+
/**
64+
* Returns the message as plain text without styling.
65+
*/
66+
public String toPlainText() {
67+
return segments.stream().map(TextSegment::text).reduce("", String::concat);
68+
}
69+
}
70+

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import de.doubleslash.keeptime.model.Project;
2525
import de.doubleslash.keeptime.rest.integration.heimat.model.ExistingAndInvalidMappings;
2626
import de.doubleslash.keeptime.rest.integration.heimat.model.HeimatTask;
27-
import de.doubleslash.keeptime.viewpopup.SearchPopup;
27+
import de.doubleslash.keeptime.viewpopup.SearchCombobox;
2828
import javafx.application.Platform;
2929
import javafx.beans.property.SimpleBooleanProperty;
3030
import javafx.beans.property.SimpleObjectProperty;
@@ -142,7 +142,7 @@ protected void updateItem(String item, boolean empty) {
142142
TableColumn<HeimatController.ProjectMapping, HeimatTask> externalColumn = new TableColumn<>("HEIMAT project");
143143
externalColumn.setCellValueFactory(data -> new SimpleObjectProperty<>(data.getValue().getHeimatTask()));
144144
externalColumn.setCellFactory(col -> new TableCell<>() {
145-
private final SearchPopup<HeimatTask> searchPopup = new SearchPopup<>(externalProjectsObservableList);
145+
private final SearchCombobox<HeimatTask> searchPopup = new SearchCombobox<>(externalProjectsObservableList);
146146

147147
{
148148
searchPopup.setDisplayTextFunction(ht -> ht == null ? "" : ht.taskHolderName() + " - " + ht.name());

0 commit comments

Comments
 (0)