Search in sources :

Example 1 with SourceData

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;
}
Also used : TVObject(com.twinsoft.convertigo.eclipse.views.mobile.MobilePickerContentProvider.TVObject) ArrayList(java.util.ArrayList) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) JSONObject(org.codehaus.jettison.json.JSONObject) TVObject(com.twinsoft.convertigo.eclipse.views.mobile.MobilePickerContentProvider.TVObject) MobileUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) MobilePageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobilePageComponentTreeObject) MobileObject(com.twinsoft.convertigo.beans.core.MobileObject) MobileComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileComponentTreeObject) SourceData(com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource.SourceData)

Example 2 with SourceData

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();
            }
        }
    }
}
Also used : UIDynamicAction(com.twinsoft.convertigo.beans.mobile.components.UIDynamicAction) JSONObject(org.codehaus.jettison.json.JSONObject) ApplicationComponent(com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent) JSONException(org.codehaus.jettison.json.JSONException) SourceData(com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource.SourceData) JSONException(org.codehaus.jettison.json.JSONException)

Example 3 with SourceData

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);
                }
            }
        }
    }
}
Also used : JSONObject(org.codehaus.jettison.json.JSONObject) UIComponent(com.twinsoft.convertigo.beans.mobile.components.UIComponent) UIControlDirective(com.twinsoft.convertigo.beans.mobile.components.UIControlDirective) JSONException(org.codehaus.jettison.json.JSONException) PageComponent(com.twinsoft.convertigo.beans.mobile.components.PageComponent) SourceData(com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource.SourceData)

Example 4 with SourceData

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);
                }
            }
        }
    }
}
Also used : JSONObject(org.codehaus.jettison.json.JSONObject) UIComponent(com.twinsoft.convertigo.beans.mobile.components.UIComponent) JSONException(org.codehaus.jettison.json.JSONException) UIForm(com.twinsoft.convertigo.beans.mobile.components.UIForm) PageComponent(com.twinsoft.convertigo.beans.mobile.components.PageComponent) SourceData(com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource.SourceData)

Example 5 with SourceData

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();
                        }
                    }
                }
            }
        }
    }
}
Also used : Project(com.twinsoft.convertigo.beans.core.Project) JSONObject(org.codehaus.jettison.json.JSONObject) JSONException(org.codehaus.jettison.json.JSONException) Sequence(com.twinsoft.convertigo.beans.core.Sequence) SourceData(com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource.SourceData)

Aggregations

SourceData (com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource.SourceData)8 JSONObject (org.codehaus.jettison.json.JSONObject)8 JSONException (org.codehaus.jettison.json.JSONException)7 UIComponent (com.twinsoft.convertigo.beans.mobile.components.UIComponent)4 ApplicationComponent (com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent)3 PageComponent (com.twinsoft.convertigo.beans.mobile.components.PageComponent)3 ArrayList (java.util.ArrayList)3 Project (com.twinsoft.convertigo.beans.core.Project)2 UISharedComponent (com.twinsoft.convertigo.beans.mobile.components.UISharedComponent)2 FullSyncConnector (com.twinsoft.convertigo.beans.connectors.FullSyncConnector)1 Connector (com.twinsoft.convertigo.beans.core.Connector)1 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)1 Document (com.twinsoft.convertigo.beans.core.Document)1 MobileObject (com.twinsoft.convertigo.beans.core.MobileObject)1 RequestableObject (com.twinsoft.convertigo.beans.core.RequestableObject)1 Sequence (com.twinsoft.convertigo.beans.core.Sequence)1 DesignDocument (com.twinsoft.convertigo.beans.couchdb.DesignDocument)1 IAction (com.twinsoft.convertigo.beans.mobile.components.IAction)1 UIActionEvent (com.twinsoft.convertigo.beans.mobile.components.UIActionEvent)1 UIActionStack (com.twinsoft.convertigo.beans.mobile.components.UIActionStack)1