use of com.teamdev.jxbrowser.dom.Document 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 + "');");
});
}
use of com.teamdev.jxbrowser.dom.Document in project JxBrowser-Examples by TeamDev-IP.
the class XPath method main.
public static void main(String[] args) {
Engine engine = Engine.newInstance(OFF_SCREEN);
Browser browser = engine.newBrowser();
SwingUtilities.invokeLater(() -> {
BrowserView view = BrowserView.newInstance(browser);
JFrame frame = new JFrame("Evaluate XPath");
frame.getContentPane().add(view, BorderLayout.CENTER);
frame.setSize(800, 600);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
});
Navigation navigation = browser.navigation();
navigation.on(FrameLoadFinished.class, event -> event.frame().document().flatMap(Document::documentElement).ifPresent(element -> {
try {
XPathResult result = element.evaluate("count(//div)");
if (result.isNumber()) {
System.out.println("Result: " + result.asNumber());
}
} catch (XPathException e) {
System.out.println(e.getMessage());
}
}));
navigation.loadUrl("https://www.teamdev.com/jxbrowser");
}
Aggregations