Search in sources :

Example 21 with UISharedComponent

use of com.twinsoft.convertigo.beans.ngx.components.UISharedComponent 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 22 with UISharedComponent

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

the class NgxBuilder method getFunctionTempTsRelativePath.

@Override
public String getFunctionTempTsRelativePath(final IUIComponent uiComponent) throws EngineException {
    UIComponent uic = (UIComponent) uiComponent;
    IScriptComponent main = uic.getMainScriptComponent();
    if (main != null) {
        File tempTsDir = null;
        String tempTsFileName = null;
        if (main instanceof ApplicationComponent) {
            UIActionStack stack = uic.getSharedAction();
            tempTsDir = stack == null ? appDir : servicesDir;
            tempTsFileName = stack == null ? "app.component.function.temp.ts" : "actionbeans.service.function.temp.ts";
        }
        if (main instanceof PageComponent) {
            PageComponent page = (PageComponent) main;
            String pageName = page.getName();
            tempTsDir = pageDir(page);
            tempTsFileName = pageName.toLowerCase() + ".function.temp.ts";
        }
        if (main instanceof UISharedComponent) {
            UISharedComponent comp = (UISharedComponent) main;
            String compName = comp.getName();
            tempTsDir = compDir(comp);
            tempTsFileName = compName.toLowerCase() + ".function.temp.ts";
        }
        if (tempTsDir != null && tempTsFileName != null) {
            if (uiComponent instanceof UICustomAction) {
                tempTsFileName = "CTS" + ((UICustomAction) uiComponent).priority + ".temp.ts";
            }
            File tempTsFile = new File(tempTsDir, tempTsFileName);
            return tempTsFile.getPath().replace(projectDir.getPath(), File.separator);
        }
    }
    return null;
}
Also used : UIActionStack(com.twinsoft.convertigo.beans.ngx.components.UIActionStack) IScriptComponent(com.twinsoft.convertigo.beans.ngx.components.IScriptComponent) ApplicationComponent(com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) IApplicationComponent(com.twinsoft.convertigo.beans.core.IApplicationComponent) IUIComponent(com.twinsoft.convertigo.beans.core.IUIComponent) UIComponent(com.twinsoft.convertigo.beans.ngx.components.UIComponent) UICustomAction(com.twinsoft.convertigo.beans.ngx.components.UICustomAction) File(java.io.File) UISharedComponent(com.twinsoft.convertigo.beans.ngx.components.UISharedComponent) IPageComponent(com.twinsoft.convertigo.beans.core.IPageComponent) PageComponent(com.twinsoft.convertigo.beans.ngx.components.PageComponent)

Example 23 with UISharedComponent

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

the class NgxBuilder method compRemoved.

@Override
public void compRemoved(final ISharedComponent sharedComponent) throws EngineException {
    UISharedComponent comp = (UISharedComponent) sharedComponent;
    if (comp != null && initDone) {
        synchronized (comp) {
            MobileApplication mobileApplication = project.getMobileApplication();
            if (mobileApplication != null) {
                ApplicationComponent application = (ApplicationComponent) mobileApplication.getApplicationComponent();
                if (application != null) {
                    writeAppSourceFiles(application);
                    deleteUselessCompDir(comp.getName(), comp.getQName());
                    moveFiles();
                    Engine.logEngine.trace("(MobileBuilder) Handled 'compRemoved'");
                    ComponentRefManager.get(Mode.use).removeKey(comp.getQName());
                }
            }
        }
    }
}
Also used : MobileApplication(com.twinsoft.convertigo.beans.core.MobileApplication) ApplicationComponent(com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) IApplicationComponent(com.twinsoft.convertigo.beans.core.IApplicationComponent) UISharedComponent(com.twinsoft.convertigo.beans.ngx.components.UISharedComponent)

Example 24 with UISharedComponent

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

the class NgxBuilder method compStyleChanged.

@Override
public void compStyleChanged(ISharedComponent sharedComponent) throws EngineException {
    UISharedComponent comp = (UISharedComponent) sharedComponent;
    if (comp != null && initDone) {
        synchronized (comp) {
            writeCompStyle(comp);
            moveFiles();
            Engine.logEngine.trace("(MobileBuilder) Handled 'compStyleChanged'");
        }
    }
}
Also used : UISharedComponent(com.twinsoft.convertigo.beans.ngx.components.UISharedComponent)

Example 25 with UISharedComponent

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

the class ApplicationComponentEditor method highlightComponent.

public void highlightComponent(MobileComponent mobileComponent, boolean selectPage) {
    C8oBrowser.run(() -> {
        if (selectPage && mobileComponent instanceof UIComponent) {
            PageComponent pageComponent = ((UIComponent) mobileComponent).getPage();
            if (pageComponent != null) {
                selectPage(pageComponent.getSegment());
            }
        }
    });
    C8oBrowser.run(() -> {
        Document doc = browser.mainFrame().get().document().get();
        MobileComponent mc = mobileComponent;
        if (mc instanceof UISharedComponent) {
            UISharedComponent uisc = (UISharedComponent) mc;
            if (uisc != null) {
                try {
                    mc = uisc.getDisplayableComponentList().get(0);
                } catch (IndexOutOfBoundsException ioobe) {
                }
            }
        } else if (mc instanceof UIUseShared) {
            UISharedComponent uisc = ((UIUseShared) mc).getTargetSharedComponent();
            if (uisc != null) {
                try {
                    mc = uisc.getDisplayableComponentList().get(0);
                } catch (IndexOutOfBoundsException ioobe) {
                }
            }
        }
        while (doc.findElementsByClassName("class" + mc.priority).isEmpty()) {
            DatabaseObject parent = mc.getParent();
            if (parent instanceof MobileComponent) {
                mc = (MobileComponent) parent;
            } else {
                return;
            }
        }
        c8oBrowser.executeJavaScriptAndReturnValue("_c8o_highlight_class('class" + mc.priority + "');");
    });
}
Also used : UIUseShared(com.twinsoft.convertigo.beans.ngx.components.UIUseShared) UIComponent(com.twinsoft.convertigo.beans.ngx.components.UIComponent) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) Document(com.teamdev.jxbrowser.dom.Document) UISharedComponent(com.twinsoft.convertigo.beans.ngx.components.UISharedComponent) PageComponent(com.twinsoft.convertigo.beans.ngx.components.PageComponent) MobileComponent(com.twinsoft.convertigo.beans.ngx.components.MobileComponent)

Aggregations

UISharedComponent (com.twinsoft.convertigo.beans.ngx.components.UISharedComponent)34 ApplicationComponent (com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent)16 EngineException (com.twinsoft.convertigo.engine.EngineException)15 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)13 UIActionStack (com.twinsoft.convertigo.beans.ngx.components.UIActionStack)13 PageComponent (com.twinsoft.convertigo.beans.ngx.components.PageComponent)11 UIComponent (com.twinsoft.convertigo.beans.ngx.components.UIComponent)11 UIUseShared (com.twinsoft.convertigo.beans.ngx.components.UIUseShared)8 MobileApplication (com.twinsoft.convertigo.beans.core.MobileApplication)7 File (java.io.File)7 IApplicationComponent (com.twinsoft.convertigo.beans.core.IApplicationComponent)6 IOException (java.io.IOException)6 CoreException (org.eclipse.core.runtime.CoreException)6 IPageComponent (com.twinsoft.convertigo.beans.core.IPageComponent)5 UIDynamicAction (com.twinsoft.convertigo.beans.ngx.components.UIDynamicAction)5 UIDynamicInvoke (com.twinsoft.convertigo.beans.ngx.components.UIDynamicInvoke)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)5 IScriptComponent (com.twinsoft.convertigo.beans.ngx.components.IScriptComponent)4 MobileSmartSourceType (com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType)4 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)4