@@ -137,57 +137,30 @@ public ProjectsListViewController(final Model model, final Controller controller
137137 availableProjectsListView .getSelectionModel ().selectFirst ();
138138 }
139139
140- private void addProjectToProjectSelectionNodeMap (final Project project ) {
141- final Pane projectElement = addProjectToProjectList (project );
142- projectSelectionNodeMap .put (project , projectElement );
140+ /**
141+ * Update UI
142+ */
143+ public void tick () {
144+ for (final Entry <Project , Label > entry : elapsedProjectTimeLabelMap .entrySet ()) {
145+ final Project p = entry .getKey ();
146+ final Label label = entry .getValue ();
147+
148+ final long seconds = model .getPastWorkItems ().stream ().filter (work -> work .getProject ().getId () == p .getId ())
149+ .mapToLong (work -> Duration .between (work .getStartTime (), work .getEndTime ()).getSeconds ()).sum ();
150+ label .setText (DateFormatter .secondsToHHMMSS (seconds ));
151+ }
143152 }
144153
145- public void changeProject (final Project newProject , final long minusSeconds ) {
154+ private void changeProject (final Project newProject , final long minusSeconds ) {
146155 if (hideable ) {
147156 mainStage .hide ();
148157 }
149158 controller .changeProject (newProject , minusSeconds );
150159 }
151160
152- public Map <Project , Node > getProjectSelectionNodeMap () {
153- return projectSelectionNodeMap ;
154- }
155-
156- private GridPane setUpGridPane (final String projectName , final Color projectColor , final boolean isWork ) {
157- final GridPane grid = new GridPane ();
158- grid .setHgap (10 );
159- grid .setVgap (10 );
160- grid .setPadding (new Insets (20 , 150 , 10 , 10 ));
161-
162- final Label nameLabel = new Label ("Name:" );
163- nameLabel .setFont (FontProvider .getDefaultFont ());
164- grid .add (nameLabel , 0 , 0 );
165-
166- final TextField projectNameTextField = new TextField (projectName );
167- projectNameTextField .setFont (FontProvider .getDefaultFont ());
168- grid .add (projectNameTextField , 1 , 0 );
169-
170- final Label colorLabel = new Label ("Color:" );
171- colorLabel .setFont (FontProvider .getDefaultFont ());
172- grid .add (colorLabel , 0 , 1 );
173-
174- final ColorPicker colorPicker = new ColorPicker (projectColor );
175- grid .add (colorPicker , 1 , 1 );
176-
177- final Label isWorkLabel = new Label ("IsWork:" );
178- isWorkLabel .setFont (FontProvider .getDefaultFont ());
179- grid .add (isWorkLabel , 0 , 2 );
180-
181- final CheckBox isWorkCheckBox = new CheckBox ();
182- isWorkCheckBox .setSelected (isWork );
183- isWorkCheckBox .setFont (FontProvider .getDefaultFont ());
184- grid .add (isWorkCheckBox , 1 , 2 );
185-
186- final Label sortIndex = new Label ("SortIndex:" );
187- sortIndex .setFont (FontProvider .getDefaultFont ());
188- grid .add (new Label ("SortIndex:" ), 0 , 3 );
189-
190- return grid ;
161+ private void addProjectToProjectSelectionNodeMap (final Project project ) {
162+ final Node projectElement = createListEntryForProject (project );
163+ projectSelectionNodeMap .put (project , projectElement );
191164 }
192165
193166 private void realignProjectList () {
@@ -198,7 +171,7 @@ private void realignProjectList() {
198171 model .getSortedAvailableProjects ().setComparator (comparator );
199172 }
200173
201- private Pane addProjectToProjectList (final Project p ) {
174+ private Node createListEntryForProject (final Project p ) {
202175 final ContextMenu contextMenu = new ContextMenu ();
203176
204177 final FXMLLoader loader = new FXMLLoader ();
@@ -342,6 +315,43 @@ private GridPane setUpEditProjectGridPane(final Project p) {
342315 return grid ;
343316 }
344317
318+ private GridPane setUpGridPane (final String projectName , final Color projectColor , final boolean isWork ) {
319+ final GridPane grid = new GridPane ();
320+ grid .setHgap (10 );
321+ grid .setVgap (10 );
322+ grid .setPadding (new Insets (20 , 150 , 10 , 10 ));
323+
324+ final Label nameLabel = new Label ("Name:" );
325+ nameLabel .setFont (FontProvider .getDefaultFont ());
326+ grid .add (nameLabel , 0 , 0 );
327+
328+ final TextField projectNameTextField = new TextField (projectName );
329+ projectNameTextField .setFont (FontProvider .getDefaultFont ());
330+ grid .add (projectNameTextField , 1 , 0 );
331+
332+ final Label colorLabel = new Label ("Color:" );
333+ colorLabel .setFont (FontProvider .getDefaultFont ());
334+ grid .add (colorLabel , 0 , 1 );
335+
336+ final ColorPicker colorPicker = new ColorPicker (projectColor );
337+ grid .add (colorPicker , 1 , 1 );
338+
339+ final Label isWorkLabel = new Label ("IsWork:" );
340+ isWorkLabel .setFont (FontProvider .getDefaultFont ());
341+ grid .add (isWorkLabel , 0 , 2 );
342+
343+ final CheckBox isWorkCheckBox = new CheckBox ();
344+ isWorkCheckBox .setSelected (isWork );
345+ isWorkCheckBox .setFont (FontProvider .getDefaultFont ());
346+ grid .add (isWorkCheckBox , 1 , 2 );
347+
348+ final Label sortIndex = new Label ("SortIndex:" );
349+ sortIndex .setFont (FontProvider .getDefaultFont ());
350+ grid .add (new Label ("SortIndex:" ), 0 , 3 );
351+
352+ return grid ;
353+ }
354+
345355 private void editProject (final ObservableList <Node > nodes , final Project p ) {
346356 final TextField projectNameTextField = (TextField ) nodes .get (1 );
347357 final ColorPicker colorPicker = (ColorPicker ) nodes .get (3 );
@@ -351,18 +361,7 @@ private void editProject(final ObservableList<Node> nodes, final Project p) {
351361 indexSpinner .getValue ());
352362 }
353363
354- public void tick () {
355- for (final Entry <Project , Label > entry : elapsedProjectTimeLabelMap .entrySet ()) {
356- final Project p = entry .getKey ();
357- final Label label = entry .getValue ();
358-
359- final long seconds = model .getPastWorkItems ().stream ().filter (work -> work .getProject ().getId () == p .getId ())
360- .mapToLong (work -> Duration .between (work .getStartTime (), work .getEndTime ()).getSeconds ()).sum ();
361- label .setText (DateFormatter .secondsToHHMMSS (seconds ));
362- }
363- }
364-
365- public ListCell <Project > returnListCellOfProject () {
364+ private ListCell <Project > returnListCellOfProject () {
366365 return new ListCell <Project >() {
367366
368367 @ Override
0 commit comments