Package javax.swing.tree

Examples of javax.swing.tree.TreeModel


      }
      try
      {
        updateFromExternalSource = true;

        final TreeModel model = getModel();
        if (model instanceof AbstractReportDataTreeModel)
        {
          final TreePath path = TreeSelectionHelper.getPathForNode((AbstractReportDataTreeModel) model,
              event.getElement());
          if (path != null)
View Full Code Here


      try
      {
        updateFromExternalSource = true;

        final TreeModel model = getModel();
        if (model instanceof AbstractReportDataTreeModel)
        {
          final TreePath path = TreeSelectionHelper.getPathForNode((AbstractReportDataTreeModel) model,
              event.getElement());
          if (path != null)
View Full Code Here

      // revalidate the data model ..
      if (showIndexColumns != WorkspaceSettings.getInstance().isShowIndexColumns())
      {
        showIndexColumns = WorkspaceSettings.getInstance().isShowIndexColumns();

        final TreeModel model = getModel();
        if (model instanceof AbstractReportDataTreeModel)
        {
          final AbstractReportDataTreeModel realModel = (AbstractReportDataTreeModel) model;
          realModel.fireTreeDataChanged();
          restoreState();
View Full Code Here

   * Checks whether the model has been changed, and if so unregister and register listeners.
   */
  private final void checkModel()
  {
    // find out whether the model object (the TreeModel) has been changed
    TreeModel model = getModelObject();
    if (model != previousModel)
    {
      if (previousModel != null)
      {
        previousModel.removeTreeModelListener(this);
      }

      previousModel = model;

      if (model != null)
      {
        model.addTreeModelListener(this);
      }
      // model has been changed, redraw whole tree
      invalidateAll();
    }
  }
View Full Code Here

   *            The tree node
   * @return iterable presentation of node children
   */
  public final Iterator<Object> nodeChildren(Object node)
  {
    TreeModel model = getTreeModel();
    int count = model.getChildCount(node);
    List<Object> nodes = new ArrayList<Object>(count);
    for (int i = 0; i < count; ++i)
    {
      nodes.add(model.getChild(node, i));
    }
    return nodes.iterator();
  }
View Full Code Here

    public void caretUpdate(CaretEvent e) {
        if (!updatingSelection) {
            int selBegin = Math.min(e.getDot(), e.getMark());
            int end = Math.max(e.getDot(), e.getMark());
            List<TreePath> paths = new ArrayList<TreePath>();
            TreeModel model = getTreeModel();
            Object root = model.getRoot();
            int rootCount = model.getChildCount(root);

            // Build an array of all the paths to all the character elements
            // in the selection.
            for (int counter = 0; counter < rootCount; counter++) {
                int start = selBegin;

                while (start <= end) {
                    TreePath path = getPathForIndex(start, root,
                            (Element) model.getChild(root, counter));
                    Element charElement = (Element) path.getLastPathComponent();

                    paths.add(path);
                    if (start >= charElement.getEndOffset()) {
                        start++;
View Full Code Here

     * updateTree with the root element, or handleChange.
     */
    protected void updateTree(DocumentEvent event) {
        updatingSelection = true;
        try {
            TreeModel model = getTreeModel();
            Object root = model.getRoot();

            for (int counter = model.getChildCount(root) - 1; counter >= 0;
                    counter--) {
                updateTree(event, (Element) model.getChild(root, counter));
            }
        } finally {
            updatingSelection = false;
        }
    }
View Full Code Here

                                                         paintBounds.y);
        Enumeration paintingEnumerator = treeState.getVisiblePathsFrom
                                              (initialPath);
        int row = treeState.getRowForPath(initialPath);
        int endY = paintBounds.y + paintBounds.height;
        TreeModel treeModel = tree.getModel();
        SynthContext cellContext = getContext(tree, Region.TREE_CELL);

        drawingCache.clear();

        setHashColor(context.getStyle().getColor(context,
                                                ColorType.FOREGROUND));

        if (paintingEnumerator != null) {
            // First pass, draw the rows

            boolean done = false;
            boolean isExpanded;
            boolean hasBeenExpanded;
            boolean isLeaf;
            Rectangle rowBounds = new Rectangle(0, 0, tree.getWidth(),0);
            Rectangle bounds;
            TreePath path;
            TreeCellRenderer renderer = tree.getCellRenderer();
            DefaultTreeCellRenderer dtcr = (renderer instanceof
                       DefaultTreeCellRenderer) ? (DefaultTreeCellRenderer)
                       renderer : null;

            configureRenderer(cellContext);
            while (!done && paintingEnumerator.hasMoreElements()) {
                path = (TreePath)paintingEnumerator.nextElement();
                if (path != null) {
                    isLeaf = treeModel.isLeaf(path.getLastPathComponent());
                    if (isLeaf) {
                        isExpanded = hasBeenExpanded = false;
                    }
                    else {
                        isExpanded = treeState.getExpandedState(path);
                        hasBeenExpanded = tree.hasBeenExpanded(path);
                    }
                    bounds = getPathBounds(tree, path);
                    rowBounds.y = bounds.y;
                    rowBounds.height = bounds.height;
                    paintRow(renderer, dtcr, context, cellContext, g,
                             paintBounds, insets, bounds, rowBounds, path,
                             row, isExpanded, hasBeenExpanded, isLeaf);
                    if ((bounds.y + bounds.height) >= endY) {
                        done = true;
                    }
                }
                else {
                    done = true;
                }
                row++;
            }

            // Draw the connecting lines and controls.
            // Find each parent and have them draw a line to their last child
            boolean rootVisible = tree.isRootVisible();
            TreePath parentPath = initialPath;
            parentPath = parentPath.getParentPath();
            while (parentPath != null) {
                paintVerticalPartOfLeg(g, paintBounds, insets, parentPath);
                drawingCache.put(parentPath, Boolean.TRUE);
                parentPath = parentPath.getParentPath();
            }
            done = false;
            paintingEnumerator = treeState.getVisiblePathsFrom(initialPath);
            while (!done && paintingEnumerator.hasMoreElements()) {
                path = (TreePath)paintingEnumerator.nextElement();
                if (path != null) {
                    isLeaf = treeModel.isLeaf(path.getLastPathComponent());
                    if (isLeaf) {
                        isExpanded = hasBeenExpanded = false;
                    }
                    else {
                        isExpanded = treeState.getExpandedState(path);
View Full Code Here

    // construct the panel
    add(new RecursivePanel("panels", l1));

    // create a tree
    TreeModel treeModel = convertToTreeModel(l1);
    final Tree tree = new Tree("tree", treeModel)
    {
      @Override
      protected String renderNode(TreeNode node)
      {
View Full Code Here

   *            the list
   * @return tree model
   */
  private TreeModel convertToTreeModel(List<Object> list)
  {
    TreeModel model = null;
    DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("<root>");
    add(rootNode, list);
    model = new DefaultTreeModel(rootNode);
    return model;
  }
View Full Code Here

TOP

Related Classes of javax.swing.tree.TreeModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.