-
Notifications
You must be signed in to change notification settings - Fork 5
/
RootTagImpl.java
71 lines (56 loc) · 1.87 KB
/
RootTagImpl.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
package org.genericsystem.reactor.gscomponents;
import org.genericsystem.reactor.modelproperties.SelectionDefaults;
import org.genericsystem.reactor.modelproperties.UserRoleDefaults;
import java.lang.annotation.Annotation;
import org.genericsystem.reactor.AnnotationsManager;
import org.genericsystem.reactor.RootTag;
import org.genericsystem.reactor.Tag;
import org.genericsystem.reactor.TagNode;
import org.genericsystem.reactor.annotations.CustomAnnotations;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
public class RootTagImpl extends FlexDiv implements RootTag, SelectionDefaults, UserRoleDefaults {
private AnnotationsManager annotationsManager;
public RootTagImpl() {
createSelectionProperty();
createLoggedUserProperty();
createAdminModeProperty();
annotationsManager = new AnnotationsManager();
Annotation annotations = getClass().getAnnotation(CustomAnnotations.class);
if (annotations != null)
for (Class<? extends Annotation> annotation : ((CustomAnnotations) annotations).value())
annotationsManager.registerAnnotation(annotation);
initRoot();
}
protected void initRoot() {
setTagNode(buildTagNode(this));
processAnnotations(this);
init();
}
@Override
public AnnotationsManager getAnnotationsManager() {
return annotationsManager;
}
public static class SimpleTableNode implements TagNode {
private final ObservableList<Tag> children = FXCollections.observableArrayList();
@Override
public ObservableList<Tag> getObservableChildren() {
return children;
}
}
@Override
public TagNode buildTagNode(Tag child) {
Tag parent = child.getParent();
if (parent != null)
parent.getObservableChildren().add(child);
return new SimpleTableNode();
}
@Override
public final <COMPONENT extends Tag> COMPONENT getParent() {
return null;
}
@Override
public RootTag getRootTag() {
return this;
}
}