Skip to content

Commit e6e6373

Browse files
DavidDamkeddamke
andauthored
Bug/can not click on projects options if hide on mouse leave is active (#104)
* created helper boolean to keep project list open on context menu open Co-authored-by: ddamke <[email protected]>
1 parent 7875e9b commit e6e6373

File tree

6 files changed

+49
-45
lines changed

6 files changed

+49
-45
lines changed

src/main/java/de/doubleslash/keeptime/Main.java renamed to src/main/java/de/doubleslash/keeptime/App.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@
6161
import javafx.stage.StageStyle;
6262

6363
@SpringBootApplication
64-
public class Main extends Application {
64+
public class App extends Application {
6565

66-
private static final Logger LOG = LoggerFactory.getLogger(Main.class);
66+
private static final Logger LOG = LoggerFactory.getLogger(App.class);
6767

6868
private ConfigurableApplicationContext springContext;
6969

@@ -83,7 +83,7 @@ public void init() throws Exception {
8383
final DefaultExceptionHandler defaultExceptionHandler = new DefaultExceptionHandler();
8484
defaultExceptionHandler.register();
8585

86-
springContext = SpringApplication.run(Main.class);
86+
springContext = SpringApplication.run(App.class);
8787
ApplicationProperties applicationProperties = springContext.getBean(ApplicationProperties.class);
8888
LOG.info("KeepTime Version: '{}'.", applicationProperties.getBuildVersion());
8989
LOG.info("KeepTime Build Timestamp: '{}'.", applicationProperties.getBuildTimestamp());
@@ -299,7 +299,4 @@ public void stop() throws Exception {
299299
springContext.stop();
300300
}
301301

302-
public static void main(final String[] args) {
303-
launch(Main.class, args);
304-
}
305302
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package de.doubleslash.keeptime;
22

3+
import static javafx.application.Application.launch;
4+
35
public class KeepTime {
46
public static void main(final String[] args) {
5-
Main.main(args);
7+
launch(App.class, args);
68
}
79
}

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

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
import org.slf4j.Logger;
2626
import org.slf4j.LoggerFactory;
2727

28-
29-
3028
import de.doubleslash.keeptime.common.ColorHelper;
3129
import de.doubleslash.keeptime.common.StyleUtils;
3230
import de.doubleslash.keeptime.model.Model;
@@ -230,21 +228,22 @@ public Project fromString(final String string) {
230228
// needs to set again because editable is ignored from fxml because of custom preselection of current Project
231229
projectComboBox.setEditable(true);
232230

233-
projectComboBox.valueProperty().addListener(
234-
(final ObservableValue<? extends Project> observable, final Project oldValue, final Project newValue) -> {
235-
if (newValue == null) {
236-
return;
237-
}
231+
projectComboBox.valueProperty()
232+
.addListener((final ObservableValue<? extends Project> observable, final Project oldValue,
233+
final Project newValue) -> {
234+
if (newValue == null) {
235+
return;
236+
}
238237

239-
selectedProject = newValue;
240-
comboChange = true;
241-
// needed to avoid exception on empty textfield https://bugs.openjdk.java.net/browse/JDK-8081700
242-
Platform.runLater(() -> {
243-
setTextColor(projectComboBox.getEditor(), newValue.getColor());
244-
});
245-
}
238+
selectedProject = newValue;
239+
comboChange = true;
240+
// needed to avoid exception on empty textfield https://bugs.openjdk.java.net/browse/JDK-8081700
241+
Platform.runLater(() -> {
242+
setTextColor(projectComboBox.getEditor(), newValue.getColor());
243+
});
244+
}
246245

247-
);
246+
);
248247

249248
enableStrgA_combo();
250249

@@ -291,17 +290,21 @@ public void changed(final ObservableValue<? extends String> observable, final St
291290
});
292291

293292
// manages Focusbehaviour
294-
projectComboBox.getEditor().focusedProperty().addListener((final ObservableValue<? extends Boolean> observable,
295-
final Boolean oldIsFocused, final Boolean newIsFocused) -> {
296-
if (newIsFocused) {
297-
// needed to avoid exception on empty textfield https://bugs.openjdk.java.net/browse/JDK-8081700
298-
Platform.runLater(() -> projectComboBox.getEditor().selectAll());
299-
} else {
300-
// needed to avoid exception on empty textfield https://bugs.openjdk.java.net/browse/JDK-8081700
301-
Platform.runLater(() -> projectComboBox.hide());
302-
}
303-
304-
});
293+
projectComboBox.getEditor()
294+
.focusedProperty()
295+
.addListener((final ObservableValue<? extends Boolean> observable, final Boolean oldIsFocused,
296+
final Boolean newIsFocused) -> {
297+
if (newIsFocused) {
298+
// needed to avoid exception on empty textfield
299+
// https://bugs.openjdk.java.net/browse/JDK-8081700
300+
Platform.runLater(() -> projectComboBox.getEditor().selectAll());
301+
} else {
302+
// needed to avoid exception on empty textfield
303+
// https://bugs.openjdk.java.net/browse/JDK-8081700
304+
Platform.runLater(() -> projectComboBox.hide());
305+
}
306+
307+
});
305308

306309
// on
307310
projectComboBox.setOnKeyReleased(ke -> {

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,9 @@
1818

1919
import java.io.File;
2020
import java.io.IOException;
21-
import java.net.URL;
22-
import java.nio.charset.Charset;
2321
import java.nio.file.Paths;
2422
import java.sql.SQLException;
25-
import java.time.LocalDate;
26-
import java.util.List;
27-
import java.util.stream.Collectors;
2823

29-
import de.doubleslash.keeptime.Main;
30-
import de.doubleslash.keeptime.model.Project;
31-
import de.doubleslash.keeptime.model.Work;
3224
import javafx.application.Platform;
3325
import javafx.scene.control.*;
3426
import org.h2.tools.RunScript;

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ private class Delta {
150150
private final BooleanProperty mouseHoveringProperty = new SimpleBooleanProperty(false);
151151
public static final LongProperty activeWorkSecondsProperty = new SimpleLongProperty(0);
152152
public static final ObjectProperty<Color> fontColorProperty = new SimpleObjectProperty<>();
153+
private boolean contextMenuOpenBoolean = false;
153154

154155
private Stage reportStage;
155156
private ReportController reportController;
@@ -268,8 +269,19 @@ private void initialize() {
268269

269270
pane.setOnMouseEntered(a -> mouseHoveringProperty.set(true));
270271

271-
pane.setOnMouseExited(a -> mouseHoveringProperty.set(false));
272+
projectsVBox.setOnContextMenuRequested(c -> { // Is needed because the Context menu loses Focus otherwise
273+
mouseHoveringProperty.set(true);
274+
LOG.trace("Options selected");
275+
contextMenuOpenBoolean = true;
276+
});
277+
278+
pane.setOnMouseExited(a -> {
279+
if (!contextMenuOpenBoolean) {
280+
mouseHoveringProperty.set(false);
281+
}
282+
contextMenuOpenBoolean = false;
272283

284+
});
273285
// Drag stage
274286
pane.setOnMousePressed(mouseEvent -> {
275287

@@ -577,7 +589,7 @@ public void savePosition() {
577589
return;
578590
}
579591

580-
LOG.debug("Stage position changed '{}'/'{}'.", mainStage.xProperty().doubleValue(),
592+
LOG.trace("Stage position changed '{}'/'{}'.", mainStage.xProperty().doubleValue(),
581593
mainStage.yProperty().doubleValue());
582594

583595
final ScreenPosHelper positionHelper = new ScreenPosHelper(mainStage.xProperty().doubleValue(),

src/main/resources/logback.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
1515
</encoder>
1616
</appender>
17-
18-
<logger name="de.doubleslash" level="debug" />
1917

2018
<root level="info">
2119
<appender-ref ref="STDOUT" />

0 commit comments

Comments
 (0)