0

Hey guys I have been struggling to figure out a solution to my problem. I want to implement a ControlsFX CheckTreeView into my JavaFx app. Basically I have a List of String that are formatted to match a navigation bar on a website. So far example Admin.Config.User would be one of the Strings. I have already parsed these String and converted them into LinkedHashMap where each parent that has children that will store a list of each child and the child's CheckBoxTreeItem.

When creating the CheckTreeView object you can pass the Root CheckBoxTreeItem or initialize with no arguments.

CheckBoxTreeItem Documentation

I'm having a really hard time visualizing how to build a tree bottom up to a root CheckBoxTreeItem.

// Contains the Nodes with children and corresponding CheckBoxTreeItems
LinkedHashMap<String, LinkedHashMap<String, CheckBoxTreeItem<String>>> navPaths = new LinkedHashMap<String, LinkedHashMap<String, CheckBoxTreeItem<String>>>();

// Was thinking about using this as a check to make sure duplicates are not added
LinkedHasMap<String, String> alreadyAdded = new LinkedHashMap<String, String>

// Check Tree View
CheckTreeView<String> checkTreeView = new CheckTreeView<>();

for(String pathNode : navPaths.keySet()){

    for(String childName : testPaths.get(pathNode).keySet()){

        // Completely lost once I get here
    }
}

// Set built root
//checkTreeView.setRoot();

I'm really struggling with this concept so much that I haven't gotten very far and I apologize if it appears I have not put any effort forward. I have been thinking about this concept for the past 12 hours and I'm just getting no where with it. If anyone could provide me with some help that would be great thanks.

user3459799
  • 345
  • 6
  • 16

1 Answers1

0

I advise getting rid of the linked hash maps, parsing directly into CheckBoxTreeItem (it is probably the only data structure you need for this task) and (perhaps) using recursive algorithms rather than iterative ones.

Here is an insert algorithm for a tree, use something like it in your parse routine to directly insert each element you parse into the Tree defined by CheckBoxTreeItems. Note you won't be able to use that algorithm exactly, you will to a develop an algorithm that suits for your particular needs.

I guess I really shouldn't be answering this question as it is quite unclear, but the information was too long for a comment... at least it might get you started down another path.

jewelsea
  • 150,031
  • 14
  • 366
  • 406