Package javax.swing.tree

Examples of javax.swing.tree.DefaultTreeModel.insertNodeInto()


            pregnancyNotificationList.add(notification);
            insertNotificationTypeNode(pregnancyNode);
            int size = treeModel.getChildCount(pregnancyNode);
            int preferredPosition = pregnancyNotificationList.indexOf(notification);
            int safePosition = (preferredPosition < size ? preferredPosition : size);
            treeModel.insertNodeInto(newNotificationNode, pregnancyNode, safePosition);
            pregnancyNode.setUserObject("Pregnancy " + "(" + pregnancyNotificationList.size() + ")");
        } else if (notification.getType() == Notification.Type.DEATH) {
            reload = (reload || deathNotificationList.isEmpty());
            deathNotificationList.add(notification);
            insertNotificationTypeNode(deathNode);
View Full Code Here


            deathNotificationList.add(notification);
            insertNotificationTypeNode(deathNode);
            int size = treeModel.getChildCount(deathNode);
            int preferredPosition = deathNotificationList.indexOf(notification);
            int safePosition = (preferredPosition < size ? preferredPosition : size);
            treeModel.insertNodeInto(newNotificationNode, deathNode, safePosition);
            deathNode.setUserObject("Death " + "(" + deathNotificationList.size() + ")");
        } else if (notification.getType() == Notification.Type.MIGRATION) {
            reload = (reload || migrationNotificationList.isEmpty());
            migrationNotificationList.add(notification);
            insertNotificationTypeNode(migrationNode);
View Full Code Here

            migrationNotificationList.add(notification);
            insertNotificationTypeNode(migrationNode);
            int size = treeModel.getChildCount(migrationNode);
            int preferredPosition = migrationNotificationList.indexOf(notification);
            int safePosition = (preferredPosition < size ? preferredPosition : size);
            treeModel.insertNodeInto(newNotificationNode, migrationNode, safePosition);
            migrationNode.setUserObject("Migration " + "(" + migrationNotificationList.size() + ")");
        }
        if (reload) {
            treeModel.reload();
        }
View Full Code Here

            DefaultTreeModel dtm = (DefaultTreeModel) tree.getModel();   // get the tree model
            //now get the index of the selected node in the DefaultTreeModel
            int index = dtm.getIndexOfChild(node.getParent(), node);
            // if selected node is first, return (can't move it up)
            if (index < node.getParent().getChildCount() - 1) {
              dtm.insertNodeInto(node, (DefaultMutableTreeNode) node.getParent(), index + 1);   // move the node
              dtm.reload();
              for (int i = 0; i < tree.getRowCount(); i++) {
                tree.expandRow(i);
              }
              tree.getSelectionModel().setSelectionPath(new TreePath(node.getPath()));
View Full Code Here

            DefaultTreeModel dtm = (DefaultTreeModel) tree.getModel();   // get the tree model
            //now get the index of the selected node in the DefaultTreeModel
            int index = dtm.getIndexOfChild(node.getParent(), node);
            // if selected node is first, return (can't move it up)
            if (index != 0) {
              dtm.insertNodeInto(node, (DefaultMutableTreeNode) node.getParent(), index - 1);   // move the node
              dtm.reload();
              for (int i = 0; i < tree.getRowCount(); i++) {
                tree.expandRow(i);
              }
              tree.getSelectionModel().setSelectionPath(new TreePath(node.getPath()));
View Full Code Here

            --childIndex;
        }
       
        childNode.setParentTree(getParentTree());
        DefaultTreeModel treeModel = (DefaultTreeModel) getParentTree().getModel();
        treeModel.insertNodeInto(childNode, this, childIndex);

        View viewManifestation = View.class.cast(childNode.getUserObject());
        viewManifestation.putClientProperty(PARENT_CLIENT_PROPERTY_NAME, getParentTree());
    }
View Full Code Here

     */
    public void refresh(MCTMutableTreeNode childNode) {
        childNode.setParentTree(getParentTree());
        DefaultTreeModel treeModel = (DefaultTreeModel) parentTree.getModel();
        TreePath path = getParentTree().getSelectionPath();
        treeModel.insertNodeInto(childNode, this, getChildCount());
        if (path != null) {
            // if the parent node is in the selection path then the refresh can cause the
            // selected node to be removed from the tree, so reset the selection to the
            if (Arrays.asList(path).contains(this.getParent())) {
                getParentTree().setSelectionPath(new TreePath(treeModel.getPathToRoot(this.getParent())));
View Full Code Here

                        }

                        switch(insertPosition) {
                            case BEFORE:
                                model.removeNodeFromParent(sourceNode);
                                model.insertNodeInto(sourceNode, newParent, index);
                                break;
                            case AFTER:
                                model.removeNodeFromParent(sourceNode);
                                model.insertNodeInto(sourceNode, newParent, index+1);
                                break;
View Full Code Here

                                model.removeNodeFromParent(sourceNode);
                                model.insertNodeInto(sourceNode, newParent, index);
                                break;
                            case AFTER:
                                model.removeNodeFromParent(sourceNode);
                                model.insertNodeInto(sourceNode, newParent, index+1);
                                break;
                            case INTO_FOLDER: //最後の子として挿入
                                model.removeNodeFromParent(sourceNode);
                                model.insertNodeInto(sourceNode, targetNode, targetNode.getChildCount());
                        }
View Full Code Here

                                model.removeNodeFromParent(sourceNode);
                                model.insertNodeInto(sourceNode, newParent, index+1);
                                break;
                            case INTO_FOLDER: //最後の子として挿入
                                model.removeNodeFromParent(sourceNode);
                                model.insertNodeInto(sourceNode, targetNode, targetNode.getChildCount());
                        }
                        TreeNode[] path = model.getPathToRoot(sourceNode);
                        ((JTree) tree).setSelectionPath(new TreePath(path));
                    }
                    return true;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.