Skip to content

Commit b40e754

Browse files
ddamkeddamke
authored andcommitted
Merge branch 'develop' into feature/update_settings_dialog_design
# Conflicts: # src/main/java/de/doubleslash/keeptime/view/SettingsController.java # src/main/resources/layouts/settings.fxml
2 parents 68adfba + 793007c commit b40e754

File tree

6 files changed

+173
-12
lines changed

6 files changed

+173
-12
lines changed

.github/workflows/mavenCi.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
3+
4+
name: Java CI with Maven
5+
6+
on:
7+
push:
8+
branches: [ "master", "develop" ]
9+
pull_request:
10+
branches: [ "master", "develop" ]
11+
12+
# Allows you to run this workflow manually from the Actions tab
13+
workflow_dispatch:
14+
15+
jobs:
16+
17+
analyze:
18+
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- uses: actions/checkout@v3
23+
- name: Set up JDK 11
24+
uses: actions/setup-java@v3
25+
with:
26+
java-version: '11'
27+
distribution: 'corretto'
28+
cache: maven
29+
- name: Analyze
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
33+
run: mvn sonar:sonar
34+
-Dsonar.host.url=${{ secrets.HOST_URL }}
35+
-Dsonar.organization=${{ secrets.ORGANIZATION_NAME }}
36+
-Dsonar.projectKey=${{ secrets.PROJECT_KEY }} -X
37+
-Dsonar.java.binaries=.
38+
-Dsonar.qualitygate.wait=true
39+
40+
41+
build_and_upload:
42+
needs: analyze
43+
runs-on: ubuntu-latest
44+
45+
steps:
46+
- uses: actions/checkout@v3
47+
- name: Set up JDK 1.8
48+
uses: actions/setup-java@v3
49+
with:
50+
java-version: '8'
51+
distribution: 'corretto'
52+
cache: maven
53+
- name: Build
54+
run: |
55+
mvn package -B clean verify
56+
57+
- name: Upload Build Artifact
58+
uses: actions/upload-artifact@v3
59+
with:
60+
name: KeepTime
61+
path: /home/runner/work/KeepTime/KeepTime/target/keeptime-*-bin.zip

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,24 @@ It is recommended to run the application at computer start so you do not forget
4848

4949
You should put the .jar in an extra folder as a *logs* and a *db* folder will be created next to it.\
5050

51-
### Migrate from old version
51+
### Migrate from older version than v1.2.0
5252

5353
1. Download new version and replace the .jar file.
5454
2. Start new version of KeepTime. Notice that your old data is not available.
5555
3. Stop KeepTime
5656
4. Copy the files (not directories) of directory `db` (next to the .jar file) into `db/1.4.197/` (path now includes the database version).
5757
5. Start KeepTime again. Notice that your data is available again.
5858

59+
### Migrate from KeepTime v1.2.0
60+
61+
1. Start your current version of KeepTime (v1.2.0)
62+
2. Go to the settings and export your KeepTime data
63+
3. Download new version and replace the .jar file.
64+
4. Start new version of KeepTime. Notice that your old data is not available.
65+
5. Open the new version and import the exported sql script
66+
6. After the import KeepTime closes automatically
67+
7. To see the changes just start the new KeepTime again
68+
5969
## Requirements
6070

6171
* Windows 7, 10

pom.xml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@
6767
<artifactId>flyway-core</artifactId>
6868
</dependency>
6969

70-
<!-- https://mvnrepository.com/artifact/com.github.kwhat/jnativehook -->
70+
<!-- https://mvnrepository.com/artifact/com.1stleg/jnativehook -->
7171
<dependency>
72-
<groupId>com.github.kwhat</groupId>
72+
<groupId>com.1stleg</groupId>
7373
<artifactId>jnativehook</artifactId>
74-
<version>2.2.2</version>
74+
<version>2.1.0</version>
7575
</dependency>
7676

7777
<!-- maven assembly plugin -->
@@ -81,6 +81,11 @@
8181
<version>3.4.2</version>
8282
<type>maven-plugin</type>
8383
</dependency>
84+
<dependency>
85+
<groupId>org.sonarsource.scanner.maven</groupId>
86+
<artifactId>sonar-maven-plugin</artifactId>
87+
<version>3.9.1.2184</version>
88+
</dependency>
8489
<dependency>
8590
<groupId>org.hamcrest</groupId>
8691
<artifactId>hamcrest-library</artifactId>

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,17 @@
2020

2121
public class SvgNodeProvider {
2222

23-
public static String getSvgPathWithXMl(Resources.RESOURCE resource) {
23+
public static String getSvgPathWithXMl(Resources.RESOURCE resource){
2424
String svgPath;
2525
Document document;
2626
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
27+
try {
28+
// fixes sonar issue RSPEC-2755
29+
dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
30+
} catch (ParserConfigurationException e) {
31+
throw new RuntimeException(e);
32+
}
33+
2734
DocumentBuilder db;
2835

2936
try {

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

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

1919
import java.io.File;
2020
import java.io.IOException;
21+
import java.net.URL;
22+
import java.nio.charset.Charset;
2123
import java.nio.file.Paths;
2224
import java.sql.SQLException;
2325
import java.util.Comparator;
26+
import java.time.LocalDate;
27+
import java.util.List;
28+
import java.util.stream.Collectors;
2429

2530
import de.doubleslash.keeptime.common.*;
2631
import de.doubleslash.keeptime.view.license.LicenseTableRow;
@@ -30,13 +35,21 @@
3035
import javafx.scene.control.cell.PropertyValueFactory;
3136
import javafx.scene.input.MouseButton;
3237
import javafx.scene.shape.SVGPath;
38+
import de.doubleslash.keeptime.Main;
39+
import de.doubleslash.keeptime.model.Project;
40+
import de.doubleslash.keeptime.model.Work;
41+
import javafx.application.Platform;
42+
import javafx.scene.control.*;
43+
import org.h2.tools.RunScript;
3344
import org.h2.tools.Script;
3445
import org.slf4j.Logger;
3546
import org.slf4j.LoggerFactory;
3647
import org.springframework.beans.factory.annotation.Autowired;
3748
import org.springframework.stereotype.Component;
3849

3950
import de.doubleslash.keeptime.ApplicationProperties;
51+
import de.doubleslash.keeptime.common.OS;
52+
import de.doubleslash.keeptime.common.Resources;
4053
import de.doubleslash.keeptime.common.Resources.RESOURCE;
4154
import de.doubleslash.keeptime.controller.Controller;
4255
import de.doubleslash.keeptime.exceptions.FXMLLoaderException;
@@ -46,7 +59,12 @@
4659
import javafx.fxml.FXMLLoader;
4760
import javafx.scene.Parent;
4861
import javafx.scene.Scene;
62+
import javafx.scene.control.Alert;
4963
import javafx.scene.control.Alert.AlertType;
64+
import javafx.scene.control.Button;
65+
import javafx.scene.control.CheckBox;
66+
import javafx.scene.control.ColorPicker;
67+
import javafx.scene.control.Label;
5068
import javafx.scene.layout.AnchorPane;
5169
import javafx.scene.layout.Region;
5270
import javafx.scene.paint.Color;
@@ -109,6 +127,9 @@ public class SettingsController {
109127
@FXML
110128
private Button exportButton;
111129

130+
@FXML
131+
private Button importButton;
132+
112133
@FXML
113134
private Button aboutButton;
114135

@@ -176,6 +197,7 @@ private void initialize() {
176197
}
177198

178199
initExportButton();
200+
initImportButton();
179201

180202
LOG.debug("saveButton.setOnAction");
181203
saveButton.setOnAction(ae -> {
@@ -322,6 +344,63 @@ protected void updateItem(final String item, final boolean empty) {
322344
BrowserHelper.openURL(GITHUB_ISSUE_PAGE);
323345
});
324346
}
347+
private void initImportButton(){
348+
LOG.debug("Initialize importButton.");
349+
importButton.setOnAction(event ->{
350+
351+
try {
352+
Alert confirmationAlert = new Alert(AlertType.CONFIRMATION , "", ButtonType.YES, ButtonType.NO);
353+
confirmationAlert.setTitle("Import");
354+
confirmationAlert.setHeaderText("Do you want to Override current Data ?");
355+
confirmationAlert.setContentText("Import previously exported .sql file. This will overwrite the currently used database contents - all current data will be lost!\n" +
356+
"\n" +
357+
"If you do not have a .sql file yet you need to open the previous version of KeepTime and in the settings dialog press \"Export\".\n" +
358+
"\n" +
359+
"You will need to restart the application after this action. If you proceed you need to select the previouls exported .sql file.");
360+
confirmationAlert.showAndWait();
361+
362+
if(confirmationAlert.getResult()==ButtonType.NO){
363+
LOG.info("User canceled import");
364+
return;
365+
}
366+
367+
final FileChooser fileChooser = new FileChooser();
368+
fileChooser.setTitle("Open Exported SQl Script");
369+
fileChooser.getExtensionFilters().add(new ExtensionFilter("SQL script files.", "*.sql"));
370+
File file = fileChooser.showOpenDialog(thisStage);
371+
if (file == null) {
372+
LOG.info("User canceled import.");
373+
return;
374+
}
375+
376+
final String url = applicationProperties.getSpringDataSourceUrl();
377+
final String username = applicationProperties.getSpringDataSourceUserName();
378+
final String password = applicationProperties.getSpringDataSourcePassword();
379+
//TODO: add an option at the next release to make the "FROM_1X flag" configurable. E.g. if we upgrade (in the release after) from H2 version 2.x to 2.x we must not set the "FROM_1X flag".
380+
new RunScript().runTool("-url", url, "-user",username,"-password",password,"-script",file.toString(),"-options", "FROM_1X");
381+
382+
Alert informationDialog = new Alert(AlertType.INFORMATION);
383+
informationDialog.setTitle("Import done");
384+
informationDialog.setHeaderText("The data was imported.");
385+
informationDialog.setContentText("KeepTime will now be CLOSED! You have to RESTART it again to see the changes");
386+
informationDialog.showAndWait();
387+
Platform.exit();
388+
389+
390+
} catch (SQLException e) {
391+
LOG.error("Could not import script file to db.", e);
392+
393+
Alert errorDialog = new Alert(AlertType.ERROR);
394+
errorDialog.setTitle("Import failed");
395+
errorDialog.setHeaderText("The current data could not be imported.");
396+
errorDialog.setContentText("Please inform a developer and provide your log file.");
397+
398+
errorDialog.showAndWait();
399+
}
400+
401+
});
402+
403+
}
325404

326405
private void initExportButton() {
327406
LOG.debug("Initialize exportButton.");

src/main/java/de/doubleslash/keeptime/viewpopup/GlobalScreenListener.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,14 @@
2424
import java.util.logging.Level;
2525
import java.util.logging.Logger;
2626

27+
import org.jnativehook.GlobalScreen;
28+
import org.jnativehook.NativeHookException;
29+
import org.jnativehook.keyboard.NativeKeyEvent;
30+
import org.jnativehook.keyboard.NativeKeyListener;
31+
import org.jnativehook.mouse.NativeMouseEvent;
32+
import org.jnativehook.mouse.NativeMouseMotionListener;
2733
import org.slf4j.LoggerFactory;
2834

29-
import com.github.kwhat.jnativehook.GlobalScreen;
30-
import com.github.kwhat.jnativehook.NativeHookException;
31-
import com.github.kwhat.jnativehook.keyboard.NativeKeyEvent;
32-
import com.github.kwhat.jnativehook.keyboard.NativeKeyListener;
33-
import com.github.kwhat.jnativehook.mouse.NativeMouseEvent;
34-
import com.github.kwhat.jnativehook.mouse.NativeMouseMotionListener;
35-
3635
import javafx.application.Platform;
3736

3837
/**

0 commit comments

Comments
 (0)