Luxor: The "Linux Kernel" for Desktop Apps
Uniting XUL, SVG, HTML, Velocity, Web Start, XSL/T, Python and more
Gerald Bauer (Chairmain, CEO, CFO and CTO of Me, Myself & I, Inc.)
Vancouver XML Developers Association (VanX) Talk, July 2002
Table of Contents
Luxor Overview
Who is this guy?
- Gerald Bauer
- independent Java, XML and Web consultant and
open-source advocate
- open-sourced Rachel (Resource Loading
Toolkit for Web Start/JNLP) and Luxor (Java XML User Interface Toolkit)
- develops Venus Application Publisher (Vamp) for Java Web Start/JNLP tool collection
- maintains Unofficial Java Web Start/JNLP FAQ
Agenda - The Road Ahead
- XUL and Rich Desktop Apps
- XUL Motors
- XUL Architecture and Samples
- Luxor XUL Design and Philosophy
- Hello Web Start - Single-Click App Launcher
- Books, Links
What is XUL?
- famous Argentinean poet - Alexandro Xul Solar (1887-1963)
- visit the Museo Xul Solar in Buenos Aires
- Ghostbuster movie character
-
|X|ML |U|ser Interface |L|anguage
- xul is pronounced "zool" - rhymes with cool
- xul is cool
XUL Vision
make building cross-platform user interfaces as easy as building web pages
-> no hard-coded, os-specific, toolkit-specific user interfaces (e.g. MFC, WindopeForms, Swing, Gtk+, etc.)
-> the answer is not yet another GUI API
use XML tags to create UIs for rich desktop apps
XUL Tag Sampling
Box Tags:
<box>
,
<hbox>
,
<vbox>
,
<groupbox>
,
<caption>
Grid Tags:
<grid>
,
<columns>
,
<column>
,
<rows>
,
<row>
Table Tags:
<table>
,
<tr>
,
<td>
Tab Box Tags:
<tabbox>
,
<tabs>
,
<tab>
,
<tabpanels>
,
<tabpanel>
Widget Tags:
<button>
,
<checkbox>
,
<choice>
,
<label>
,
<spacer>
,
<text>
,
<image>
,
<gadget>
Menu Tags:
<menubar>
,
<menu>
,
<menuref>
,
<menitem>
,
<displayurl>
Data Tags:
<list>
,
<map>
,
<entry>
Portal Tags:
<portal>
,
<portlet>
And Much More
First Impression - Xul In Action - Toolbar Example
|
<xul>
<toolbar id="MAIN">
<toolbarbutton command="COPY_FORM"
label="Copy Form"
icon="COPY_FORM"
tooltip="Copy Form Data To Clipboard"
accesskey="C" />
<toolbarbutton command="PASTE_FORM"
label="Paste Form"
icon="PASTE_FORM"
tooltip="Paste Form Data From Clipboard; Auto-Fill"
accesskey="P" />
</toolbar>
</xul>
|
|
What is a Rich Desktop App? Mind Your Language
Synonyms
- Rich Desktop App
- Rich Internet App
- (Super) Rich Client
- Thick Client (derog,dated) (!)
- Fat Client (derog,dated) (!)
- Obese Client (derog,dated) (!)
(!) taboo word likely to shock and best avoided
Why Xul? Isn't Dynamic HTML (aka HTML, DOM, JavaScript) enough?
- rich user experience (interactivity, drag'n'drop, editing, high-end graphics, multi-tasking (threads))
- nomadic use; offline access
- load balancing (fast desktop CPUs are everywhere; desktop handles some computation)
- responsiveness (avoid excessive server roundtrips)
Excurs: What's wrong with Applets for rich zero-admin desktop apps?
- Dependent on browser's Java runtime (JVM)
- Applet is bound to Web page
- No shared jars (libraries)
- No offline startup-up
- No desktop integration (startup without browser through desktop icon or startup menu entry)
- No CD installer
- No native libs
- Requires Java in browser
- Applets = Mini App
- And More
Beyond DHTML/Javascript: Inside a Rich Desktop App
- Built-in HTML Browser
- Built-in HTTP Server
- Built-in Template Engine
- Built-in Portal Engine
- Built-in Scripting Engine
- Built-in XUL Motor
- Built-in Download/Upload Manager
- Built-in Bookmark/History Manager
- Themes, Skins and Look & Feels
- Zero-Admin, Zero-Touch, Zero-Hassle (Single-Click Install, Auto Upgrade, Always-Up-To-Date)
- And Much More
Real World Desktop App Example
Venus Application Publisher (Vamp)
Component | Provider |
HTML Browser | Swing JEditorPane |
HTTP Server | Rachel (Open-Source, Ultra-Light Weight, Multi-Threaded HTTP Server) |
Template Engine | Apache Velocity, XSL-T |
Portal Engine | Luxor (Porlet API, Portal Markup) |
XUL Motor | Luxor (Nile) |
Scripting Engine | Jython (Python) |
SVG 2D Graphics | Apache Batik |
Download/Upload Manager | Homegrown (Upcoming) |
Bookmark/History Manager | Homegrown (Upcoming) |
Themes, Skins, Look & Feels |
CSS, Skin L&F, Kunststoff L&F, Oyoaha L&F |
Zero-Admin, Zero-Hassle, Always Up-To-Date | Web Start (Single-Click Magic) |
Xul Motors: The Big Three
Mozilla
-
Xul Granddaddy; runs on Mac OS, Linux, Solaris, FreeBSD, Irix, BeOS, HPUX, OS/2, BSD, and more
Luxor
-
Xul toolkit includes web server, portal engine, template engine, scripting interpreter and more
XML Windowing Toolkit (XWT)
-
Xul "Lite"; available as self-installing ActiveX browser plug-in
More Xul Motors: The Minor League
-
GUI Builder
- Peter Köker's GUI Builder
builds Swing apps from a Xul dialect dubbed "GUI Design Language" (GDL)
and supports scripting in Pnuts.
GUI Builder also includes a JavaDoc-like tool dubbed GuiDoc
that automatically creates HTML documentation from Xul files
(source available under the GNU Lesser Public License) -
-
Xybrix
- Jim Wissner's Xybrix
builds Swing apps dressed up in Kunststoff L&F from a Xul dialect
that includes XForms support (source available under an MIT License)
-
Thinlets
- a Xul motor packed into a 24 k jar runs Java 1.1 applet oldies
-
Proto
- Pierre Morel's Proto, a Xul forerunner,
builds Swing apps from XML descriptions and supports scripting in
Javascript or Tcl (frozen since 1999)
- and many more (XwingML, eNode Xalt, GNU Enterprise Forms, Harmonia UI-ML, Netspedition Zulu, Nexaweb and so on)
The Late HP Bluestone's XwingML - Failed Early XUL Attempt
-
HP's Bluestone XwingML, a early XUL dialect,
dumps the state of a GUI tree 1:1 in XML. No value added.
HP pulled XwingML and it's no longer with us.
Example:
<XwingML>
<JFrame name="MainFrame" title="Bluestone XMLEdit" image="icon.gif" x="10%" y="10%" width="80%" height="80%">
<JMenuBar>
<JMenu text="File" mnemonic="F">
<JMenuItem icon="open.gif" text="Open..." mnemonic="O" accelerator="VK_O,CTRL_MASK" actionListener="OpenFile"/>
<JMenuItem icon="save.gif" text="Save" mnemonic="S" accelerator="VK_S,CTRL_MASK" actionCommand="save" actionListener="SaveFile"/>
...
<JTabbedPane>
<Tab title="XML">
<JScrollPane>
<JTextArea name="EditorArea" tabSize="3" fontName="Monospaced" fontSize="14"/>
</JScrollPane>
</Tab>
<Tab title="DOM">
<JScrollPane>
<JTree name="DocumentTree" className="DOMTree">
</JTree>
</JScrollPane>
</Tab>
</JTabbedPane>
</JSplitPane>
</JFrame>
</XwingML>
|
Sun Java Bean Persistance - Java Rules, XML is not for Humans
- XUL markup is designed like HTML for
speed-coding in a plain-vanilla text editor.
- You don't need a GUI designer to untangle the unreadable haystack dumped using Java Bean Persistance.
Swing XML Java Bean Persistance Haystack:
<object class="javax.swing.JPanel">
<void method="add">
<object id="button1" class="javax.swing.JButton"/>
</void>
<void method="add">
<object class="javax.swing.JLabel">
<void method="setLabelFor">
<object idref="button1"/>
</void>
</object>
</void>
</object>
|
Java Swing Hard-Core Version:
JPanel panel1 = new JPanel();
JButton button1 = new JButton();
JLabel label1 = new JLabel();
panel1.add(button1);
panel1.add(label1);
label1.setLabelFor(button1);
|
XUL Contestant:
<hbox>
<button id="button1" />
<label for="button1" />
</hbox>
|
And the winner is... Do I need to comment?
XUL Architecture - Beyond Hairballs and Spaghetti Code
Break UI into Four Parts
-
Content: structure and description of UI elements (use XUL)
-
Appearance: look & feel, skins, themes specify appearance of UI (use CSS2, GTK/KDE themes, etc.)
-
Behavior: specified in Java or Python
-
Locale: localization information for internationalization (possible use of XUL)
Xul Apps: Proof of the Pudding
Mozilla XUL World Wonder:
Komodo / Active State
- Dev Studio for Perl, Python, XSL-T and more
Menu Example
|
<xul>
<menubar id="MAIN">
<menu id="View" label="View" accesskey="V">
<menuitem id="ResetTransform"
label="Initial View"
icon="BLANK"
accesskey="T"
key="ResetTransform"
command="ResetTransformAction" />
<menuitem id="ZoomIn"
label="Zoom In"
icon="ZOOMIN"
accesskey="I"
key="ZoomIn"
command="ZoomInAction" />
<menuitem id="ZoomOut"
label="Zoom Out"
icon="ZOOMOUT"
accesskey="O"
key="ZoomOut"
command="ZoomOutAction" />
<menuseparator/>
<menuref id="UseStylesheet" label="Use Stylesheet" icon="BLANK" />
<menuseparator/>
<menuitem id="PreviousTransform"
label="Previous Transform"
icon="BLANK"
accesskey="P"
key="PreviousTransform"
command="PreviousTransformAction" />
<menuitem id="NextTransform"
label="Next Transform"
icon="BLANK"
accesskey="N"
key="NextTransform"
command="NextTransformAction" />
<menuitem id="SetTransform"
label="Transform"
icon="BLANK"
accesskey="S"
key="SetTransform"
command="SetTransformAction" />
<menuseparator/>
<menuitem id="ThumbnailDialog"
label="Thumbnail"
icon="BLANK"
accesskey="M"
key="ThumbnailDialog"
command="ThumbnailDialogAction" />
<menuitem id="ViewSource"
label="View Source"
icon="SOURCE"
accesskey="V"
key="ViewSource"
command="ViewSourceAction" />
</menu>
</menubar>
</xul>
|
|
Menu Example Continued: Icons and Shortcuts
<xul>
<icon id="BLANK" ref="images/16x16/blank.gif" />
<icon id="ZOOMIN" ref="images/16x16/zoomin.gif" />
<icon id="ZOOMOUT" ref="images/16x16/zoomout.gif" />
<icon id="SOURCE" ref="images/16x16/source.gif" />
<keyset>
<key id="ResetTransform" modifiers="control" key="T" />
<key id="ZoomIn" modifiers="control" key="I" />
<key id="ZoomOut" modifiers="control" key="O" />
<key id="PreviousTransform" modifiers="control" key="K" />
<key id="NextTransform" modifiers="control" key="L" />
<key id="SetTransform" modifiers="control" key="S" />
<key id="ThumbnailDialog" modifiers="control" key="Y" />
<key id="ViewSource" modifiers="control" key="U" />
</keyset>
</xul>
|
Menu Example Benefits: XUL vs Java
XML Version:
<menuitem id="ZoomIn"
label="Zoom In" icon="ZOOMIN" accesskey="I"
key="ZoomIn" command="ZoomInAction" />
|
Java Version:
JMenuItem mi = new JMenuItem( "Zoom In" );
mi.addActionListener( cmdZoomIn );
mi.setMnemonic( 'I' );
mi.setAccelerator( KeyStroke.getKeyStroke( "control I" ) );
mi.setIcon( new ImageIcon( "images/16x16/zoomin.gif" ) );
|
DisplayURL Menu Example
|
<menu id="help" label="Help" accesskey="H">
<displayurl label="Venus Application Publisher Home Page"
url="http://www.vamphq.com"
icon="BLANK_ICON" />
<displayurl label="Venus Application Publisher Discussion Forum"
url="http://groups.yahoo.com/group/vamp-user"
icon="BLANK_ICON" />
<displayurl label="Frequently Asked Questions (FAQ)"
url="http://www.vamphq.com/faq.html"
icon="BLANK_ICON" />
<menuseparator/>
<displayurl label="Java Web Start Home Page"
url="http://java.sun.com/products/javawebstart"
icon="BLANK_ICON" />
<displayurl label="Java Web Start Discussion Forum"
url="http://forum.java.sun.com/forum.jsp?forum=38"
icon="BLANK_ICON" />
<displayurl label="Java Web Start FAQ"
url="http://java.sun.com/products/javawebstart/faq.html"
icon="BLANK_ICON" />
<menuseparator/>
<menuitem command="about"
label="About..." icon="ABOUT_ICON" />
</menu>
|
|
Target Attribute - Display in Built-In or Household Browser
- Built-in - page displayed in built-in HTML browser widget
- Household (default) - page displayed in free-standing household browser (e.g. Mozilla, Opera, Konqueror)
Choice Example
<list id="card">
<entry value="American Express" />
<entry value="Discover" />
<entry value="Master Card" />
<entry value="Visa" />
</list>
|
|
|
<vbox>
<label value="Choose a method of payment:" />
<choice list="card" />
</vbox>
<vbox>
<label value="Choose a method of payment:" />
<choice list="card" type="radio" />
</vbox>
|
|
Multiple Choice Example
<list id="activity">
<entry value="Aerobics" />
<entry value="Aikido" />
<entry value="Basketball" />
<entry value="Bicycling" />
<entry value="Golfing" />
<entry value="Hiking" />
</list>
|
|
|
<vbox>
<label value="Choose the activities you enjoy:" />
<mchoice list="activity" />
</vbox>
<vbox>
<label value="Choose the activities you enjoy:" />
<mchoice list="activity" type="list" />
</vbox>
|
|
Box Layout Example
<list id="radio">
<entry value="Mocha" />
<entry value="Espresso" />
<entry value="Cappucino" />
</list>
|
|
|
<vbox>
<hbox>
<label value="Text field:" />
<text id="name" value="Xul Rocks" cols="40" />
</hbox>
<hbox>
<label value="Text area:" />
<textarea rows="3" cols="20" />
<label value="Password:" />
<password cols="10" value="secrect" />
</hbox>
<hbox>
<label value="Radio buttons:" />
<choice list="radio" type="radio" />
</hbox>
<hbox>
<label value="Check boxes:" />
<checkbox label="Cream" />
<checkbox label="Sugar" />
<checkbox label="Milk" />
<checkbox label="Chocolate" />
</hbox>
</vbox>
|
|
Portal Example
<portal id="select-icon">
<portlet id="head"/>
<div align="center">
<table border="0" width="90%" cellspacing="0" cellpadding="0">
<tr><td>
<portlet id="user-banner" />
<portlet id="title"/>
<portlet id="directory-breadcrumb" />
<portlet id="icon-file-list" />
<portlet id="directory-list" />
<portlet id="file-root-list" />
</td></tr>
</table>
</div>
</portal>
|
|
|
Luxor Xul Design Principles - Freedom, Choice, Excellence
-
Reuse, Reuse, Reuse.
Build on existing infrastructure.
Don't reinvent the wheel, the tooth brush or the alphabet.
- No hidden agenda. No backdoor. No lock-in.
- No sacred cows. Cut the crap. No bullshit. Clean it up, Mr. Fix.
- No kings or queens. Everyone is welcome. Working code beats know-it-all blabber.
- Release early. Release often. No big bang and design behind closed door
a la Billy Boy and the Yes-man brigade.
- Modul-mania. Extensible. Embeddable.
Five Freedoms - Xul Charter
- Freedom to Choose Your Runtime - Java, Mono, C/C++
- Freedom to Choose Your GUI Designer -
- Freedom to Choose Your GUI Toolkit - Swing, SWT, Gtk#, Qt
- Freedom to Choose Your Scripting Language - Python, Perl, Tcl
- Freedom to Choose Your Programming Language - Java, C#, Shark
Luxor Combos - Pick and Choose
Runtime, Language / GUI Toolkit / Scripting
- Java / Swing / Jython
- Java / SWT / Jython
- Mono C# / Gnome Gtk# / Python.Njet
- C,C++ / Qt,Gtk+ / CPython
Walled Garden Deja Vu - The HTML Story Repeats Itself with XUL
Vendors push their own rich desktop app APIs
hoping to lock-in a horde of suckers
- Micropoly pushes Windope Forms
- Sun pushes Swing (known as Java Foundation Classes/JFC)
- IBM pushes "Standard" Widget Toolkit (SWT)
- Trolltech pushes Qt
- Micromedia pushes Flash
- and so on
Who is pushing Xul? How about you? Join the Free World.
XML is not ... / The "Golden Hammer" Fallacy
Golden Hammer - When you have a hammer in your hand, everything starts to look like a
nail.
Don't get swamped away in the XML craze.
XML has limits and is not the magic bullet that will solve
everything from world hunger, to peace in the Middle East
to folding your laundry and cleaning your carpet.
- XML is not a scripting language --> choose Python
- XML is not a heavy-duty programming language --> choose Java, C#, Shark
- XML is not a style-sheet language --> choose CSS
What's wrong with Javascript? Javascript vs. Python
Python's "object-based" subset is roughly equivalent to JavaScript.
Like JavaScript (and unlike Java), Python supports a programming style
that uses simple functions and variables without engaging in class definitions.
However, for JavaScript, that's all there is.
Python, on the other hand, supports writing much larger programs and better code reuse
through a true object-oriented programming style, where classes and inheritance play an important role.
-- Guido van Rossum
Javascript's syntax is too complicated for casual use: Curly brackets, semicolons, and more
Summary: Javascript is too hard for beginners and too impotent for programmers.
DOM = Death by cOMmittee
- lesson from CORBA; trying to please everybody with "multi-language"
lowest denominator APIs pleases nobody
- don't let Fortran, Cobol, C or Javascript
cripple the API for Java, C# or Python
- lots of great ideas; however, serious clean-up needed
JDOM Mission:
There is no compelling reason for a Java API to manipulate
XML to be complex, tricky, unintuitive, or a pain in the neck.
JDOM is both Java-centric and Java-optimized.
It behaves like Java, it uses Java collections,
it is completely natural API for Java developers.
- lesson from JDOM
- use built-in data structures (lists, trees, etc.); don't reinvent string APIs, list APIs, and so on
- use established names; don't confuse everybody with a new lingo
- use short names for the most popular methods; typing matters
- use exceptions
- don't overdo the factory pattern or overuse abstract methods/interfaces
- add convenience methods en masse (no academic lambda minimalism)
The Death of the General Purpose Language
Beyond Hairballs and Spaghetti Code.
Prefer the single-purpose languages below
to general-purpose languages such as Java, C# or Shark.
- HTML, XUL / Content, Structure
- CSS / Visual Styles
- Python / Scripting
- XPath / Tree Node Addressing
- SQL / Data Queries, Updates, etc.
- String Tables / Internationalization
- Velocity, XSL-T / Template
Xul vs. XForms
Xul is to XForms what the USA is to Texas
or what Canada is to Quebec.
Luxor will include a cleaned-up XForms engine.
Tags not found in XForms:
<tree>
, <datagrid>
, <menubar>
, <toolbar>
,
and many more
Modul-Mania: Luxor Building Blocks
-
Apollo - Test Skeleton for Web Start/JNLP
-
Caramel - Java Extensions (non-GUI only)
-
Houston - Yet Another Status and Logging Toolkit
-
Nile - Luxor "Lite"; Transforms Xul Markup Streams in Sizzling Widgets (Upcoming in Fall)
-
Rachel - Resource Loading (includes HTTP web service)
-
Salsa - Swing GUI Add-Ons
-
Shark - Java On Steroids; Do More with Less (Lines Of Code) (Upcoming in Spring)
- And More
XUL Benefits
- Powerful widget markup (XML, Babe)
- Built on proven standards (Reuse, Reuse, Reuse)
- Platform portability (Runs Anywhere)
- Splits presentation and application logic (Beyond Hairballs and Spaghetti Code)
- Easy customization, localization, or branding (Your Way or the Highway)
- makes UI building easier: (almost) no Java/C#/Shark code required
- makes cross-platform UI easier
- language agnostic: Java, C#, C++, Perl, Shark, etc.
- toolkit/API agnostic: WinForms, Gtk+, KDE, Swing, etc.
- makes UI easier to customize (skins, roles, skill-levels, etc.)
- UI can be loaded at start-up from web-server, database, etc.
- UI can be easily updated
- UI can be created on the fly using template engines
- UI can be tested in browser like a web page (just hit reload)
- XUL is XML
- and more
Hello Web Start - Single-Click App Launcher Magic
- Multiple Java Runtimes (JREs)
- Offline Start-Up
- Shared Jars (URL)
- Desktop Integration (Desktop Icons, Startup Menu Entry)
- Upgrade (jar diffs)
- Auto-Install of Java Runtimes (JREs)
- Auto-Upgrade of Web Start
- Multiple Versions, Languages and OSes
- Auto-Install of Native Libs
- Built on top of HTTP (proxy, firewall, caching, logs, clustering)
- Single-Click Startup using standard HTML hyperlink;
e.g. <a href="venus.jnlp">Kick Start Venus Application Publisher</a>
- Single-Click Install (No Directories Required)
- Free, Redistributable in 12 languages
- Source Available
- Scheduled Off-Hour Upgrades
- App Manager
- Offline CD Installers
- Clear Separation of User Data and Apps
- Signed Apps, JSSE (SSL), JAAS (plug-able authorization (aka login)), JCE (crypto services)
- And Much More
Web Start XML Startup File (aka JNLP File)
- Describes an application
- XML document
Example:
<jnlp href="venus.jnlp" codebase="http://www.jenomics.de/vamp">
<information>
<title>Venus Application Publisher</title>
<vendor>Gerald Bauer</vendor>
<homepage href="http://www.vamphq.com"/>
<description>A user-friendly tool to help you package, sign and publish Java Network Launching Protocol (JNLP) apps.</description>
<icon href="venus.gif"/>
<offline-allowed />
</information>
<security>
<all-permissions />
</security>
<resources>
<j2se version="1.4 1.3" />
<jar href="lib/venus.jar" />
<jar href="lib/luxor.jar" />
<jar href="lib/bcel.jar" />
<jar href="lib/kunststoff-1.11.jar" />
<jar href="lib/velocity-1.1.jar" />
...
<jar href="lib/log4j.jar" />
<jar href="lib/skinlf-1.1.jar" />
<jar href="lib/getopt108.jar" />
</resources>
<application-desc main-class="venus.Tool" />
</jnlp>
|
Web Start In Action: Start Me Up
Web Start downloads all required Jars from Web Server
Web Start In A Nutshell
Secure One-Click Startup From Any Browser, For Any Platform, From Anywhere.
- one-click start-up (as easy as browsing the web; download progress pop-up lets user knows what's going on)
- from any browser (Netscape, Exporer, Opera, Mozilla, etc.)
- for any platform (Windows, Linux, Mac, etc.)
- anywhere (works with any plain-vanilla web server)
- secure (code signing and sandboxing - no access to disk; no access to network other than the origination server
aka "phone home" restriction)
Xul Library: Books for the Beach
Essential Xul Programming
- by Vaughn Bullard, Kevin Smith and Michael Daconta (July 2001);
covers the whole Mozilla Xul machinery including CSS, XBL and RDF (448 pages)
Creating Applications with Mozilla
- upcoming O'Reilly Xul thriller (September 2002) by David Boswell,
Brian King, Ian Oeschger, Pete Collins and Eric Murphy (480 pages)
Web Start Links
Web Start/JNLP
FAQs - Answers, Answers, Answers
That's it - The Future Just Happened
Visit http://www.vamphq.com
or http://luxor-xul.sourceforge.net for more info