Skip to content

Commit 4c9fa7d

Browse files
committed
Merge branch 'develop' into feature/#11_sorting_possibility
# Conflicts: # src/main/java/de/doubleslash/keeptask/view/MainWindowController.java # src/main/resources/layouts/ViewLayout.fxml
2 parents 0d55f8c + b6c44b3 commit 4c9fa7d

25 files changed

Lines changed: 745 additions & 1017 deletions

assembly.xml

Lines changed: 0 additions & 26 deletions
This file was deleted.

pom.xml

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,6 @@
8989
<artifactId>flyway-core</artifactId>
9090
</dependency>
9191

92-
<!-- https://mvnrepository.com/artifact/com.1stleg/jnativehook -->
93-
<dependency>
94-
<groupId>com.1stleg</groupId>
95-
<artifactId>jnativehook</artifactId>
96-
<version>2.1.0</version>
97-
</dependency>
98-
9992
<!-- maven assembly plugin -->
10093
<dependency>
10194
<groupId>org.apache.maven.plugins</groupId>
@@ -162,26 +155,6 @@
162155
<generateGitPropertiesFile>false</generateGitPropertiesFile>
163156
</configuration>
164157
</plugin>
165-
166-
<plugin>
167-
<artifactId>maven-assembly-plugin</artifactId>
168-
<executions>
169-
<execution>
170-
<id>create-keeptask-zip</id>
171-
<phase>package</phase>
172-
<goals>
173-
<goal>single</goal>
174-
</goals>
175-
<configuration>
176-
<descriptors>
177-
<descriptor>./assembly.xml</descriptor>
178-
</descriptors>
179-
<finalName>KeepTask-${project.version}</finalName>
180-
</configuration>
181-
</execution>
182-
</executions>
183-
</plugin>
184-
185158
</plugins>
186159
</build>
187160
</project>

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

Lines changed: 57 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
import java.io.IOException;
2020
import java.io.PrintWriter;
2121
import java.io.StringWriter;
22-
import java.util.List;
2322

23+
import de.doubleslash.keeptask.common.FxmlLayout;
2424
import de.doubleslash.keeptask.common.Resources;
2525
import de.doubleslash.keeptask.common.Resources.RESOURCE;
26-
import de.doubleslash.keeptask.common.WorkItem;
26+
import de.doubleslash.keeptask.view.MainWindowController;
2727
import javafx.fxml.FXMLLoader;
2828
import javafx.scene.Scene;
2929
import javafx.scene.image.Image;
@@ -39,8 +39,6 @@
3939
import de.doubleslash.keeptask.common.FontProvider;
4040
import de.doubleslash.keeptask.controller.Controller;
4141
import de.doubleslash.keeptask.model.Model;
42-
import de.doubleslash.keeptask.view.ViewController;
43-
import de.doubleslash.keeptask.viewpopup.GlobalScreenListener;
4442
import javafx.application.Application;
4543
import javafx.scene.control.Alert;
4644
import javafx.scene.control.Alert.AlertType;
@@ -63,9 +61,7 @@ public class App extends Application {
6361

6462
private Controller controller;
6563

66-
private ViewController viewController;
67-
68-
private GlobalScreenListener globalScreenListener;
64+
private MainWindowController viewController;
6965

7066
@Override
7167
public void init() throws Exception {
@@ -77,9 +73,9 @@ public void init() throws Exception {
7773
ApplicationProperties applicationProperties = springContext.getBean(ApplicationProperties.class);
7874
LOG.info("KeepTask Version: '{}'.", applicationProperties.getBuildVersion());
7975
LOG.info("KeepTask Build Timestamp: '{}'.", applicationProperties.getBuildTimestamp());
80-
LOG.info("KeepTask Git Infos: id '{}', branch '{}', time '{}', dirty '{}'.",
81-
applicationProperties.getGitCommitId(), applicationProperties.getGitBranch(),
82-
applicationProperties.getGitCommitTime(), applicationProperties.getGitDirty());
76+
LOG.info("KeepTask Git Infos: id '{}', branch '{}', time '{}', dirty '{}'.", applicationProperties.getGitCommitId(), applicationProperties.getGitBranch(), applicationProperties.getGitCommitTime(), applicationProperties.getGitDirty());
77+
78+
FxmlLayout.setContext(springContext);
8379

8480
model = springContext.getBean(Model.class);
8581
controller = springContext.getBean(Controller.class);
@@ -93,73 +89,76 @@ public void start(final Stage primaryStage) {
9389
LOG.info("UI successfully initialised.");
9490
} catch (final Exception e) {
9591
LOG.error("There was an error while initialising the UI", e);
96-
97-
final Alert alert = new Alert(AlertType.ERROR);
98-
alert.setTitle("Error");
99-
alert.setHeaderText("Could not start application");
100-
alert.setContentText("Please send the error with your logs folder to a developer");
101-
102-
final StringWriter sw = new StringWriter();
103-
final PrintWriter pw = new PrintWriter(sw);
104-
e.printStackTrace(pw);
105-
final String exceptionText = sw.toString();
106-
107-
final Label label = new Label("The exception stacktrace was:");
108-
109-
final TextArea textArea = new TextArea(exceptionText);
110-
textArea.setEditable(false);
111-
textArea.setWrapText(true);
112-
113-
textArea.setMaxWidth(Double.MAX_VALUE);
114-
textArea.setMaxHeight(Double.MAX_VALUE);
115-
GridPane.setVgrow(textArea, Priority.ALWAYS);
116-
GridPane.setHgrow(textArea, Priority.ALWAYS);
117-
118-
final GridPane expContent = new GridPane();
119-
expContent.setMaxWidth(Double.MAX_VALUE);
120-
expContent.add(label, 0, 0);
121-
expContent.add(textArea, 0, 1);
122-
123-
alert.getDialogPane().setExpandableContent(expContent);
124-
alert.showAndWait();
125-
System.exit(1);
92+
showExceptionAndExit(e);
12693
}
12794
}
12895

96+
12997
private void initialiseApplication(final Stage primaryStage) throws Exception {
13098
FontProvider.loadFonts();
13199

132-
List<WorkItem> workItems = model.getWorkItemRepository().findAll();
133-
model.setWorkItems(workItems);
100+
controller.init();
134101

135-
initialiseUI(primaryStage);
102+
initialiseAndShowUI(primaryStage);
136103
}
137104

138-
private void initialiseUI(final Stage primaryStage) throws IOException {
105+
private void initialiseAndShowUI(final Stage primaryStage) throws IOException {
139106
LOG.debug("Initialising main UI.");
140-
141-
// Load root layout from fxml file.
142-
final FXMLLoader loader = new FXMLLoader();
143-
loader.setLocation(Resources.getResource(RESOURCE.FXML_VIEW_LAYOUT));
144-
loader.setControllerFactory(springContext::getBean);
145-
final Pane mainPane = loader.load();
107+
primaryStage.setTitle("KeepTask");
146108
primaryStage.initStyle(StageStyle.TRANSPARENT);
147109
primaryStage.getIcons().add(new Image(Resources.getResource(RESOURCE.ICON_MAIN).toString()));
148-
// Show the scene containing the root layout.
149-
final Scene mainScene = new Scene(mainPane, Color.TRANSPARENT);
150-
151-
152-
primaryStage.setTitle("KeepTask");
153-
primaryStage.setScene(mainScene);
154110
primaryStage.setAlwaysOnTop(true);
155111
primaryStage.setResizable(false);
156-
157112
primaryStage.setOnCloseRequest(windowEvent -> LOG.info("On close request"));
158113

159-
primaryStage.show();
114+
final FXMLLoader loader = FxmlLayout.createLoaderFor(RESOURCE.FXML_VIEW_LAYOUT);
115+
116+
final Pane mainPane = loader.load();
160117
viewController = loader.getController();
161118
viewController.setMainStage(primaryStage);
162119

120+
final Scene mainScene = new Scene(mainPane, Color.TRANSPARENT);
121+
primaryStage.setScene(mainScene);
122+
123+
primaryStage.show();
124+
}
125+
126+
private static void showExceptionAndExit(Exception e) {
127+
final Alert alert = new Alert(AlertType.ERROR);
128+
alert.setTitle("Error");
129+
alert.setHeaderText("Could not start application");
130+
alert.setContentText("Please send the error with your logs folder to a developer");
131+
132+
final String exceptionText = getExceptionAsString(e);
133+
134+
final Label label = new Label("The exception stacktrace was:");
135+
136+
final TextArea textArea = new TextArea(exceptionText);
137+
textArea.setEditable(false);
138+
textArea.setWrapText(true);
139+
140+
textArea.setMaxWidth(Double.MAX_VALUE);
141+
textArea.setMaxHeight(Double.MAX_VALUE);
142+
GridPane.setVgrow(textArea, Priority.ALWAYS);
143+
GridPane.setHgrow(textArea, Priority.ALWAYS);
144+
145+
final GridPane expContent = new GridPane();
146+
expContent.setMaxWidth(Double.MAX_VALUE);
147+
expContent.add(label, 0, 0);
148+
expContent.add(textArea, 0, 1);
149+
150+
alert.getDialogPane().setExpandableContent(expContent);
151+
152+
alert.showAndWait();
153+
System.exit(1);
154+
}
155+
156+
private static String getExceptionAsString(Exception e) {
157+
final StringWriter sw = new StringWriter();
158+
final PrintWriter pw = new PrintWriter(sw);
159+
e.printStackTrace(pw);
160+
final String exceptionText = sw.toString();
161+
return exceptionText;
163162
}
164163

165164
@Override

src/main/java/de/doubleslash/keeptask/common/DateFormatter.java

Lines changed: 0 additions & 58 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package de.doubleslash.keeptask.common;
2+
3+
import javafx.fxml.FXMLLoader;
4+
import org.springframework.context.ConfigurableApplicationContext;
5+
6+
public class FxmlLayout {
7+
8+
private static ConfigurableApplicationContext springContext;
9+
10+
// TODO I guess we can get the context also via Spring annotation
11+
public static void setContext(ConfigurableApplicationContext springContext) {
12+
FxmlLayout.springContext = springContext;
13+
}
14+
15+
public static FXMLLoader createLoaderFor(Resources.RESOURCE resource) {
16+
final FXMLLoader loader = new FXMLLoader();
17+
loader.setLocation(Resources.getResource(resource));
18+
loader.setControllerFactory(springContext::getBean);
19+
return loader;
20+
}
21+
}

0 commit comments

Comments
 (0)