-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Although this is a maven project, the only supported way to build a release is by using IntelliJ IDEA as the pom.xml does not provide a packaging goal yet. All relevant IntelliJ configuration files are shared in the git repository including two artifact defintions, one for the binary and one for the sources.
But even without pre-defined configurations (e.g. in Eclipse) building the code is pretty straightforward as all required libraries are shared in git. One just has to declare source, resource, and lib folder (standard maven paths). Currently the SWT binary is not included in the JAR file by choice to let the user choose the used version.
The main public interface is IBrowser, which has a few extensions. This interface encapsulates roughly the following functionality in different variants:
- Loading a URL.
- Checking the loading state or waiting for a specific Javascript condition to be true.
- Injecting and executing Javascript and CSS code; the difference is that injected code persists and may be called from the website itself.
- Some utility methods for querying and setting parts of the HTML's DOM.
- Methods concerning the display and management of the wrapped browser, like
setSize(),runOnDisposal(Runnable), orsetFocus().
Currently, there are three extensions. IJQueryBrowser and IBootstrapBrowser inject the JQuery and the Bootstrap library into a website, respectively. They also provide additional methods to the browser interface, which have not been tested in detail yet.
IEventCatchBrowser supports the registration of listeners for events in the website, such as the hovering of links. Currently, this functionality is separated from the interface hierachy as those methods were not needed and made some trouble. However, there is no major problem and it could be included again if needed.
The extension mechanism itself probably requires some re-work (see Issue 2)

Browser implements the public API. The actual implementation is partitioned into the Browser and InternalBrowserWrapper. The idea behind this is that the InternalBrowserWrapper just adds the minimally required functionality to the wrapped browser, basically delayed method execution, while the Browser calls the methods of the InternalBrowserWrapper to provide a rich interface with a choice between different parameters. The actual (wrapped) browser is hidden behind the IWrappedBrowser interface so that the used one can be switched.
As a switch of the browser is likely, all SWT related functionality has been extracted to form a parallel class hierachy.

SWTBrowser is an SWT Composite and thus multiple inheritance is emulated. The SWTBrowser does not have to be an Composite so that this structured can be simplified later on.
As all toolkit-specific stuff has been separated there are only three interfaces to be implemented.
There are already experimental implementation for the JavaFX browser and the JxBrowser in two branches (javafx and jxbrowser). These existing implementations should give a pretty good idea how they should be completed. As JavaFX requires to be compiled with Java 8 and JxBrowser demands a licence.jar it may require small manual steps to get the branches running. Download the necessary files for the JxBrowser from its homepage.
IWrappedBrowser abstracts the browser itself. As is oriented on the SWT browser interface it is somewhat tricky to implement it for the JavaFX browser, but it can be adapated. The JxBrowser has a similar interface as the SWT browser.
Each Browser originates from a different GUI toolkit (SWT, Swing, and JavaFX) and each toolkit uses a different UI thread (EDT). As a result, the UIExecutor interface as to be implemented accordingly.
A browser function makes Java code callable from Javascript. Each browser has a different implementation of those browser functions, but the only method that has to be wrapped is dispose().
As a last step, a factory method for the creation has to be written, this method has to supply all three implementation classes to the InternalBrowserWrapper. The current implementation have this method in the SWTBrowser, JavaFxBrowser, and JxBrowser, which decorate the Browser class. At the moment these decorations are minimal so that nearly all calls are simply delegated to the Browser.



