Search in sources :

Example 11 with UIUseShared

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

the class ApplicationComponentEditor method highlightPoint.

private void highlightPoint(int x, int y) {
    x = c8oBrowser.fixDPI(x);
    y = c8oBrowser.fixDPI(y);
    Node node = browser.mainFrame().get().inspect(x, y).node().orElse(null);
    while (!(node == null || node instanceof Element)) {
        node = node.parent().orElse(null);
    }
    if (node == null) {
        return;
    }
    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 UISharedComponent) {
                            UISharedComponent uisc = (UISharedComponent) databaseObject;
                            if (uisc != null) {
                                databaseObject = uisc;
                            }
                        } else 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();
                if (databaseObject instanceof MobileComponent && !databaseObject.equals(exHighlightMobileComponent)) {
                    if (dragStartMobileComponent != null) {
                        DatabaseObject ancestor = databaseObject;
                        while (dragStartMobileComponent != ancestor && ancestor != null) {
                            ancestor = ancestor.getParent();
                        }
                        if (dragStartMobileComponent == ancestor) {
                            return;
                        }
                    }
                    c8oBrowser.getDisplay().asyncExec(() -> ConvertigoPlugin.getDefault().getProjectExplorerView().objectSelected(new CompositeEvent(databaseObject)));
                    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 12 with UIUseShared

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

Example 13 with UIUseShared

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

the class SharedComponentWizard method createUseShared.

private UIUseShared createUseShared(String qname) throws Exception {
    UIUseShared uius = new UIUseShared();
    uius.setSharedComponentQName(qname);
    uius.hasChanged = true;
    uius.bNew = true;
    for (String name : dlg_map.keySet()) {
        String value = ovarMap.get(name).keySet().iterator().next();
        uius.add(createUseVariable(dlg_map.get(name), value));
    }
    UIComponent uic = (UIComponent) getLastInList();
    MobileComponent mc = (MobileComponent) uic.getParent();
    if (mc instanceof ApplicationComponent) {
        ApplicationComponent parent = (ApplicationComponent) mc;
        parent.add((DatabaseObject) uius, uic.priority);
    } else if (mc instanceof PageComponent) {
        PageComponent parent = (PageComponent) mc;
        parent.add((DatabaseObject) uius, uic.priority);
    } else if (mc instanceof UIComponent) {
        UIComponent parent = (UIComponent) mc;
        parent.add((DatabaseObject) uius, uic.priority);
    }
    return uius;
}
Also used : ApplicationComponent(com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) UIUseShared(com.twinsoft.convertigo.beans.ngx.components.UIUseShared) UIComponent(com.twinsoft.convertigo.beans.ngx.components.UIComponent) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) PageComponent(com.twinsoft.convertigo.beans.ngx.components.PageComponent) MobileComponent(com.twinsoft.convertigo.beans.ngx.components.MobileComponent)

Aggregations

DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)13 UIUseShared (com.twinsoft.convertigo.beans.ngx.components.UIUseShared)13 UISharedComponent (com.twinsoft.convertigo.beans.ngx.components.UISharedComponent)9 EngineException (com.twinsoft.convertigo.engine.EngineException)8 PageComponent (com.twinsoft.convertigo.beans.ngx.components.PageComponent)7 UIComponent (com.twinsoft.convertigo.beans.ngx.components.UIComponent)7 UIActionStack (com.twinsoft.convertigo.beans.ngx.components.UIActionStack)6 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)6 ApplicationComponent (com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent)5 CoreException (org.eclipse.core.runtime.CoreException)5 MobileComponent (com.twinsoft.convertigo.beans.ngx.components.MobileComponent)4 UIDynamicAction (com.twinsoft.convertigo.beans.ngx.components.UIDynamicAction)4 UIDynamicInvoke (com.twinsoft.convertigo.beans.ngx.components.UIDynamicInvoke)4 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 MobileSmartSourceType (com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType)3 UICompEvent (com.twinsoft.convertigo.beans.ngx.components.UICompEvent)3 UICompVariable (com.twinsoft.convertigo.beans.ngx.components.UICompVariable)3 IonBean (com.twinsoft.convertigo.beans.ngx.components.dynamic.IonBean)3 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)3