forked from bisq-network/bisq
/
FormBuilder.java
2166 lines (1721 loc) · 108 KB
/
FormBuilder.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/
package bisq.desktop.util;
import bisq.desktop.components.AddressTextField;
import bisq.desktop.components.AutoTooltipButton;
import bisq.desktop.components.AutoTooltipCheckBox;
import bisq.desktop.components.AutoTooltipLabel;
import bisq.desktop.components.AutoTooltipRadioButton;
import bisq.desktop.components.AutoTooltipSlideToggleButton;
import bisq.desktop.components.AutocompleteComboBox;
import bisq.desktop.components.BalanceTextField;
import bisq.desktop.components.BisqTextArea;
import bisq.desktop.components.BisqTextField;
import bisq.desktop.components.BsqAddressTextField;
import bisq.desktop.components.BusyAnimation;
import bisq.desktop.components.ExternalHyperlink;
import bisq.desktop.components.FundsTextField;
import bisq.desktop.components.HyperlinkWithIcon;
import bisq.desktop.components.InfoInputTextField;
import bisq.desktop.components.InfoTextField;
import bisq.desktop.components.InputTextField;
import bisq.desktop.components.PasswordTextField;
import bisq.desktop.components.TextFieldWithCopyIcon;
import bisq.desktop.components.TextFieldWithIcon;
import bisq.desktop.components.TitledGroupBg;
import bisq.desktop.components.TxIdTextField;
import bisq.core.locale.Res;
import bisq.common.util.Tuple2;
import bisq.common.util.Tuple3;
import bisq.common.util.Tuple4;
import de.jensd.fx.fontawesome.AwesomeDude;
import de.jensd.fx.fontawesome.AwesomeIcon;
import de.jensd.fx.glyphs.GlyphIcons;
import de.jensd.fx.glyphs.materialdesignicons.utils.MaterialDesignIconFactory;
import com.jfoenix.controls.JFXComboBox;
import com.jfoenix.controls.JFXDatePicker;
import com.jfoenix.controls.JFXTextArea;
import com.jfoenix.controls.JFXToggleButton;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.ContentDisplay;
import javafx.scene.control.DatePicker;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TableView;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleButton;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
import org.jetbrains.annotations.NotNull;
import static bisq.desktop.util.GUIUtil.getComboBoxButtonCell;
public class FormBuilder {
private static final String MATERIAL_DESIGN_ICONS = "'Material Design Icons'";
///////////////////////////////////////////////////////////////////////////////////////////
// TitledGroupBg
///////////////////////////////////////////////////////////////////////////////////////////
public static TitledGroupBg addTitledGroupBg(GridPane gridPane, int rowIndex, int rowSpan, String title) {
return addTitledGroupBg(gridPane, rowIndex, rowSpan, title, 0);
}
public static TitledGroupBg addTitledGroupBg(GridPane gridPane,
int rowIndex,
int columnIndex,
int rowSpan,
String title) {
TitledGroupBg titledGroupBg = addTitledGroupBg(gridPane, rowIndex, rowSpan, title, 0);
GridPane.setColumnIndex(titledGroupBg, columnIndex);
return titledGroupBg;
}
public static TitledGroupBg addTitledGroupBg(GridPane gridPane,
int rowIndex,
int columnIndex,
int rowSpan,
String title,
double top) {
TitledGroupBg titledGroupBg = addTitledGroupBg(gridPane, rowIndex, rowSpan, title, top);
GridPane.setColumnIndex(titledGroupBg, columnIndex);
return titledGroupBg;
}
public static TitledGroupBg addTitledGroupBg(GridPane gridPane,
int rowIndex,
int rowSpan,
String title,
double top) {
TitledGroupBg titledGroupBg = new TitledGroupBg();
titledGroupBg.setText(title);
titledGroupBg.prefWidthProperty().bind(gridPane.widthProperty());
GridPane.setRowIndex(titledGroupBg, rowIndex);
GridPane.setRowSpan(titledGroupBg, rowSpan);
GridPane.setMargin(titledGroupBg, new Insets(top + 8, -10, -12, -10));
gridPane.getChildren().add(titledGroupBg);
return titledGroupBg;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Label
///////////////////////////////////////////////////////////////////////////////////////////
public static Label addLabel(GridPane gridPane, int rowIndex, String title) {
return addLabel(gridPane, rowIndex, title, 0);
}
public static Label addLabel(GridPane gridPane, int rowIndex, String title, double top) {
Label label = new AutoTooltipLabel(title);
GridPane.setRowIndex(label, rowIndex);
GridPane.setMargin(label, new Insets(top, 0, 0, 0));
gridPane.getChildren().add(label);
return label;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Label + Subtext
///////////////////////////////////////////////////////////////////////////////////////////
public static Tuple3<Label, Label, VBox> addLabelWithSubText(GridPane gridPane,
int rowIndex,
String title,
String description) {
return addLabelWithSubText(gridPane, rowIndex, title, description, 0);
}
public static Tuple3<Label, Label, VBox> addLabelWithSubText(GridPane gridPane,
int rowIndex,
String title,
String description,
double top) {
Label label = new AutoTooltipLabel(title);
Label subText = new AutoTooltipLabel(description);
VBox vBox = new VBox();
vBox.getChildren().setAll(label, subText);
GridPane.setRowIndex(vBox, rowIndex);
GridPane.setMargin(vBox, new Insets(top, 0, 0, 0));
gridPane.getChildren().add(vBox);
return new Tuple3<>(label, subText, vBox);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Multiline Label
///////////////////////////////////////////////////////////////////////////////////////////
public static Label addMultilineLabel(GridPane gridPane, int rowIndex) {
return addMultilineLabel(gridPane, rowIndex, 0);
}
public static Label addMultilineLabel(GridPane gridPane, int rowIndex, String text) {
return addMultilineLabel(gridPane, rowIndex, text, 0);
}
public static Label addMultilineLabel(GridPane gridPane, int rowIndex, double top) {
return addMultilineLabel(gridPane, rowIndex, "", top);
}
public static Label addMultilineLabel(GridPane gridPane, int rowIndex, String text, double top) {
return addMultilineLabel(gridPane, rowIndex, text, top, 600);
}
public static Label addMultilineLabel(GridPane gridPane, int rowIndex, String text, double top, double maxWidth) {
Label label = new AutoTooltipLabel(text);
label.setWrapText(true);
label.setMaxWidth(maxWidth);
GridPane.setHalignment(label, HPos.LEFT);
GridPane.setHgrow(label, Priority.ALWAYS);
GridPane.setRowIndex(label, rowIndex);
GridPane.setMargin(label, new Insets(top + Layout.FLOATING_LABEL_DISTANCE, 0, 0, 0));
gridPane.getChildren().add(label);
return label;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Label + TextField
///////////////////////////////////////////////////////////////////////////////////////////
public static Tuple3<Label, TextField, VBox> addTopLabelReadOnlyTextField(GridPane gridPane,
int rowIndex,
String title) {
return addTopLabelTextField(gridPane, rowIndex, title, "", -15);
}
public static Tuple3<Label, TextField, VBox> addTopLabelReadOnlyTextField(GridPane gridPane,
int rowIndex,
int columnIndex,
String title) {
Tuple3<Label, TextField, VBox> tuple = addTopLabelTextField(gridPane, rowIndex, title, "", -15);
GridPane.setColumnIndex(tuple.third, columnIndex);
return tuple;
}
public static Tuple3<Label, TextField, VBox> addTopLabelReadOnlyTextField(GridPane gridPane,
int rowIndex,
String title,
double top) {
return addTopLabelTextField(gridPane, rowIndex, title, "", top - 15);
}
public static Tuple3<Label, TextField, VBox> addTopLabelReadOnlyTextField(GridPane gridPane,
int rowIndex,
String title,
String value) {
return addTopLabelReadOnlyTextField(gridPane, rowIndex, title, value, 0);
}
public static Tuple3<Label, TextField, VBox> addTopLabelReadOnlyTextField(GridPane gridPane,
int rowIndex,
int columnIndex,
String title,
String value,
double top) {
Tuple3<Label, TextField, VBox> tuple = addTopLabelTextField(gridPane, rowIndex, title, value, top - 15);
GridPane.setColumnIndex(tuple.third, columnIndex);
return tuple;
}
public static Tuple3<Label, TextField, VBox> addTopLabelReadOnlyTextField(GridPane gridPane,
int rowIndex,
int columnIndex,
String title,
double top) {
Tuple3<Label, TextField, VBox> tuple = addTopLabelTextField(gridPane, rowIndex, title, "", top - 15);
GridPane.setColumnIndex(tuple.third, columnIndex);
return tuple;
}
public static Tuple3<Label, TextField, VBox> addTopLabelReadOnlyTextField(GridPane gridPane,
int rowIndex,
String title,
String value,
double top) {
return addTopLabelTextField(gridPane, rowIndex, title, value, top - 15);
}
public static Tuple3<Label, TextField, VBox> addTopLabelTextField(GridPane gridPane, int rowIndex, String title) {
return addTopLabelTextField(gridPane, rowIndex, title, "", 0);
}
public static Tuple3<Label, TextField, VBox> addCompactTopLabelTextField(GridPane gridPane,
int rowIndex,
String title,
String value) {
return addTopLabelTextField(gridPane, rowIndex, title, value, -Layout.FLOATING_LABEL_DISTANCE);
}
public static Tuple3<Label, TextField, VBox> addCompactTopLabelTextField(GridPane gridPane,
int rowIndex,
int colIndex,
String title,
String value) {
final Tuple3<Label, TextField, VBox> labelTextFieldVBoxTuple3 = addTopLabelTextField(gridPane, rowIndex, title, value, -Layout.FLOATING_LABEL_DISTANCE);
GridPane.setColumnIndex(labelTextFieldVBoxTuple3.third, colIndex);
return labelTextFieldVBoxTuple3;
}
public static Tuple3<Label, TextField, VBox> addCompactTopLabelTextField(GridPane gridPane,
int rowIndex,
String title,
String value,
double top) {
return addTopLabelTextField(gridPane, rowIndex, title, value, top - Layout.FLOATING_LABEL_DISTANCE);
}
public static Tuple3<Label, TextField, VBox> addTopLabelTextField(GridPane gridPane,
int rowIndex,
String title,
String value) {
return addTopLabelTextField(gridPane, rowIndex, title, value, 0);
}
public static Tuple3<Label, TextField, VBox> addTopLabelTextField(GridPane gridPane,
int rowIndex,
String title,
double top) {
return addTopLabelTextField(gridPane, rowIndex, title, "", top);
}
public static Tuple3<Label, TextField, VBox> addTopLabelTextField(GridPane gridPane,
int rowIndex,
String title,
String value,
double top) {
TextField textField = new BisqTextField(value);
textField.setEditable(false);
textField.setFocusTraversable(false);
final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, textField, top);
// TOD not 100% sure if that is a good idea....
//topLabelWithVBox.first.getStyleClass().add("jfx-text-field-top-label");
return new Tuple3<>(topLabelWithVBox.first, textField, topLabelWithVBox.second);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Confirmation Fields
///////////////////////////////////////////////////////////////////////////////////////////
public static Tuple2<Label, Label> addConfirmationLabelLabel(GridPane gridPane,
int rowIndex,
String title1,
String title2) {
return addConfirmationLabelLabel(gridPane, rowIndex, title1, title2, 0);
}
public static Tuple2<Label, Label> addConfirmationLabelLabel(GridPane gridPane,
int rowIndex,
String title1,
String title2,
double top) {
Label label1 = addLabel(gridPane, rowIndex, title1);
label1.getStyleClass().add("confirmation-label");
Label label2 = addLabel(gridPane, rowIndex, title2);
label2.getStyleClass().add("confirmation-value");
GridPane.setColumnIndex(label2, 1);
GridPane.setMargin(label1, new Insets(top, 0, 0, 0));
GridPane.setHalignment(label1, HPos.LEFT);
GridPane.setMargin(label2, new Insets(top, 0, 0, 0));
return new Tuple2<>(label1, label2);
}
public static Tuple2<Label, TextArea> addConfirmationLabelTextArea(GridPane gridPane,
int rowIndex,
String title1,
String title2,
double top) {
Label label = addLabel(gridPane, rowIndex, title1);
label.getStyleClass().add("confirmation-label");
TextArea textArea = addTextArea(gridPane, rowIndex, title2);
((JFXTextArea) textArea).setLabelFloat(false);
GridPane.setColumnIndex(textArea, 1);
GridPane.setMargin(label, new Insets(top, 0, 0, 0));
GridPane.setHalignment(label, HPos.LEFT);
GridPane.setMargin(textArea, new Insets(top, 0, 0, 0));
return new Tuple2<>(label, textArea);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Label + TextFieldWithIcon
///////////////////////////////////////////////////////////////////////////////////////////
public static Tuple2<Label, TextFieldWithIcon> addTopLabelTextFieldWithIcon(GridPane gridPane,
int rowIndex,
String title,
double top) {
return addTopLabelTextFieldWithIcon(gridPane, rowIndex, 0, title, top);
}
public static Tuple2<Label, TextFieldWithIcon> addTopLabelTextFieldWithIcon(GridPane gridPane,
int rowIndex,
int columnIndex,
String title,
double top) {
TextFieldWithIcon textFieldWithIcon = new TextFieldWithIcon();
textFieldWithIcon.setMouseTransparent(true);
textFieldWithIcon.setFocusTraversable(false);
return new Tuple2<>(addTopLabelWithVBox(gridPane, rowIndex, columnIndex, title, textFieldWithIcon, top).first, textFieldWithIcon);
}
///////////////////////////////////////////////////////////////////////////////////////////
// HyperlinkWithIcon
///////////////////////////////////////////////////////////////////////////////////////////
public static HyperlinkWithIcon addHyperlinkWithIcon(GridPane gridPane, int rowIndex, String title, String url) {
return addHyperlinkWithIcon(gridPane, rowIndex, title, url, 0);
}
public static HyperlinkWithIcon addHyperlinkWithIcon(GridPane gridPane,
int rowIndex,
String title,
String url,
double top) {
HyperlinkWithIcon hyperlinkWithIcon = new ExternalHyperlink(title);
hyperlinkWithIcon.setOnAction(e -> GUIUtil.openWebPage(url));
GridPane.setRowIndex(hyperlinkWithIcon, rowIndex);
GridPane.setColumnIndex(hyperlinkWithIcon, 0);
GridPane.setMargin(hyperlinkWithIcon, new Insets(top, 0, 0, 0));
GridPane.setHalignment(hyperlinkWithIcon, HPos.LEFT);
gridPane.getChildren().add(hyperlinkWithIcon);
return hyperlinkWithIcon;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Label + HyperlinkWithIcon
///////////////////////////////////////////////////////////////////////////////////////////
public static Tuple2<Label, HyperlinkWithIcon> addLabelHyperlinkWithIcon(GridPane gridPane,
int rowIndex,
String labelTitle,
String title,
String url) {
return addLabelHyperlinkWithIcon(gridPane, rowIndex, labelTitle, title, url, 0);
}
public static Tuple2<Label, HyperlinkWithIcon> addLabelHyperlinkWithIcon(GridPane gridPane,
int rowIndex,
String labelTitle,
String title,
String url,
double top) {
Label label = addLabel(gridPane, rowIndex, labelTitle, top);
HyperlinkWithIcon hyperlinkWithIcon = new ExternalHyperlink(title);
hyperlinkWithIcon.setOnAction(e -> GUIUtil.openWebPage(url));
GridPane.setRowIndex(hyperlinkWithIcon, rowIndex);
GridPane.setMargin(hyperlinkWithIcon, new Insets(top, 0, 0, -4));
gridPane.getChildren().add(hyperlinkWithIcon);
return new Tuple2<>(label, hyperlinkWithIcon);
}
public static Tuple3<Label, HyperlinkWithIcon, VBox> addTopLabelHyperlinkWithIcon(GridPane gridPane,
int rowIndex,
int columnIndex,
String title,
String value,
String url,
double top) {
Tuple3<Label, HyperlinkWithIcon, VBox> tuple = addTopLabelHyperlinkWithIcon(gridPane,
rowIndex,
title,
value,
url,
top);
GridPane.setColumnIndex(tuple.third, columnIndex);
return tuple;
}
public static Tuple3<Label, HyperlinkWithIcon, VBox> addTopLabelHyperlinkWithIcon(GridPane gridPane,
int rowIndex,
String title,
String value,
String url,
double top) {
HyperlinkWithIcon hyperlinkWithIcon = new ExternalHyperlink(value);
hyperlinkWithIcon.setOnAction(e -> GUIUtil.openWebPage(url));
hyperlinkWithIcon.getStyleClass().add("hyperlink-with-icon");
GridPane.setRowIndex(hyperlinkWithIcon, rowIndex);
Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, hyperlinkWithIcon, top - 15);
return new Tuple3<>(topLabelWithVBox.first, hyperlinkWithIcon, topLabelWithVBox.second);
}
///////////////////////////////////////////////////////////////////////////////////////////
// TextArea
///////////////////////////////////////////////////////////////////////////////////////////
public static TextArea addTextArea(GridPane gridPane, int rowIndex, String prompt) {
return addTextArea(gridPane, rowIndex, prompt, 0);
}
public static TextArea addTextArea(GridPane gridPane, int rowIndex, String prompt, double top) {
JFXTextArea textArea = new BisqTextArea();
textArea.setPromptText(prompt);
textArea.setLabelFloat(true);
textArea.setWrapText(true);
GridPane.setRowIndex(textArea, rowIndex);
GridPane.setColumnIndex(textArea, 0);
GridPane.setMargin(textArea, new Insets(top + Layout.FLOATING_LABEL_DISTANCE, 0, 0, 0));
gridPane.getChildren().add(textArea);
return textArea;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Label + TextArea
///////////////////////////////////////////////////////////////////////////////////////////
public static Tuple2<Label, TextArea> addCompactTopLabelTextArea(GridPane gridPane,
int rowIndex,
String title,
String prompt) {
return addTopLabelTextArea(gridPane, rowIndex, title, prompt, -Layout.FLOATING_LABEL_DISTANCE);
}
public static Tuple2<Label, TextArea> addCompactTopLabelTextArea(GridPane gridPane,
int rowIndex,
int colIndex,
String title,
String prompt) {
return addTopLabelTextArea(gridPane, rowIndex, colIndex, title, prompt, -Layout.FLOATING_LABEL_DISTANCE);
}
public static Tuple2<Label, TextArea> addTopLabelTextArea(GridPane gridPane,
int rowIndex,
String title,
String prompt) {
return addTopLabelTextArea(gridPane, rowIndex, title, prompt, 0);
}
public static Tuple2<Label, TextArea> addTopLabelTextArea(GridPane gridPane,
int rowIndex,
int colIndex,
String title,
String prompt) {
return addTopLabelTextArea(gridPane, rowIndex, colIndex, title, prompt, 0);
}
public static Tuple2<Label, TextArea> addTopLabelTextArea(GridPane gridPane,
int rowIndex,
String title,
String prompt,
double top) {
return addTopLabelTextArea(gridPane, rowIndex, 0, title, prompt, top);
}
public static Tuple2<Label, TextArea> addTopLabelTextArea(GridPane gridPane, int rowIndex, int colIndex,
String title, String prompt, double top) {
TextArea textArea = new BisqTextArea();
textArea.setPromptText(prompt);
textArea.setWrapText(true);
final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, textArea, top);
GridPane.setColumnIndex(topLabelWithVBox.second, colIndex);
return new Tuple2<>(topLabelWithVBox.first, textArea);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Label + DatePicker
///////////////////////////////////////////////////////////////////////////////////////////
public static Tuple2<Label, DatePicker> addTopLabelDatePicker(GridPane gridPane,
int rowIndex,
String title,
double top) {
DatePicker datePicker = new JFXDatePicker();
final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, datePicker, top);
return new Tuple2<>(topLabelWithVBox.first, datePicker);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Label + TxIdTextField
///////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("UnusedReturnValue")
public static Tuple2<Label, TxIdTextField> addLabelTxIdTextField(GridPane gridPane,
int rowIndex,
String title,
String value) {
return addLabelTxIdTextField(gridPane, rowIndex, title, value, 0);
}
public static Tuple2<Label, TxIdTextField> addLabelTxIdTextField(GridPane gridPane,
int rowIndex,
String title,
String value,
double top) {
Label label = addLabel(gridPane, rowIndex, title, top);
label.getStyleClass().add("confirmation-label");
GridPane.setHalignment(label, HPos.LEFT);
TxIdTextField txTextField = new TxIdTextField();
txTextField.setup(value);
GridPane.setRowIndex(txTextField, rowIndex);
GridPane.setColumnIndex(txTextField, 1);
gridPane.getChildren().add(txTextField);
return new Tuple2<>(label, txTextField);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Label + InputTextField
///////////////////////////////////////////////////////////////////////////////////////////
public static InputTextField addInputTextField(GridPane gridPane, int rowIndex, String title) {
return addInputTextField(gridPane, rowIndex, title, 0);
}
public static InputTextField addInputTextField(GridPane gridPane, int rowIndex, String title, double top) {
InputTextField inputTextField = new InputTextField();
inputTextField.setLabelFloat(true);
inputTextField.setPromptText(title);
GridPane.setRowIndex(inputTextField, rowIndex);
GridPane.setColumnIndex(inputTextField, 0);
GridPane.setMargin(inputTextField, new Insets(top + Layout.FLOATING_LABEL_DISTANCE, 0, 0, 0));
gridPane.getChildren().add(inputTextField);
return inputTextField;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Label + InputTextField
///////////////////////////////////////////////////////////////////////////////////////////
public static Tuple2<Label, InputTextField> addTopLabelInputTextField(GridPane gridPane,
int rowIndex,
String title) {
return addTopLabelInputTextField(gridPane, rowIndex, title, 0);
}
public static Tuple2<Label, InputTextField> addTopLabelInputTextField(GridPane gridPane,
int rowIndex,
String title,
double top) {
final Tuple3<Label, InputTextField, VBox> topLabelWithVBox = addTopLabelInputTextFieldWithVBox(gridPane, rowIndex, title, top);
return new Tuple2<>(topLabelWithVBox.first, topLabelWithVBox.second);
}
public static Tuple3<Label, InputTextField, VBox> addTopLabelInputTextFieldWithVBox(GridPane gridPane,
int rowIndex,
String title,
double top) {
InputTextField inputTextField = new InputTextField();
final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, inputTextField, top);
return new Tuple3<>(topLabelWithVBox.first, inputTextField, topLabelWithVBox.second);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Label + InfoInputTextField
///////////////////////////////////////////////////////////////////////////////////////////
public static Tuple2<Label, InfoInputTextField> addTopLabelInfoInputTextField(GridPane gridPane,
int rowIndex,
String title) {
return addTopLabelInfoInputTextField(gridPane, rowIndex, title, 0);
}
public static Tuple2<Label, InfoInputTextField> addTopLabelInfoInputTextField(GridPane gridPane,
int rowIndex,
String title,
double top) {
InfoInputTextField inputTextField = new InfoInputTextField();
final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, inputTextField, top);
return new Tuple2<>(topLabelWithVBox.first, inputTextField);
}
///////////////////////////////////////////////////////////////////////////////////////////
// PasswordField
///////////////////////////////////////////////////////////////////////////////////////////
public static PasswordTextField addPasswordTextField(GridPane gridPane, int rowIndex, String title) {
return addPasswordTextField(gridPane, rowIndex, title, 0);
}
public static PasswordTextField addPasswordTextField(GridPane gridPane, int rowIndex, String title, double top) {
PasswordTextField passwordField = new PasswordTextField();
passwordField.setPromptText(title);
GridPane.setRowIndex(passwordField, rowIndex);
GridPane.setColumnIndex(passwordField, 0);
GridPane.setColumnSpan(passwordField, 2);
GridPane.setMargin(passwordField, new Insets(top + 10, 0, 20, 0));
gridPane.getChildren().add(passwordField);
return passwordField;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Label + InputTextField + CheckBox
///////////////////////////////////////////////////////////////////////////////////////////
public static Tuple3<Label, InputTextField, ToggleButton> addTopLabelInputTextFieldSlideToggleButton(GridPane gridPane,
int rowIndex,
String title,
String toggleButtonTitle) {
InputTextField inputTextField = new InputTextField();
ToggleButton toggleButton = new JFXToggleButton();
toggleButton.setText(toggleButtonTitle);
VBox.setMargin(toggleButton, new Insets(4, 0, 0, 0));
final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, inputTextField, 0);
topLabelWithVBox.second.getChildren().add(toggleButton);
return new Tuple3<>(topLabelWithVBox.first, inputTextField, toggleButton);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Label + InputTextField + Button
///////////////////////////////////////////////////////////////////////////////////////////
public static Tuple3<Label, InputTextField, Button> addTopLabelInputTextFieldButton(GridPane gridPane,
int rowIndex,
String title,
String buttonTitle) {
InputTextField inputTextField = new InputTextField();
Button button = new AutoTooltipButton(buttonTitle);
button.setDefaultButton(true);
HBox hBox = new HBox();
hBox.setSpacing(10);
hBox.getChildren().addAll(inputTextField, button);
HBox.setHgrow(inputTextField, Priority.ALWAYS);
final Tuple2<Label, VBox> labelVBoxTuple2 = addTopLabelWithVBox(gridPane, rowIndex, title, hBox, 0);
return new Tuple3<>(labelVBoxTuple2.first, inputTextField, button);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Label + TextField + Button
///////////////////////////////////////////////////////////////////////////////////////////
public static Tuple3<Label, TextField, Button> addTopLabelTextFieldButton(GridPane gridPane,
int rowIndex,
String title,
String buttonTitle) {
return addTopLabelTextFieldButton(gridPane, rowIndex, title, buttonTitle, 0);
}
public static Tuple3<Label, TextField, Button> addTopLabelTextFieldButton(GridPane gridPane,
int rowIndex,
String title,
String buttonTitle,
double top) {
TextField textField = new BisqTextField();
textField.setEditable(false);
textField.setMouseTransparent(true);
textField.setFocusTraversable(false);
Button button = new AutoTooltipButton(buttonTitle);
button.setDefaultButton(true);
HBox hBox = new HBox();
hBox.setSpacing(10);
hBox.getChildren().addAll(textField, button);
HBox.setHgrow(textField, Priority.ALWAYS);
final Tuple2<Label, VBox> labelVBoxTuple2 = addTopLabelWithVBox(gridPane, rowIndex, title, hBox, top);
return new Tuple3<>(labelVBoxTuple2.first, textField, button);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Label + InputTextField + Label + InputTextField
///////////////////////////////////////////////////////////////////////////////////////////
public static Tuple2<InputTextField, InputTextField> addInputTextFieldInputTextField(GridPane gridPane,
int rowIndex,
String title1,
String title2) {
InputTextField inputTextField1 = new InputTextField();
inputTextField1.setPromptText(title1);
inputTextField1.setLabelFloat(true);
InputTextField inputTextField2 = new InputTextField();
inputTextField2.setLabelFloat(true);
inputTextField2.setPromptText(title2);
HBox hBox = new HBox();
hBox.setSpacing(10);
hBox.getChildren().addAll(inputTextField1, inputTextField2);
GridPane.setRowIndex(hBox, rowIndex);
GridPane.setColumnIndex(hBox, 0);
GridPane.setMargin(hBox, new Insets(Layout.FLOATING_LABEL_DISTANCE, 0, 0, 0));
gridPane.getChildren().add(hBox);
return new Tuple2<>(inputTextField1, inputTextField2);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Label + TextField + Label + TextField
///////////////////////////////////////////////////////////////////////////////////////////
public static Tuple4<Label, TextField, Label, TextField> addCompactTopLabelTextFieldTopLabelTextField(GridPane gridPane,
int rowIndex,
String title1,
String title2) {
TextField textField1 = new BisqTextField();
textField1.setEditable(false);
textField1.setMouseTransparent(true);
textField1.setFocusTraversable(false);
final Tuple2<Label, VBox> topLabelWithVBox1 = getTopLabelWithVBox(title1, textField1);
TextField textField2 = new BisqTextField();
textField2.setEditable(false);
textField2.setMouseTransparent(true);
textField2.setFocusTraversable(false);
final Tuple2<Label, VBox> topLabelWithVBox2 = getTopLabelWithVBox(title2, textField2);
HBox hBox = new HBox();
hBox.setSpacing(10);
hBox.getChildren().addAll(topLabelWithVBox1.second, topLabelWithVBox2.second);
GridPane.setRowIndex(hBox, rowIndex);
gridPane.getChildren().add(hBox);
return new Tuple4<>(topLabelWithVBox1.first, textField1, topLabelWithVBox2.first, textField2);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Button + CheckBox
///////////////////////////////////////////////////////////////////////////////////////////
public static Tuple2<Button, CheckBox> addButtonCheckBox(GridPane gridPane,
int rowIndex,
String buttonTitle,
String checkBoxTitle) {
return addButtonCheckBox(gridPane, rowIndex, buttonTitle, checkBoxTitle, 0);
}
public static Tuple2<Button, CheckBox> addButtonCheckBox(GridPane gridPane,
int rowIndex,
String buttonTitle,
String checkBoxTitle,
double top) {
Button button = new AutoTooltipButton(buttonTitle);
button.setDefaultButton(true);
CheckBox checkBox = new AutoTooltipCheckBox(checkBoxTitle);
HBox.setMargin(checkBox, new Insets(6, 0, 0, 0));
HBox hBox = new HBox();
hBox.setSpacing(20);
hBox.getChildren().addAll(button, checkBox);
GridPane.setRowIndex(hBox, rowIndex);
GridPane.setColumnIndex(hBox, 1);
hBox.setPadding(new Insets(top, 0, 0, 0));
gridPane.getChildren().add(hBox);
return new Tuple2<>(button, checkBox);
}
///////////////////////////////////////////////////////////////////////////////////////////
// CheckBox
///////////////////////////////////////////////////////////////////////////////////////////
public static CheckBox addCheckBox(GridPane gridPane, int rowIndex, String checkBoxTitle) {
return addCheckBox(gridPane, rowIndex, checkBoxTitle, 0);
}
public static CheckBox addCheckBox(GridPane gridPane, int rowIndex, String checkBoxTitle, double top) {
return addCheckBox(gridPane, rowIndex, 0, checkBoxTitle, top);
}
public static CheckBox addCheckBox(GridPane gridPane,
int rowIndex,
int colIndex,
String checkBoxTitle,
double top) {
CheckBox checkBox = new AutoTooltipCheckBox(checkBoxTitle);
GridPane.setMargin(checkBox, new Insets(top, 0, 0, 0));
GridPane.setRowIndex(checkBox, rowIndex);
GridPane.setColumnIndex(checkBox, colIndex);
gridPane.getChildren().add(checkBox);
return checkBox;
}
///////////////////////////////////////////////////////////////////////////////////////////
// RadioButton
///////////////////////////////////////////////////////////////////////////////////////////
public static RadioButton addRadioButton(GridPane gridPane, int rowIndex, ToggleGroup toggleGroup, String title) {
RadioButton radioButton = new AutoTooltipRadioButton(title);
radioButton.setToggleGroup(toggleGroup);
GridPane.setRowIndex(radioButton, rowIndex);
gridPane.getChildren().add(radioButton);
return radioButton;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Label + RadioButton + RadioButton
///////////////////////////////////////////////////////////////////////////////////////////
public static Tuple3<Label, RadioButton, RadioButton> addTopLabelRadioButtonRadioButton(GridPane gridPane,
int rowIndex,
ToggleGroup toggleGroup,
String title,
String radioButtonTitle1,
String radioButtonTitle2,
double top) {
RadioButton radioButton1 = new AutoTooltipRadioButton(radioButtonTitle1);
radioButton1.setToggleGroup(toggleGroup);
radioButton1.setPadding(new Insets(6, 0, 0, 0));
RadioButton radioButton2 = new AutoTooltipRadioButton(radioButtonTitle2);
radioButton2.setToggleGroup(toggleGroup);
radioButton2.setPadding(new Insets(6, 0, 0, 0));
HBox hBox = new HBox();
hBox.setSpacing(10);
hBox.getChildren().addAll(radioButton1, radioButton2);
final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, hBox, top);
return new Tuple3<>(topLabelWithVBox.first, radioButton1, radioButton2);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Label + TextField + RadioButton + RadioButton
///////////////////////////////////////////////////////////////////////////////////////////
public static Tuple4<Label, TextField, RadioButton, RadioButton> addTopLabelTextFieldRadioButtonRadioButton(GridPane gridPane,
int rowIndex,
ToggleGroup toggleGroup,
String title,
String textFieldTitle,
String radioButtonTitle1,
String radioButtonTitle2,
double top) {
TextField textField = new BisqTextField();
textField.setPromptText(textFieldTitle);
RadioButton radioButton1 = new AutoTooltipRadioButton(radioButtonTitle1);
radioButton1.setToggleGroup(toggleGroup);
radioButton1.setPadding(new Insets(6, 0, 0, 0));
RadioButton radioButton2 = new AutoTooltipRadioButton(radioButtonTitle2);
radioButton2.setToggleGroup(toggleGroup);
radioButton2.setPadding(new Insets(6, 0, 0, 0));
HBox hBox = new HBox();
hBox.setSpacing(10);
hBox.getChildren().addAll(textField, radioButton1, radioButton2);
final Tuple2<Label, VBox> labelVBoxTuple2 = addTopLabelWithVBox(gridPane, rowIndex, title, hBox, top);
return new Tuple4<>(labelVBoxTuple2.first, textField, radioButton1, radioButton2);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Label + CheckBox
///////////////////////////////////////////////////////////////////////////////////////////
public static CheckBox addLabelCheckBox(GridPane gridPane, int rowIndex, String title) {
return addLabelCheckBox(gridPane, rowIndex, title, 0);
}