Search in sources :

Example 1 with UnsupportedRenderingModeException

use of com.teamdev.jxbrowser.browser.UnsupportedRenderingModeException in project flutter-intellij by flutter.

the class JxBrowserManager method loadClasses.

private void loadClasses(@NotNull String[] fileNames) {
    final List<Path> paths = new ArrayList<>();
    final ClassLoader current = Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
        try {
            for (String fileName : fileNames) {
                assert fileName != null;
                paths.add(Paths.get(getFilePath(fileName)));
            }
            // noinspection ConstantConditions
            fileUtils.loadPaths(this.getClass().getClassLoader(), paths);
        } catch (Exception ex) {
            LOG.info("Failed to load JxBrowser file", ex);
            setStatusFailed(new InstallationFailedReason(FailureType.CLASS_LOAD_FAILED));
            return;
        }
        LOG.info("Loaded JxBrowser files successfully: " + paths);
        try {
            final Class<?> clazz = Class.forName("com.teamdev.jxbrowser.browser.UnsupportedRenderingModeException");
            final Constructor<?> constructor = clazz.getConstructor(RenderingMode.class);
            constructor.newInstance(RenderingMode.HARDWARE_ACCELERATED);
            // noinspection ThrowableNotThrown
            final UnsupportedRenderingModeException test = new UnsupportedRenderingModeException(RenderingMode.HARDWARE_ACCELERATED);
        } catch (NoClassDefFoundError | ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
            LOG.info("Failed to find JxBrowser class: ", e);
            setStatusFailed(new InstallationFailedReason(FailureType.CLASS_NOT_FOUND));
            return;
        }
    } finally {
        Thread.currentThread().setContextClassLoader(current);
    }
    analytics.sendEvent(ANALYTICS_CATEGORY, "installed");
    status.set(JxBrowserStatus.INSTALLED);
    installation.complete(JxBrowserStatus.INSTALLED);
}
Also used : Path(java.nio.file.Path) ArrayList(java.util.ArrayList) TimeoutException(java.util.concurrent.TimeoutException) UnsupportedRenderingModeException(com.teamdev.jxbrowser.browser.UnsupportedRenderingModeException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ExecutionException(java.util.concurrent.ExecutionException) InvocationTargetException(java.lang.reflect.InvocationTargetException) UnsupportedRenderingModeException(com.teamdev.jxbrowser.browser.UnsupportedRenderingModeException)

Aggregations

UnsupportedRenderingModeException (com.teamdev.jxbrowser.browser.UnsupportedRenderingModeException)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1