use of com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource.SourceData in project convertigo by convertigo.
the class MobilePickerComposite method getModelData.
// private List<String> getSourceList() {
// TVObject tvoSelected = null;
// Object selected = checkboxTreeViewer.getStructuredSelection().getFirstElement();
// if (selected != null && selected instanceof TVObject) {
// tvoSelected = (TVObject)selected;
// }
//
// List<String> sourceList = new ArrayList<String>();
// List<TVObject> tvoList = GenericUtils.cast(Arrays.asList(checkboxTreeViewer.getCheckedElements()));
// for (TVObject tvo : tvoList) {
// if (tvo.equals(tvoSelected)) {
// sourceList.add(0, tvo.getSource());
// }
// else {
// sourceList.add(tvo.getSource());
// }
// }
// return sourceList;
// }
private List<SourceData> getModelData() {
TVObject tvoSelected = null;
Object selected = checkboxTreeViewer.getStructuredSelection().getFirstElement();
if (selected != null && selected instanceof TVObject) {
tvoSelected = (TVObject) selected;
}
List<SourceData> sourceList = new ArrayList<SourceData>();
List<TVObject> tvoList = GenericUtils.cast(Arrays.asList(checkboxTreeViewer.getCheckedElements()));
for (TVObject tvo : tvoList) {
SourceData sd = tvo.getSourceData();
if (sd != null) {
if (tvo.equals(tvoSelected)) {
sourceList.add(0, sd);
} else {
sourceList.add(sd);
}
}
}
return sourceList;
}
use of com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource.SourceData in project convertigo by convertigo.
the class MobilePickerContentProvider method addGlobals.
private void addGlobals(TVObject tvi, Object object) {
if (object != null) {
Map<String, UIDynamicAction> globals = null;
if (object instanceof ApplicationComponent) {
globals = new HashMap<>();
getGlobalActions(object, globals);
}
if (globals != null) {
try {
JSONObject jsonFSSA = new JSONObject().put("FullSyncSyncAction", new JSONObject().put("progress", new JSONObject().put("changed", "").put("continuous", "").put("finished", "").put("pull", "").put("current", "").put("total", "").put("status", "").put("taskInfo", "").put("raw", "")));
JSONObject jsonInfos = new JSONObject();
for (String key : globals.keySet()) {
if ("FullSyncSyncAction".equals(key)) {
jsonInfos.put(key, jsonFSSA.get(key));
} else {
jsonInfos.put(key, "");
}
}
SourceData sd = null;
try {
sd = Filter.Global.toSourceData(new JSONObject());
} catch (Exception e) {
e.printStackTrace();
}
tvi.add(new TVObject("sharedObject", object, sd, jsonInfos));
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}
use of com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource.SourceData in project convertigo by convertigo.
the class MobilePickerContentProvider method addIterations.
private void addIterations(TVObject tvi, Object object) {
if (object != null) {
List<UIComponent> list = null;
if (object instanceof PageComponent) {
list = ((PageComponent) object).getUIComponentList();
} else if (object instanceof UIComponent) {
list = ((UIComponent) object).getUIComponentList();
}
if (list != null) {
for (UIComponent uic : list) {
if (uic instanceof UIControlDirective) {
// 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;
}
}
UIControlDirective uicd = (UIControlDirective) uic;
if (showInPicker && AttrDirective.ForEach.equals(AttrDirective.getDirective(uicd.getDirectiveName()))) {
SourceData sd = null;
try {
sd = Filter.Iteration.toSourceData(new JSONObject().put("priority", uic.priority));
} catch (JSONException e) {
e.printStackTrace();
}
TVObject tuic = tvi.add(new TVObject(uic.toString(), uic, sd));
addIterations(tuic, uic);
} else {
addIterations(tvi, uic);
}
} else {
addIterations(tvi, uic);
}
}
}
}
}
use of com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource.SourceData in project convertigo by convertigo.
the class MobilePickerContentProvider method addForms.
private void addForms(TVObject tvi, Object object) {
if (object != null) {
List<UIComponent> list = null;
if (object instanceof PageComponent) {
list = ((PageComponent) object).getUIComponentList();
} else if (object instanceof UIComponent) {
list = ((UIComponent) object).getUIComponentList();
}
if (list != null) {
for (UIComponent uic : list) {
if (uic instanceof UIForm) {
// do not add to prevent selection on itself or children
if (uic.equals(selected)) {
return;
}
SourceData sd = null;
try {
sd = Filter.Form.toSourceData(new JSONObject().put("priority", uic.priority));
} catch (JSONException e) {
e.printStackTrace();
}
TVObject tuic = tvi.add(new TVObject(uic.toString(), uic, sd));
addForms(tuic, uic);
} else {
addForms(tvi, uic);
}
}
}
}
}
use of com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource.SourceData in project convertigo by convertigo.
the class MobilePickerContentProvider method addSequences.
private void addSequences(Map<String, Set<String>> map, TVObject tvs, Object object, boolean isReferenced) {
if (object != null) {
if (object instanceof Project) {
Project project = (Project) object;
for (Sequence s : project.getSequencesList()) {
String label = isReferenced ? s.getQName() : s.getName();
SourceData sd = null;
try {
sd = Filter.Sequence.toSourceData(new JSONObject().put("sequence", s.getQName()));
} catch (JSONException e) {
e.printStackTrace();
}
tvs.add(new TVObject(label, s, sd));
Set<String> infos = map.get(s.getQName());
if (infos != null) {
for (String info : infos) {
try {
JSONObject jsonInfo = new JSONObject(info);
if (jsonInfo.has("marker")) {
String marker = jsonInfo.getString("marker");
if (!marker.isEmpty()) {
sd = Filter.Sequence.toSourceData(new JSONObject().put("sequence", s.getQName()).put("marker", marker));
tvs.add(new TVObject(label + "#" + marker, s, sd, jsonInfo));
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}
}
}
}
Aggregations