|
|
@ -15,6 +15,7 @@ import com.teamdev.jxbrowser.chromium.events.ScriptContextListener; |
|
|
|
import com.teamdev.jxbrowser.engine.Engine; |
|
|
|
import com.teamdev.jxbrowser.engine.Engine; |
|
|
|
import com.teamdev.jxbrowser.engine.EngineOptions; |
|
|
|
import com.teamdev.jxbrowser.engine.EngineOptions; |
|
|
|
import com.teamdev.jxbrowser.engine.RenderingMode; |
|
|
|
import com.teamdev.jxbrowser.engine.RenderingMode; |
|
|
|
|
|
|
|
import com.teamdev.jxbrowser.event.Observer; |
|
|
|
import com.teamdev.jxbrowser.js.JsObject; |
|
|
|
import com.teamdev.jxbrowser.js.JsObject; |
|
|
|
import com.teamdev.jxbrowser.net.Scheme; |
|
|
|
import com.teamdev.jxbrowser.net.Scheme; |
|
|
|
import com.teamdev.jxbrowser.view.swing.BrowserView; |
|
|
|
import com.teamdev.jxbrowser.view.swing.BrowserView; |
|
|
@ -100,7 +101,7 @@ public class NewModernUIPane<T> extends ModernUIPane<T> { |
|
|
|
EngineOptions options; |
|
|
|
EngineOptions options; |
|
|
|
if (scheme != null && requestCallback != null) { |
|
|
|
if (scheme != null && requestCallback != null) { |
|
|
|
options = EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED).addSwitch("--disable-google-traffic").addScheme(scheme, requestCallback).build(); |
|
|
|
options = EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED).addSwitch("--disable-google-traffic").addScheme(scheme, requestCallback).build(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
options = EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED).addSwitch("--disable-google-traffic").build(); |
|
|
|
options = EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED).addSwitch("--disable-google-traffic").build(); |
|
|
|
} |
|
|
|
} |
|
|
|
Engine engine = Engine.newInstance(options); |
|
|
|
Engine engine = Engine.newInstance(options); |
|
|
@ -161,6 +162,29 @@ public class NewModernUIPane<T> extends ModernUIPane<T> { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void disposeBrowser() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (browser != null) { |
|
|
|
|
|
|
|
browser.close(); |
|
|
|
|
|
|
|
browser = null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void clearCache() { |
|
|
|
|
|
|
|
if (browser != null) { |
|
|
|
|
|
|
|
browser.engine().httpCache().clear(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void executeJavaScript(String javaScript) { |
|
|
|
|
|
|
|
if (browser != null) { |
|
|
|
|
|
|
|
browser.mainFrame().ifPresent(frame -> { |
|
|
|
|
|
|
|
frame.executeJavaScript(javaScript); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static class Builder<T> extends ModernUIPane.Builder<T> { |
|
|
|
public static class Builder<T> extends ModernUIPane.Builder<T> { |
|
|
|
|
|
|
|
|
|
|
|
private NewModernUIPane<T> pane = new NewModernUIPane<>(); |
|
|
|
private NewModernUIPane<T> pane = new NewModernUIPane<>(); |
|
|
@ -191,7 +215,7 @@ public class NewModernUIPane<T> extends ModernUIPane<T> { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public NewModernUIPane.Builder<T> withURL(final String url) { |
|
|
|
public NewModernUIPane.Builder<T> withURL(final String url) { |
|
|
|
pane.scheme = Scheme.of("file"); |
|
|
|
pane.scheme = Scheme.of("file"); |
|
|
|
pane.requestCallback = new NxComplexInterceptRequestCallback(null); |
|
|
|
pane.requestCallback = new NxComplexInterceptRequestCallback(null); |
|
|
|
pane.browser.navigation().loadUrl(url); |
|
|
|
pane.browser.navigation().loadUrl(url); |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
@ -301,6 +325,14 @@ public class NewModernUIPane<T> extends ModernUIPane<T> { |
|
|
|
return prepare(callback); |
|
|
|
return prepare(callback); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public ModernUIPane.Builder<T> prepareForV7(Class event, Observer listener) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pane.browser.navigation().on(event, listener); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return this; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public NewModernUIPane<T> build() { |
|
|
|
public NewModernUIPane<T> build() { |
|
|
|
return pane; |
|
|
|
return pane; |
|
|
|