[jdom-interest] JDOMTreeModel

adam flinton aflinton at armature.com
Thu Jun 27 00:52:47 PDT 2002


Yup.

www.xmlmiddleware.net

It's hung off my existing softfab.com site

There is a sourceforge page which contains the download:

http://sourceforge.net/projects/xmlmiddleware/

Adam

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

--
Adam Flinton 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20020627/0a3dd864/attachment.htm


More information about the jdom-interest mailing list