-
Notifications
You must be signed in to change notification settings - Fork 5
/
ExtendedRootTag.java
109 lines (89 loc) · 3.04 KB
/
ExtendedRootTag.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
package org.genericsystem.reactor.gscomponents;
import org.genericsystem.api.core.annotations.Components;
import org.genericsystem.api.core.annotations.InstanceClass;
import org.genericsystem.api.core.annotations.Meta;
import org.genericsystem.api.core.annotations.SystemGeneric;
import org.genericsystem.api.core.annotations.constraints.InstanceValueClassConstraint;
import org.genericsystem.common.Generic;
import org.genericsystem.defaults.tools.TransformationObservableList;
import org.genericsystem.reactor.Tag;
import org.genericsystem.reactor.TagNode;
import org.genericsystem.reactor.gscomponents.ExtendedRootTag.GTagType.GTagName;
import javafx.collections.ObservableList;
public class ExtendedRootTag extends RootTagImpl {
public class GenericTagNode implements TagNode {
private ObservableList<Tag> children;
private GTag delegate;
private Tag parent;
public GenericTagNode(Tag parent) {
this.parent = parent;
this.children = new TransformationObservableList<GTag, Tag>((ObservableList) delegate.getObservableInheritings(), (i, gtag) -> {
TagImpl result = null;
try {
result = ((Class<? extends TagImpl>) gtag.getValue()).newInstance();
} catch (IllegalAccessException | InstantiationException e) {
throw new IllegalStateException(e);
}
result.setParent(ExtendedRootTag.this);
result.getRootTag().getAnnotationsManager().processAnnotations(result);
result.init();
return result;
}, tag -> {
// nothing to do here
}) {
@Override
public boolean add(Tag child) {
Generic genericChild = delegate.getMeta().setInstance(delegate, child.getClass());// Aie! , marchera pas, comment distinguer les signatures des generics ???
genericChild.setHolder(delegate.getRoot().find(GTagName.class), child.getTag());
return true;
};
};
}
Class<? extends TagImpl> getClazz() {
return (Class<? extends TagImpl>) delegate.getValue();
}
@SuppressWarnings("unchecked")
@Override
public <COMPONENT extends Tag> COMPONENT getParent() {
return (COMPONENT) parent;
}
@Override
public ObservableList<Tag> getObservableChildren() {
return children;
}
public void setDelegateGeneric(GTag delegate) {
this.delegate = delegate;
}
public GTag getDelegateGeneric() {
return delegate;
}
}
@Override
public TagNode buildTagNode(Tag parent) {
return new GenericTagNode(parent);
}
@SystemGeneric
@InstanceClass(GTag.class)
@InstanceValueClassConstraint(Class.class)
public static interface GTagType extends Generic {
@SystemGeneric
@Components(GTagType.class)
@InstanceValueClassConstraint(String.class)
public static interface GTagName extends Generic {
}
@SystemGeneric
@Components(GTagType.class)
@InstanceValueClassConstraint(String.class)
public static interface GTagStyleType extends Generic {
}
@SystemGeneric
@Components(GTagStyleType.class)
@InstanceValueClassConstraint(String.class)
public static interface StyleValue extends Generic {
}
}
@SystemGeneric
@Meta(GTagType.class)
public static interface GTag extends Generic {
}
}