Skip to content

Commit 4fa50bf

Browse files
authored
Merge pull request #39 from doubleSlashde/feature/PRIVAT-1556_searchableProjectDescription
Added searchable project description.
2 parents fb026c3 + 1825a1f commit 4fa50bf

File tree

18 files changed

+411
-509
lines changed

18 files changed

+411
-509
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ logs/
2929
*.jar
3030

3131
config.xml
32-
db/
32+
/db/

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

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

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public enum RESOURCE {
3838
FXML_VIEW_POPUP_LAYOUT("/layouts/ViewLayoutPopup.fxml"),
3939
FXML_REPORT("/layouts/report.fxml"),
4040
FXML_ABOUT("/layouts/about.fxml"),
41+
FXML_MANAGE_PROJECT("/layouts/manage-project.fxml"),
4142

4243
// icon
4344
ICON_MAIN("/icons/icon.png"),

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
// Copyright 2019 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+
117
package de.doubleslash.keeptime.common;
218

319
public class StyleUtils {

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,13 @@ public void changeProject(final Project newProject, final long minusSeconds) {
9191
model.activeWorkItem.set(work);
9292
}
9393

94-
public void addNewProject(final String projectName, final boolean isWork, final Color projectColor,
95-
final int index) {
96-
final Project project = new Project(projectName, projectColor, isWork, index, false);
94+
public void addNewProject(final Project project) {
95+
LOG.info("Creating new project '{}'.", project);
9796
model.getAllProjects().add(project);
9897
model.getAvailableProjects().add(project);
9998

10099
final List<Project> changedProjects = resortProjectIndexes(model.getAvailableProjects(), project,
101-
model.getAvailableProjects().size(), index);
100+
model.getAvailableProjects().size(), project.getIndex());
102101
changedProjects.add(project);
103102
model.getProjectRepository().saveAll(changedProjects);
104103
}
@@ -167,18 +166,19 @@ private boolean isProjectActive(final Project p) {
167166
return p == model.activeWorkItem.get().getProject();
168167
}
169168

170-
public void editProject(final Project p, final String newName, final Color newColor, final boolean isWork,
171-
final int newIndex) {
172-
LOG.info("Changing project '{}' to '{}' '{}' '{}'", p, newName, newColor, isWork);
169+
public void editProject(final Project projectToBeUpdated, final Project newValuedProject) {
170+
LOG.info("Changing project '{}' to '{}'.", projectToBeUpdated, newValuedProject);
173171

174-
p.setName(newName);
175-
p.setColor(newColor);
176-
p.setWork(isWork);
177-
final int oldIndex = p.getIndex();
178-
p.setIndex(newIndex);
172+
projectToBeUpdated.setName(newValuedProject.getName());
173+
projectToBeUpdated.setDescription(newValuedProject.getDescription());
174+
projectToBeUpdated.setColor(newValuedProject.getColor());
175+
projectToBeUpdated.setWork(newValuedProject.isWork());
176+
final int oldIndex = projectToBeUpdated.getIndex();
177+
projectToBeUpdated.setIndex(newValuedProject.getIndex());
179178

180-
final List<Project> changedProjects = resortProjectIndexes(model.getAvailableProjects(), p, oldIndex, newIndex);
181-
changedProjects.add(p);
179+
final List<Project> changedProjects = resortProjectIndexes(model.getAvailableProjects(), projectToBeUpdated,
180+
oldIndex, newValuedProject.getIndex());
181+
changedProjects.add(projectToBeUpdated);
182182

183183
// save all projects which changed index
184184
model.getProjectRepository().saveAll(changedProjects);

src/main/java/de/doubleslash/keeptime/model/Model.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public Model(final ProjectRepository projectRepository, final WorkRepository wor
5454

5555
public static final Color ORIGINAL_TASK_BAR_FONT_COLOR = Color.BLACK;
5656

57-
public static final Project DEFAULT_PROJECT = new Project("Idle", Color.ORANGE, false, 0, true);
57+
public static final Project DEFAULT_PROJECT = new Project("Idle", "", Color.ORANGE, false, 0, true);
5858
private Project idleProject = DEFAULT_PROJECT;
5959

6060
private final ObservableList<Project> availableProjects = FXCollections.observableArrayList();

src/main/java/de/doubleslash/keeptime/model/Project.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import javax.persistence.GeneratedValue;
2323
import javax.persistence.GenerationType;
2424
import javax.persistence.Id;
25+
import javax.persistence.Lob;
2526
import javax.persistence.Table;
2627

2728
import de.doubleslash.keeptime.model.persistenceconverter.ColorConverter;
@@ -38,6 +39,9 @@ public class Project {
3839

3940
private String name;
4041

42+
@Lob
43+
private String description;
44+
4145
@Convert(converter = ColorConverter.class, disableConversion = false)
4246
private Color color;
4347

@@ -53,19 +57,21 @@ public Project() {
5357
// Needed for jpa
5458
}
5559

56-
public Project(final String name, final Color color, final boolean isWork, final int index,
60+
public Project(final String name, final String description, final Color color, final boolean isWork, final int index,
5761
final boolean isDefault) {
5862
super();
5963
this.name = name;
64+
this.description = description;
6065
this.color = color;
6166
this.isWork = isWork;
6267
this.isDefault = isDefault;
6368
this.isEnabled = true;
6469
this.index = index;
6570
}
6671

67-
public Project(final String name, final Color color, final boolean isWork, final int index) {
68-
this(name, color, isWork, index, false);
72+
public Project(final String name, final String description, final Color color, final boolean isWork,
73+
final int index) {
74+
this(name, description, color, isWork, index, false);
6975
}
7076

7177
public String getName() {
@@ -120,10 +126,18 @@ public void setIndex(final int index) {
120126
this.index = index;
121127
}
122128

129+
public String getDescription() {
130+
return description;
131+
}
132+
133+
public void setDescription(final String description) {
134+
this.description = description;
135+
}
136+
123137
@Override
124138
public String toString() {
125-
return "Project [id=" + id + ", name=" + name + ", color=" + color + ", isWork=" + isWork + ", isDefault="
126-
+ isDefault + ", isEnabled=" + isEnabled + "]";
139+
return "Project [id=" + id + ", name=" + name + ", description=" + description + ", color=" + color + ", isWork="
140+
+ isWork + ", isDefault=" + isDefault + ", isEnabled=" + isEnabled + ", index=" + index + "]";
127141
}
128142

129143
}

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
// Copyright 2019 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+
117
package de.doubleslash.keeptime.view;
218

319
import java.util.Optional;
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// Copyright 2019 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.view;
18+
19+
import org.slf4j.Logger;
20+
import org.slf4j.LoggerFactory;
21+
22+
import de.doubleslash.keeptime.model.Model;
23+
import de.doubleslash.keeptime.model.Project;
24+
import javafx.fxml.FXML;
25+
import javafx.scene.control.CheckBox;
26+
import javafx.scene.control.ColorPicker;
27+
import javafx.scene.control.Spinner;
28+
import javafx.scene.control.SpinnerValueFactory.IntegerSpinnerValueFactory;
29+
import javafx.scene.control.TextArea;
30+
import javafx.scene.control.TextField;
31+
import javafx.scene.layout.GridPane;
32+
33+
public class ManageProjectController {
34+
35+
private static final Logger LOG = LoggerFactory.getLogger(ManageProjectController.class);
36+
37+
private Model model;
38+
39+
@FXML
40+
private GridPane grid;
41+
42+
@FXML
43+
private TextField nameTextField;
44+
45+
@FXML
46+
private TextArea descriptionTextArea;
47+
48+
@FXML
49+
private ColorPicker textFillColorPicker;
50+
51+
@FXML
52+
private CheckBox isWorkCheckBox;
53+
54+
@FXML
55+
private Spinner<Integer> sortIndexSpinner;
56+
57+
public void setModel(final Model model) {
58+
this.model = model;
59+
}
60+
61+
public void secondInitialize() {
62+
if (model != null) {
63+
final int availableProjectAmount = model.getAllProjects().size();
64+
sortIndexSpinner
65+
.setValueFactory(new IntegerSpinnerValueFactory(0, availableProjectAmount, availableProjectAmount));
66+
sortIndexSpinner.getValueFactory().setValue(model.getAvailableProjects().size());
67+
}
68+
}
69+
70+
public void initializeWith(final Project project) {
71+
LOG.info("Setting values.");
72+
nameTextField.setText(project.getName());
73+
descriptionTextArea.setText(project.getDescription());
74+
textFillColorPicker.setValue(project.getColor());
75+
isWorkCheckBox.setSelected(project.isWork());
76+
sortIndexSpinner.getValueFactory().setValue(project.getIndex());
77+
}
78+
79+
public Project getProjectFromUserInput() {
80+
return new Project(nameTextField.getText(), descriptionTextArea.getText(), textFillColorPicker.getValue(),
81+
isWorkCheckBox.isSelected(), sortIndexSpinner.getValue());
82+
}
83+
84+
}

0 commit comments

Comments
 (0)