Search in sources :

Example 26 with ApplicationComponent

use of com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent 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 UISharedComponentEvent || 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) UISharedComponentEvent(com.twinsoft.convertigo.beans.ngx.components.UISharedComponentEvent)

Example 27 with ApplicationComponent

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

the class NgxPickerContentProvider method addLocals.

private void addLocals(TVObject tvi, Object object) {
    if (object != null) {
        Map<String, UIDynamicAction> locals = null;
        if (object instanceof ApplicationComponent) {
            locals = new HashMap<>();
            getLocalActions(object, locals);
        }
        if (locals != null) {
            try {
                JSONObject jsonInfos = new JSONObject();
                for (String key : locals.keySet()) {
                    jsonInfos.put(key, "");
                }
                SourceData sd = null;
                try {
                    sd = Filter.Local.toSourceData(new JSONObject());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                tvi.add(new TVObject("localObject", object, sd, jsonInfos));
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }
}
Also used : UIDynamicAction(com.twinsoft.convertigo.beans.ngx.components.UIDynamicAction) JSONObject(org.codehaus.jettison.json.JSONObject) ApplicationComponent(com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) JSONException(org.codehaus.jettison.json.JSONException) SourceData(com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.SourceData) JSONException(org.codehaus.jettison.json.JSONException)

Example 28 with ApplicationComponent

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

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

Example 29 with ApplicationComponent

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

the class NgxBuilder method appPwaChanged.

@Override
public void appPwaChanged(final IApplicationComponent appComponent) throws EngineException {
    ApplicationComponent app = (ApplicationComponent) appComponent;
    if (app != null && initDone) {
        synchronized (app) {
            // for worker
            configurePwaApp(app);
            // for prod mode
            writeAppComponentTs(app);
            // for worker
            writeAppModuleTs(app);
            moveFiles();
            Engine.logEngine.trace("(MobileBuilder) Handled 'appPwaChanged'");
        }
    }
}
Also used : ApplicationComponent(com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) IApplicationComponent(com.twinsoft.convertigo.beans.core.IApplicationComponent)

Example 30 with ApplicationComponent

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

the class NgxBuilder method appTsChanged.

@Override
public void appTsChanged(final IApplicationComponent appComponent, boolean forceTemp) throws EngineException {
    ApplicationComponent app = (ApplicationComponent) appComponent;
    if (app != null && initDone) {
        synchronized (app) {
            writeAppComponentTs(app);
            moveFiles();
            File tempTsFile = new File(appDir, "app.component.temp.ts");
            if (forceTemp && tempTsFile.exists()) {
                writeAppComponentTempTs(app);
            }
            Engine.logEngine.trace("(MobileBuilder) Handled 'appTsChanged'");
        }
    }
}
Also used : ApplicationComponent(com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) IApplicationComponent(com.twinsoft.convertigo.beans.core.IApplicationComponent) File(java.io.File)

Aggregations

ApplicationComponent (com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent)49 IApplicationComponent (com.twinsoft.convertigo.beans.core.IApplicationComponent)25 UISharedComponent (com.twinsoft.convertigo.beans.ngx.components.UISharedComponent)18 PageComponent (com.twinsoft.convertigo.beans.ngx.components.PageComponent)16 EngineException (com.twinsoft.convertigo.engine.EngineException)13 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)12 MobileApplication (com.twinsoft.convertigo.beans.core.MobileApplication)12 File (java.io.File)12 UIComponent (com.twinsoft.convertigo.beans.ngx.components.UIComponent)10 UIActionStack (com.twinsoft.convertigo.beans.ngx.components.UIActionStack)8 JSONException (org.codehaus.jettison.json.JSONException)8 JSONObject (org.codehaus.jettison.json.JSONObject)8 UIUseShared (com.twinsoft.convertigo.beans.ngx.components.UIUseShared)7 PartInitException (org.eclipse.ui.PartInitException)7 UICustomAction (com.twinsoft.convertigo.beans.ngx.components.UICustomAction)6 UIDynamicAction (com.twinsoft.convertigo.beans.ngx.components.UIDynamicAction)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)6 IPageComponent (com.twinsoft.convertigo.beans.core.IPageComponent)5 Project (com.twinsoft.convertigo.beans.core.Project)5 IScriptComponent (com.twinsoft.convertigo.beans.ngx.components.IScriptComponent)5