Skip to content

Commit 8fadeb1

Browse files
authored
Merge pull request #36 from doubleSlashde/feature/searchbarForProjectsInMainView
Feature/searchbar for projects in main view
2 parents d3855c2 + eecde97 commit 8fadeb1

File tree

9 files changed

+562
-408
lines changed

9 files changed

+562
-408
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ private void initialisePopupUI(final Stage primaryStage) throws IOException {
227227
final ViewControllerPopup viewControllerPopupController = loader.getController();
228228
viewControllerPopupController.setStage(popupViewStage);
229229
viewControllerPopupController.setControllerAndModel(controller, model);
230+
viewControllerPopupController.secondInitialize();
231+
230232
globalScreenListener.setViewController(viewControllerPopupController);
231233
}
232234

@@ -263,6 +265,7 @@ public void handle(final WindowEvent event) {
263265
// Give the controller access to the main app.
264266
viewController.setStage(primaryStage);
265267
viewController.setController(controller, model);
268+
viewController.secondInitialize();
266269

267270
}
268271

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package de.doubleslash.keeptime.common;
2+
3+
public class StyleUtils {
4+
5+
private StyleUtils() {
6+
7+
}
8+
9+
/**
10+
* Returns a new String representing a JavaFX style with a new given value for a given attribute.
11+
*
12+
* @param style
13+
* A String representing a JavaFX style.
14+
* @param attribute
15+
* A String representing a JavaFX style attribute.
16+
* @param newValue
17+
* A String representing the value that should be assigned to the given JavaFX style attribute.
18+
* @return A String representing the new JavaFX style.
19+
*/
20+
public static String changeStyleAttribute(final String style, final String attribute, final String newValue) {
21+
final String newStyleAttribute = "-" + attribute + ": " + newValue + "; ";
22+
if (style.contains(attribute)) {
23+
return style.replaceAll("-" + attribute + ": " + "[^;]+;", newStyleAttribute);
24+
}
25+
return style + newStyleAttribute;
26+
}
27+
28+
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ public void deleteProject(final Project p) {
142142
LOG.error("You cannot delete the default project. Tried to delete project '{}'", p);
143143
return;
144144
}
145+
146+
if (isProjectActive(p)) {
147+
changeProject(model.getIdleProject());
148+
}
149+
145150
LOG.info("Disabeling project '{}'.", p);
146151

147152
final int indexToRemove = p.getIndex();
@@ -158,6 +163,10 @@ public void deleteProject(final Project p) {
158163
model.getProjectRepository().saveAll(changedProjects);
159164
}
160165

166+
private boolean isProjectActive(final Project p) {
167+
return p == model.activeWorkItem.get().getProject();
168+
}
169+
161170
public void editProject(final Project p, final String newName, final Color newColor, final boolean isWork,
162171
final int newIndex) {
163172
LOG.info("Changing project '{}' to '{}' '{}' '{}'", p, newName, newColor, isWork);

0 commit comments

Comments
 (0)