Multi-parent JTree

Hi! I would like to build a JTree with more than one parent is this possible? How to do it?

Jenny,
it is possible, but a pain in the neck. the multiple children are no problem, that's part of the tree classes.
however, if a node has to have more than 1 parent you need to create a clone of that node and then you can add it to another parent. to keep the children you need to do a 'deep clone', ie clone the children as well.
the problems start, if you want to allow editing of nodes, eg add/remove children. then you need to make sure you propagate the changes to all clones (this applies [possibly] to explode/collapse and selection as well).
thomas

Similar Messages

  • Changing parent when not in multi-parent mode

    We are currently working with ALLOW_MULTI_PARENT_WORKSPACES =NO. However, we have children that were created under the wrong parent.
    1. Is there a way to move or copy the children to the correct parent without having to re-create them manually? Or are my only 2 options manual or multi-parent?
    2. If I change the workspace to multi-parent, would the fact that the original parent was not created using the ADDASPARENTWORKSPACE stop me from using REMOVEASPARENTWORKSPACE after adding the proper parent to the workspace?
    3. Is it possible to copy a child workspace to another parent?
    Cheers

    Hi,
    Workspaces cannot be copied or removed after they have been created. You can add another workspace using multi-parent but the original changes made to the table would remain within the workspace and would also prevent you from removing the original workspace as a parent.
    These types of changes typically need to be done manually.
    Regards,
    Ben

  • Multi parent child in a AppModuleDataControl

    Hi
    I'm trying to create an application that require multiple (5+) level of parent/child relationship in a AppModuleDataControl...
    (using the following tutorial as an example: http://docs.oracle.com/cd/E37547_01/tutorials/tut_rich_app/tut_rich_app_2.html)
    Is it something that is possible?
    Thanks in advance

    User, please tell us your jdev version.
    Yes, this is possible. Where do you see a problem? If your data mode has this kind of relationship you can build it (or if the foreign keys are setup in the db you get it automatically). a sample up to lever 3: JDeveloper & ADF: Multiple Cascading Tables | JDev & ADF Goodies
    Timo

  • Need hierarchical chart that support multi-parent multi-child for each node

    I'm looking for a charting solution to display the parent-child relationships between jobs in our job schedule. A given job may have 0 or more parent jobs and may have 0 or more child jobs. Similar to org chart but allowing child node(s) to link to more than 1 parent node. Any ideas...?

    Correct; our job scheduler is InControl and I can pull the schedule data from there into our database for reporting. Ultimately my goal is to get the data from InControl into our database for reporting/visualization, and build an Apex application that will allow us to make changes to the schedule (add/remove/modify jobs and their dependencies) and then generate a report to serve as the job documentation for our team and for the schedulers to make the corresponding changes in InControl, and so the data center operators have up-to-date information for overnight support in the event of job failures. It's just that visualization piece that seems elusive, the rest is just writing queries designing the app, writing the report, etc.

  • Multi parents in j3d

    is there a way around the single parent limitation, and can anyone please explain to me why is this so critical to have only one parent please...
    thank you,
    Adam
    wow, is there no one on this forum to save the day??
    Edited by: TacB0sS on Apr 2, 2009 9:14 AM for patient reasons

    Yes, Solaris supports multithreading of a process via a couple of thread interfaces. I would suggest taking a look at http://docs.sun.com and look for the "Multithreaded Programming Guide" related to the version of Solaris that you are interested in. The guide completely explains the API's and has sample code.
    Alan
    Sun Developer Technical Support
    http://www.sun.com/developers/support

  • How to cut, copy and paste a tree node in JTree?????

    Hi, Java GUI guru. Thank you for your help in advance.
    I am working on a File Explorer project with JTree. There are cut, copy and paste item menus in my menu bar. I need three EventAction methods or classes to implements the three tasks. I tried to use Clipboard to copy and paste tree node. But I can not copy any tree node from my tree.
    Are there any body has sample source code about cut, copy, and paste for tree? If possible, would you mind send me your sample source code to [email protected]
    I would appreciate you very very much for your help!!!!
    X.G.

    Hi, Paul Clapham:
    Thank you for your quick answer.
    I store the node in a DefaultMutableTreeNode variable, and assign it to another DefaultMutableTreeNode variable. I set up two classes (CopyNode and PasteNode). Here they are as follows:
    //CopyNode class
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import javax.swing.event.*;
    public class CopyNode implements ActionListener{
    private TreeList jtree;
    String treeNodeName;
    TreePath currentSelection;
    DefaultMutableTreeNode currentNode;
    public CopyNode(TreeList t){
    jtree = t;
    public void actionPerformed(ActionEvent e){
    currentSelection = jtree.tree.getSelectionPath();
    if(currentSelection != null){
    currentNode = (DefaultMutableTreeNode)(currentSelection.getLastPathComponent());
    treeNodeName = currentNode.toString();
    //PasteNode class
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import javax.swing.event.*;
    public class PasteNode extends DefaultMutableTreeNode{
    private TreeList jtree;
    CopyNode copyNode;
    public PasteNode(TreeList t){
    jtree = t;
    copyNode = new CopyNode(t);
    public DefaultMutableTreeNode addObject(Object child){
    DefaultMutableTreeNode parentNode = null;
    TreePath parentPath = jtree.tree.getSelectionPath();
    if(parentPath == null){
    parentNode = jtree.root;
    else{
    parentNode = (DefaultMutableTreeNode)parentPath.getLastPathComponent();
    return addObject(parentNode, child, true);
    public DefaultMutableTreeNode addObject(DefaultMutableTreeNode parent, Object child, boolean shouldBeVisible){
    DefaultMutableTreeNode childNode = copyNode.currentNode;
    if(parent == null){
    parent = jtree.root;
    jtree.treemodel.insertNodeInto(childNode, parent, parent.getChildCount());
    if(shouldBeVisible){
    jtree.tree.scrollPathToVisible(new TreePath(childNode.getPath()));
    return childNode;
    I used these two classes objects in "actionPerformed(ActionEvent e)" methods in my tree:
    //invoke copyNode
    copyItem = new JMenuItem("Copy");
    copyItem.addActionListener(copyNode);
    //invoke pasteNode
    pasteItem = new JMenuItem("Paste");
    pasteItem.addActionListener(
    new ActionListener(){
    public void actionPerformed(ActionEvent e){
    pasteName.addObject(copyName.treeNodeName);
    When I run the drive code, making a copy some node from my tree list, I got bunch of error messages.
    Can you figour out what is wrong in my two classes? If you have sample code, would you mind mail me for reference.
    Thank you very much in advance.
    X.G.

  • Someone please help me Design the database of bill of materials with 1 item can have mutiple parent

    I got this sample from  Uri
    Dimant (MCC, MVP) ,
    The problem is i want 1 item to have multiple parent  but this example don t   let 1  item to have multiple parents. this is not suit for my objective. 
    CREATE TABLE Employees
      empid   int         NOT NULL,
      mgrid   int         NULL,
      empname varchar(25) NOT NULL,
      salary  money       NOT NULL,
      CONSTRAINT PK_Employees PRIMARY KEY(empid),
      CONSTRAINT FK_Employees_mgrid_empid
        FOREIGN KEY(mgrid)
        REFERENCES Employees(empid)
    CREATE INDEX idx_nci_mgrid ON Employees(mgrid)
    SET NOCOUNT ON
    INSERT INTO Employees VALUES(1 , NULL, 'Nancy'   , $10000.00)
    INSERT INTO Employees VALUES(2 , 1   , 'Andrew'  , $5000.00)
    INSERT INTO Employees VALUES(3 , 1   , 'Janet'   , $5000.00)
    INSERT INTO Employees VALUES(4 , 1   , 'Margaret', $5000.00) 
    INSERT INTO Employees VALUES(5 , 2   , 'Steven'  , $2500.00)
    INSERT INTO Employees VALUES(6 , 2   , 'Michael' , $2500.00)
    INSERT INTO Employees VALUES(7 , 3   , 'Robert'  , $2500.00)
    INSERT INTO Employees VALUES(8 , 3   , 'Laura'   , $2500.00)
    INSERT INTO Employees VALUES(9 , 3   , 'Ann'     , $2500.00)
    INSERT INTO Employees VALUES(10, 4   , 'Ina'     , $2500.00)
    INSERT INTO Employees VALUES(11, 7   , 'David'   , $2000.00)
    INSERT INTO Employees VALUES(12, 7   , 'Ron'     , $2000.00)
    INSERT INTO Employees VALUES(13, 7   , 'Dan'     , $2000.00)
    INSERT INTO Employees VALUES(14, 11  , 'James'   , $1500.00)
    WITH EmpCTE(empid, empname, mgrid, lvl)
    AS
      -- Anchor Member (AM)
      SELECT empid, empname, mgrid, 0
      FROM Employees
      WHERE empid = 1
      UNION ALL
      -- Recursive Member (RM)
      SELECT E.empid, E.empname, E.mgrid, M.lvl+1
      FROM Employees AS E
        JOIN EmpCTE AS M
          ON E.mgrid = M.empid
    SELECT * FROM EmpCTE
    My object is
    I want to design the database of bill of materials which contain item and amount.
    So the amount of child will depend on amount of parent in term of ratio. For example
    A(1)               A(2)
    |         ---->     |
    B(2)               B(4)
    My problem is when i try to add the parent and child . Let A is the parent of B , If i try to add A to be the child of C
    I want B to come along with A as well. For example
    A                       C
    |     C  --->        |           For this I have to store the relation of all item in  my list to check that this item have a child or not if yes
    B                            
    A              The child must come along with its parent , What the Er-diagram should be for all of my requirement?
        |
        B
    Base on the example that Uri
    Dimant gave me ,  i have to stroe 1 item wtih multi parents for example if b is a child of a And b  have c as child , When i insert D as a parent of B   , c will automatic come along with B , But this not seem gonna work.
    item   Parent 
     A      NULL
    B         A
    C         B
    B         D
    Am i wrong to go this way  , any idea

    thanks Uri
    Dimant
    I am
    little confuse about how can i write
    hierarchy sql  from this relation  , Thanks
    so far i got 
    WITH EmpCTE(cid, cname, pid, lvl)
    AS
      SELECT      cid , cname ,  children.pid , 0
      FROM            children INNER JOIN
      parents ON children.pid = parents.pid
      where  cid = 1
      UNION ALL
      SELECT      E.cid , E.cname ,  E.pid , M.lvl+1
      FROM       ( select  cid , cname , children.pid FROM  children INNER JOIN
      parents ON children.pid = parents.pid) AS E JOIN EmpCTE AS M
          ON E.pid = M.cid
    SELECT * FROM EmpCTE  

  • Jtree - Problem creating a very large one

    Hi,
    I need to create a multi-level JTree that is very large (aroung 600-650 nodes all in all). At present I am doing the same by creating DefaultMutableTreeNodes and adding them one by one to the tree. It takes a very long time to complete(obviously).
    Is there any way of doing this faster? The tree is being constructed from run-time data.
    Thanks in advance,
    Regards,
    Achyuth

    Two thoughts. First, I create 100's of nodes and it's pretty fast. It could be how you are creating/adding them. Make sure your code is not the bottleneck. If you are traversing the entire tree or some other odd way of doing it, it could be the problem. I only say that because I am able to create an object structre, parse XML as I create that structe and create all the nodes and its less than 1 second on a PIV 1.7Ghz system. Maybe on slower systems its a lot slower, but for me its up immediately.
    Another way, however, is to keep a Map of "paths" to child items in memory. As you build your object from whever, use a Map to keep path info. Now, add listeners to the tree for expand/collapse. Each time it is about to expand, build up the nodes and add them to the expanding node at that point. If it collapses, discard them. This does one of two things. First, for large trees, you aren't wasting tons of time building the tree at the start, and more so, its probably likely that all those nodes aren't going to be expanded/shown right away. Second, it conserves resources. If your tree MUST open in a fully epxanded state, well, then you may be out of luck. But I would much prefer epxanding and building the child nodes at that moment, rather than do the whole thing first.

  • ADF 11g hiearchyViewer widget: can rendering of the graph be customized

    The hiearchyViewer widget supports rendering a graph of one parent to many children nodes. I have a need to display a directed graph where many parent nodes is linked to a common child node . Is it possible to extend the hiearchyViewer widget to override the graph rendering algorithm? If the answer is yes, how may I able to do it, or is there sample code I can review? If the answer is no, how can I create an ADF widget that uses the same flash library the hierarchyViewer ADF widget is using to render its graph. Thank you.

    The HV can't show multi-parents to a children relationship.
    We are working on a new component that should be able to do that - hopefully it will make it into the 12 release.
    You can see a couple of beta screenshots here:
    http://one-size-doesnt-fit-all.blogspot.com/2011/10/adf-take-aways-from-oracle-open-world.html

  • Problem with Jtree to xml tranform..how to set/get parent of a node?

    Hi,
    I am trying to develop xml import/export module.In import wizard, I am parsing the xml file and the display it in Jtree view using xml tree model which implements TreeModel and xml tree node.I am using jaxp api..
    It is workin fine.
    I got stuck with removal of selected node and save it as a new xml.
    I am not able to get parent node of selected node in remove process,itz throwing null.I think i missed to define parent when i load treemodel.Plz help me out..give some ideas to do it..
    thanks
    -bala
    Edited by: r_bala on May 9, 2008 4:44 AM

    there's no way anyone can help you without seeing your code.

  • JTree - Trying to make selection a parent select all children

    I have a jtree with checkboxes and titles. This is my first semester working with java, I started out in cpp so I'm pretty new to GUIs. I found an example of a Jtree with checkboxes on the leaf nodes online and was able to modify it to have checkboxes on all nodes.
    I have been reading through example code of JTrees but have not been able to figure out how to modify children when a parent is modified. If I clicked on an expandable node with sub nodes, I'd want all checkboxes under it to become checked. I've been trying to figure this out for a few days now.
    I tried adding a System.out to the getTreeCellEditorComponent class of the cell editor, to see if that's where I'm supposed to put the code (when i figure out what it is) but it gave unexpected output. Clicking a checkbox the first time called the println once, but after that, each click called println multiple times per click. I'm worried that having the extra calls to the code could mess things up. Where would I want to put code for it to be called only once per time the checkbox is clicked?
    Oh, I also tried adding a listener to the checkbox in the renderer but it gave really weird results too.
    How does the TreePath class work? I tried some stuff with getClosestPathForLocation but couldn't get anything to work.
    Thank you very much for your time and help.

    Thanks for pointing that out. I had tried a few others but yes his was very close to what I want. I just removed the node icons.
    Thanks

  • Remove multi table property defined in Parent descriptor

    I tried to remove a multi table property(which is defined in a parent descriptor) in a child, but it does not get removed.
    <!-- Parent descr -->
    <item-descriptor name="parent" ...>
         <table name="testTable" type="multi" id-column-name="id" multi-column-name="seq_num">
              <property name="testProperty" column-name="property1_id" data-type="map" component-data-type="string">
              </property>
         </table>
    </item-descriptor>
    <!-- Child descr -->
    <item-descriptor name="child" super-type="parent" sub-type-value="child" xml-combine="append">
         <table name="testTable" type="multi" id-column-name="id" multi-column-name="seq_num">
              <property name="testProperty" xml-combine="remove">
              </property>
         </table>
    </item-descriptor>
    Above code does not remove the property "testProperty" in child descriptor.
    If i have a auxiliary table type, rather than multi table type, then it is working fine. Not sure why it is not working in multi table property.
    Does anyone have any idea?
    Thanks!!!

    Hi,
    xml-combine is applicable when combining two or more xml definition files.
    When you say it worked for you for a table of type auxiliary, the properties are in same xml or in different xml files?
    In your case, you are actually trying to override a property from parent item descriptor in a child item descriptor.
    I would suggest to have the testProperty removed from the parent item descriptor and let the children item descriptors define the testProperty.
    Hope this helps.
    Keep posting the updates / questions.
    Thanks,
    Gopinath Ramasamy

  • How to set the horisontal offset for a node relative its parent in JTree?

    When using large icons for nodes in a JTree the whole tree looks very compact. I found a method setRowHeight(int height) to set the row height that got med some space between the rows. But I couldn't find a simular method to increase the offset between a child node and its parent.
    Any suggestions?

    You can control the offset through the BasicTreeUI, as discussed in this thread:
    http://forum.java.sun.com/thread.jspa?threadID=630707&messageID=3636590
    See reply #8 and #9.

  • How to know if a parent has no children in JTree?

    How to know if a parent has no children in JTree?

    Be careful about depending on isLeaf. Common practice states that isLeaf() returns true ONLY if the node in question is not capable of having children (for example, a file in Windows Explorer). A directory with no items in it would not be a leaf node, but would have a child count of 0.

  • JTree - Parent Icon for children

    Hello,
    I have a JTree that displays Categories (=Parent) and it's content (=Child):
    Cat 1
    Cat 2
    Content 1
    Cat 3
      Cat 3.1
        Content
    ...There are some categories that do not have children, and so their icon is the same as the leaves's icon.
    How can I change the icon of categories who do not have children to a "parent-icon"?
    thanks,

    Inherit DefaultTreeCellrenderer and override getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus). Now you can set the icons individually.
    Tutorial:
    http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html

Maybe you are looking for

  • HP Deskjet 1510 will not print

    Hi Everyone, I am not really tech savy so please be patient. BEFORE I CONTINUE PLEASE NOTE I HAVE READ OTHER MESSAGES REGARDING THIS TOPIC HOWEVER I AM STILL AT A LOSS. I have purchased a hp deskjet 1510 printer. I am having trouble printing from a w

  • Insert Single record multiple times in a same database table

    Hello Guys, I need your thoughts for below scenario... I have a data file with 14 colums, more than 10000 records and in below format Data File Format id name c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 Now my requirement is for each record in a data file

  • I want to delete all my apps

    Hi I have itunes on a mac and the kids have 408 apps on my computer. Of which things like 4 different types/copies of a battery status are clearly not needed. I want to blitz them all and just delete the lot. However, they both have purchased items t

  • Understanding statistics from a Cisco WLC?

    Hello, From the "Monitor" page on our Cisco WLC.  If you go to "Access Points" from the left side then choose one of the Radios like 802.11b/g/n.  That will list all the APs connected with your controller. 1) First question, some of the APs listed sh

  • COPYING between databases

    I am trying to copy content of one DB table into an other DB table how can i do this? tables are same dadabases are different. they are oracle database. help!!!!SOS!!!!