<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>RE: [jdom-interest] JDOMTreeModel</TITLE>
</HEAD>
<BODY>
<BR>
<P><FONT SIZE=2>Yup.</FONT>
</P>
<P><FONT SIZE=2>www.xmlmiddleware.net</FONT>
</P>
<P><FONT SIZE=2>It's hung off my existing softfab.com site</FONT>
</P>
<P><FONT SIZE=2>There is a sourceforge page which contains the download:</FONT>
</P>
<P><FONT SIZE=2><A HREF="http://sourceforge.net/projects/xmlmiddleware/" TARGET="_blank">http://sourceforge.net/projects/xmlmiddleware/</A></FONT>
</P>
<P><FONT SIZE=2>Adam</FONT>
</P>
<P><FONT SIZE=2>> -----Original Message-----</FONT>
<BR><FONT SIZE=2>> From: Sikkin.com Support [<A HREF="mailto:support@sikkin.com">mailto:support@sikkin.com</A>]</FONT>
<BR><FONT SIZE=2>> Sent: 26 June 2002 20:48</FONT>
<BR><FONT SIZE=2>> To: adam flinton</FONT>
<BR><FONT SIZE=2>> Subject: Re: [jdom-interest] JDOMTreeModel</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> Adam,</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> I don't find "binaries" newsgroup in news.barkto.com</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> Could you give me an another address to download ypur work</FONT>
<BR><FONT SIZE=2>> Thanks in advance</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> Pierre-Gilles Raynaud</FONT>
<BR><FONT SIZE=2>> Technologies support</FONT>
<BR><FONT SIZE=2>> Sikkin.com</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> adam flinton wrote:</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> > Dear JDOM People,</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > Please scroll down to the "JDOMTreeModel:" bit.</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > -----------------------------------------------------</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > Dear All,</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > After much work over the Xmas period......I have the Alpha of the </FONT>
<BR><FONT SIZE=2>> > XMLDBMS Mapbuilder. Actually I had it a while ago but then </FONT>
<BR><FONT SIZE=2>> work + home + </FONT>
<BR><FONT SIZE=2>> > a load of things stopped me writing this document......</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > This has been build against: JDK 1.2.2_006, JDOM Beta 7.</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > You will need to include your DB JDBC drivers .zip or .jar in your </FONT>
<BR><FONT SIZE=2>> > classpath.</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > I am including the XMLDBMS version 1.1 code I have been </FONT>
<BR><FONT SIZE=2>> working against </FONT>
<BR><FONT SIZE=2>> > (Ron could you do a merge as I don't think I've changed anything in </FONT>
<BR><FONT SIZE=2>> > that). You can get the JDOM code from www.jdom.org.</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > Also in the zip is my test Properties file (MapProps.txt) & a test </FONT>
<BR><FONT SIZE=2>> > Settings.xml</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > You can get this code from the binaries newsgroup in news.barkto.com</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > Look for a posting called "XMLDBMS Mapbuilder Alpha 1".</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > The Server Code is in there as well.</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > I have used the Version 1 DTD as a base however it should be easily </FONT>
<BR><FONT SIZE=2>> > capable of moving to any Map Document (or indeed any XML Document).</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > The main thing which needs looking at (apart from Version </FONT>
<BR><FONT SIZE=2>> 2.0 Support) </FONT>
<BR><FONT SIZE=2>> > is simply Interfaces & where to use them so as to ensure that the </FONT>
<BR><FONT SIZE=2>> > Mapbuilder can load the right classes to deal with a </FONT>
<BR><FONT SIZE=2>> specific Document </FONT>
<BR><FONT SIZE=2>> > type (inc the relevant Menu's, Actions, JInternalFrame </FONT>
<BR><FONT SIZE=2>> Handlers etc). </FONT>
<BR><FONT SIZE=2>> > It's not much work however I simply wanted to chuck this </FONT>
<BR><FONT SIZE=2>> out so people </FONT>
<BR><FONT SIZE=2>> > could play (& possibly even help).</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > There is a completely updated Properties Editor which is </FONT>
<BR><FONT SIZE=2>> hopefully a </FONT>
<BR><FONT SIZE=2>> > heck of a lot better than the old one (& can cope with </FONT>
<BR><FONT SIZE=2>> using different </FONT>
<BR><FONT SIZE=2>> > class'es for version 1 & 2 etc.</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > The Properties editor is where any testing of mapfile,XSLT, </FONT>
<BR><FONT SIZE=2>> JMS etc. is </FONT>
<BR><FONT SIZE=2>> > doen from At the moment there is a mini "test" GUI which is </FONT>
<BR><FONT SIZE=2>> again simply </FONT>
<BR><FONT SIZE=2>> > not wired up yet because of time constraints. Again it is simple & </FONT>
<BR><FONT SIZE=2>> > should be rapid.</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > The Mapbuilder is a MapDesigner. Again some bits aren't </FONT>
<BR><FONT SIZE=2>> wired up (e.g. </FONT>
<BR><FONT SIZE=2>> > the "links" view (i.e. a tree of classmaps held together by their </FONT>
<BR><FONT SIZE=2>> > relationships with each other).</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > The DB part produces a fairly complete JDBC Picture as an </FONT>
<BR><FONT SIZE=2>> XML Doc which </FONT>
<BR><FONT SIZE=2>> > you can save etc. It acts as a Cache. Some things need to </FONT>
<BR><FONT SIZE=2>> be actively </FONT>
<BR><FONT SIZE=2>> > selected via it's JTree Menus (e.g. SchemaDetails has an </FONT>
<BR><FONT SIZE=2>> Option to get </FONT>
<BR><FONT SIZE=2>> > all procedures, an getting fileds etc for a given table requires a </FONT>
<BR><FONT SIZE=2>> > selection.)</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > Again many things are lurking e.g. Possibly not every </FONT>
<BR><FONT SIZE=2>> element refreshes </FONT>
<BR><FONT SIZE=2>> > correctly etc. Find the probs.</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > The code that builds the XML view of your JDBC enabled DB is in:</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > org.xmlmiddleware.xmldbms.gui.treebuilder.JDBCTreeBuilder</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > How to Use:</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > It uses the Std Version 1.1 Properties interface as such to </FONT>
<BR><FONT SIZE=2>> start the </FONT>
<BR><FONT SIZE=2>> > MapBuilder you simply call (from my .bat file)</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > SET JARHOME=D:\aat\Jars</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > java -cp </FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> %JARHOME%\xmldbms.jar;%JARHOME%\classes12.zip;%JARHOME%\db2jav</FONT>
<BR><FONT SIZE=2>> a.zip;%JARHOME%\xerces.jar;%JARHOME%\xalan.jar;%JARHOME%\jaxp.</FONT>
<BR><FONT SIZE=2>> jar;%JARHOME%\jdom.jar;.; </FONT>
<BR><FONT SIZE=2>> > org.xmlmiddleware.xmldbms.gui.mapbuilder.Mapbuilder </FONT>
<BR><FONT SIZE=2>> File=MapProps.txt</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > The PropertiesEditor can be started either from the </FONT>
<BR><FONT SIZE=2>> MapBuilder or on </FONT>
<BR><FONT SIZE=2>> > it's own e.g.</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > SET JARHOME=D:\aat\Jars</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > java -cp </FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> %JARHOME%\xmldbms.jar;%JARHOME%\xerces.jar;%JARHOME%\xalan.jar</FONT>
<BR><FONT SIZE=2>> ;%JARHOME%\jaxp.jar;%JARHOME%\jdom.jar;.; </FONT>
<BR><FONT SIZE=2>> > org.xmlmiddleware.xmldbms.gui.PropertiesEditor File=MapProps.txt</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > It uses a settings file & can use a DBCache XML file thus in the </FONT>
<BR><FONT SIZE=2>> > Properties File there are 2 new values:</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > settingsfile</FONT>
<BR><FONT SIZE=2>> > e.g. settingsfile=D\:\\Move\\aat\\Settings.xml</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > If this is not set then it will look into it's local dir for a file </FONT>
<BR><FONT SIZE=2>> > called Settings.xml</FONT>
<BR><FONT SIZE=2>> > If this is not found then it will create a new (blank) settings file</FONT>
<BR><FONT SIZE=2>> > And</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > dbfile</FONT>
<BR><FONT SIZE=2>> > e.g. dbfile=D\:\\Move\\aat\\db.xml</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > If this is not set then it will look into it's local dir for a file </FONT>
<BR><FONT SIZE=2>> > called db.xml</FONT>
<BR><FONT SIZE=2>> > If this is not found then it will create a new (blank) DBCache</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > I have not yet produced a DTD for the settings simply </FONT>
<BR><FONT SIZE=2>> because I was not </FONT>
<BR><FONT SIZE=2>> > sure it has been finished. If people want I will run my </FONT>
<BR><FONT SIZE=2>> Settings.xml off </FONT>
<BR><FONT SIZE=2>> > against a DTD from Document tool.</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > The Elements which I have Written JInternalFrames for are:</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > ClassMap - org.xmlmiddleware.xmldbms.gui.v1.ClassMap</FONT>
<BR><FONT SIZE=2>> > IgnoreRoot - org.xmlmiddleware.xmldbms.gui.v1.IgnoreRoot</FONT>
<BR><FONT SIZE=2>> > Options - org.xmlmiddleware.xmldbms.gui.v1.Options</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > Equally you can select a table from the JDBC view & create </FONT>
<BR><FONT SIZE=2>> a std ClassMap.</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > What makes (hopefully) the whole thing so extensible??? </FONT>
<BR><FONT SIZE=2>> Well as they say </FONT>
<BR><FONT SIZE=2>> > the fewer the lines of code the more thought is required & </FONT>
<BR><FONT SIZE=2>> what you're </FONT>
<BR><FONT SIZE=2>> > seeing here is about version 8...where all the others were </FONT>
<BR><FONT SIZE=2>> scrapped. The </FONT>
<BR><FONT SIZE=2>> > key is the JDOMTreeModel.</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > JDOMTreeModel:</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > I have been looking at the JTree & JDOM. We have 2 </FONT>
<BR><FONT SIZE=2>> different forms of </FONT>
<BR><FONT SIZE=2>> > XML Mapfile (version 1.0 & 2.0) & thus I had to cope with </FONT>
<BR><FONT SIZE=2>> the idea of </FONT>
<BR><FONT SIZE=2>> > multiple Docs. Also I built some code which creates a </FONT>
<BR><FONT SIZE=2>> JDOM/XML "picture" </FONT>
<BR><FONT SIZE=2>> > of a Database using the JDBC DB & ResultSet Metadata & had </FONT>
<BR><FONT SIZE=2>> a settings </FONT>
<BR><FONT SIZE=2>> > Doc thus I had 4 Docs. So I wanted an easy & generic way to bind a </FONT>
<BR><FONT SIZE=2>> > JDOM/XML Doc to a JTree.</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > Thus I have created a JDOMTreeModel which extends DefaultTreeModel.</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > It uses a class called ElementNode which extends BasicNode </FONT>
<BR><FONT SIZE=2>> which in turn </FONT>
<BR><FONT SIZE=2>> > extends javax.swing.tree.DefaultMutableTreeNode.</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > The BasicNode is there because at some point I may need </FONT>
<BR><FONT SIZE=2>> other sorts of </FONT>
<BR><FONT SIZE=2>> > Nodes.</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > An Element Node Contains that element. It also overloads a </FONT>
<BR><FONT SIZE=2>> some methods </FONT>
<BR><FONT SIZE=2>> > e.g. getName such that (in getName) it returns the Value in </FONT>
<BR><FONT SIZE=2>> an element </FONT>
<BR><FONT SIZE=2>> > (if there is one) or if there isn't then it returns the </FONT>
<BR><FONT SIZE=2>> Element Name. It </FONT>
<BR><FONT SIZE=2>> > also has a method called getElement which simply returns </FONT>
<BR><FONT SIZE=2>> the element for </FONT>
<BR><FONT SIZE=2>> > that Node.</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > The best idea is to have a static Node as a field in your </FONT>
<BR><FONT SIZE=2>> GUI Class that </FONT>
<BR><FONT SIZE=2>> > whenever the mouse reports that a Node has been selected </FONT>
<BR><FONT SIZE=2>> you simply set </FONT>
<BR><FONT SIZE=2>> > the "hidden node" to the selected Node. This gives you a </FONT>
<BR><FONT SIZE=2>> single point to </FONT>
<BR><FONT SIZE=2>> > query against.</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > This makes doing any Swing/JTree based GUI using an XML </FONT>
<BR><FONT SIZE=2>> Document as a </FONT>
<BR><FONT SIZE=2>> > base so easy......</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > example:</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > //To setup a JTM - It is usefull to provide a root node when </FONT>
<BR><FONT SIZE=2>> > constructing even if you are then going</FONT>
<BR><FONT SIZE=2>> > // to replace it via the document you're feeding in.</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > JDOMTreeModel JTM = new JDOMTreeModel(new ElementNode(new </FONT>
<BR><FONT SIZE=2>> > Element("Root")));</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > // You then feed in your JDOM Doc</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > JTM.setDoc(Doc);</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > // Then you simply use it as the Model for your JTree e.g.</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > JTree DBTree = new JTree();</FONT>
<BR><FONT SIZE=2>> > DBTree.setModel(JTM);</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > & You're done.</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > Other stuff:</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > I have created a std TreeListener</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > public class BasicTreeListener</FONT>
<BR><FONT SIZE=2>> > extends java.awt.event.MouseAdapter</FONT>
<BR><FONT SIZE=2>> > implements</FONT>
<BR><FONT SIZE=2>> > javax.swing.event.TreeExpansionListener,</FONT>
<BR><FONT SIZE=2>> > javax.swing.event.TreeSelectionListener</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > Useage Example:</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > BasicTreeListener BTL = new BasicTreeListener( getDBTree(), </FONT>
<BR><FONT SIZE=2>> > getTreePopupMenu());</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > getDBTree().addTreeExpansionListener( BTL );</FONT>
<BR><FONT SIZE=2>> > getDBTree().addTreeSelectionListener( BTL );</FONT>
<BR><FONT SIZE=2>> > getDBTree().addMouseListener( BTL );</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > getDBTree().setEditable(false);</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > All you have left to do....is decide what menu's you want </FONT>
<BR><FONT SIZE=2>> adding onto </FONT>
<BR><FONT SIZE=2>> > the JTree & thus the ActionPerformed.</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > Please look at </FONT>
<BR><FONT SIZE=2>> > org.xmlmiddleware.xmldbms.gui.mapbuilder.Mapbuilder.initTree()</FONT>
<BR><FONT SIZE=2>> > &</FONT>
<BR><FONT SIZE=2>> > org.xmlmiddleware.xmldbms.gui.mapbuilder.Mapbuilder.addMenus()</FONT>
<BR><FONT SIZE=2>> > & finally</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> org.xmlmiddleware.xmldbms.gui.mapbuilder.Mapbuilder.actionPerf</FONT>
<BR><FONT SIZE=2>> ormed(ActionEvent) </FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > to see how to do this.</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > So if you want to build something which can view any JDOM </FONT>
<BR><FONT SIZE=2>> Doc (& thus </FONT>
<BR><FONT SIZE=2>> > any XML) as a JTree and then have menu actions coming off </FONT>
<BR><FONT SIZE=2>> from the Tree </FONT>
<BR><FONT SIZE=2>> > it couldn't get much easier. In essence your GUI can edit </FONT>
<BR><FONT SIZE=2>> an Element </FONT>
<BR><FONT SIZE=2>> > (e.g. I am using code within JInternalFrames) & then the </FONT>
<BR><FONT SIZE=2>> JDOM Doc is </FONT>
<BR><FONT SIZE=2>> > automatically updated.</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > Enjoy</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> > Adam</FONT>
<BR><FONT SIZE=2>> > </FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> </FONT>
</P>
<P><FONT SIZE=2>--</FONT>
<BR><FONT SIZE=2>Adam Flinton </FONT>
</P>
</BODY>
</HTML>