Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #36866

Re: Custom JTree does this make sense?

From Martin Gregorie <martin@address-in-sig.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Custom JTree does this make sense?
Date 2017-07-12 16:56 +0000
Organization A noiseless patient Spider
Message-ID <ok5kb8$q3o$1@dont-email.me> (permalink)
References <e7950596-536f-46cd-8af7-34bf7b12fcdc@googlegroups.com> <7dd7b213-f067-406b-845c-b4849d5106eb@googlegroups.com> <ojmab7$dgf$1@dont-email.me> <c185f3fd-c0b1-4671-9d2a-248acec43986@googlegroups.com>

Show all headers | View raw


On Wed, 12 Jul 2017 08:45:51 -0700, Eric Douglas wrote:

> Yes it is a recursive table.  Storing the data is the easy part.  I'm
> trying to find an easy new GUI to maintain it, and it doesn't seem to be
> designed for that.
>
As I said, this is a classic Bill Of Materials. You could do a lot worse 
than making a few searches and seeing what others have done. A good place 
to start may be here: 

http://www.vertabelo.com/blog/technical-articles/identifying-the-bill-of-
materials-bom-structure-in-databases

even be here: http://www.billofmaterials.net/ though this is really just 
a product.

I think this is a type of structure which is a lot easier to manage in an 
RDBMS rather than as an in-memory table, so you might want to look at 
using Derby, H2 or HSQL - all are fairly lightweight databases and all 
are implemented in Java. I haven't used any of them, mainly because I ise 
PostgreSQL, one of the relative heavyweights of the OSS database world.
 
I have worked with BOM databases (for a paint manufacturer and in 
financial systems [some of the more complex financial instruments are 
best represented as a BOM structure) with both were a really long time 
ago.

> My best guess is I need to throw out DefaultMutableTreeNode, have my own
> custom node class simply implement MutableTreeNode, copy much of the
> code from DefaultMutableTreeNode, and customize to allow multiple
> parents and/or shared children.
>
Seems reasonable. BTW, its unusual for anybody to look at both the Part-
is-made-from and the Part-is-used-in hierarchies at once, because 
generally they fall into different parts of an organisation - designers 
and production engineers will use the Part-is-made-from view, while the 
Part-is-used-in view is more the province of the parts purchasing 
department. This means that you can consider them separately.

> The only way I could see to extend DefaultMutableTreeNode is to
> implement some kind of listener, for my custom node to listen to another
> node, to add child whenever the other node adds, remove whenever it
> removes, which would have to be bi-directional.  Any changes made to or
> under left foot copy to right foot and vice versa.
>
Where are you putting the number-used attribute? In a database this goes 
nicely in what I called the Component entity, which looks more or less 
like this

Component
  PrimeKey
    PartKey      - prime key of the Part made from the Component
    ComponentKey - prime key of the Part  used to make it
  NumberUsed     - number of Part.ComponentKey items need to make 
                   Part.Partkey

but I suspect from your comments that you are regarding the Component as 
a relationship between entities rather than an entity in its own right. 
You'll find life becomes easier if you treat Component as an entity (Java 
Class or database table) and it gives you somewhere to store the number 
used, which is certainly something you need to keep (chairs usually have 
four legs and feet and are held together with several screws or a few 
cubic centimetres of glue).
 

-- 
martin@   | Martin Gregorie
gregorie. | Essex, UK
org       |

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Custom JTree does this make sense? Eric Douglas <e.d.programmer@gmail.com> - 2017-07-06 10:52 -0700
  Re: Custom JTree does this make sense? Eric Douglas <e.d.programmer@gmail.com> - 2017-07-06 11:13 -0700
    Re: Custom JTree does this make sense? Martin Gregorie <martin@address-in-sig.invalid> - 2017-07-06 21:33 +0000
      Re: Custom JTree does this make sense? Eric Douglas <e.d.programmer@gmail.com> - 2017-07-12 08:45 -0700
        Re: Custom JTree does this make sense? Martin Gregorie <martin@address-in-sig.invalid> - 2017-07-12 16:56 +0000
          Re: Custom JTree does this make sense? Eric Douglas <e.d.programmer@gmail.com> - 2017-07-12 10:27 -0700
            Re: Custom JTree does this make sense? Martin Gregorie <martin@address-in-sig.invalid> - 2017-07-12 18:31 +0000

csiph-web