Search in sources :

Example 11 with ApplicationComponent

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

the class NgxComponentImportVariablesAction method run.

public void run() {
    Display display = Display.getDefault();
    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    Shell shell = getParentShell();
    shell.setCursor(waitCursor);
    try {
        ProjectExplorerView explorerView = getProjectExplorerView();
        if (explorerView != null) {
            TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
            Object databaseObject = treeObject.getObject();
            if (databaseObject != null) {
                if (databaseObject instanceof UIDynamicAction) {
                    UIDynamicAction dynAction = (UIDynamicAction) databaseObject;
                    IonBean ionBean = ((UIDynamicAction) dynAction).getIonBean();
                    if (ionBean != null) {
                        // Case of CallSequenceAction
                        if (ionBean.getName().equals("CallSequenceAction")) {
                            Object value = ionBean.getProperty("requestable").getValue();
                            if (!value.equals(false)) {
                                String target = value.toString();
                                if (!target.isEmpty()) {
                                    try {
                                        String projectName = target.substring(0, target.indexOf('.'));
                                        String sequenceName = target.substring(target.indexOf('.') + 1);
                                        Project p = Engine.theApp.databaseObjectsManager.getProjectByName(projectName);
                                        Sequence sequence = p.getSequenceByName(sequenceName);
                                        int size = sequence.numberOfVariables();
                                        for (int i = 0; i < size; i++) {
                                            RequestableVariable variable = (RequestableVariable) sequence.getVariable(i);
                                            if (variable != null) {
                                                String variableName = variable.getName();
                                                if (dynAction.getVariable(variableName) == null) {
                                                    if (!StringUtils.isNormalized(variableName))
                                                        throw new EngineException("Variable name is not normalized : \"" + variableName + "\".");
                                                    UIControlVariable uiVariable = new UIControlVariable();
                                                    uiVariable.setName(variableName);
                                                    uiVariable.setComment(variable.getDescription());
                                                    uiVariable.setVarSmartType(new MobileSmartSourceType(variable.getDefaultValue().toString()));
                                                    dynAction.addUIComponent(uiVariable);
                                                    uiVariable.bNew = true;
                                                    uiVariable.hasChanged = true;
                                                    dynAction.hasChanged = true;
                                                }
                                            }
                                        }
                                    } catch (Exception e) {
                                    }
                                }
                            }
                        } else // Case of InvokeAction
                        if (ionBean.getName().equals("InvokeAction")) {
                            UIDynamicInvoke dynInvoke = (UIDynamicInvoke) databaseObject;
                            UIActionStack stack = dynInvoke.getTargetSharedAction();
                            if (stack != null) {
                                for (UIStackVariable variable : stack.getVariables()) {
                                    String variableName = variable.getName();
                                    if (dynAction.getVariable(variableName) == null) {
                                        if (!StringUtils.isNormalized(variableName))
                                            throw new EngineException("Variable name is not normalized : \"" + variableName + "\".");
                                        UIControlVariable uiVariable = new UIControlVariable();
                                        uiVariable.setName(variableName);
                                        uiVariable.setComment(variable.getComment());
                                        MobileSmartSourceType msst = new MobileSmartSourceType();
                                        msst.setMode(MobileSmartSourceType.Mode.SCRIPT);
                                        msst.setSmartValue(variable.getVariableValue());
                                        uiVariable.setVarSmartType(msst);
                                        dynAction.addUIComponent(uiVariable);
                                        uiVariable.bNew = true;
                                        uiVariable.hasChanged = true;
                                        dynAction.hasChanged = true;
                                    }
                                }
                            }
                        }
                        if (dynAction.hasChanged) {
                            IScriptComponent main = dynAction.getMainScriptComponent();
                            if (main != null) {
                                if (main instanceof ApplicationComponent) {
                                    ((ApplicationComponent) main).markApplicationAsDirty();
                                }
                                if (main instanceof PageComponent) {
                                    ((PageComponent) main).markPageAsDirty();
                                }
                            }
                            explorerView.reloadTreeObject(treeObject);
                            StructuredSelection structuredSelection = new StructuredSelection(treeObject);
                            ConvertigoPlugin.getDefault().getPropertiesView().selectionChanged((IWorkbenchPart) explorerView, structuredSelection);
                        }
                    }
                } else if (databaseObject instanceof UIUseShared) {
                    UIUseShared useShared = (UIUseShared) databaseObject;
                    UISharedComponent sharedComp = useShared.getTargetSharedComponent();
                    if (sharedComp != null) {
                        for (UICompVariable variable : sharedComp.getVariables()) {
                            String variableName = variable.getName();
                            if (useShared.getVariable(variableName) == null) {
                                if (!StringUtils.isNormalized(variableName))
                                    throw new EngineException("Variable name is not normalized : \"" + variableName + "\".");
                                UIUseVariable uiVariable = new UIUseVariable();
                                uiVariable.setName(variableName);
                                uiVariable.setComment(variable.getComment());
                                MobileSmartSourceType msst = new MobileSmartSourceType();
                                msst.setMode(MobileSmartSourceType.Mode.SCRIPT);
                                msst.setSmartValue(variable.getVariableValue());
                                uiVariable.setVarSmartType(msst);
                                useShared.addUIComponent(uiVariable);
                                uiVariable.bNew = true;
                                uiVariable.hasChanged = true;
                                useShared.hasChanged = true;
                            }
                        }
                        if (useShared.hasChanged) {
                            IScriptComponent main = useShared.getMainScriptComponent();
                            if (main != null) {
                                if (main instanceof ApplicationComponent) {
                                    ((ApplicationComponent) main).markApplicationAsDirty();
                                }
                                if (main instanceof PageComponent) {
                                    ((PageComponent) main).markPageAsDirty();
                                }
                            }
                            explorerView.reloadTreeObject(treeObject);
                            StructuredSelection structuredSelection = new StructuredSelection(treeObject);
                            ConvertigoPlugin.getDefault().getPropertiesView().selectionChanged((IWorkbenchPart) explorerView, structuredSelection);
                        }
                    }
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to add variables to action !");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : IonBean(com.twinsoft.convertigo.beans.ngx.components.dynamic.IonBean) MobileSmartSourceType(com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType) UIUseShared(com.twinsoft.convertigo.beans.ngx.components.UIUseShared) EngineException(com.twinsoft.convertigo.engine.EngineException) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) UIControlVariable(com.twinsoft.convertigo.beans.ngx.components.UIControlVariable) Cursor(org.eclipse.swt.graphics.Cursor) UISharedComponent(com.twinsoft.convertigo.beans.ngx.components.UISharedComponent) PageComponent(com.twinsoft.convertigo.beans.ngx.components.PageComponent) Shell(org.eclipse.swt.widgets.Shell) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) UIUseVariable(com.twinsoft.convertigo.beans.ngx.components.UIUseVariable) UICompVariable(com.twinsoft.convertigo.beans.ngx.components.UICompVariable) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) IScriptComponent(com.twinsoft.convertigo.beans.ngx.components.IScriptComponent) ApplicationComponent(com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) UIStackVariable(com.twinsoft.convertigo.beans.ngx.components.UIStackVariable) Sequence(com.twinsoft.convertigo.beans.core.Sequence) EngineException(com.twinsoft.convertigo.engine.EngineException) Project(com.twinsoft.convertigo.beans.core.Project) UIActionStack(com.twinsoft.convertigo.beans.ngx.components.UIActionStack) UIDynamicAction(com.twinsoft.convertigo.beans.ngx.components.UIDynamicAction) UIDynamicInvoke(com.twinsoft.convertigo.beans.ngx.components.UIDynamicInvoke) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) Display(org.eclipse.swt.widgets.Display)

Example 12 with ApplicationComponent

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

the class ApplicationComponentEditor method launchBuilder.

public void launchBuilder(boolean forceInstall, boolean forceClean) {
    final int buildCount = ++this.buildCount;
    // Close editors (*.temp.ts) to avoid npm error at build launch
    ConvertigoPlugin.getDisplay().syncExec(new Runnable() {

        public void run() {
            try {
                ApplicationComponent app = applicationEditorInput.application;
                IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
                if (activePage != null) {
                    IEditorReference[] editorRefs = activePage.getEditorReferences();
                    for (int i = 0; i < editorRefs.length; i++) {
                        IEditorReference editorRef = (IEditorReference) editorRefs[i];
                        try {
                            IEditorInput editorInput = editorRef.getEditorInput();
                            if (editorInput != null && editorInput instanceof ComponentFileEditorInput) {
                                if (((ComponentFileEditorInput) editorInput).is(app) || ((ComponentFileEditorInput) editorInput).isChildOf(app)) {
                                    activePage.closeEditor(editorRef.getEditor(false), false);
                                }
                            }
                        } catch (Exception e) {
                        }
                    }
                }
            } catch (Throwable t) {
            }
        }
    });
    // Launch build
    Engine.execute(() -> {
        initLoader();
        project = applicationEditorInput.application.getProject();
        ionicDir = new File(project.getDirPath(), "_private/ionic");
        nodeModules = new File(ionicDir, "node_modules");
        String nodeVersion = ProcessUtils.getNodeVersion(project);
        nodeDir = ProcessUtils.getDefaultNodeDir();
        try {
            nodeDir = ProcessUtils.getNodeDir(nodeVersion, (r, t, x) -> {
                appendOutput("Downloading nodejs " + nodeVersion + ": " + Math.round((r * 100f) / t) + "%");
            });
        } catch (Exception e1) {
        }
        {
            String versions = "Will use nodejs " + ProcessUtils.getNodeVersion(nodeDir) + " and npm " + ProcessUtils.getNpmVersion(nodeDir);
            appendOutput(versions);
            Engine.logStudio.info(versions);
        }
        String path = nodeDir.getAbsolutePath();
        terminateNode(false);
        MobileBuilder mb = project.getMobileBuilder();
        if (forceInstall || !nodeModules.exists() || mb.getNeedPkgUpdate()) {
            boolean[] running = { true };
            try {
                if (forceClean) {
                    appendOutput("...", "...", "Removing existing node_modules... This can take several seconds...");
                    Engine.logStudio.info("Removing existing node_modules... This can take several seconds...");
                    com.twinsoft.convertigo.engine.util.FileUtils.deleteQuietly(nodeModules);
                }
                appendOutput("Installing node_modules... This can take several minutes depending on your network connection speed...");
                Engine.logStudio.info("Installing node_modules... This can take several minutes depending on your network connection speed...");
                if (!nodeModules.exists()) {
                    File packageLockTpl = new File(ionicDir, "package-lock-tpl.json");
                    if (packageLockTpl.exists()) {
                        com.twinsoft.convertigo.engine.util.FileUtils.copyFile(packageLockTpl, new File(ionicDir, "package-lock.json"));
                    }
                }
                ProcessBuilder pb = ProcessUtils.getNpmProcessBuilder(path + File.pathSeparator + ionicDir.toString(), "npm", "install", "--legacy-peer-deps", "--loglevel", "info");
                pb.redirectErrorStream(true);
                pb.directory(ionicDir);
                Process p = pb.start();
                processes.add(p);
                BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
                String line;
                while ((line = br.readLine()) != null) {
                    line = pRemoveEchap.matcher(line).replaceAll("");
                    if (StringUtils.isNotBlank(line)) {
                        Engine.logStudio.info(line);
                        appendOutput(line);
                    }
                }
                Engine.logStudio.info(line);
                appendOutput("\\o/");
            } catch (Exception e) {
                appendOutput(":( " + e);
            }
            running[0] = false;
        }
        mb.setNeedPkgUpdate(false);
        build(path, buildCount, mb);
    });
}
Also used : Element(com.teamdev.jxbrowser.dom.Element) CoreException(org.eclipse.core.runtime.CoreException) FocusEvent(org.eclipse.swt.events.FocusEvent) ApplicationComponent(com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) StringUtils(org.apache.commons.lang3.StringUtils) Point(org.eclipse.swt.graphics.Point) UISharedComponent(com.twinsoft.convertigo.beans.ngx.components.UISharedComponent) Matcher(java.util.regex.Matcher) Composite(org.eclipse.swt.widgets.Composite) PartInitException(org.eclipse.ui.PartInitException) KeyEvent(org.eclipse.swt.events.KeyEvent) PageComponent(com.twinsoft.convertigo.beans.ngx.components.PageComponent) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) KeyAdapter(org.eclipse.swt.events.KeyAdapter) IEditorPart(org.eclipse.ui.IEditorPart) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) IEditorInput(org.eclipse.ui.IEditorInput) PlatformUI(org.eclipse.ui.PlatformUI) Set(java.util.Set) ToolItem(org.eclipse.swt.widgets.ToolItem) IOUtils(org.apache.commons.io.IOUtils) MenuItem(org.eclipse.swt.widgets.MenuItem) SWT(org.eclipse.swt.SWT) JsAccessible(com.teamdev.jxbrowser.js.JsAccessible) EditorPart(org.eclipse.ui.part.EditorPart) SwtUtils(com.twinsoft.convertigo.eclipse.swt.SwtUtils) DatabaseObjectFoundException(com.twinsoft.convertigo.engine.DatabaseObjectFoundException) SelectionListener(org.eclipse.swt.events.SelectionListener) UIControlEvent(com.twinsoft.convertigo.beans.ngx.components.UIControlEvent) MobileComponent(com.twinsoft.convertigo.beans.ngx.components.MobileComponent) JFaceResources(org.eclipse.jface.resource.JFaceResources) IEditorSite(org.eclipse.ui.IEditorSite) UIActionStack(com.twinsoft.convertigo.beans.ngx.components.UIActionStack) RequestPermissionCallback(com.teamdev.jxbrowser.permission.callback.RequestPermissionCallback) GridData(org.eclipse.swt.layout.GridData) RowData(org.eclipse.swt.layout.RowData) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) Engine(com.twinsoft.convertigo.engine.Engine) UIUseShared(com.twinsoft.convertigo.beans.ngx.components.UIUseShared) JSONObject(org.codehaus.jettison.json.JSONObject) JSONArray(org.codehaus.jettison.json.JSONArray) PaletteSource(com.twinsoft.convertigo.eclipse.dnd.PaletteSource) MobileDebugView(com.twinsoft.convertigo.eclipse.views.mobile.MobileDebugView) MobileBuilderBuildMode(com.twinsoft.convertigo.engine.enums.MobileBuilderBuildMode) NgxBuilderBuildMode(com.twinsoft.convertigo.engine.enums.NgxBuilderBuildMode) JsObject(com.teamdev.jxbrowser.js.JsObject) InputStreamReader(java.io.InputStreamReader) File(java.io.File) Node(com.teamdev.jxbrowser.dom.Node) Project(com.twinsoft.convertigo.beans.core.Project) JSONException(org.codehaus.jettison.json.JSONException) ModifyListener(org.eclipse.swt.events.ModifyListener) FileUtils(com.twinsoft.convertigo.engine.util.FileUtils) IEditorReference(org.eclipse.ui.IEditorReference) UIComponent(com.twinsoft.convertigo.beans.ngx.components.UIComponent) BufferedReader(java.io.BufferedReader) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ProcessUtils(com.twinsoft.convertigo.engine.util.ProcessUtils) GridLayout(org.eclipse.swt.layout.GridLayout) WalkHelper(com.twinsoft.convertigo.engine.helpers.WalkHelper) ClipboardAction(com.twinsoft.convertigo.eclipse.popup.actions.ClipboardAction) ToolBar(org.eclipse.swt.widgets.ToolBar) VerifyListener(org.eclipse.swt.events.VerifyListener) MobileEventListener(com.twinsoft.convertigo.engine.mobile.MobileEventListener) EnginePropertiesManager(com.twinsoft.convertigo.engine.EnginePropertiesManager) InjectJsCallback(com.teamdev.jxbrowser.browser.callback.InjectJsCallback) UIDynamicInvoke(com.twinsoft.convertigo.beans.ngx.components.UIDynamicInvoke) NetworkUtils(com.twinsoft.convertigo.engine.util.NetworkUtils) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Collection(java.util.Collection) UIDynamicAction(com.twinsoft.convertigo.beans.ngx.components.UIDynamicAction) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ConvertigoPlugin(com.twinsoft.convertigo.eclipse.ConvertigoPlugin) PropertyName(com.twinsoft.convertigo.engine.EnginePropertiesManager.PropertyName) List(java.util.List) Pattern(java.util.regex.Pattern) ShowContextMenuCallback(com.teamdev.jxbrowser.browser.callback.ShowContextMenuCallback) Label(org.eclipse.swt.widgets.Label) CompositeEvent(com.twinsoft.convertigo.eclipse.editors.CompositeEvent) Document(com.teamdev.jxbrowser.dom.Document) Image(org.eclipse.swt.graphics.Image) Rectangle(org.eclipse.swt.graphics.Rectangle) FocusListener(org.eclipse.swt.events.FocusListener) Event(org.eclipse.swt.widgets.Event) Frame(com.teamdev.jxbrowser.frame.Frame) MobileBuilder(com.twinsoft.convertigo.engine.mobile.MobileBuilder) HashSet(java.util.HashSet) PaletteSourceTransfer(com.twinsoft.convertigo.eclipse.dnd.PaletteSourceTransfer) BatchOperationHelper(com.twinsoft.convertigo.engine.helpers.BatchOperationHelper) Charset(java.nio.charset.Charset) UIDynamicElement(com.twinsoft.convertigo.beans.ngx.components.UIDynamicElement) Browser(com.teamdev.jxbrowser.browser.Browser) LinkedList(java.util.LinkedList) TreeParent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent) Response(com.teamdev.jxbrowser.browser.callback.InjectJsCallback.Response) Job(org.eclipse.core.runtime.jobs.Job) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) RowLayout(org.eclipse.swt.layout.RowLayout) IResource(org.eclipse.core.resources.IResource) NumberUtils(org.apache.commons.lang3.math.NumberUtils) KeyListener(org.eclipse.swt.events.KeyListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) FocusAdapter(org.eclipse.swt.events.FocusAdapter) C8oBrowser(com.twinsoft.convertigo.eclipse.swt.C8oBrowser) Control(org.eclipse.swt.widgets.Control) InputStreamReader(java.io.InputStreamReader) ApplicationComponent(com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) Point(org.eclipse.swt.graphics.Point) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) DatabaseObjectFoundException(com.twinsoft.convertigo.engine.DatabaseObjectFoundException) JSONException(org.codehaus.jettison.json.JSONException) IEditorReference(org.eclipse.ui.IEditorReference) MobileBuilder(com.twinsoft.convertigo.engine.mobile.MobileBuilder) BufferedReader(java.io.BufferedReader) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) File(java.io.File) IEditorInput(org.eclipse.ui.IEditorInput)

Example 13 with ApplicationComponent

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

the class ApplicationComponentEditor method init.

@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
    setSite(site);
    setInput(input);
    applicationEditorInput = (ApplicationComponentEditorInput) input;
    ApplicationComponent application = applicationEditorInput.application;
    Project project = application.getProject();
    datasetDir = new File(project.getDirPath(), "dataset");
    datasetDir.mkdirs();
    devicePref = new File(Engine.USER_WORKSPACE_PATH, "studio/device-" + project.getName() + ".json");
    setPartName(project.getName() + " [A: " + application.getName() + "]");
    terminateNode(false);
}
Also used : Project(com.twinsoft.convertigo.beans.core.Project) ApplicationComponent(com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) File(java.io.File)

Example 14 with ApplicationComponent

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

the class ComponentManager method makeComponents.

private synchronized List<Component> makeComponents() {
    if (components != null) {
        return components;
    }
    components = new ArrayList<Component>(10);
    try {
        String group;
        // Add Customs
        group = GROUP_CUSTOMS;
        components.add(getDboComponent(UIElement.class, group));
        components.add(getDboComponent(UIAttribute.class, group));
        components.add(getDboComponent(UIAnimation.class, group));
        components.add(getDboComponent(UICustom.class, group));
        components.add(getDboComponent(UIText.class, group));
        components.add(getDboComponent(UIStyle.class, group));
        components.add(getDboComponent(UITheme.class, group));
        // Add shared components
        group = GROUP_SHARED_COMPONENTS;
        // components.add(getDboComponent(UISharedComponent.class,group)); // deprecated
        components.add(getDboComponent(UISharedRegularComponent.class, group));
        components.add(getDboComponent(UIUseShared.class, group));
        components.add(getDboComponent(UICompVariable.class, group));
        components.add(getDboComponent(UIUseVariable.class, group));
        components.add(getDboComponent(UICompEvent.class, group));
        // Add shared actions
        group = GROUP_SHARED_ACTIONS;
        components.add(getDboComponent(UIActionStack.class, group));
        components.add(getDboComponent(UIStackVariable.class, group));
        // Add Controls
        group = GROUP_CONTROLS;
        components.add(getDboComponent(UIControlEvent.class, group));
        components.add(getDboComponent(UIAppEvent.class, group));
        components.add(getDboComponent(UIPageEvent.class, group));
        components.add(getDboComponent(UISharedComponentEvent.class, group));
        components.add(getDboComponent(UIAppGuard.class, group));
        components.add(getDboComponent(UIEventSubscriber.class, group));
        components.add(getDboComponent(UIActionErrorEvent.class, group));
        components.add(getDboComponent(UIActionFailureEvent.class, group));
        components.add(getDboComponent(UIActionFinallyEvent.class, group));
        components.add(getDboComponent(UIActionLoopEvent.class, group));
        components.add(getDboComponent(UIActionCaseEvent.class, group));
        components.add(getDboComponent(UIActionCaseDefaultEvent.class, group));
        components.add(getDboComponent(UIActionElseEvent.class, group));
        components.add(getDboComponent(UIControlDirective.class, group));
        // Add Actions
        group = GROUP_ACTIONS;
        components.add(getDboComponent(UIControlVariable.class, group));
        components.add(getDboComponent(UICustomAction.class, group));
        components.add(getDboComponent(UICustomAsyncAction.class, group));
        components.add(getDboComponent(UIForm.class, "Forms"));
    // components.add(getDboComponent(UIFormControlValidator.class,"Forms"));
    // components.add(getDboComponent(UIFormCustomValidator.class,"Forms"));
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    }
    for (final IonBean bean : instance.bCache.values()) {
        components.add(new Component() {

            @Override
            public boolean isAllowedIn(DatabaseObject parent) {
                if (bean.getTag().equals("ion-menu")) {
                    return parent instanceof ApplicationComponent;
                }
                if (bean.getClassName().startsWith("com.twinsoft.convertigo.beans.ngx.components.UIDynamicMenuItem")) {
                    if (parent instanceof UIComponent) {
                        if (parent instanceof UIDynamicMenuItem)
                            return false;
                        UIDynamicMenu menu = ((UIComponent) parent).getMenu();
                        return menu != null;
                    }
                }
                Class<?> dboClass;
                try {
                    dboClass = Class.forName(bean.getClassName());
                    if (acceptDatabaseObjects(parent, dboClass)) {
                        return isTplCompatible(parent, createBean());
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                return false;
            }

            @Override
            public String getLabel() {
                return bean.getLabel();
            }

            @Override
            public String getImagePath() {
                return bean.getIconColor32Path();
            }

            @Override
            public String getGroup() {
                return bean.getGroup();
            }

            @Override
            public String getDescription() {
                return bean.getDescription();
            }

            @Override
            public String getName() {
                return bean.getName();
            }

            @Override
            public String getTag() {
                return bean.getTag();
            }

            @Override
            public String getPropertiesDescription() {
                String propertiesDescription = "";
                List<IonProperty> properties = new ArrayList<IonProperty>();
                properties.addAll(bean.getProperties().values());
                Collections.sort(properties, new Comparator<IonProperty>() {

                    @Override
                    public int compare(IonProperty p1, IonProperty p2) {
                        return p1.getLabel().compareTo(p2.getLabel());
                    }
                });
                for (IonProperty ionProperty : properties) {
                    if (!ionProperty.isHidden()) {
                        propertiesDescription += "<li><i>" + ionProperty.getLabel() + "</i>";
                        propertiesDescription += "</br>" + ionProperty.getDescription() + "</li>";
                    }
                }
                Class<?> dboClass;
                try {
                    dboClass = Class.forName(bean.getClassName());
                    BeanInfo beanInfo = Introspector.getBeanInfo(dboClass);
                    PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
                    propertyDescriptors = propertyDescriptors.clone();
                    Arrays.sort(propertyDescriptors, (o1, o2) -> {
                        if (o1.isExpert() == o2.isExpert()) {
                            return o1.getDisplayName().compareTo(o2.getDisplayName());
                        } else if (o1.isExpert()) {
                            return 1;
                        } else {
                            return -1;
                        }
                    });
                    for (PropertyDescriptor dbopd : propertyDescriptors) {
                        if (!dbopd.isHidden() && !Boolean.TRUE.equals(dbopd.getValue("disable"))) {
                            propertiesDescription += "<li><i>" + dbopd.getDisplayName() + "</i>";
                            propertiesDescription += "</br>" + dbopd.getShortDescription().replace("|", "") + "</li>";
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                return propertiesDescription.isEmpty() ? "" : "<ul>" + propertiesDescription + "</ul>";
            }

            @Override
            protected DatabaseObject createBean() {
                DatabaseObject dbo = bean.createBean();
                return dbo;
            }

            @Override
            protected JSONObject getHint() {
                return bean.getHint();
            }
        });
    }
    Collections.sort(components, new Comparator<Component>() {

        @Override
        public int compare(Component c1, Component c2) {
            return c1.getLabel().compareTo(c2.getLabel());
        }
    });
    return components = Collections.unmodifiableList(components);
}
Also used : UISharedRegularComponent(com.twinsoft.convertigo.beans.ngx.components.UISharedRegularComponent) Arrays(java.util.Arrays) UIActionEvent(com.twinsoft.convertigo.beans.ngx.components.UIActionEvent) UIAnimation(com.twinsoft.convertigo.beans.ngx.components.UIAnimation) UIAttribute(com.twinsoft.convertigo.beans.ngx.components.UIAttribute) UIAppEvent(com.twinsoft.convertigo.beans.ngx.components.UIAppEvent) Mode(com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType.Mode) ApplicationComponent(com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) UISharedComponentEvent(com.twinsoft.convertigo.beans.ngx.components.UISharedComponentEvent) UIDynamicIterate(com.twinsoft.convertigo.beans.ngx.components.UIDynamicIterate) UISharedComponent(com.twinsoft.convertigo.beans.ngx.components.UISharedComponent) UIControlVariable(com.twinsoft.convertigo.beans.ngx.components.UIControlVariable) UICompVariable(com.twinsoft.convertigo.beans.ngx.components.UICompVariable) Map(java.util.Map) PageComponent(com.twinsoft.convertigo.beans.ngx.components.PageComponent) UIControlDirective(com.twinsoft.convertigo.beans.ngx.components.UIControlDirective) UIForm(com.twinsoft.convertigo.beans.ngx.components.UIForm) UIStyle(com.twinsoft.convertigo.beans.ngx.components.UIStyle) BeanDescriptor(java.beans.BeanDescriptor) Method(java.lang.reflect.Method) GenericUtils(com.twinsoft.convertigo.engine.util.GenericUtils) UIActionElseEvent(com.twinsoft.convertigo.beans.ngx.components.UIActionElseEvent) MobileSmartSourceType(com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType) UICustomAsyncAction(com.twinsoft.convertigo.beans.ngx.components.UICustomAsyncAction) IntrospectionException(java.beans.IntrospectionException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) PropertyDescriptor(java.beans.PropertyDescriptor) UICustomAction(com.twinsoft.convertigo.beans.ngx.components.UICustomAction) UIElement(com.twinsoft.convertigo.beans.ngx.components.UIElement) UISharedRegularComponent(com.twinsoft.convertigo.beans.ngx.components.UISharedRegularComponent) UITheme(com.twinsoft.convertigo.beans.ngx.components.UITheme) URLUtils(com.twinsoft.convertigo.engine.util.URLUtils) UIAppGuard(com.twinsoft.convertigo.beans.ngx.components.UIAppGuard) SortedMap(java.util.SortedMap) UIControlEvent(com.twinsoft.convertigo.beans.ngx.components.UIControlEvent) WeakValueHashMap(com.twinsoft.convertigo.engine.util.WeakValueHashMap) MobileComponent(com.twinsoft.convertigo.beans.ngx.components.MobileComponent) UIUseVariable(com.twinsoft.convertigo.beans.ngx.components.UIUseVariable) HashMap(java.util.HashMap) UIActionFailureEvent(com.twinsoft.convertigo.beans.ngx.components.UIActionFailureEvent) ArrayList(java.util.ArrayList) Introspector(java.beans.Introspector) UIDynamicMenuItem(com.twinsoft.convertigo.beans.ngx.components.UIDynamicMenuItem) UIActionStack(com.twinsoft.convertigo.beans.ngx.components.UIActionStack) UIDynamicElement(com.twinsoft.convertigo.beans.ngx.components.UIDynamicElement) BeanInfo(java.beans.BeanInfo) MySimpleBeanInfo(com.twinsoft.convertigo.beans.core.MySimpleBeanInfo) UIEventSubscriber(com.twinsoft.convertigo.beans.ngx.components.UIEventSubscriber) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) Iterator(java.util.Iterator) Engine(com.twinsoft.convertigo.engine.Engine) UIDynamicEmit(com.twinsoft.convertigo.beans.ngx.components.UIDynamicEmit) UIDynamicMenu(com.twinsoft.convertigo.beans.ngx.components.UIDynamicMenu) IAction(com.twinsoft.convertigo.beans.ngx.components.IAction) UIUseShared(com.twinsoft.convertigo.beans.ngx.components.UIUseShared) JSONObject(org.codehaus.jettison.json.JSONObject) JSONArray(org.codehaus.jettison.json.JSONArray) UIText(com.twinsoft.convertigo.beans.ngx.components.UIText) UIActionLoopEvent(com.twinsoft.convertigo.beans.ngx.components.UIActionLoopEvent) UICustom(com.twinsoft.convertigo.beans.ngx.components.UICustom) File(java.io.File) UIActionFinallyEvent(com.twinsoft.convertigo.beans.ngx.components.UIActionFinallyEvent) UIDynamicSwitch(com.twinsoft.convertigo.beans.ngx.components.UIDynamicSwitch) UICompEvent(com.twinsoft.convertigo.beans.ngx.components.UICompEvent) TreeMap(java.util.TreeMap) JSONException(org.codehaus.jettison.json.JSONException) FileUtils(com.twinsoft.convertigo.engine.util.FileUtils) UIComponent(com.twinsoft.convertigo.beans.ngx.components.UIComponent) UIDynamicAttr(com.twinsoft.convertigo.beans.ngx.components.UIDynamicAttr) UIActionErrorEvent(com.twinsoft.convertigo.beans.ngx.components.UIActionErrorEvent) Comparator(java.util.Comparator) Collections(java.util.Collections) UIActionCaseDefaultEvent(com.twinsoft.convertigo.beans.ngx.components.UIActionCaseDefaultEvent) UIActionCaseEvent(com.twinsoft.convertigo.beans.ngx.components.UIActionCaseEvent) UIPageEvent(com.twinsoft.convertigo.beans.ngx.components.UIPageEvent) InputStream(java.io.InputStream) UIDynamicIf(com.twinsoft.convertigo.beans.ngx.components.UIDynamicIf) UIStackVariable(com.twinsoft.convertigo.beans.ngx.components.UIStackVariable) UICompEvent(com.twinsoft.convertigo.beans.ngx.components.UICompEvent) UIPageEvent(com.twinsoft.convertigo.beans.ngx.components.UIPageEvent) UIUseShared(com.twinsoft.convertigo.beans.ngx.components.UIUseShared) BeanInfo(java.beans.BeanInfo) MySimpleBeanInfo(com.twinsoft.convertigo.beans.core.MySimpleBeanInfo) UIControlDirective(com.twinsoft.convertigo.beans.ngx.components.UIControlDirective) UIControlVariable(com.twinsoft.convertigo.beans.ngx.components.UIControlVariable) Comparator(java.util.Comparator) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) UIUseVariable(com.twinsoft.convertigo.beans.ngx.components.UIUseVariable) List(java.util.List) ArrayList(java.util.ArrayList) UIActionFailureEvent(com.twinsoft.convertigo.beans.ngx.components.UIActionFailureEvent) UIComponent(com.twinsoft.convertigo.beans.ngx.components.UIComponent) UIAnimation(com.twinsoft.convertigo.beans.ngx.components.UIAnimation) InvocationTargetException(java.lang.reflect.InvocationTargetException) UIDynamicMenu(com.twinsoft.convertigo.beans.ngx.components.UIDynamicMenu) UIAppGuard(com.twinsoft.convertigo.beans.ngx.components.UIAppGuard) JSONObject(org.codehaus.jettison.json.JSONObject) UIStyle(com.twinsoft.convertigo.beans.ngx.components.UIStyle) UIDynamicMenuItem(com.twinsoft.convertigo.beans.ngx.components.UIDynamicMenuItem) UIActionElseEvent(com.twinsoft.convertigo.beans.ngx.components.UIActionElseEvent) UIElement(com.twinsoft.convertigo.beans.ngx.components.UIElement) UICustom(com.twinsoft.convertigo.beans.ngx.components.UICustom) UIAppEvent(com.twinsoft.convertigo.beans.ngx.components.UIAppEvent) UITheme(com.twinsoft.convertigo.beans.ngx.components.UITheme) UIActionErrorEvent(com.twinsoft.convertigo.beans.ngx.components.UIActionErrorEvent) UIActionCaseDefaultEvent(com.twinsoft.convertigo.beans.ngx.components.UIActionCaseDefaultEvent) UIForm(com.twinsoft.convertigo.beans.ngx.components.UIForm) UIEventSubscriber(com.twinsoft.convertigo.beans.ngx.components.UIEventSubscriber) UIControlEvent(com.twinsoft.convertigo.beans.ngx.components.UIControlEvent) UIText(com.twinsoft.convertigo.beans.ngx.components.UIText) UIActionLoopEvent(com.twinsoft.convertigo.beans.ngx.components.UIActionLoopEvent) ApplicationComponent(com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) UISharedComponent(com.twinsoft.convertigo.beans.ngx.components.UISharedComponent) PageComponent(com.twinsoft.convertigo.beans.ngx.components.PageComponent) UISharedRegularComponent(com.twinsoft.convertigo.beans.ngx.components.UISharedRegularComponent) MobileComponent(com.twinsoft.convertigo.beans.ngx.components.MobileComponent) UIComponent(com.twinsoft.convertigo.beans.ngx.components.UIComponent) UICompVariable(com.twinsoft.convertigo.beans.ngx.components.UICompVariable) PropertyDescriptor(java.beans.PropertyDescriptor) ApplicationComponent(com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) UIStackVariable(com.twinsoft.convertigo.beans.ngx.components.UIStackVariable) IntrospectionException(java.beans.IntrospectionException) InvocationTargetException(java.lang.reflect.InvocationTargetException) JSONException(org.codehaus.jettison.json.JSONException) UIActionStack(com.twinsoft.convertigo.beans.ngx.components.UIActionStack) UIAttribute(com.twinsoft.convertigo.beans.ngx.components.UIAttribute) UIActionCaseEvent(com.twinsoft.convertigo.beans.ngx.components.UIActionCaseEvent) UIActionFinallyEvent(com.twinsoft.convertigo.beans.ngx.components.UIActionFinallyEvent) UICustomAsyncAction(com.twinsoft.convertigo.beans.ngx.components.UICustomAsyncAction) UICustomAction(com.twinsoft.convertigo.beans.ngx.components.UICustomAction) UISharedComponentEvent(com.twinsoft.convertigo.beans.ngx.components.UISharedComponentEvent)

Example 15 with ApplicationComponent

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

the class NgxBuilder method addPage.

private void addPage(PageComponent page) throws EngineException {
    MobileApplication mobileApplication = project.getMobileApplication();
    if (mobileApplication != null) {
        ApplicationComponent application = (ApplicationComponent) mobileApplication.getApplicationComponent();
        if (application != null) {
            writePageSourceFiles(page);
            writeAppSourceFiles(application);
        }
    }
}
Also used : MobileApplication(com.twinsoft.convertigo.beans.core.MobileApplication) ApplicationComponent(com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) IApplicationComponent(com.twinsoft.convertigo.beans.core.IApplicationComponent)

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