@@ -127,7 +127,8 @@ public class ViewController {
127127 double startX = -1 ;
128128
129129 class Delta {
130- double x , y ;
130+ double x ;
131+ double y ;
131132 }
132133
133134 private final Delta dragDelta = new Delta ();
@@ -532,8 +533,6 @@ private Node addProjectToProjectList(final Project p) {
532533 final MouseButton button = a .getButton ();
533534 if (button == MouseButton .PRIMARY ) {
534535 changeProject (p , 0 );
535- } else if (button == MouseButton .SECONDARY ) {
536-
537536 }
538537
539538 });
@@ -677,35 +676,11 @@ private Node addProjectToProjectList(final Project p) {
677676 editMenuItem .setOnAction (e -> {
678677 // TODO refactor to use "add project" controls
679678 LOG .info ("Edit project" );
680- final Dialog <ButtonType > dialog = new Dialog <>();
681- dialog .setTitle ("Edit project" );
682- dialog .setHeaderText ("Edit project '" + p .getName () + "'" );
683-
684- dialog .getDialogPane ().getButtonTypes ().addAll (ButtonType .OK , ButtonType .CANCEL );
685-
686- final GridPane grid = new GridPane ();
687- grid .setHgap (10 );
688- grid .setVgap (10 );
689- grid .setPadding (new Insets (20 , 150 , 10 , 10 ));
690-
691- grid .add (new Label ("Name:" ), 0 , 0 );
692- final TextField projectNameTextField = new TextField (p .getName ());
693- grid .add (projectNameTextField , 1 , 0 );
694-
695- grid .add (new Label ("Color:" ), 0 , 1 );
696- final ColorPicker colorPicker = new ColorPicker (p .getColor ());
697- grid .add (colorPicker , 1 , 1 );
698-
699- grid .add (new Label ("IsWork:" ), 0 , 2 );
700- final CheckBox isWorkCheckBox = new CheckBox ();
701- isWorkCheckBox .setSelected (p .isWork ());
702- grid .add (isWorkCheckBox , 1 , 2 );
679+ Dialog <ButtonType > dialog = new Dialog <>();
680+ dialog = setUpEditProjectDialog (p );
703681
704- grid .add (new Label ("SortIndex:" ), 0 , 3 );
705- final Spinner <Integer > indexSpinner = new Spinner <>();
706- final int availableProjectAmount = model .availableProjects .size ();
707- indexSpinner .setValueFactory (new IntegerSpinnerValueFactory (0 , availableProjectAmount - 1 , p .getIndex ()));
708- grid .add (indexSpinner , 1 , 3 );
682+ GridPane grid = new GridPane ();
683+ grid = setUpEditProjectGridPane (p );
709684
710685 // TODO disable OK button if no name is set
711686 dialog .getDialogPane ().setContent (grid );
@@ -741,6 +716,43 @@ private Node addProjectToProjectList(final Project p) {
741716 return projectElement ;
742717 }
743718
719+ private Dialog <ButtonType > setUpEditProjectDialog (final Project p ) {
720+ final Dialog <ButtonType > dialog = new Dialog <>();
721+ dialog .setTitle ("Edit project" );
722+ dialog .setHeaderText ("Edit project '" + p .getName () + "'" );
723+ dialog .getDialogPane ().getButtonTypes ().addAll (ButtonType .OK , ButtonType .CANCEL );
724+ return dialog ;
725+ }
726+
727+ private GridPane setUpEditProjectGridPane (final Project p ) {
728+ final GridPane grid = new GridPane ();
729+
730+ grid .setHgap (10 );
731+ grid .setVgap (10 );
732+ grid .setPadding (new Insets (20 , 150 , 10 , 10 ));
733+
734+ grid .add (new Label ("Name:" ), 0 , 0 );
735+ final TextField projectNameTextField = new TextField (p .getName ());
736+ grid .add (projectNameTextField , 1 , 0 );
737+
738+ grid .add (new Label ("Color:" ), 0 , 1 );
739+ final ColorPicker colorPicker = new ColorPicker (p .getColor ());
740+ grid .add (colorPicker , 1 , 1 );
741+
742+ grid .add (new Label ("IsWork:" ), 0 , 2 );
743+ final CheckBox isWorkCheckBox = new CheckBox ();
744+ isWorkCheckBox .setSelected (p .isWork ());
745+ grid .add (isWorkCheckBox , 1 , 2 );
746+
747+ grid .add (new Label ("SortIndex:" ), 0 , 3 );
748+ final Spinner <Integer > indexSpinner = new Spinner <>();
749+ final int availableProjectAmount = model .availableProjects .size ();
750+ indexSpinner .setValueFactory (new IntegerSpinnerValueFactory (0 , availableProjectAmount - 1 , p .getIndex ()));
751+ grid .add (indexSpinner , 1 , 3 );
752+
753+ return grid ;
754+ }
755+
744756 private void realignProjectList () {
745757 LOG .debug ("Sorting project view" );
746758 final ObservableList <Node > children = availableProjectVbox .getChildren ();
0 commit comments