Skip to content

Commit

Permalink
Change ChildForEach
Browse files Browse the repository at this point in the history
  • Loading branch information
nfeybesse committed Sep 23, 2016
1 parent a07fde5 commit 6c6be70
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,22 @@ public static void main(String[] mainArgs) {

@org.genericsystem.reactor.annotations.Style.BackgroundColor("Green")
@org.genericsystem.reactor.annotations.DirectSelect(Car.class)
@org.genericsystem.reactor.annotations.ForEach.ChildForEach(ObservableListExtractor.SUBINSTANCES.class)
@org.genericsystem.reactor.annotations.ForEach.ChildForEach(decorate = GSContentComponent.class, forEach = ObservableListExtractor.SUBINSTANCES.class)
public static class GSInstancesComposite extends org.genericsystem.reactor.gs3.GSComposite {

}

@BackgroundColor("Blue")
@FlexDirection("row")
@DirectSelect(Car.class)
@ChildForEach(ObservableListExtractor.SUBINSTANCES.class)
@ChildForEach(decorate = GSContentComponent.class, forEach = ObservableListExtractor.SUBINSTANCES.class)
public static class GSRowInstancesComposite extends GSComposite {

}

@BackgroundColor("Red")
@DirectSelect(Car.class)
@ChildForEach(ObservableListExtractor.ATTRIBUTES_OF_TYPE.class)
@ChildForEach(decorate = GSContentComponent.class, forEach = ObservableListExtractor.ATTRIBUTES_OF_TYPE.class)
@ReactorDependencies({ GSHeaderComponent.class, GSContentComponent.class })
public static class GSTypeAttributes extends GSComposite {

Expand All @@ -95,7 +95,7 @@ public static class GSTypeAttributes extends GSComposite {
@Style.Color("White")
@DirectSelect(Car.class)
@FlexDirection("row")
@ChildForEach(ObservableListExtractor.ATTRIBUTES_OF_TYPE.class)
@ChildForEach(decorate = GSContentComponent.class, forEach = ObservableListExtractor.ATTRIBUTES_OF_TYPE.class)
@ChildFlexDirection("row")
@ReactorDependencies({ GSHeaderComponent.class, GSContentComponent.class })
public static class GSTypeAttributesRow extends GSComposite {
Expand All @@ -105,22 +105,22 @@ public static class GSTypeAttributesRow extends GSComposite {
@org.genericsystem.reactor.annotations.Style.BackgroundColor("Orange")
@org.genericsystem.reactor.annotations.Style.FlexDirection("row")
@org.genericsystem.reactor.annotations.Style.ChildFlexDirection("row")
@org.genericsystem.reactor.annotations.ForEach.ChildForEach(ObservableListExtractor.ATTRIBUTES_OF_INSTANCES.class)
@org.genericsystem.reactor.annotations.ForEach.ChildForEach(decorate = GSContentComponent.class, forEach = ObservableListExtractor.ATTRIBUTES_OF_INSTANCES.class)
@org.genericsystem.reactor.annotations.ReactorDependencies({ GSHeaderComponent.class, GSContentComponent.class })
public static class GSInstanceAttributesRow extends org.genericsystem.reactor.gs3.GSComposite {

}

@org.genericsystem.reactor.annotations.Style.BackgroundColor("Brown")
@org.genericsystem.reactor.annotations.ForEach.ChildForEach(ObservableListExtractor.HOLDERS.class)
@org.genericsystem.reactor.annotations.ForEach.ChildForEach(decorate = GSContentComponent.class, forEach = ObservableListExtractor.HOLDERS.class)
@org.genericsystem.reactor.annotations.ReactorDependencies({ GSContentComponent.class })
public static class GSHolders extends org.genericsystem.reactor.gs3.GSComposite {

}

@BackgroundColor("Pink")
@FlexDirection("row")
@ChildForEach(ObservableListExtractor.COMPONENTS.class)
@ChildForEach(decorate = GSContentComponent.class, forEach = ObservableListExtractor.COMPONENTS.class)
@ReactorDependencies({ GSHeaderComponent.class, GSContentComponent.class })
public static class GSValueComponents extends GSComposite {

Expand Down Expand Up @@ -196,7 +196,7 @@ public static class GSInstanceAttributesRow_ extends GSInstanceAttributesRow {
public static class Unit {
}

@org.genericsystem.reactor.annotations.DirectSelect(Power.class)
@org.genericsystem.reactor.annotations.DirectSelect(Car.class)
@org.genericsystem.reactor.annotations.ReactorDependencies({ GSHeaderComponent_.class, GSInstanceContentComponent__.class })
public static class GSTypeTableInstancesComposite extends GSTypeLabeledInstancesComposite {
@org.genericsystem.reactor.annotations.ReactorDependencies({ GSInstanceAttributesRow__.class })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
@Target({ ElementType.TYPE })
@Inherited
public @interface ParentForEach {
int pos() default 0;

}

@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE })
@Inherited
public @interface ChildForEach {
Class<? extends Supplier<ObservableListExtractor>>[] value();
Class<?> decorate();

Class<? extends Supplier<ObservableListExtractor>> forEach();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,18 @@ public GSTagImpl get(Object key) {

public CompositeTagImpl() {
super();
nodes.put(getClass(), this);
ReactorDependencies deps = getClass().getAnnotation(ReactorDependencies.class);
if (deps != null) {
System.out.println("Declaring classes : " + Arrays.toString(getClass().getDeclaredClasses()));
System.out.println("ReactorDependencies : " + Arrays.toString(deps.value()));
for (Class<? extends GSTagImpl> clazz : deps.value())
find(clazz);
}
for (Tag tag : nodes.values())
tag.postfix();
initComposite();
}

public CompositeTagImpl(Tag parent) {
super(parent);
init();
style();
initComposite();
processAnnotations(getClass(), this);
}

private void initComposite() {
nodes.put(getClass(), this);
ReactorDependencies deps = getClass().getAnnotation(ReactorDependencies.class);
if (deps != null) {
Expand Down Expand Up @@ -121,16 +117,17 @@ private static void processAnnotations(Class<? extends GSTagImpl> tagClass, Tag
}
}
} else {

ChildForEach childForEach = result.getParent().getClass().getAnnotation(ChildForEach.class);
if (childForEach != null) {
try {
result.forEach(childForEach.value()[parentForEach.pos()].newInstance().get());
if (childForEach.decorate().isAssignableFrom(result.getClass()))
result.forEach(childForEach.forEach().newInstance().get());
} catch (InstantiationException | IllegalAccessException e) {
throw new IllegalStateException(e);
}
} else
System.out.println("Warning : unable to find childForEach on : " + result.getParent().getClass().getSimpleName() + " for : " + tagClass.getSimpleName());

}

Select select = tagClass.getAnnotation(Select.class);
Expand Down

0 comments on commit 6c6be70

Please sign in to comment.