[XOM-interest] Node.getParent() swing.tree.TreeNode.getParent()collision

Michael Kay mike at saxonica.com
Thu May 1 10:45:41 EDT 2008


The general solution to this kind of problem is to use two objects in a
one-to-one relationship with each other: one of them acts as the XOM tree
node, the other acts as the Swing tree node. (I'm sure this is a standard
design pattern, but I've forgotten its name).

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: xom-interest-bounces at lists.ibiblio.org 
> [mailto:xom-interesont-bounces at lists.ibiblio.org] On Behalf Of 
> Grant Wood
> Sent: 01 May 2008 00:13
> To: xom-interest at lists.ibiblio.org
> Subject: [XOM-interest] Node.getParent() 
> swing.tree.TreeNode.getParent()collision
> 
> Hello,
> 
> I'm trying to use a XOM Document as a TreeModel for a swing 
> application.
> 
> To do this, I have extended Element  to implement  swing's 
> TreeModel, Mutable TreeNode and TreeNode.
> 
> problem is, javax.swing.tree.TreeNode requires:
> 
> 	public TreeNode getParent()
> 
> Which causes a conflict with nu.xom.Node in which getParent() 
> is final.  This makes perfect sense, and i'm just sorry I 
> hadn't realized this conflict sooner.
> 
> Previously, this same XML data tree was being rendered using 
> a JList and an Element implementing the ListModel interface, 
> which worked great, but will require an unnecessarily 
> complicated ListCellRenderer to do what I'm am trying to do 
> next.  I decided to implement the same interface using a 
> JTree to simplify a few things for myself, but have now run 
> into this conflict.
> 
> I've searched through the mail archive looking for anyone who 
> has run into this before but haven't found anything.
> 
> What is are suggestions for using XOM with JTree or working 
> around conflicts like this?
> 
> Thanks for your suggestions, I apologize if there is a 
> example or thread that I missed which discusses this.
> 
> 
> -Grant Wood
> _______________________________________________
> XOM-interest mailing list
> XOM-interest at lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/xom-interest



More information about the XOM-interest mailing list