use of com.twinsoft.convertigo.beans.mobile.components.UIControlEvent in project convertigo by convertigo.
the class MobilePickerContentProvider method addActions.
private void addActions(TVObject tvi, Object object) {
if (object != null) {
List<? extends UIComponent> list = null;
if (object instanceof ApplicationComponent) {
ApplicationComponent app = (ApplicationComponent) object;
list = app.getUIAppEventList();
list.addAll(GenericUtils.cast(app.getUIEventSubscriberList()));
list.addAll(GenericUtils.cast(app.getSharedActionList()));
} else if (object instanceof UIActionStack) {
if (tvi != null && "actions".equals(tvi.getName())) {
list = new ArrayList<>(Arrays.asList((UIActionStack) object));
} else {
list = ((UIActionStack) object).getUIComponentList();
}
} else if (object instanceof UISharedComponent) {
list = ((UISharedComponent) object).getUIComponentList();
} else if (object instanceof PageComponent) {
list = ((PageComponent) object).getUIComponentList();
} else if (object instanceof UIComponent) {
list = ((UIComponent) object).getUIComponentList();
}
if (list != null) {
TVObject tvEvents = null, tvControls = null;
if (tvi != null && "actions".equals(tvi.getName())) {
tvEvents = tvi.children.get(0);
tvControls = tvi.children.get(1);
}
for (UIComponent uic : list) {
// do not add to prevent selection on itself or children
if (uic.equals(selected)) {
return;
}
// do not add if not parent of selected (popped picker only)
boolean showInPicker = true;
if (selected != null && selected instanceof UIComponent) {
String selectedQName = ((UIComponent) selected).getQName();
String uicQName = uic.getQName() + ".";
if (!selectedQName.startsWith(uicQName)) {
showInPicker = false;
}
}
if (showInPicker) {
if (uic instanceof UIAppEvent || uic instanceof UIPageEvent || uic instanceof UIEventSubscriber) {
TVObject tve = tvEvents == null ? tvi.add(new TVObject(uic.toString(), uic, null)) : tvEvents.add(new TVObject(uic.toString(), uic, null));
addActions(tve, uic);
} else if (uic instanceof UIActionEvent || uic instanceof UIControlEvent) {
TVObject tve = tvControls == null ? tvi.add(new TVObject(uic.toString(), uic, null)) : tvControls.add(new TVObject(uic.toString(), uic, null));
addActions(tve, uic);
} else if (uic instanceof IAction || uic instanceof UIActionStack) {
SourceData sd = null;
try {
sd = Filter.Action.toSourceData(new JSONObject().put("priority", uic.priority));
} catch (JSONException e) {
e.printStackTrace();
}
TVObject tuic = tvi.add(new TVObject(uic.toString(), uic, sd));
addActions(tuic, uic);
} else {
addActions(tvi, uic);
}
// } else {
// addActions(tvi, uic);
}
}
}
}
}
Aggregations