Example usage for javax.swing.tree DefaultMutableTreeNode getUserObject

List of usage examples for javax.swing.tree DefaultMutableTreeNode getUserObject

Introduction

In this page you can find the example usage for javax.swing.tree DefaultMutableTreeNode getUserObject.

Prototype

public Object getUserObject() 

Source Link

Document

Returns this node's user object.

Usage

From source file:org.apache.directory.fortress.web.panel.PermListPanel.java

private void removeSelectedItems(TreeGrid<DefaultTreeModel, DefaultMutableTreeNode, String> grid) {
    Collection<IModel<DefaultMutableTreeNode>> selected = grid.getSelectedItems();

    for (IModel<DefaultMutableTreeNode> model : selected) {
        DefaultMutableTreeNode node = model.getObject();
        treeModel.removeNodeFromParent(node);
        Permission perm = (Permission) node.getUserObject();
        log.debug(".removeSelectedItems perm objNm: " + perm.getObjName() + " opNm: " + perm.getOpName());
        List<Permission> perms = ((List<Permission>) getDefaultModel().getObject());
        perms.remove(perm);//from  w  w  w .  j a v a  2  s .  c o  m
    }
}

From source file:org.apache.directory.fortress.web.panel.PwPolicyListPanel.java

private void removeSelectedItems(TreeGrid<DefaultTreeModel, DefaultMutableTreeNode, String> grid) {
    Collection<IModel<DefaultMutableTreeNode>> selected = grid.getSelectedItems();
    for (IModel<DefaultMutableTreeNode> model : selected) {
        DefaultMutableTreeNode node = model.getObject();
        treeModel.removeNodeFromParent(node);
        PwPolicy policy = (PwPolicy) node.getUserObject();
        log.debug(".removeSelectedItems policy node: " + policy.getName());
        List<PwPolicy> policies = ((List<PwPolicy>) getDefaultModel().getObject());
        policies.remove(policy);//from   w ww .  j  ava2  s .  c o m
    }
}

From source file:org.apache.directory.fortress.web.panel.RoleListPanel.java

private void removeSelectedItems(TreeGrid<DefaultTreeModel, DefaultMutableTreeNode, String> grid) {
    Collection<IModel<DefaultMutableTreeNode>> selected = grid.getSelectedItems();
    for (IModel<DefaultMutableTreeNode> model : selected) {
        DefaultMutableTreeNode node = model.getObject();
        treeModel.removeNodeFromParent(node);
        Role role = (Role) node.getUserObject();
        log.debug(".removeSelectedItems role node: " + role.getName());
        List<Role> roles = ((List<Role>) getDefaultModel().getObject());
        roles.remove(role);//www. j a  va 2s  . c o m
    }
}

From source file:org.apache.directory.fortress.web.panel.SDListPanel.java

private void removeSelectedItems(TreeGrid<DefaultTreeModel, DefaultMutableTreeNode, String> grid) {
    Collection<IModel<DefaultMutableTreeNode>> selected = grid.getSelectedItems();
    for (IModel<DefaultMutableTreeNode> model : selected) {
        DefaultMutableTreeNode node = model.getObject();
        treeModel.removeNodeFromParent(node);
        SDSet sdSet = (SDSet) node.getUserObject();
        log.debug(".removeSelectedItems sdset node: " + sdSet.getName());
        List<SDSet> sdSets = ((List<SDSet>) getDefaultModel().getObject());
        sdSets.remove(sdSet);/*  www . j  a v  a2s.c  o  m*/
    }
}

From source file:org.apache.directory.fortress.web.panel.UserListPanel.java

private void removeSelectedItems(TreeGrid<DefaultTreeModel, DefaultMutableTreeNode, String> grid) {
    Collection<IModel<DefaultMutableTreeNode>> selected = grid.getSelectedItems();
    for (IModel<DefaultMutableTreeNode> model : selected) {
        DefaultMutableTreeNode node = model.getObject();
        treeModel.removeNodeFromParent(node);
        User user = (User) node.getUserObject();
        LOG.debug(".removeSelectedItems user node: " + user.getUserId());
        List<User> users = ((List<User>) getDefaultModel().getObject());
        users.remove(user);//from  w  ww  . ja  va2  s  . c om
    }
}

From source file:org.apache.jackrabbit.oak.explorer.NodeStoreTree.java

@Override
public void valueChanged(TreeSelectionEvent e) {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
    if (node == null) {
        return;//w w  w  .  ja va 2  s  .c  o  m
    }
    // load child nodes:
    try {
        addChildren(node);
        updateStats(node);
    } catch (IllegalStateException ex) {
        ex.printStackTrace();

        StringBuilder sb = new StringBuilder();
        sb.append(ex.getMessage());
        sb.append(newline);

        NamePathModel model = (NamePathModel) node.getUserObject();
        NodeState state = model.getState();
        String recordId = backend.getRecordId(state);
        if (recordId != null) {
            sb.append("Record ");
            sb.append(recordId);
            sb.append(newline);
        }
        setText(sb.toString());
    }
}

From source file:org.apache.jackrabbit.oak.explorer.NodeStoreTree.java

private void addChildren(DefaultMutableTreeNode parent) {
    NamePathModel model = (NamePathModel) parent.getUserObject();
    if (model.isLoaded()) {
        return;//from  w  w w  .jav  a2s  . c o  m
    }

    List<NamePathModel> kids = newArrayList();
    for (ChildNodeEntry ce : model.getState().getChildNodeEntries()) {
        NamePathModel c = new NamePathModel(ce.getName(), concat(model.getPath(), ce.getName()),
                ce.getNodeState(), sizeCache, skipSizeCheck, backend);
        kids.add(c);
    }
    sort(kids);
    for (NamePathModel c : kids) {
        DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(c, true);
        treeModel.insertNodeInto(childNode, parent, parent.getChildCount());
    }
    model.loaded();
}

From source file:org.apache.jackrabbit.oak.explorer.NodeStoreTree.java

private void updateStats(DefaultMutableTreeNode parent) {
    NamePathModel model = (NamePathModel) parent.getUserObject();

    StringBuilder sb = new StringBuilder();
    sb.append(model.getPath());/*from  w  w w  . j a  va2 s.co m*/
    sb.append(newline);

    NodeState state = model.getState();
    String tarFile = "";

    if (backend.isPersisted(state)) {
        String recordId = backend.getRecordId(state);
        sb.append("Record ").append(recordId);
        tarFile = backend.getFile(state);
        if (tarFile != null) {
            sb.append(" in ").append(tarFile);
        }
        sb.append(newline);

        String templateId = backend.getTemplateRecordId(state);
        String f = backend.getTemplateFile(state);
        sb.append("TemplateId ");
        sb.append(templateId);
        if (f != null && !f.equals(tarFile)) {
            sb.append(" in ").append(f);
        }
        sb.append(newline);
    }

    sb.append("Size: ");
    sb.append("  direct: ");
    sb.append(byteCountToDisplaySize(model.getSize()[0]));
    sb.append(";  linked: ");
    sb.append(byteCountToDisplaySize(model.getSize()[1]));
    sb.append(newline);

    sb.append("Properties (count: ").append(state.getPropertyCount()).append(")");
    sb.append(newline);
    Map<String, String> propLines = newTreeMap();
    for (PropertyState ps : state.getProperties()) {
        StringBuilder l = new StringBuilder();
        l.append("  - ").append(ps.getName()).append(" = {").append(ps.getType()).append("} ");
        if (ps.getType().isArray()) {
            int count = ps.count();
            l.append("(count ").append(count).append(") [");

            String separator = ", ";
            int max = 50;
            if (ps.getType() == Type.BINARIES) {
                separator = newline + "      ";
                max = Integer.MAX_VALUE;
                l.append(separator);
            }
            for (int i = 0; i < Math.min(count, max); i++) {
                if (i > 0) {
                    l.append(separator);
                }
                l.append(toString(ps, i, tarFile));
            }
            if (count > max) {
                l.append(", ... (").append(count).append(" values)");
            }
            if (ps.getType() == Type.BINARIES) {
                l.append(separator);
            }
            l.append("]");

        } else {
            l.append(toString(ps, 0, tarFile));
        }
        printPropertyState(backend, ps, tarFile, l);
        propLines.put(ps.getName(), l.toString());
    }

    for (String l : propLines.values()) {
        sb.append(l);
        sb.append(newline);
    }

    sb.append("Child nodes (count: ").append(state.getChildNodeCount(Long.MAX_VALUE)).append(")");
    sb.append(newline);
    Map<String, String> childLines = newTreeMap();
    for (ChildNodeEntry ce : state.getChildNodeEntries()) {
        StringBuilder l = new StringBuilder();
        l.append("  + ").append(ce.getName());
        NodeState c = ce.getNodeState();
        printNodeState(backend, c, tarFile, l);
        childLines.put(ce.getName(), l.toString());
    }
    for (String l : childLines.values()) {
        sb.append(l);
        sb.append(newline);
    }

    if ("/".equals(model.getPath())) {
        sb.append("File Reader Index");
        sb.append(newline);

        for (String path : backend.getTarFiles()) {
            sb.append(path);
            sb.append(newline);
        }
        sb.append("----------");
    }

    setText(sb.toString());
}

From source file:org.apache.jetspeed.portlets.site.PortalSiteManager.java

private void setFolderTreeNodeLoadedByPath(final Node node, boolean loaded) {
    DefaultMutableTreeNode destParentTreeNode = getTreeNodeByPath(node.getPath());
    SiteTreeNode siteTreeNode = (SiteTreeNode) destParentTreeNode.getUserObject();
    siteTreeNode.setLoaded(loaded);//from www  .ja va  2  s  .  c om
}

From source file:org.apache.jetspeed.portlets.site.PortalSiteManager.java

private void findTreeNodeByPath(DefaultMutableTreeNode node, String path,
        List<DefaultMutableTreeNode> treeNodeList, int maxSize) {
    SiteTreeNode siteTreeNode = (SiteTreeNode) node.getUserObject();

    if (siteTreeNode != null && path.equals(siteTreeNode.getNodePath())) {
        treeNodeList.add(node);//from ww  w.j a  v a  2s .c  o  m
    }

    if (treeNodeList.size() >= maxSize) {
        return;
    }

    for (Enumeration children = node.children(); children.hasMoreElements();) {
        DefaultMutableTreeNode child = (DefaultMutableTreeNode) children.nextElement();
        findTreeNodeByPath(child, path, treeNodeList, maxSize);

        if (treeNodeList.size() >= maxSize) {
            return;
        }
    }
}