This demo program acts as a recipe program and toggles between showing and editing a fully-formatted, rich-text HTML version of a recipe. The program is meant to demonstrate how the new BBjHtmlEdit control can be used to provide a WYSIWYG editor for HTML files similar to popular word processor applications. Much like the BBjHtmlView control, you can get and set the text for the control, presumably based on the contents of a .html file on the disk or text from a database table. The BBjHtmlEdit control is not tied directly to a source, and so the application program is responsible for filling it and saving out any user changes to the content.
The BBjHtmlEdit control also has the ability to get and set plain text, so it's use as an editor extends to text or ASCII files as well.
This demo program runs in both GUI Thin Client and BUI (Browser User Interface). It makes use of a BBjListBox on the left hand side to provide a list of recipes, and the list items are composed of HTML text show that the entries are formatted nicely with various text styles and images. The Java-supplied HTML renderer in GUI isn't as advanced as the BUI version, so the GUI version mostly relies on HTML tags for formatting where the BUI version uses inline styles.
The demo should run well on any GUI or BUI device. The main limiting factor is screen real estate, as the demo requires a reasonably-sized window in order to display the BBjHtmlEdit control and its toolbar fully, along with the recipe list and other controls. It should run fine on a tablet, such as a 1024x768 pixel or better iPad, but won't fit on anything smaller (like a phone) without scrolling. It uses the BBMig Layout Manager to resize and position the controls so that it fits well on the target display, regardless of device orientation.
To see the program in action, click or copy and past the following link into your browser to run it from the BBj BUI Showcase page: https://www.poweredbybbj.com/apps/BBjRecipes. The published version of the demo is slightly different from this version (and the version demonstrated at BASIS TechCon 2015), as the published version won't save out any changes to the recipe files.
This section covers the demo's reliance on external dependencies, such as 3rd Party JARs, Web Services, Developer API keys, and other BBj programs such as utilities, external custom class definitions, and setup programs.
BASIS Utilities:
BBUtils
(for SSL status for Jetty)BBMigPane
(for the BBMig layout manager)Java Libraries:
java.awt.Font
(for custom BBjButton fonts)java.io.File
(for loading the external font file)BBj Programs:
BBjRecipes.createHtmlFiles.src
(CALLed when the Restore Files button is clicked, and is used to build a set of HTML recipe pages based off of an HTML template file and DATA statements)The BBjRecipes.createHtmlFiles.src
program has its own set of dependencies, but it isn't required to run the demo. Its main purpose is to recreate all of the recipes to a known-good state, essentially undoing any user modifications that may have taken place to the recipe HTML files on disk. It relies on a third-party Java library named JSoup to parse the source HTML template file and create the recipe files. In order to run correctly, the JSoup jar file (jsoup-1.8.2.jar
- the latest version when the demo was written) must be added to the classpath. The program provides useful information to this effect in a message box, and the library is a nice addition as it allows you to create/edit/search/replace text and tags in an HTML string via an object-oriented document model.
Other Files:
Third-party JAR Files for Custom BBj or Java code:
Load and run the BBjRecipes.src
program from a BBj interpreter or from the Eclipse IDE after ensuring that the following prerequisites are met:
<BBjHome>/utils/
directory is in your prefix so that the demo program can find and use the distributed BASIS utilities.