1 package org.simantics.g3d.property;
\r
3 import java.util.Collections;
\r
4 import java.util.List;
\r
6 import org.simantics.g3d.property.annotations.PropertyContributor;
\r
8 public class PropertyTabUtil {
\r
11 @SuppressWarnings("unchecked")
\r
12 public static List<PropertyTabContributor> getContributors(Object input) {
\r
13 PropertyTabContributorFactory factory = resolveFactory(input.getClass());
\r
14 if (factory == null)
\r
15 return Collections.EMPTY_LIST;
\r
16 return factory.getContributors(input);
\r
19 private static PropertyTabContributorFactory resolveFactory(Class<?> clazz) {
\r
20 PropertyContributor contributor = clazz.getAnnotation(PropertyContributor.class);
\r
21 if (contributor != null)
\r
23 return contributor.value().newInstance();
\r
24 } catch (InstantiationException e) {
\r
25 e.printStackTrace();
\r
26 } catch (IllegalAccessException e) {
\r
27 e.printStackTrace();
\r
29 Class<?> superClass = clazz.getSuperclass();
\r
30 if (superClass != null)
\r
31 return resolveFactory(superClass);
\r