-
Notifications
You must be signed in to change notification settings - Fork 5
/
GSLinks.java
595 lines (505 loc) · 21.8 KB
/
GSLinks.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
package org.genericsystem.reactor.gs;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import org.genericsystem.api.core.exceptions.RollbackException;
import org.genericsystem.common.Generic;
import org.genericsystem.reactor.Model;
import org.genericsystem.reactor.ReactorStatics;
import org.genericsystem.reactor.Tag;
import org.genericsystem.reactor.gs.GSCheckBoxWithValue.GSCheckBoxDisplayer;
import org.genericsystem.reactor.gs.GSCheckBoxWithValue.GSCheckBoxEditor;
import org.genericsystem.reactor.gs.GSInputTextWithConversion.GSInputTextCreatorWithConversion;
import org.genericsystem.reactor.gs.GSInputTextWithConversion.GSInputTextEditorWithConversion;
import org.genericsystem.reactor.gs.GSSelect.CompositeSelectWithEmptyEntry;
import org.genericsystem.reactor.gs.GSSelect.InstanceCompositeSelect;
import org.genericsystem.reactor.gstag.GSButton;
import org.genericsystem.reactor.gstag.GSCheckBox;
import org.genericsystem.reactor.gstag.GSLabel.GSLabelDisplayer;
import org.genericsystem.reactor.model.GenericModel;
import org.genericsystem.reactor.model.ObservableListExtractor;
import org.genericsystem.reactor.model.StringExtractor;
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
import javafx.beans.binding.Bindings;
import javafx.beans.property.Property;
import javafx.beans.value.ObservableValue;
public class GSLinks {
static final Logger log = LoggerFactory.getLogger(Tag.class);
public static class GSCellDisplayer extends GSSection {
protected final GSTagConstructor holderDisplayerConstructor;
protected final GSTagConstructor booleanHolderDisplayerConstructor;
protected final GSTagConstructor linkDisplayerConstructor;
private final boolean needMeta;
public GSCellDisplayer(GSTag parent, GSTagConstructor holderDisplayerConstructor, GSTagConstructor booleanHolderDisplayerConstructor, GSTagConstructor linkDisplayerConstructor) {
this(parent, FlexDirection.ROW, holderDisplayerConstructor, booleanHolderDisplayerConstructor, linkDisplayerConstructor);
}
public GSCellDisplayer(GSTag parent, FlexDirection direction, GSTagConstructor holderDisplayerConstructor, GSTagConstructor booleanHolderDisplayerConstructor, GSTagConstructor linkDisplayerConstructor) {
this(parent, direction, holderDisplayerConstructor, booleanHolderDisplayerConstructor, linkDisplayerConstructor, true);
}
public GSCellDisplayer(GSTag parent, FlexDirection direction, GSTagConstructor holderDisplayerConstructor, GSTagConstructor booleanHolderDisplayerConstructor, GSTagConstructor linkDisplayerConstructor, boolean needMeta) {
super(parent, direction);
this.holderDisplayerConstructor = holderDisplayerConstructor;
this.booleanHolderDisplayerConstructor = booleanHolderDisplayerConstructor;
this.linkDisplayerConstructor = linkDisplayerConstructor;
this.needMeta = needMeta;
addStyle("flex", "1");
addStyle("overflow", "hidden");
content();
}
public void content() {
new GSSection(this, this.getDirection()) {
{
style(this);
if (needMeta)
select(gs -> gs[0].getComponents().size() < 2 && !Boolean.class.equals(gs[0].getMeta().getInstanceValueClassConstraint()) ? gs[0] : null);
else
select(gs -> gs[0].getComponents().size() < 2 && !Boolean.class.equals(gs[0].getInstanceValueClassConstraint()) ? gs[0] : null);
holderDisplayerConstructor.build(this);
}
};
new GSSection(this, this.getDirection()) {
{
style(this);
if (needMeta)
select(gs -> gs[0].getComponents().size() < 2 && Boolean.class.equals(gs[0].getMeta().getInstanceValueClassConstraint()) ? gs[0] : null);
else
select(gs -> gs[0].getComponents().size() < 2 && Boolean.class.equals(gs[0].getInstanceValueClassConstraint()) ? gs[0] : null);
booleanHolderDisplayerConstructor.build(this);
}
};
new GSSection(this, this.getDirection()) {
{
addStyle("flex", "1");
select(gs -> gs[0].getComponents().size() >= 2 ? gs[0] : null);
GSTag components = linkDisplayerConstructor.build(this);
style(components);
}
};
}
public void style(Tag<?> tag) {
tag.addStyle("justify-content", "center");
tag.addStyle("align-items", "center");
tag.addStyle("flex", "1");
tag.addStyle("margin-right", "1px");
tag.addStyle("margin-bottom", "1px");
tag.addStyle("overflow", "hidden");
}
}
public static class GSCellEditor extends GSCellDisplayer {
public GSCellEditor(GSTag parent, GSTagConstructor holderEditorConstructor, GSTagConstructor booleanHolderEditorConstructor, GSTagConstructor linkEditorConstructor) {
this(parent, FlexDirection.ROW, holderEditorConstructor, booleanHolderEditorConstructor, linkEditorConstructor);
}
public GSCellEditor(GSTag parent, FlexDirection direction, GSTagConstructor holderEditorConstructor, GSTagConstructor booleanHolderEditorConstructor, GSTagConstructor linkEditorConstructor) {
super(parent, direction, holderEditorConstructor, booleanHolderEditorConstructor, linkEditorConstructor, false);
}
@Override
public void style(Tag<?> tag) {
super.style(tag);
tag.addStyle("color", "#ffffff");
tag.addStyle("background-color", "#dda5e2");
}
}
public static class GSSingleLinkComponentDisplayer extends GSSection {
public GSSingleLinkComponentDisplayer(GSTag parent) {
super(parent, FlexDirection.ROW);
GSTag label = new GSLabelDisplayer(this);
}
}
public static class GSLinkComponentsDisplayer extends GSSingleLinkComponentDisplayer {
public GSLinkComponentsDisplayer(GSTag parent) {
super(parent);
// TODO: filter only once.
forEach(StringExtractor.SIMPLE_CLASS_EXTRACTOR, gs -> ObservableListExtractor.COMPONENTS.apply(gs).filtered(g -> !g.equals(gs[3])));
}
}
public static class GSLinkComponentsTitleDisplayer extends GSSingleLinkComponentDisplayer {
public GSLinkComponentsTitleDisplayer(GSTag parent) {
super(parent);
forEach(StringExtractor.SIMPLE_CLASS_EXTRACTOR, gs -> ObservableListExtractor.COMPONENTS.apply(gs).filtered(g -> !g.equals(gs[2])));
}
}
public static class GSInstanceLinkComponentsTitleDisplayer extends GSSingleLinkComponentDisplayer {
public GSInstanceLinkComponentsTitleDisplayer(GSTag parent) {
super(parent);
forEach(StringExtractor.SIMPLE_CLASS_EXTRACTOR, gs -> ObservableListExtractor.COMPONENTS.apply(gs).filtered(g -> !g.equals(gs[2].getMeta())));
}
}
public static class GSInstanceCellDisplayer extends GSCellDisplayer {
public GSInstanceCellDisplayer(GSTag parent) {
super(parent, GSLabelDisplayer::new, GSCheckBoxDisplayer::new, GSLinkComponentsDisplayer::new);
}
@Override
public void style(Tag<?> tag) {
super.style(tag);
tag.addPrefixBinding(modelContext -> ((Model) modelContext).getObservableStyles(tag).put("background-color",
"Color".equals(StringExtractor.SIMPLE_CLASS_EXTRACTOR.apply(((GenericModel) modelContext).getGeneric().getMeta())) ? ((GenericModel) modelContext).getString().getValue() : "#dda5e2"));
}
}
public static class LinkTitleDisplayer extends GSCellDisplayer {
public LinkTitleDisplayer(GSTag parent) {
this(parent, GSLabelDisplayer::new, GSCheckBoxDisplayer::new, GSLinkComponentsTitleDisplayer::new);
}
public LinkTitleDisplayer(GSTag parent, GSTagConstructor holderDisplayerConstructor, GSTagConstructor booleanHolderDisplayerConstructor, GSTagConstructor linkDisplayerConstructor) {
super(parent, FlexDirection.ROW, holderDisplayerConstructor, booleanHolderDisplayerConstructor, linkDisplayerConstructor);
}
@Override
public void style(Tag<?> tag) {
super.style(tag);
tag.addStyle("color", "#ffffff");
tag.addStyle("background-color", "#ffa5a5");
}
}
public static class InstanceLinkTitleDisplayer extends LinkTitleDisplayer {
public InstanceLinkTitleDisplayer(GSTag parent) {
super(parent, GSLabelDisplayer::new, GSCheckBoxDisplayer::new, GSInstanceLinkComponentsTitleDisplayer::new);
}
}
@FunctionalInterface
public interface GSTagConstructor {
GSTag build(GSTag parent);
}
public static class GSAttributeCreator extends GSCellEditor {
public GSAttributeCreator(GSTag parent, FlexDirection direction) {
super(parent, direction, GSHolderCreator::new, GSBooleanHolderCreator::new, GSLinkCreator::new);
}
@Override
public void style(Tag<?> tag) {
tag.addStyle("flex", "1");
tag.addStyle("color", "#ffffff");
tag.addStyle("background-color", "#dda5a5");
tag.addStyle("margin-right", "1px");
tag.addStyle("margin-bottom", "1px");
tag.addStyle("overflow", "hidden");
}
}
@FunctionalInterface
public interface GSInputTextConstructor {
GSInputTextWithConversion build(GSTag parent);
}
public static class GSHolderEditor extends GSSection {
protected GSInputTextWithConversion input;
public GSHolderEditor(GSTag parent) {
this(parent, GSInputTextEditorWithConversion::new);
}
public GSHolderEditor(GSTag parent, GSInputTextConstructor constructor) {
super(parent, FlexDirection.ROW);
addStyle("flex", "1");
addStyle("width", "100%");
addStyle("height", "100%");
input = constructor.build(this);
}
}
public static class GSHolderEditorWithRemoval extends GSHolderEditor {
public GSHolderEditorWithRemoval(GSTag parent) {
super(parent);
new GSButton(this) {
{
addStyle("justify-content", "center");
addStyle("align-items", "center");
setText("×");
bindAction(GenericModel::remove);
}
};
}
}
public static class GSHolderAdder extends GSHolderEditor {
public GSHolderAdder(GSTag parent) {
super(parent, GSInputTextWithConversion::new);
new GSButton(this) {
{
addStyle("justify-content", "center");
addStyle("align-items", "center");
setText("+");
bindAction(model -> {
Property<Serializable> observable = input.getProperty(ReactorStatics.VALUE, model);
if (observable.getValue() != null) {
model.getGenerics()[3].addHolder(model.getGenerics()[2], observable.getValue());
observable.setValue(null);
}
});
}
};
}
}
public static class GSHolderCreator extends GSHolderEditor {
public GSHolderCreator(GSTag parent) {
super(parent, GSInputTextCreatorWithConversion::new);
if (parent != null && parent.getParent() != null && parent.getParent().getParent() instanceof GSInstanceCreator) {
input.addPrefixBinding(model -> ((GSInstanceCreator) parent.getParent().getParent()).getHoldersValues().put(model.getGeneric(), model.getProperty(input, ReactorStatics.VALUE)));
input.addPrefixBinding(model -> ((GSInstanceCreator) parent.getParent().getParent()).getPropertiesInvalid().add(model.getObservableValue(input, ReactorStatics.INVALID)));
}
}
}
@FunctionalInterface
public interface GSCheckBoxConstructor {
GSCheckBox build(GSTag parent);
}
public static class GSBooleanHolderEditor extends GSSection {
protected GSCheckBox checkbox;
public GSBooleanHolderEditor(GSTag parent) {
this(parent, GSCheckBoxEditor::new);
}
public GSBooleanHolderEditor(GSTag parent, GSCheckBoxConstructor constructor) {
super(parent, FlexDirection.ROW);
addStyle("flex", "1");
addStyle("width", "100%");
addStyle("height", "100%");
new GSSection(this, FlexDirection.ROW) {
{
addStyle("justify-content", "center");
addStyle("align-items", "center");
addStyle("width", "100%");
addStyle("height", "100%");
checkbox = constructor.build(this);
}
};
}
}
public static class GSBooleanHolderEditorWithRemoval extends GSBooleanHolderEditor {
public GSBooleanHolderEditorWithRemoval(GSTag parent) {
super(parent);
new GSButton(this) {
{
addStyle("justify-content", "center");
addStyle("align-items", "center");
setText("×");
bindAction(GenericModel::remove);
}
};
}
}
public static class GSBooleanHolderAdder extends GSBooleanHolderEditor {
public GSBooleanHolderAdder(GSTag parent) {
super(parent, GSCheckBoxWithValue::new);
new GSButton(this) {
{
addStyle("justify-content", "center");
addStyle("align-items", "center");
setText("+");
bindAction(model -> {
Property<Serializable> observable = checkbox.getProperty(ReactorStatics.VALUE, model);
model.getGenerics()[3].addHolder(model.getGenerics()[2], observable.getValue());
observable.setValue(null);
});
}
};
}
}
public static class GSBooleanHolderCreator extends GSBooleanHolderEditor {
public GSBooleanHolderCreator(GSTag parent) {
super(parent, GSCheckBoxWithValue::new);
if (parent != null && parent.getParent() != null && parent.getParent().getParent() instanceof GSInstanceCreator)
checkbox.addPrefixBinding(model -> ((GSInstanceCreator) parent.getParent().getParent()).getHoldersValues().put(model.getGeneric(), model.getProperty(checkbox, ReactorStatics.VALUE)));
}
}
@FunctionalInterface
public interface GSLinkComponentConstructor {
GSLinkComponentSelector build(GSTag parent);
}
public static class GSLinkEditor extends GSSection {
protected GSLinkComponentSelector components;
public GSLinkEditor(GSTag parent) {
this(parent, GSLinkComponentEditor::new);
}
public GSLinkEditor(GSTag parent, GSLinkComponentConstructor constructor) {
super(parent, FlexDirection.ROW);
createNewProperty(ReactorStatics.COMPONENTS);
components = constructor.build(this);
}
}
public static class GSLinkEditorWithRemoval extends GSLinkEditor {
public GSLinkEditorWithRemoval(GSTag parent) {
super(parent);
new GSButton(this) {
{
addStyle("justify-content", "center");
addStyle("align-items", "center");
addStyle("height", "100%");
setText("×");
bindAction(GenericModel::remove);
}
};
}
}
public static class GSLinkCreator extends GSLinkEditor {
public GSLinkCreator(GSTag parent) {
this(parent, GSLinkComponentCreator::new);
}
public GSLinkCreator(GSTag parent, GSLinkComponentConstructor constructor) {
super(parent, constructor);
if (parent != null && parent.getParent() != null && parent.getParent().getParent() instanceof GSInstanceCreator)
addPostfixBinding(model -> ((GSInstanceCreator) parent.getParent().getParent()).getLinksValues().put(model.getGeneric(), (List<Property<GenericModel>>) getProperty(ReactorStatics.COMPONENTS, model).getValue()));
}
}
public static class GSLinkAdder extends GSLinkCreator {
public GSLinkAdder(GSTag parent) {
super(parent, GSLinkComponentAdder::new);
new GSButton(this) {
{
addStyle("justify-content", "center");
addStyle("align-items", "center");
addStyle("height", "100%");
setText("+");
bindAttribute(ReactorStatics.DISABLED, ReactorStatics.DISABLED, model -> Bindings.createStringBinding(() -> {
List<Generic> selectedGenerics = ((List<Property<GenericModel>>) getProperty(ReactorStatics.COMPONENTS, model).getValue()).stream().filter(obs -> obs.getValue() != null).map(obs -> obs.getValue().getGeneric())
.filter(gen -> gen != null).collect(Collectors.toList());
return selectedGenerics.size() + 1 != model.getGeneric().getComponents().size() ? ReactorStatics.DISABLED : "";
}, ((List<Property<GenericModel>>) getProperty(ReactorStatics.COMPONENTS, model).getValue()).stream().toArray(Property[]::new)));
bindAction(model -> {
try {
List<Property<GenericModel>> selectedComponents = (List<Property<GenericModel>>) getProperty(ReactorStatics.COMPONENTS, model).getValue();
List<Generic> selectedGenerics = selectedComponents.stream().filter(obs -> obs.getValue() != null).map(obs -> obs.getValue().getGeneric()).filter(gen -> gen != null).collect(Collectors.toList());
model.getGenerics()[3].setHolder(model.getGeneric(), null, selectedGenerics.stream().toArray(Generic[]::new));
selectedComponents.stream().forEach(sel -> sel.setValue(null));
} catch (RollbackException e) {
e.printStackTrace();
}
});
}
};
}
}
@FunctionalInterface
public interface GSSelectConstructor {
GSSelect build(GSTag parent);
}
public static class GSLinkComponentSelector extends GSSection {
protected GSSelect select;
public GSLinkComponentSelector(GSTag parent) {
this(parent, InstanceCompositeSelect::new);
}
public GSLinkComponentSelector(GSTag parent, GSSelectConstructor constructor) {
super(parent, FlexDirection.ROW);
addStyle("flex", "1");
addStyle("width", "100%");
addStyle("height", "100%");
addStyle("justify-content", "center");
addStyle("align-items", "center");
select = constructor.build(this);
select.select(gs -> gs[1].isReferentialIntegrityEnabled(pos(gs[1], gs[0])) ? gs[0] : null);
select.addPostfixBinding(model -> {
if ("Color".equals(StringExtractor.SIMPLE_CLASS_EXTRACTOR.apply(model.getGeneric().getMeta())))
model.getObservableStyles(select).put("background-color", (String) model.getObservableValue(select, ReactorStatics.SELECTION_STRING).getValue());
});
select.optionElement.addPrefixBinding(model -> {
if ("Color".equals(StringExtractor.SIMPLE_CLASS_EXTRACTOR.apply(model.getGeneric().getMeta())))
model.getObservableStyles(select.optionElement).put("background-color", model.getString().getValue());
});
select.addStyle("width", "100%");
select.addStyle("height", "100%");
select.addPostfixBinding(model -> {
Property selectedComponents = getProperty(ReactorStatics.COMPONENTS, model.getParent());
if (selectedComponents != null) {
if (selectedComponents.getValue() == null)
selectedComponents.setValue(new ArrayList<Property<GenericModel>>());
((List<Property<GenericModel>>) selectedComponents.getValue()).add(model.getProperty(select, ReactorStatics.SELECTION));
}
});
new GSLabelDisplayer(this) {
{
select(gs -> !gs[1].isReferentialIntegrityEnabled(pos(gs[1], gs[0])) ? gs[0] : null);
}
};
}
}
public static class GSLinkComponentEditor extends GSLinkComponentSelector {
public GSLinkComponentEditor(GSTag parent) {
super(parent);
forEach(StringExtractor.SIMPLE_CLASS_EXTRACTOR, gs -> ObservableListExtractor.COMPONENTS.apply(gs).filtered(g -> !g.equals(gs[3])));
}
}
public static class GSLinkComponentAdder extends GSLinkComponentSelector {
public GSLinkComponentAdder(GSTag parent) {
super(parent, CompositeSelectWithEmptyEntry::new);
forEach(StringExtractor.SIMPLE_CLASS_EXTRACTOR, gs -> ObservableListExtractor.COMPONENTS.apply(gs).filtered(g -> !g.equals(gs[4])));
}
}
public static class GSLinkComponentCreator extends GSLinkComponentSelector {
public GSLinkComponentCreator(GSTag parent) {
super(parent, CompositeSelectWithEmptyEntry::new);
forEach(StringExtractor.SIMPLE_CLASS_EXTRACTOR, gs -> ObservableListExtractor.COMPONENTS.apply(gs).filtered(g -> !g.equals(gs[2])));
}
}
public static class GSInstanceCreator extends GSComposite {
private Property<Serializable> newInstanceValue;
private final Map<Generic, Property<Serializable>> holdersValues = new HashMap<>();
private final Map<Generic, List<Property<GenericModel>>> componentsValues = new HashMap<>();
private final List<ObservableValue> propertiesInvalid = new ArrayList<>();
public GSInstanceCreator(GSTag parent, FlexDirection flexDirection) {
super(parent, flexDirection);
}
public Map<Generic, Property<Serializable>> getHoldersValues() {
return holdersValues;
}
public Map<Generic, List<Property<GenericModel>>> getLinksValues() {
return componentsValues;
}
public List<ObservableValue> getPropertiesInvalid() {
return propertiesInvalid;
}
@Override
protected void header() {
new GSHolderCreator(this) {
{
input.addPrefixBinding(model -> newInstanceValue = model.getProperty(input, ReactorStatics.VALUE));
}
};
}
@Override
protected void sections() {
new GSAttributeCreator(this, FlexDirection.ROW) {
{
forEach(StringExtractor.SIMPLE_CLASS_EXTRACTOR, ObservableListExtractor.ATTRIBUTES_OF_TYPE);
}
};
}
@Override
protected void footer() {
new GSSection(this, this.getDirection()) {
{
if (this.getDirection().equals(FlexDirection.ROW)) {
addStyle("flex", "0");
addStyle("min-width", "100px");
} else {
addStyle("flex", "1");
}
addStyle("background-color", "#dda5a5");
addStyle("margin-right", "1px");
addStyle("margin-bottom", "1px");
new GSButton(this) {
{
bindAttribute(ReactorStatics.DISABLED, ReactorStatics.DISABLED, model -> {
ObservableValue<Boolean> invalid = Bindings.createBooleanBinding(() -> propertiesInvalid.stream().map(input -> (Boolean) input.getValue()).filter(bool -> bool != null).reduce(false, (a, b) -> a || b),
propertiesInvalid.stream().toArray(ObservableValue[]::new));
return Bindings.createStringBinding(() -> Boolean.TRUE.equals(invalid.getValue()) ? ReactorStatics.DISABLED : "", invalid);
});
bindAction(model -> {
Generic newInstance = model.getGeneric().setInstance(newInstanceValue.getValue());
for (Entry<Generic, Property<Serializable>> entry : holdersValues.entrySet())
if (entry.getValue().getValue() != null) {
newInstance.setHolder(entry.getKey(), entry.getValue().getValue());
entry.getValue().setValue(null);
}
for (Entry<Generic, List<Property<GenericModel>>> entry : componentsValues.entrySet()) {
List<Generic> selectedGenerics = entry.getValue().stream().filter(obs -> obs.getValue() != null).map(obs -> obs.getValue().getGeneric()).filter(gen -> gen != null).collect(Collectors.toList());
if (!selectedGenerics.isEmpty() && selectedGenerics.size() + 1 == entry.getKey().getComponents().size())
newInstance.setHolder(entry.getKey(), null, selectedGenerics.stream().toArray(Generic[]::new));
entry.getValue().stream().forEach(sel -> sel.setValue(null));
}
newInstanceValue.setValue(null);
});
setText("Add");
addStyle("width", "100%");
addStyle("height", "100%");
}
};
}
};
}
}
}