Example usage for javax.swing.tree TreeModel getChild

List of usage examples for javax.swing.tree TreeModel getChild

Introduction

In this page you can find the example usage for javax.swing.tree TreeModel getChild.

Prototype

public Object getChild(Object parent, int index);

Source Link

Document

Returns the child of parent at index index in the parent's child array.

Usage

From source file:org.pentaho.reporting.designer.core.ReportDesignerFrame.java

private void insertReports(final TreeModel model, final Object currentLevel, final XulMenupopup popup)
        throws XulException {
    final int childCount = model.getChildCount(currentLevel);
    for (int i = 0; i < childCount; i += 1) {
        final ReportDesignerView frame = context.getView();

        final Object child = model.getChild(currentLevel, i);
        if (model.isLeaf(child)) {
            final DefaultMutableTreeNode node = (DefaultMutableTreeNode) child;
            final File file = new File(String.valueOf(node.getUserObject()));
            final OpenSampleReportAction action = new OpenSampleReportAction(file, node.toString());
            action.setReportDesignerContext(context);
            popup.addChild(frame.createMenuItem(action));
        } else {//from w ww.j  av  a 2  s  . c o  m
            final XulMenupopup childPopup = frame.createPopupMenu(String.valueOf(child), popup);
            insertReports(model, child, childPopup);
        }
    }
}