How to restrict leaf node

Hi,
My current JTree code behavior is such that when I add new node in JTree it adds to it's parent and selects that node by default (I mean focus goes to the new node).. and can keep max three node and 5 leaf
Following is an example of that:
RootNode
-Node1
--Node1a
--Node1b
-Node2
--Node2a
-Node3
--Node3a
--Node3b
The scenario is:
When I add a new leaf it should see if total five leaf is connected in any combination of any node and give msg 'u can connect max 5 leaf'...
i mean if one node ---max 5 leaf
if two node is connected ---max 5 leaf(we can add 5 leaf in two node)
if three node is connected---max 5 leaf(we can add 5 leaf in three node)
How do i proceed.... need help
regards
tarique

Redefine add() method of your node and do your processing there.
Denis Krukovsky
http://dotuseful.sourceforge.net/

Similar Messages

  • How to Restrict the node level in account hierarchy

    Hi experts,
    I want to restrict the node level in account hierarchy. I attached one example. in that if i click 6000 node again it want to show error message. for one parent node i want to create only two child node. Further if i create means it want to show error msgs and not allow to create the node..
    Regards,
    gopi

    Hi ,
    The component is bp_hier, and method is onnew_node.
    IF lv_tree->is_locked( ) = abap_false.
         lv_tree->lock( ).
       ENDIF.
       CHECK lv_tree->is_locked( ) = abap_true.
       lv_index = typed_context->accounthierarchy->selected_index.
       lv_tree_node = typed_context->accounthierarchy->get_node_by_index( lv_index ).
    *key = lv_tree_node->node_key.
      CALL METHOD lv_api->get_node_parent
         EXPORTING
           iv_node_key        = key
         IMPORTING
           ev_parent_node_key = lv_paent_key
    *      ev_tree_guid       =
    *   lv_parent = lv_tree_node->parent_entity.
    *    typed_context->accounthierarchy->parent_entity.
    CALL METHOD lv_tree_node->get_children
       receiving
         rt_children = rt_child.
       CHECK lv_tree_node IS BOUND.
       lv_tree_node->is_leaf = abap_false.
       TRY.
           lv_proxy_node ?= lv_tree_node.
           TRY.
               lv_object ?= lv_proxy_node->bo.
             CATCH cx_sy_move_cast_error.
               lv_mixed_node ?= lv_proxy_node->bo.
               lv_object ?= lv_mixed_node->if_bsp_wd_ext_property_access~get_model_node( ).
           ENDTRY.
           lv_object_name = lv_object->get_name( ).
           IF lv_object_name = 'BuilHierarchyNode'.
             lv_relation_name = 'BuilHNodeRel'.
           ELSEIF lv_object_name = 'BuilHierarchyHeader'.
             lv_relation_name = 'BuilHeaderNodeRel'.
           ELSE.
             RETURN.
           ENDIF.
           lv_tree_node->get_children( ).
           lv_object = lv_object->create_related_entity( lv_relation_name ).
           lv_child_node = lv_proxy_node->node_factory->get_proxy(
               iv_bo = lv_object
               iv_proxy_type = 'CL_BP_HIER_HIERARCHYTREEV_CN05'
               iv_parent_proxy = lv_tree_node ).
           lv_tree_node->expand_node( ).
           typed_context->accounthierarchy->refresh( ).
           typed_context->accounthierarchy->deselect_all( ).
           lv_child_node->selected = abap_true.
           lv_child_node->is_leaf  = abap_true.
    *accounthierarchy
    *      selectedhierarchynode
           lv_col_wrap = typed_context->selectedhierarchynode->get_collection_wrapper( ).
           lv_col_wrap->clear( ).
    This is the code.
    i wrote . but its not getting.

  • How to Find the node or leaf node selected in Tree UI element:

    Hi All,
    I have a tree structure with three level design. We have a button, which will perform some operation on the specific node or leaf node on every level.
    When we select any node or leaf node, we have action Onction getting called.  But what we want is that, after we select the node or leaf node,  we press a button below the tree design and perform some operation on the node selected.
    But how to get information that on Application , which node or leaf node has been slected ?
    Thanks
    PG

    Hi,
    Found the solution.
    Juts keep on reading all the nodes, system gives the complete path of the tree by using Lead selection and then we can use this path to peform the update operation on tree structure.
    Thanks alot for the hint.
    Regards
    PG

  • ADF TreeTable - How to hide Disclose/Expand icon for leaf node

    We are using ADF Tree Table in our application.
    Whenever a node is expanded - all the child nodes have the disclose/expand icon along with it.
    But, we don't want to show the disclose/expand icon if it is a leaf node.
    How can this be done?
    JDeveloper Version: JDeveloper 11.1.1.3
    Thanks,
    Navaneeth

    I have a hierarchical tree based on single POJO based class exposed as data control.
    (i.e) a node can have many levels.
    Can you specify how we can use the folder icon for this - Can you please provide some detailed information?
    Thanks in advance,
    Navaneeth

  • How to make the leaf node of the APEX tree downloadable

    Hi All,
    I am trying to build a "library" page for my application, with the documents as the leaf nodes of the tree. The documents come from a database table, and each document is a BLOB.
    My question is, how should I write the "link" part of the APEX tree query to make the lead node document downloadable for the end users?
    Thanks,
    Christine

    Hilary helped me out of this by creating a new form page with two new items there corresponding to the PK and BLOB column, then in the tree query use apex_util.get_blob_file_src function as the link. Below is the email from Hilary:
    1. Created Form, page 13, based upon your table storing the documents as BLOBs. The form page has just two associated items: P13_DOC and P13_DOC_ID. The item P13_DOC is of type FILE and contains a source type of DB column, which is the first required parameters of the function get_blob_file_src. NOTE: I could have created a form region on the same page as your tree, but chose to generate a separate page. You may choose to change this yourself.
    2. Updated the Tree query on pg 12 to use the following link for tree nodes of level 4:
    apex_util.get_blob_file_src('P13_DOC',v.attr3)
    ...where P13_DOC is the application page item mentioned in step 1 above, and v.attr3 should hold the unique ID associated with the document. Your tree now allows users to download the listed documents.

  • How to get the leaf node in a hierachy????

    if i get a record that a parent node in a hierachy table ,so how can i get the leaf node of this parent node quicklly?????thank you!

    Hi xuhuanjun ,
    Refer to the below threads which disucss the same.
    Re: how to ensure a hierarchy tree's node is a internal leaf???????
    Re: Retrieve Hierarchy Leaf Node using API.
    Hope it helps.
    Thanks,
    Minaz

  • Hierarchical query - Stop at specific leaf nodes - How to in Oracle 9i ?

    Table H -- Master table to build Hierarchical tree
    C -- Child
    P -- Parent
    Table RN -- Table defining Root Nodes
    N -- Node
    Table LN -- Table defining Leaf Nodes
    N -- Node
    The following Query can generate trees starting with the nodes specified in the Table:RN
    SELECT LEVEL L, C, P, SYS_CONNECT_BY_PATH(C,'/') SCBP
    FROM H
    START WITH C IN ( SELECT N FROM RN )
    CONNECT BY PRIOR C = P
    How do I limit the tree to the nodes specified in the LN table ?
    "CONNECT BY" does not support "IN" clause
    i.e
    CONNECT BY PRIOR C = P AND P NOT IN (SELECT N FROM LN)
    Say we have 2 trees
    1-2-3-4-5
    A-B-C-D-E
    RN : 2,B
    LN : 5,D
    Result:
    2,3,4 (5 is excluded)
    B,C (D is excluded)
    Any help is appreciated...

    What about:
    select level l, c, p, sys_connect_by_path(c,'/') scbp
      from (select * from h
             where c not in (select n from ln))  -- filter via an inline view
    start with c in ( select n from rn )
    connect by prior c = p;

  • How to know which leaf node i click and how to add a listener to each node?

    hi! hello to all members, i have a problem i know how to create a listener, but i dont know how to add a listener to each leaf node. here is the scenario i want to do, i have a JTree where theres a topic that you can select on each leaf node, so when the user click the specific topic it will open another JFrame,which i dont know how to do it also, that its! the next problem will be how do i know which leaf node i select, so that i can open a right topic before the JFrame will open?please, i am very need this to solve quickly as possible. thanks again to all members.

    What you have to do is to add a mouse listener on your JTree. Try something like this:
    tree.addMouseListener(new java.awt.event.MouseAdapter() {
             public void mouseReleased(MouseEvent e) {
                tree_mouseReleased(e);
    private void tree_mouseReleased(MouseEvent e) {
          TreePath selPath = tree.getSelectionPath();
          // Check If the click is the Right Click
          if (e.isPopupTrigger() == true) {
          // This is your right Click
           else {
                     // This is your Left Click
    }Your other problem: Set the userObject on nodes and on left click compare it with your object, if it matches, display the appropriate file. Alternatively, if your nodes are unique, you can match the names to open the file.
    Hope this Helps
    Regard
    Raheel

  • How to restrict max children for a node containing different node types

    Hi,
    I have the following XML:
    <categories>
        <category id="hsp">
            <cardUsage id="hsp.approvals">
                <tabUsage id="hsp.approvals.puListing"/>
                <tabUsage id="hsp.approvals.puDashboard"/>
            </cardUsage>
            <cardClusterUsage id="hsp.someCluster">
                <cardUsage id="hsp.someCluster.approvals"/>
            </cardClusterUsage>
        </category>
        <category  id="psb">
        </category>
        <category  id="pfp">
        </category>
        <category  id="cx">
        </category>
    </categories>
    I need to put a restriction that node category cannot have more than 16 children (cardUsage nodes + cardClusterUsage nodes).
    The way I was thinking to achieve this is, use a new node Usage as child of category. I could set maxOccurs on Usage to 16. And then in Usage use the xs:choice to choose between cardUsage and cardClusterUsage. And setting the maxOccurs to 1.
    Please let me know if there is a better way to do this. Or you see any flaws in my proposal.
    Thanks for you time in advance,
    Manish.

    Does the order of category children matter?
    If not, you can directly set maxOccurs to 16 in the xs:choice element :
    <xs:element name="category">
      <xs:complexType>
        <xs:choice maxOccurs="16">
          <xs:element name="cardUsage" type="..."/>
          <xs:element name="cardClusterUsage" type="..."/>
        </xs:choice>
        <xs:attribute name="id" type="string"/>
      </xs:complexType>
    </xs:element>

  • How to test a 'leaf' node when parses a DTD?

    Hi All:
    Suppose I have <!ELEMENT Name (#PCDATA)> in my dtd. What is the correct way to test the node is a 'leaf' node? I am thinking to use ElementDecl.ELEMENTS to eliminate leaves. Is it correct? As far as I see, the type of leaves is ElementDecl.MIXED. Please verify.
    Thanks!
    Frank

    Hello Sai,
    I am afraid you have posted your question in the wrong forum. This forum is about Oracle On Track Communication, a next-generation social enterprise collaboration product.
    Please re-post your question in an ADF related forum and I am sure someone will be able to answer.
    Thank you,
    Ernst.

  • How to not display nodes in a tree if Oracle roles are NOT used?

    How to not display nodes in a tree if Oracle roles are NOT used?
    We don't use Oracle DB roles to grant users access to Forms from the menu. We use a template and role system of our own. Basically a few tables with templates and roles.
    We want to convert our normal Forms menu to a tree menu and one of our key requirements is that when the tree is populated ONLY nodes with programs (i.e. forms) he has been granted to execute is shown.
    Since we don't use Oracle Roles how to do this in a tree?
    I created a function to show/hide LEAF nodes, BUT problem is that there are sub-menu nodes showing even if the leaf-nodes under it has not being displayed. My function has suppressed it.
    My tree query is like this:
    SELECT
         t.status, LEVEL, t.label, t.icon, t.node VALUE
    FROM
         tma_tree_menu t
    WHERE
    tma_authenticate_sys_chk_role(USER, t.node) = 1
    CONNECT BY
         PRIOR t.node = t.master
    START WITH
         t.MASTER IS NULL
    ORDER SIBLINGS BY
    t.position
    The tma_authenticate_sys_chk_role will return 1 only if the user has access to the form under that node.
    I tried the FTree functions in Forms but even that has nothing.
    Any help would be greatly appreciated.
    Edited by: Channa on Mar 17, 2010 6:49 AM

    Would you share the source code? I guess what I need is how exactly you retreive the user credentials from the DB table and set that boolean variable.
    and then how to condition it in UIX?

  • How to compress leafs of the hierarchy

    Hi guys
    I have a hierarchy  for some levels.
    Level 1
    Level2
    Level3
    i want to show the results for the Nodes. I dont want to show up the leafs. How to compress leafs
    and how to achive this
    Regards
    AK

    Hi matt,
    Root is also required.
    I cannot remove office city, coz the same hierarchy is required  for some other reports.
    I want see only
    North                         -  25
            -City1                 -  15
            -City 2                -  10
    South                          -30
              -City3                -15
              -City4                -15
    West                            -40
               - city 5              -20
               - City 6              -20
    East                             -80
            -City 7                  -40
            -City8                   -40
    I want to show the  north, west, south, east  .     values. i dont want to see the leafs
    Regards
    AK

  • Filteredtreemodel, how to hide parent nodes if no children

    hi. i have surfed and read a lot of posts and topics here regarding filteredtreemodel. some i found hard to understand so i chose to use NiceGuy1's code from long ago since it's the easiest to understand.
    package test;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.tree.DefaultTreeModel;
    import javax.swing.tree.TreeNode;
    import java.util.ArrayList;
    import java.util.Enumeration;
    public class FilteredTreeModel extends DefaultTreeModel {
        // this hashmap gets the list of pdf files and the filter status
        private String filterText;
        private DefaultMutableTreeNode orig_root;
        public FilteredTreeModel(DefaultMutableTreeNode root) {
            super(root);
            orig_root = root;
        public void setFilterText(String s) {
            this.filterText = s;
            reload();
        public String getFilterText() {
            return this.filterText;
        @Override
        public Object getChild(Object parent, int index) {
            return getFilteredChildren(parent).get(index);
        @Override
        public int getChildCount(Object parent) {
            return getFilteredChildCount(parent);
        @Override
        public int getIndexOfChild(Object parent, Object child) {
            return getFilteredChildren(parent).indexOf(child);
        private int getFilteredChildCount(Object parent) {
            return getFilteredChildren(parent).size();
        private ArrayList<TreeNode> getFilteredChildren(Object parent) {
            ArrayList<TreeNode> filteredChildren = new ArrayList<TreeNode>();
            DefaultMutableTreeNode parentNode = null;
            parentNode = (DefaultMutableTreeNode)parent;
            for (Enumeration e=parentNode.children(); e.hasMoreElements();) {
                DefaultMutableTreeNode nextNode = (DefaultMutableTreeNode) e.nextElement();
                DefaultMutableTreeNode dummy = null;
                  if (nextNode.children().hasMoreElements()) {
                      filteredChildren.add(nextNode);
                } else {
                    // if node is leaf node
                    if (filterText == null ) {
                        // add right away if no filter
                        filteredChildren.add(nextNode);
                    } else {
                        // if filter matches this leaf node, add it. if not, how to check if
                        // parent nodes have empty children and remove it.
            return filteredChildren;
    }i havent had luck the whole day trying to make this work. it seemed that once the filteredChildren.add() is called, it gets rendered to the treecellrenreder right away so if i wnat to remove the parents (in case it has no children based on the filter),the parent nodes will stay put in the jtree. any workaround? or ideas? i dont want to use a different defaulttreemodel for this. i want to avoid that because i have lots of nodes in my jtree.

    Looks like you need this:
    for (Enumeration e=parentNode.getFilteredChildren(); e.hasMoreElements();) Edit: okay, that was just a quick guess. Actually you're going to get into trouble if you try to recursively suppress nodes with no children. First you suppress all the leaf nodes (because they naturally don't have any children). Then you suppress all of their parents, because now they don't have any unsuppressed children. Then you suppress all of the parents' parents, because now they don't have any unsuppressed children... and so on until you only have the root left. So you need to refine that requirement.
    But I get what you're saying. I had to do a similar thing, only I didn't use a FilteredTreeModel, I just built the TreeModel based on a selection from another tree. It's ridiculously hard to do when you don't get the nodes in order from the database, too, but that's a different problem.

  • How to highlight Tree node with a diff color

    I have created tree node and want to highlight Selected node with a different background color. Any Ideas how can we achieve that? -R

    It's an item on page 4 of the application that the blog example is taken from. The tree query:
    SELECT EMPLOYEE_ID AS ID
         , MANAGER_ID  AS PID
         , CASE
             WHEN EMPLOYEE_ID = :P4_EMPLOYEE_ID THEN
                 '<span style="color:white;background-color:blue;">'||
                 LAST_NAME||
                 '</span>'
             ELSE
                 LAST_NAME
           END AS NAME
         , 'f?p=&APP_ID.:4:'||:SESSION||'::NO::P4_EMPLOYEE_ID:'||EMPLOYEE_ID AS LINK
         , NULL        AS A1
         , NULL        AS A2
      FROM #OWNER#.EMPLOYEESgenerates leaf nodes that link to page 4, setting the value of P4_EMPLOYEE_ID. When page 4 is rendered, P4_EMPLOYEE_ID contains the ID of the clicked node, the page displays details of the employee with this ID, and the case expression in the tree query causes the corresponding display value to be highlighted.
    See the sections Managing Session State Values and Using f?p Syntax to Link Pages in the documentation to understand how to set session state values using URLs.
    http://download.oracle.com/docs/cd/E14373_01/appdev.32/e11838/concept.htm

  • How to restrict the default selection of first row in ALV  in Webdynpro

    Hi Experts,
    In webdynpro i used ALV to display the bulk amount of datas under a view container. While running it ll cme by default selection on first row. how to restrict that.....

    Hi Vimal,
    Whenever we create nodes then by default the Initialization lead selection property of  node is always checked. That why in the alv by default the first row is selected.
    To restrict this default selection just unchecked the Initialization lead selection property of your node.
    Regard
    Manoj Kumar

Maybe you are looking for

  • Performance issue in the table

    Hi All i have one table which is based on a VO. This VO has 150 attributes.I am facing performance issue. first Q is i need to display only 15 attributes in the table. but other attributes are also required . so i have two options . 1. make other as

  • GoLive to Dreamweaver - a few questions

    I've just made the move from GoLive to Dreamweaver. Fortunately I now use the code view so it really doesn't seem all that different. However, there are a few things that are easy in GoLive but I can't find an easy way of doing it in Dreamweaver. If

  • BB Pearl Flip - ring tones/sounds quit and shuts itself off

    I'm having major problems with my phone since I got it.  I'm on my fthird phone since May 2!!!  On exactly 8 days on the first phone the ringers/sound would quit and would say there was an error on the phone and wouldn't play the sample music.  I bro

  • 1099 Misc Process

    Hi Experts, We need to run the 1099 Misc process every year. we have developed a custom program copying the standard program RFW1099M. Before starting the 1099 Misc process for the 01/01/2009 to 31/12/2009 we need to know the OSS  notes for this stan

  • Error in Leave Application

    Hi, We are getting the following error in the Leave Application. Application error occurred during request processing.  Details:          com.sap.tc.webdynpro.services.sal.core.DispatcherException: Wrong WebDynpro-URL: no application name specified E