Search in sources :

Example 1 with Element

use of com.teamdev.jxbrowser.dom.Element 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);
    }
    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.mobile.components.UIDynamicElement) UIUseShared(com.twinsoft.convertigo.beans.mobile.components.UIUseShared) WalkHelper(com.twinsoft.convertigo.engine.helpers.WalkHelper) UISharedComponent(com.twinsoft.convertigo.beans.mobile.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.mobile.components.UIActionStack) UIDynamicInvoke(com.twinsoft.convertigo.beans.mobile.components.UIDynamicInvoke) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) DatabaseObjectFoundException(com.twinsoft.convertigo.engine.DatabaseObjectFoundException) CompositeEvent(com.twinsoft.convertigo.eclipse.editors.CompositeEvent) MobileComponent(com.twinsoft.convertigo.beans.mobile.components.MobileComponent)

Example 2 with Element

use of com.teamdev.jxbrowser.dom.Element 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)

Aggregations

Element (com.teamdev.jxbrowser.dom.Element)2 Node (com.teamdev.jxbrowser.dom.Node)2 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)2 CompositeEvent (com.twinsoft.convertigo.eclipse.editors.CompositeEvent)2 DatabaseObjectFoundException (com.twinsoft.convertigo.engine.DatabaseObjectFoundException)2 WalkHelper (com.twinsoft.convertigo.engine.helpers.WalkHelper)2 Matcher (java.util.regex.Matcher)2 JSONException (org.codehaus.jettison.json.JSONException)2 CoreException (org.eclipse.core.runtime.CoreException)2 PartInitException (org.eclipse.ui.PartInitException)2 JsObject (com.teamdev.jxbrowser.js.JsObject)1 MobileComponent (com.twinsoft.convertigo.beans.mobile.components.MobileComponent)1 UIActionStack (com.twinsoft.convertigo.beans.mobile.components.UIActionStack)1 UIDynamicElement (com.twinsoft.convertigo.beans.mobile.components.UIDynamicElement)1 UIDynamicInvoke (com.twinsoft.convertigo.beans.mobile.components.UIDynamicInvoke)1 UISharedComponent (com.twinsoft.convertigo.beans.mobile.components.UISharedComponent)1 UIUseShared (com.twinsoft.convertigo.beans.mobile.components.UIUseShared)1 MobileComponent (com.twinsoft.convertigo.beans.ngx.components.MobileComponent)1 UIActionStack (com.twinsoft.convertigo.beans.ngx.components.UIActionStack)1 UIDynamicElement (com.twinsoft.convertigo.beans.ngx.components.UIDynamicElement)1