B4J Library [B4X] [XUI] jSD_TreeList

SD_TreeList

Author:
Star-Dust
Version: 0.22
  • B4XTree
    • Events:
      • Click (IDLeaf As String, LeafName As String)
      • ClickBranch (ID As String, Expanded As Boolean)
      • LongRightClick (IDLeaf As String, LeafName As String)
    • Fields:
      • BadgeBackgroundColor As Int
      • BadgeDept As Int
      • BadgeTextColor As Int
      • BadgeTextSize As Int
    • Functions:
      • Add (Name As String, IDBranch As String, FontAwesoneSymbol As String, Color As Int, ListLeaf As String()) As String
        Add Branch with Symbol(FontAwesone) and Leaf (list)
      • Add2 (Name As String, IDBranch As String, Symbol As String, FontSymbol As B4XFont, Color As Int, ListLeaf As String()) As String
        Add Branch with Symbol(FontAwesone) and Leaf (list)
      • AddBranch (Name As String, IDBranch As String, IDParent As String, FontAwesoneSymbol As String, Color As Int) As String
        Add Branch
      • AddBranch2 (Name As String, IDBranch As String, IDParent As String, Symbol As String, FontSymbol As B4XFont, Color As Int) As String
        Add Branch with Symbol
      • AddBranchDoubleSymbol (Name As String, IDBranch As String, IDParent As String, OpenSymbol As String, CloseSymbol As String, FontSymbol As B4XFont, Color As Int) As String
        Add Branch with double symbol
      • AddDoubleSymbol (Name As String, IDBranch As String, OpenSymbol As String, CloseSymbol As String, FontSymbol As B4XFont, Color As Int, ListLeaf As String()) As String
        Add Branch with double Symbol and Leaf (list)
      • AddLeaf (Name As String, Info As String, IDBLeaf As String, IDParent As String) As String
        Add Leaf to branch
      • AddLeafOnTop (Name As String, Info As String, IDLeaf As String, IDBranch As String) As String
        Add Leaf on top to Branch
      • AddLeafwithSymbol (Name As String, Info As String, IDBLeaf As String, IDParent As String, FontAwesoneSymbol As String, FontSymbol As B4XFont) As String
        Add Leaf with Symbol to branch
      • Class_Globals As String
      • Clear As String
      • CollapsesAllBranch As String
      • CollapsesBranch (IDBranch As String) As String
      • CollapsesBranchAndSOn (IDBranch As String) As String
      • DesignerCreateView (Base As Object, Lbl As Label, Props As Map) As String
        Base type must be Object
      • ExpandAllBranch As String
      • ExpandBranch (IDBranch As String) As String
      • ExpandBranchAndSon (IDBranch As String) As String
      • GetBranchName (IDBranch As String) As String
      • GetBranchOfLeaf (IDLeaf As String) As String
      • GetLeafBadgeActive (IDLeaf As String) As Boolean
      • GetLeafBadgeText (IDLeaf As String) As String
      • GetLeafInfo (IDLeaf As String) As String
      • GetLeafName (IDLeaf As String) As String
      • Initialize (Callback As Object, EventName As String) As String
      • Invalidate
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • ListOfIDBraches (IDBranche As String) As List
        Returns a list of strings
        This list contains the IDs of the sub-branches attached To a branch
      • ListOfIDLeafs (IDBranche As String) As List
        Returns a list of strings
        This list contains the IDs of the leaves attached To a branch
      • MoveLeaf (IDLeaf As String, NewIDBranch As String) As String
      • RemoveBranch (IDBranch As String) As String
      • RemoveLeaf (IDLeaf As String) As String
      • SetBranch (IDBranch As String, NewName As String) As String
      • SetLayout (Left As Int, Top As Int, Widh As Int, Height As Int) As String
      • SetLeaf (IDLeaf As String, NewName As String, NewInfo As String) As String
      • SetLeafBadge (IDLeaf As String, BadgeActive As Boolean, BadgeText As String) As String
      • Sort (Ascending As Boolean) As String
      • TreeToJson As String
    • Properties:
      • Base As B4XView [read only]
      • BranchTextColor As Int
      • Height As Int
      • ItemHeight As Int
        Min = 40dip, Max= 100dip
      • LeafTextColor As Int
      • Left As Int
      • OnlyCornerColor As Boolean
      • OpenOnlyOneBranch As Boolean
      • TextSize As Int
      • TimeAnimation As Int
      • Top As Int
      • Width As Int


Log version
  • 0.21
    Added AddLeafwithSymbol method. Now you can insert a Symbolo with FontAwesone or FontMaterial in the branch
  • 0.22 - Improved tree JSON production (method TreeToJson )



Preview.gif
1623772714080.png
 

Attachments

  • B4J Sample.zip
    2.6 KB · Views: 494
  • B4A Sample.zip
    9.7 KB · Views: 310
  • B4i Sample.zip
    110.9 KB · Views: 233
  • jSD_TreeList 0.22.zip
    15 KB · Views: 99
  • aSD_TreeList 0.22.zip
    14.8 KB · Views: 108
  • iSD_TreeList 0.22.zip
    193.1 KB · Views: 93
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
It works fine for me. I am attaching an example.
I guess you are getting the parameters wrong, instead of putting the branch ID you are perhaps entering the branch name

1644093903664.png


Scan the whole tree:
ScanTree("","")
ScanTrre Sub:
Private Sub ScanTree(IDB As String, space As String)
    Log(space & IDB)
    For Each IDLeaf As String In B4XTree1.ListOfIDLeafs(IDB)
        Log(space & " " & IDLeaf)
    Next
    For Each IDBranche As String In B4XTree1.ListOfIDBraches(IDB)
        ScanTree(IDBranche,space & " ")
    Next
End Sub
 

Attachments

  • Sample2.zip
    2.6 KB · Views: 111
Last edited:

micro

Well-Known Member
Licensed User
Longtime User
I guess you are getting the parameters wrong, instead of putting the branch ID you are perhaps entering the branch name
in fact I did so
menusd.ListOfIDLeafs(menusd.GetBranchName(ID)).Size
I was fooled by the word GetBranchName
with menusd.ListOfIDLeafs(ID) work fine
Thanks
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.20
  • GetLeafBadgeActive (IDLeaf As String) As Boolean
    Returns if the leaf has the active badge
  • GetLeafBadgeText (IDLeaf As String) As String
    Returns the badge text
 

Theera

Well-Known Member
Licensed User
Longtime User
Update 0.20
  • GetLeafBadgeActive (IDLeaf As String) As Boolean
    Returns if the leaf has the active badge
  • GetLeafBadgeText (IDLeaf As String) As String
    Returns the badge text
Is there example for study,sir? I'm rather stupid in coding and English,if I see example will make me understand how to use.
 

Cableguy

Expert
Licensed User
Longtime User
Is there example for study,sir? I'm rather stupid in coding and English,if I see example will make me understand how to use.
I can imagine something like...

B4X:
Sub B4XTree1_Click (IDLeaf As String, LeafName As String)
If GetLeafBadgeActive (IDLeaf) = True Then 'Leaf has a Badge
'Do something
Else 'Leaf has no badge
'Do something else
End If
End Sub
 

Star-Dust

Expert
Licensed User
Longtime User
Update rel. 0.21
  • Added AddLeafwithSymbol method. Now you can insert a Symbol with FontAwesone or FontMaterial in the branch

B4X:
    B4XTree1.AddLeafwithSymbol("Leaf B Symbol","Symbol","LBF","B1",Chr(0xF0F9),xui.CreateFontAwesome(14))

1656788323284.png
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Update 0.22
  • Improved tree JSON production (method TreeToJson )

After obtaining the JSON (perhaps stored) you can transform it into MAP and populate the tree
B4X:
Dim Tm As Map = B4XTree1.TreeToJson.As(JSON).ToMap
B4XTree1.Clear
ScanMap(Tm,"")

Private Sub ScanMap(M As Map,IDParent As String)
    For Each K As String In M.Keys
        Log(K)
        Dim SubM As Map = M.Get(K)
        Log(SubM)
        If SubM.ContainsKey("Leaf")=False Then
            B4XTree1.AddLeaf(SubM.Get("Name"),SubM.Get("Info"),SubM.Get("ID"),IDParent)
        Else
            B4XTree1.AddBranch(K,SubM.Get("ID"),IDParent,SubM.Get("Symbol"),SubM.Get("Color"))
            ScanMap(SubM.Get("Leaf"),SubM.Get("ID"))
        End If
    Next
End Sub
 
Last edited:
Top