Search in sources :

Example 1 with SourceData

use of com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.SourceData in project convertigo by convertigo.

the class NgxPickerContentProvider 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.ngx.components.MobileSmartSource.SourceData)

Example 2 with SourceData

use of com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.SourceData in project convertigo by convertigo.

the class NgxPickerComposite 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.NgxPickerContentProvider.TVObject) ArrayList(java.util.ArrayList) NgxComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxComponentTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) JSONObject(org.codehaus.jettison.json.JSONObject) NgxUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxUIComponentTreeObject) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) TVObject(com.twinsoft.convertigo.eclipse.views.mobile.NgxPickerContentProvider.TVObject) NgxPageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxPageComponentTreeObject) MobileObject(com.twinsoft.convertigo.beans.core.MobileObject) SourceData(com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.SourceData)

Example 3 with SourceData

use of com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.SourceData in project convertigo by convertigo.

the class NgxPickerContentProvider 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.ngx.components.UIComponent) UIControlDirective(com.twinsoft.convertigo.beans.ngx.components.UIControlDirective) JSONException(org.codehaus.jettison.json.JSONException) PageComponent(com.twinsoft.convertigo.beans.ngx.components.PageComponent) SourceData(com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.SourceData)

Example 4 with SourceData

use of com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.SourceData in project convertigo by convertigo.

the class NgxPickerContentProvider 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);
                }
            }
        }
    }
}
Also used : UIAppEvent(com.twinsoft.convertigo.beans.ngx.components.UIAppEvent) UIPageEvent(com.twinsoft.convertigo.beans.ngx.components.UIPageEvent) IAction(com.twinsoft.convertigo.beans.ngx.components.IAction) ApplicationComponent(com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) ArrayList(java.util.ArrayList) UIComponent(com.twinsoft.convertigo.beans.ngx.components.UIComponent) JSONException(org.codehaus.jettison.json.JSONException) UIEventSubscriber(com.twinsoft.convertigo.beans.ngx.components.UIEventSubscriber) UISharedComponent(com.twinsoft.convertigo.beans.ngx.components.UISharedComponent) PageComponent(com.twinsoft.convertigo.beans.ngx.components.PageComponent) SourceData(com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.SourceData) UIActionStack(com.twinsoft.convertigo.beans.ngx.components.UIActionStack) UIControlEvent(com.twinsoft.convertigo.beans.ngx.components.UIControlEvent) JSONObject(org.codehaus.jettison.json.JSONObject) UIActionEvent(com.twinsoft.convertigo.beans.ngx.components.UIActionEvent)

Example 5 with SourceData

use of com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.SourceData in project convertigo by convertigo.

the class NgxPickerContentProvider method addSharedComponents.

private void addSharedComponents(TVObject tvi, Object object) {
    if (object != null) {
        List<? extends UIComponent> list = null;
        if (object instanceof ApplicationComponent) {
            list = ((ApplicationComponent) object).getSharedComponentList();
        } else if (object instanceof UISharedComponent) {
            list = new ArrayList<>(Arrays.asList((UISharedComponent) object));
        }
        if (list != null) {
            for (UIComponent uic : list) {
                if (uic instanceof UISharedComponent) {
                    // 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) {
                        SourceData sd = null;
                        try {
                            sd = Filter.Shared.toSourceData(new JSONObject().put("priority", uic.priority));
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                        tvi.add(new TVObject(uic.toString(), uic, sd));
                    }
                }
            }
        }
    }
}
Also used : JSONObject(org.codehaus.jettison.json.JSONObject) ApplicationComponent(com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) ArrayList(java.util.ArrayList) UIComponent(com.twinsoft.convertigo.beans.ngx.components.UIComponent) JSONException(org.codehaus.jettison.json.JSONException) UISharedComponent(com.twinsoft.convertigo.beans.ngx.components.UISharedComponent) SourceData(com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.SourceData)

Aggregations

SourceData (com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.SourceData)8 JSONObject (org.codehaus.jettison.json.JSONObject)8 JSONException (org.codehaus.jettison.json.JSONException)7 UIComponent (com.twinsoft.convertigo.beans.ngx.components.UIComponent)4 ApplicationComponent (com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent)3 PageComponent (com.twinsoft.convertigo.beans.ngx.components.PageComponent)3 ArrayList (java.util.ArrayList)3 Project (com.twinsoft.convertigo.beans.core.Project)2 UISharedComponent (com.twinsoft.convertigo.beans.ngx.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.ngx.components.IAction)1 UIActionEvent (com.twinsoft.convertigo.beans.ngx.components.UIActionEvent)1 UIActionStack (com.twinsoft.convertigo.beans.ngx.components.UIActionStack)1