QueryEditorGraphLibrary
Query Editor (Visual SQL Editor) Graph Library Upgrade
Current functionality
The Query Editor includes three input panes. One is the graph pane, which presents a graphical rendition of the query. Nodes in the graph represent instances of tables in the FROM clause; edges represent equality constraints between columns of the respective tables, typically imposed by Foreign Key constraints.
Various operations can be performed on the graph, and are reflected in the other two panes (tabular and text). Operations include adding table instances (via menu or drag/drop), and selecting/deselecting columns for inclusion in the SELECT clause.
The graph nodes are relatively complex. They present a list of the columns in the associated table, with an icon showing key status, and a checkbox to indicate whether or not they appear in the SELECT clause. In order to represent the complete list of columns, the contents of the node are scrollable.
The graph pane is currently implemented with jgraph.
Planned functionality
Move the current functionality, with little or no UI change, onto the Netbeans Visual Library http://graph.netbeans.org
Advantages
- The Visual Library provides improved functionality, notably much better graph rendering.
- The Visual Library is already used widely in Netbeans.
Discussion
The graph pane currently uses specific jgraph functionality, including adding/removing nodes and edges, and finding or enumerating the nodes/edges of the graph. This work is performed in a single class, QueryBuilder, in a small number of methods.
Most jgraph methods have corresponding functions in Visual Library, so the port can be relatively direct. One exception is discussed below.
Open Issue
In the jgraph implementation, graph nodes are implemented using JInternalFrames. This makes use of the fact that nodes in jgraph are Swing components.
Nodes in Visual Library are _not_ Swing components, so that implementation will not carry over directly. There are at least three alternatives:
1. Implement the equivalent functionality using Visual Library Widgets. This approach is most in
the spirit of the Visual Library, but may require more work to duplicate Swing functionality.
2. Use the ComponentWidget, which allows Swing components to be attached to Widgets http://graph.netbeans.org/documentation.html#ComponentWidget
There are some indications that this does not provide all the required functionality. http://blogs.sun.com/geertjan/entry/swing_components_and_visual_library
3. Use an alternative UI -- for example, leaving the nodes as opaque rectangles that
expand dynamically when clicked, to show all columns.
The first two methods preserve the current UI, so no change is needed. The third method would require a UI change. I will pursue the methods in the order listed.


