Search in sources :

Example 6 with UICustomAction

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

the class NgxPickerComposite method lookupModelData.

private Map<String, Object> lookupModelData(TVObject tvObject) {
    Map<String, Object> data = new HashMap<String, Object>();
    Map<String, String> params = new HashMap<String, String>();
    DatabaseObject dbo = null;
    String searchPath = "";
    Object object = tvObject.getObject();
    JSONObject infos = tvObject.getInfos();
    if (object != null) {
        try {
            if (object instanceof RequestableObject) {
                dbo = (RequestableObject) object;
                searchPath = "";
            } else if (object instanceof DesignDocument) {
                dbo = (DesignDocument) object;
                DesignDocument dd = (DesignDocument) dbo;
                params.put("ddoc", dd.getName());
                params.put("view", tvObject.getParent().getName());
                params.put("include_docs", infos.has("include_docs") ? infos.getString("include_docs") : "false");
                searchPath = tvObject.getName().startsWith("get") ? ".rows.value" : "";
            } else if (object instanceof UIControlDirective) {
                dbo = (UIControlDirective) object;
                do {
                    UIControlDirective directive = (UIControlDirective) dbo;
                    String rootDboName = "";
                    if (directive.getPage() != null) {
                        rootDboName = directive.getPage().getName();
                    } else if (directive.getMenu() != null) {
                        rootDboName = directive.getMenu().getName();
                    }
                    MobileSmartSourceType msst = directive.getSourceSmartType();
                    MobileSmartSource mss = msst.getSmartSource();
                    if (mss != null) {
                        dbo = mss.getDatabaseObject(rootDboName);
                        params.putAll(mss.getParameters());
                        searchPath = mss.getModelPath().replaceAll("\\?\\.", ".") + searchPath;
                    } else {
                        dbo = null;
                    }
                } while (dbo != null && dbo instanceof UIControlDirective);
            } else if (object instanceof UIForm) {
                dbo = (UIForm) object;
                searchPath = "";
            } else if (object instanceof ApplicationComponent) {
                dbo = (ApplicationComponent) object;
                params.put("json", infos.toString());
                searchPath = "";
            } else if (object instanceof UIActionStack) {
                dbo = (UIActionStack) object;
                searchPath = "";
            } else if (object instanceof IAction) {
                if (object instanceof UIDynamicAction) {
                    dbo = (UIDynamicAction) object;
                    searchPath = "";
                } else if (object instanceof UICustomAction) {
                    dbo = (UICustomAction) object;
                    searchPath = "";
                }
            } else if (object instanceof UISharedComponent) {
                dbo = (UISharedComponent) object;
                searchPath = "";
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    data.put("databaseObject", dbo);
    data.put("params", params);
    data.put("searchPath", searchPath);
    return data;
}
Also used : RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) IAction(com.twinsoft.convertigo.beans.ngx.components.IAction) HashMap(java.util.HashMap) MobileSmartSourceType(com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType) ApplicationComponent(com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) UIControlDirective(com.twinsoft.convertigo.beans.ngx.components.UIControlDirective) UIForm(com.twinsoft.convertigo.beans.ngx.components.UIForm) UISharedComponent(com.twinsoft.convertigo.beans.ngx.components.UISharedComponent) PartInitException(org.eclipse.ui.PartInitException) JSONException(org.codehaus.jettison.json.JSONException) UIActionStack(com.twinsoft.convertigo.beans.ngx.components.UIActionStack) MobileSmartSource(com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource) UIDynamicAction(com.twinsoft.convertigo.beans.ngx.components.UIDynamicAction) JSONObject(org.codehaus.jettison.json.JSONObject) DesignDocument(com.twinsoft.convertigo.beans.couchdb.DesignDocument) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) UICustomAction(com.twinsoft.convertigo.beans.ngx.components.UICustomAction) 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)

Aggregations

UICustomAction (com.twinsoft.convertigo.beans.ngx.components.UICustomAction)6 ApplicationComponent (com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent)5 UIActionStack (com.twinsoft.convertigo.beans.ngx.components.UIActionStack)4 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)3 IScriptComponent (com.twinsoft.convertigo.beans.ngx.components.IScriptComponent)3 UIComponent (com.twinsoft.convertigo.beans.ngx.components.UIComponent)3 IApplicationComponent (com.twinsoft.convertigo.beans.core.IApplicationComponent)2 IPageComponent (com.twinsoft.convertigo.beans.core.IPageComponent)2 IUIComponent (com.twinsoft.convertigo.beans.core.IUIComponent)2 RequestableObject (com.twinsoft.convertigo.beans.core.RequestableObject)2 DesignDocument (com.twinsoft.convertigo.beans.couchdb.DesignDocument)2 IAction (com.twinsoft.convertigo.beans.ngx.components.IAction)2 PageComponent (com.twinsoft.convertigo.beans.ngx.components.PageComponent)2 UIDynamicAction (com.twinsoft.convertigo.beans.ngx.components.UIDynamicAction)2 UIForm (com.twinsoft.convertigo.beans.ngx.components.UIForm)2 UISharedComponent (com.twinsoft.convertigo.beans.ngx.components.UISharedComponent)2 EngineException (com.twinsoft.convertigo.engine.EngineException)2 File (java.io.File)2 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)2 FormatedContent (com.twinsoft.convertigo.beans.common.FormatedContent)1