use of com.twinsoft.convertigo.beans.mobile.components.UIComponent in project convertigo by convertigo.
the class ComponentManager method makeComponents.
private synchronized List<Component> makeComponents() {
if (components != null) {
return components;
}
components = new ArrayList<Component>(10);
try {
String group;
// Add Customs
group = GROUP_CUSTOMS;
components.add(getDboComponent(UIElement.class, group));
components.add(getDboComponent(UIAttribute.class, group));
components.add(getDboComponent(UIAnimation.class, group));
components.add(getDboComponent(UICustom.class, group));
components.add(getDboComponent(UIText.class, group));
components.add(getDboComponent(UIStyle.class, group));
components.add(getDboComponent(UITheme.class, group));
// Add shared components
group = GROUP_SHARED_COMPONENTS;
components.add(getDboComponent(UISharedComponent.class, group));
components.add(getDboComponent(UIUseShared.class, group));
components.add(getDboComponent(UICompVariable.class, group));
// Add shared actions
group = GROUP_SHARED_ACTIONS;
components.add(getDboComponent(UIActionStack.class, group));
components.add(getDboComponent(UIStackVariable.class, group));
// Add Controls
group = GROUP_CONTROLS;
components.add(getDboComponent(UIControlEvent.class, group));
components.add(getDboComponent(UIAppEvent.class, group));
components.add(getDboComponent(UIPageEvent.class, group));
components.add(getDboComponent(UIEventSubscriber.class, group));
components.add(getDboComponent(UIActionErrorEvent.class, group));
components.add(getDboComponent(UIActionFailureEvent.class, group));
components.add(getDboComponent(UIActionFinallyEvent.class, group));
components.add(getDboComponent(UIActionLoopEvent.class, group));
components.add(getDboComponent(UIActionElseEvent.class, group));
components.add(getDboComponent(UIControlDirective.class, group));
// Add Actions
group = GROUP_ACTIONS;
components.add(getDboComponent(UIControlVariable.class, group));
components.add(getDboComponent(UICustomAction.class, group));
components.add(getDboComponent(UIForm.class, "Forms"));
components.add(getDboComponent(UIFormControlValidator.class, "Forms"));
components.add(getDboComponent(UIFormCustomValidator.class, "Forms"));
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
for (final IonBean bean : instance.bCache.values()) {
components.add(new Component() {
@Override
public boolean isAllowedIn(DatabaseObject parent) {
if (bean.getTag().equals("ion-menu")) {
return parent instanceof ApplicationComponent;
}
if (bean.getClassName().startsWith("com.twinsoft.convertigo.beans.mobile.components.UIDynamicMenuItem")) {
if (parent instanceof UIComponent) {
if (parent instanceof UIDynamicMenuItem)
return false;
UIDynamicMenu menu = ((UIComponent) parent).getMenu();
return menu != null;
}
}
Class<?> dboClass;
try {
dboClass = Class.forName(bean.getClassName());
if (acceptDatabaseObjects(parent, dboClass)) {
return isTplCompatible(parent, createBean());
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
@Override
public String getLabel() {
return bean.getLabel();
}
@Override
public String getImagePath() {
return bean.getIconColor32Path();
}
@Override
public String getGroup() {
return bean.getGroup();
}
@Override
public String getDescription() {
return bean.getDescription();
}
@Override
public String getName() {
return bean.getName();
}
@Override
public String getTag() {
return bean.getTag();
}
@Override
public String getPropertiesDescription() {
String propertiesDescription = "";
List<IonProperty> properties = new ArrayList<IonProperty>();
properties.addAll(bean.getProperties().values());
Collections.sort(properties, new Comparator<IonProperty>() {
@Override
public int compare(IonProperty p1, IonProperty p2) {
return p1.getLabel().compareTo(p2.getLabel());
}
});
for (IonProperty ionProperty : properties) {
if (!ionProperty.isHidden()) {
propertiesDescription += "<li><i>" + ionProperty.getLabel() + "</i>";
propertiesDescription += "</br>" + ionProperty.getDescription() + "</li>";
}
}
Class<?> dboClass;
try {
dboClass = Class.forName(bean.getClassName());
BeanInfo beanInfo = Introspector.getBeanInfo(dboClass);
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
propertyDescriptors = propertyDescriptors.clone();
Arrays.sort(propertyDescriptors, (o1, o2) -> {
if (o1.isExpert() == o2.isExpert()) {
return o1.getDisplayName().compareTo(o2.getDisplayName());
} else if (o1.isExpert()) {
return 1;
} else {
return -1;
}
});
for (PropertyDescriptor dbopd : propertyDescriptors) {
if (!dbopd.isHidden() && !Boolean.TRUE.equals(dbopd.getValue("disable"))) {
propertiesDescription += "<li><i>" + dbopd.getDisplayName() + "</i>";
propertiesDescription += "</br>" + dbopd.getShortDescription().replace("|", "") + "</li>";
}
}
} catch (Exception e) {
e.printStackTrace();
}
return propertiesDescription.isEmpty() ? "" : "<ul>" + propertiesDescription + "</ul>";
}
@Override
protected DatabaseObject createBean() {
DatabaseObject dbo = bean.createBean();
return dbo;
}
});
}
Collections.sort(components, new Comparator<Component>() {
@Override
public int compare(Component c1, Component c2) {
return c1.getLabel().compareTo(c2.getLabel());
}
});
return components = Collections.unmodifiableList(components);
}
Aggregations