Search in sources :

Example 1 with MobileComponent

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

the class ApplicationComponentEditor method highlightPoint.

private void highlightPoint(int x, int y) {
    Node node = browser.mainFrame().get().inspect(x, y).node().get();
    while (!(node == null || node instanceof Element)) {
        node = node.parent().orElse(null);
    }
    Object shadowHost = c8oBrowser.executeFunctionAndReturnValue("_c8o_getShadowHost", node);
    if (shadowHost != null && shadowHost instanceof Element) {
        node = (Element) shadowHost;
    }
    while (node != null) {
        Element element = (Element) node;
        if (element.equals(exHighlightElement)) {
            return;
        }
        exHighlightElement = element;
        String classes = element.attributeValue("class");
        Matcher mPriority = pPriority.matcher(classes);
        if (mPriority.find()) {
            try {
                node = null;
                long priority = Long.parseLong(mPriority.group(1));
                new WalkHelper() {

                    @Override
                    protected void walk(DatabaseObject databaseObject) throws Exception {
                        if (databaseObject instanceof UIUseShared) {
                            UISharedComponent uisc = ((UIUseShared) databaseObject).getTargetSharedComponent();
                            if (uisc != null) {
                                databaseObject = uisc;
                            }
                        } else if (databaseObject instanceof UIDynamicInvoke) {
                            UIDynamicInvoke uidi = (UIDynamicInvoke) databaseObject;
                            UIActionStack uisa = uidi.getTargetSharedAction();
                            if (uisa != null) {
                                if (!uidi.isRecursive()) {
                                    databaseObject = uisa;
                                }
                            }
                        }
                        if (databaseObject.priority == priority) {
                            throw new DatabaseObjectFoundException(databaseObject);
                        }
                        super.walk(databaseObject);
                    }
                }.init(applicationEditorInput.application);
            } catch (DatabaseObjectFoundException e) {
                DatabaseObject databaseObject = e.getDatabaseObject();
                c8oBrowser.getDisplay().asyncExec(() -> ConvertigoPlugin.getDefault().getProjectExplorerView().objectSelected(new CompositeEvent(databaseObject)));
                if (databaseObject instanceof MobileComponent && !databaseObject.equals(exHighlightMobileComponent)) {
                    highlightComponent(exHighlightMobileComponent = (MobileComponent) databaseObject, false);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else {
            node = node.parent().orElse(null);
            while (!(node == null || node instanceof Element)) {
                node = node.parent().orElse(null);
            }
        }
    }
}
Also used : Matcher(java.util.regex.Matcher) Node(com.teamdev.jxbrowser.dom.Node) Element(com.teamdev.jxbrowser.dom.Element) UIDynamicElement(com.twinsoft.convertigo.beans.ngx.components.UIDynamicElement) UIUseShared(com.twinsoft.convertigo.beans.ngx.components.UIUseShared) WalkHelper(com.twinsoft.convertigo.engine.helpers.WalkHelper) UISharedComponent(com.twinsoft.convertigo.beans.ngx.components.UISharedComponent) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) DatabaseObjectFoundException(com.twinsoft.convertigo.engine.DatabaseObjectFoundException) JSONException(org.codehaus.jettison.json.JSONException) UIActionStack(com.twinsoft.convertigo.beans.ngx.components.UIActionStack) UIDynamicInvoke(com.twinsoft.convertigo.beans.ngx.components.UIDynamicInvoke) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) JSONObject(org.codehaus.jettison.json.JSONObject) JsObject(com.teamdev.jxbrowser.js.JsObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectFoundException(com.twinsoft.convertigo.engine.DatabaseObjectFoundException) CompositeEvent(com.twinsoft.convertigo.eclipse.editors.CompositeEvent) MobileComponent(com.twinsoft.convertigo.beans.ngx.components.MobileComponent)

Example 2 with MobileComponent

use of com.twinsoft.convertigo.beans.ngx.components.MobileComponent 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());
            }
        }
        Document doc = browser.mainFrame().get().document().get();
        MobileComponent mc = mobileComponent;
        if (mc instanceof UIUseShared) {
            UISharedComponent uisc = ((UIUseShared) mc).getTargetSharedComponent();
            if (uisc != null) {
                try {
                    mc = uisc.getUIComponentList().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)

Example 3 with MobileComponent

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

the class NgxComponentTreeObject method closeAllEditors.

public void closeAllEditors(boolean save) {
    MobileComponent mc = getObject();
    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(mc) || ((ComponentFileEditorInput) editorInput).isChildOf(mc)) {
                        activePage.closeEditor(editorRef.getEditor(false), save);
                    }
                }
            } catch (Exception e) {
            }
        }
    }
}
Also used : IEditorReference(org.eclipse.ui.IEditorReference) ComponentFileEditorInput(com.twinsoft.convertigo.eclipse.editors.ngx.ComponentFileEditorInput) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorInput(org.eclipse.ui.IEditorInput) MobileComponent(com.twinsoft.convertigo.beans.ngx.components.MobileComponent)

Example 4 with MobileComponent

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

the class NgxPickerContentProvider method getChildren.

@Override
public Object[] getChildren(Object parentElement) {
    if (parentElement instanceof TVObject) {
        return ((TVObject) parentElement).children.toArray();
    } else if (parentElement instanceof MobileComponent) {
        MobileComponent mobileComponent = (MobileComponent) parentElement;
        Project project = mobileComponent.getProject();
        ProjectExplorerView projectExplorerView = ConvertigoPlugin.getDefault().getProjectExplorerView();
        List<String> projectNames = Engine.theApp.databaseObjectsManager.getAllProjectNamesList();
        Map<String, Set<String>> map = mobileComponent.getApplication().getInfoMap();
        TVObject root = new TVObject("root", mobileComponent, null);
        if (filter.equals(Filter.Action)) {
            TVObject tvi = root.add(new TVObject("actions"));
            TVObject tvEvents = tvi.add(new TVObject("events"));
            TVObject tvControls = tvi.add(new TVObject("controls"));
            addActions(tvi, mobileComponent);
            if (tvEvents.isEmpty()) {
                tvi.remove(tvEvents);
            }
            if (tvControls.isEmpty()) {
                tvi.remove(tvControls);
            }
        }
        if (filter.equals(Filter.Shared)) {
            TVObject tvi = root.add(new TVObject("shared"));
            addSharedComponents(tvi, mobileComponent);
        }
        if (filter.equals(Filter.Sequence)) {
            TVObject tvs = root.add(new TVObject("sequences"));
            for (String projectName : projectNames) {
                try {
                    Project p = projectExplorerView.getProject(projectName);
                    boolean isReferenced = !p.getName().equals(project.getName());
                    addSequences(map, tvs, isReferenced ? p : project, isReferenced);
                } catch (Exception e) {
                }
            }
        }
        if (filter.equals(Filter.Database)) {
            TVObject tvd = root.add(new TVObject("databases"));
            for (String projectName : projectNames) {
                try {
                    Project p = projectExplorerView.getProject(projectName);
                    boolean isReferenced = !p.getName().equals(project.getName());
                    addFsObjects(map, tvd, isReferenced ? p : project, isReferenced);
                } catch (Exception e) {
                }
            }
        }
        if (filter.equals(Filter.Iteration)) {
            TVObject tvi = root.add(new TVObject("iterations"));
            addIterations(tvi, mobileComponent);
        }
        if (filter.equals(Filter.Form)) {
            TVObject tvi = root.add(new TVObject("forms"));
            addForms(tvi, mobileComponent);
        }
        if (filter.equals(Filter.Global)) {
            TVObject tvi = root.add(new TVObject("globals"));
            addGlobals(tvi, mobileComponent.getApplication());
        }
        return root.children.toArray();
    } else if (parentElement instanceof JSONObject) {
        JSONObject jsonObject = (JSONObject) parentElement;
        TVObject root = new TVObject("root", jsonObject, null);
        addJsonObjects(root);
        return root.children.toArray();
    }
    return new Object[0];
}
Also used : Project(com.twinsoft.convertigo.beans.core.Project) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) JSONObject(org.codehaus.jettison.json.JSONObject) ArrayList(java.util.ArrayList) List(java.util.List) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) JSONObject(org.codehaus.jettison.json.JSONObject) HashMap(java.util.HashMap) Map(java.util.Map) JSONException(org.codehaus.jettison.json.JSONException) MobileComponent(com.twinsoft.convertigo.beans.ngx.components.MobileComponent)

Aggregations

MobileComponent (com.twinsoft.convertigo.beans.ngx.components.MobileComponent)4 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)3 UISharedComponent (com.twinsoft.convertigo.beans.ngx.components.UISharedComponent)2 UIUseShared (com.twinsoft.convertigo.beans.ngx.components.UIUseShared)2 JSONException (org.codehaus.jettison.json.JSONException)2 JSONObject (org.codehaus.jettison.json.JSONObject)2 Document (com.teamdev.jxbrowser.dom.Document)1 Element (com.teamdev.jxbrowser.dom.Element)1 Node (com.teamdev.jxbrowser.dom.Node)1 JsObject (com.teamdev.jxbrowser.js.JsObject)1 Project (com.twinsoft.convertigo.beans.core.Project)1 PageComponent (com.twinsoft.convertigo.beans.ngx.components.PageComponent)1 UIActionStack (com.twinsoft.convertigo.beans.ngx.components.UIActionStack)1 UIComponent (com.twinsoft.convertigo.beans.ngx.components.UIComponent)1 UIDynamicElement (com.twinsoft.convertigo.beans.ngx.components.UIDynamicElement)1 UIDynamicInvoke (com.twinsoft.convertigo.beans.ngx.components.UIDynamicInvoke)1 CompositeEvent (com.twinsoft.convertigo.eclipse.editors.CompositeEvent)1 ComponentFileEditorInput (com.twinsoft.convertigo.eclipse.editors.ngx.ComponentFileEditorInput)1 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)1 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)1