DefaultTreeModel and Wicket Tree: setAsksAllowsChildren doesn't work

后端 未结 4 752
萌比男神i
萌比男神i 2021-01-24 08:49

I\'m using Wicket\'s Tree component in a web app. But empty folders are shown in a file-way. Just like this: \"enter

4条回答
  •  生来不讨喜
    2021-01-24 08:59

    You can override Folder.getStyleClass to return the desired Icon. I got something like this:

    @Override
    protected String getStyleClass() {
        String styleClass;
        if (isFolder(getModelObject()))
            {
                if (tree.getState(matter) == State.EXPANDED)
                     {
                         styleClass = getOpenStyleClass();
                     } else {
                         styleClass = getClosedStyleClass();
                     }
                 } else {
                     styleClass = getOtherStyleClass(matter);
                 }
    
                 if (isSelected()) {
                     styleClass += " " + getSelectedStyleClass();
                 }
    
                 return styleClass;
            }
    

    Your implementation of isFolder() may vary.

提交回复
热议问题