Skip to Content.
Sympa Menu

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

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: "Michael Kay" <mike AT saxonica.com>
  • To: "'Grant Wood'" <grant AT nanode.org>, <xom-interest AT lists.ibiblio.org>
  • Subject: Re: [XOM-interest] Node.getParent() swing.tree.TreeNode.getParent()collision
  • Date: Thu, 1 May 2008 15:45:41 +0100


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




  • Re: [XOM-interest] Node.getParent() swing.tree.TreeNode.getParent()collision, Michael Kay, 05/01/2008

Archive powered by MHonArc 2.6.24.

Top of Page