Example usage for javax.swing.tree DefaultMutableTreeNode DefaultMutableTreeNode

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

Introduction

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

Prototype

public DefaultMutableTreeNode(Object userObject) 

Source Link

Document

Creates a tree node with no parent, no children, but which allows children, and initializes it with the specified user object.

Usage

From source file:org.alfresco.repo.jive.impl.MockJiveService.java

/**
 * Alternative mock data that returns a tree of communities matched to the mocked up screen shots.
 * @return//  ww w.j av  a 2s.c o m
 */
private final TreeModel buildMockData2() {
    TreeModel result = null;

    DefaultMutableTreeNode root = new DefaultMutableTreeNode(new JiveCommunity(0, "Alfresco Green Energy"));
    DefaultMutableTreeNode child1 = new DefaultMutableTreeNode(new JiveCommunity(1, "Engineering"));
    DefaultMutableTreeNode child2 = new DefaultMutableTreeNode(new JiveCommunity(2, "Finance"));
    DefaultMutableTreeNode child3 = new DefaultMutableTreeNode(new JiveCommunity(3, "Human Resources"));
    DefaultMutableTreeNode child31 = new DefaultMutableTreeNode(new JiveCommunity(31, "Archived Policies"));
    DefaultMutableTreeNode child32 = new DefaultMutableTreeNode(new JiveCommunity(32, "Company Policies"));
    DefaultMutableTreeNode child33 = new DefaultMutableTreeNode(
            new JiveCommunity(33, "Performance Appraisals"));
    DefaultMutableTreeNode child4 = new DefaultMutableTreeNode(new JiveCommunity(4, "Marketing"));

    // Now link all of the nodes together to create the tree structure
    root.add(child1);
    root.add(child2);
    root.add(child3);
    root.add(child4);

    child3.add(child31);
    child3.add(child32);
    child3.add(child33);

    result = new DefaultTreeModel(root);
    return (result);
}

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

private DefaultTreeModel createTreeModel(List<AuthZ> authZs) {
    DefaultTreeModel model;//ww w .  j  av  a2  s. c om
    rootNode = new DefaultMutableTreeNode(null);
    model = new DefaultTreeModel(rootNode);
    if (authZs == null)
        LOG.debug("no Authorizations found");
    else {
        LOG.debug("AuthZ found:" + authZs.size());
        info("Loading " + authZs.size() + " objects into list panel");
        loadTree(authZs);
    }
    return model;
}

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

private void loadTree(List<AuthZ> authZs) {
    for (AuthZ authZ : authZs) {
        Date start = null;/*from   w  w w.  j  av a2 s . c o m*/
        try {
            start = TUtil.decodeGeneralizedTime(authZ.getReqStart());
        } catch (ParseException pe) {
            LOG.warn("ParseException=" + pe.getMessage());
        }
        if (start != null) {
            SimpleDateFormat formatter = new SimpleDateFormat(GlobalIds.AUDIT_TIMESTAMP_FORMAT);
            String formattedDate = formatter.format(start);
            authZ.setReqStart(formattedDate);
        }
        authZ.setReqResult(GlobalIds.FAILURE);
        /*
                TODO: On RC40 - Replace above line with the following:
                if(StringUtils.isNotEmpty( authZ.getReqAssertion() ) && (authZ.getReqAssertion().equals( org.apache.directory.fortress.core.GlobalIds.AUTH_Z_FAILED_VALUE ) ) )
                {
                    authZ.setReqResult( GlobalIds.FAILURE );
                }
                else
                {
                    authZ.setReqResult( GlobalIds.SUCCESS );
                }
        */
        authZ.setReqAuthzID(AuditUtils.getAuthZId(authZ.getReqAuthzID()));
        AuditUtils.mapAuthZPerm(authZ);
        rootNode.add(new DefaultMutableTreeNode(authZ));
    }
}

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

private DefaultTreeModel createTreeModel(List<Bind> binds) {
    DefaultTreeModel model;/* w  ww .j  a v a  2  s  .  c o  m*/
    rootNode = new DefaultMutableTreeNode(null);
    model = new DefaultTreeModel(rootNode);
    if (binds == null)
        LOG.debug("no Authentications found");
    else {
        LOG.debug("Binds found:" + binds.size());
        info("Loading " + binds.size() + " objects into list panel");
        loadTree(binds);
    }
    return model;
}

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

private void loadTree(List<Bind> binds) {
    for (Bind bind : binds) {
        Date start = null;/*from   ww w  .  jav  a2 s .  c  o m*/
        try {
            start = TUtil.decodeGeneralizedTime(bind.getReqStart());
        } catch (ParseException pe) {
            LOG.warn("ParseException=" + pe.getMessage());
        }
        if (start != null) {
            SimpleDateFormat formatter = new SimpleDateFormat(GlobalIds.AUDIT_TIMESTAMP_FORMAT);
            String formattedDate = formatter.format(start);
            bind.setReqStart(formattedDate);
        }
        if (bind.getReqResult().equals(GlobalIds.BIND_SUCCESS_CODE)) {
            bind.setReqResult(GlobalIds.SUCCESS);
        } else {
            bind.setReqResult(GlobalIds.FAILURE);
        }
        bind.setReqDN(AuditUtils.getAuthZId(bind.getReqDN()));
        rootNode.add(new DefaultMutableTreeNode(bind));
    }
}

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

private DefaultTreeModel createTreeModel(List<Mod> mods) {
    DefaultTreeModel model;//w w  w  .j a  v a2  s  . c  o m
    rootNode = new DefaultMutableTreeNode(null);
    model = new DefaultTreeModel(rootNode);
    if (mods == null)
        LOG.debug("no Modifications found");
    else {
        LOG.debug("AuthZ found:" + mods.size());
        info("Loading " + mods.size() + " objects into list panel");
        loadTree(mods);
    }
    return model;
}

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

private void loadTree(List<Mod> mods) {
    for (Mod mod : mods) {
        Date start = null;/*from ww  w . ja v a  2  s.  co  m*/
        try {
            start = TUtil.decodeGeneralizedTime(mod.getReqStart());
        } catch (ParseException pe) {
            LOG.warn("ParseException=" + pe.getMessage());
        }
        if (start != null) {
            SimpleDateFormat formatter = new SimpleDateFormat(GlobalIds.AUDIT_TIMESTAMP_FORMAT);
            String formattedDate = formatter.format(start);
            mod.setReqStart(formattedDate);
        }
        rootNode.add(new DefaultMutableTreeNode(mod));
    }
}

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

public GroupListPanel(String id) {
    super(id);//from   ww  w.j a  v  a  2s.c  o m
    GroupListModel groupListModel = new GroupListModel(new Group(""), SecUtils.getSession(this));
    setDefaultModel(groupListModel);
    addGrid();
    radioGroup = new RadioGroup("searchOptions", new PropertyModel(this, "selectedRadioButton"));
    add(radioGroup);
    Radio groupRb = new Radio("groupRb", new Model(Character.valueOf(NAMES)));
    radioGroup.add(groupRb);
    Radio memberRb = new Radio("memberRb", new Model(Character.valueOf(MEMBERS)));
    radioGroup.add(memberRb);
    addMemberSearchModal(memberRb);
    radioGroup.setOutputMarkupId(true);
    radioGroup.setRenderBodyOnly(false);
    searchValFld = new TextField(GlobalIds.SEARCH_VAL, new PropertyModel<String>(this, GlobalIds.SEARCH_VAL));
    searchValFld.setOutputMarkupId(true);
    AjaxFormComponentUpdatingBehavior ajaxUpdater = new AjaxFormComponentUpdatingBehavior(GlobalIds.ONBLUR) {
        /** Default serialVersionUID */
        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            target.add(searchValFld);
        }
    };
    searchValFld.add(ajaxUpdater);
    radioGroup.add(searchValFld);

    this.listForm.add(radioGroup);
    selectedRadioButton = NAMES;

    this.listForm.add(new SecureIndicatingAjaxButton(GlobalIds.SEARCH, GlobalIds.GROUP_MGR, "find") {
        /** Default serialVersionUID */
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form form) {
            log.debug(".search.onSubmit selected radio button: " + selectedRadioButton);
            info("Searching Group Objects...");
            if (!StringUtils.isNotEmpty(searchVal)) {
                searchVal = "";
            }
            Group srchObject = new Group();
            switch (selectedRadioButton) {
            case NAMES:
                log.debug(".onSubmit GROUP RB selected");
                srchObject.setName(searchVal);
                break;
            case MEMBERS:
                log.debug(".onSubmit MEMBERS RB selected");
                srchObject.setMember(searchVal);
                break;
            }
            setDefaultModel(new GroupListModel(srchObject, SecUtils.getSession(this)));
            treeModel.reload();
            rootNode.removeAllChildren();
            List<Group> groups = (List<Group>) getDefaultModelObject();
            if (CollectionUtils.isNotEmpty(groups)) {
                for (Group group : groups)
                    rootNode.add(new DefaultMutableTreeNode(group));
                info("Search returned " + groups.size() + " matching objects");
            } else {
                info("No matching objects found");
            }
            target.add(grid);
        }

        @Override
        public void onError(AjaxRequestTarget target, Form form) {
            log.warn(".search.onError");
            target.add();
        }

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            AjaxCallListener ajaxCallListener = new AjaxCallListener() {
                /** Default serialVersionUID */
                private static final long serialVersionUID = 1L;

                @Override
                public CharSequence getFailureHandler(Component component) {
                    return GlobalIds.WINDOW_LOCATION_REPLACE_COMMANDER_HOME_HTML;
                }
            };
            attributes.getAjaxCallListeners().add(ajaxCallListener);
        }
    });
}

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

private DefaultTreeModel createTreeModel(List<Group> groups) {
    DefaultTreeModel model;/*from  w  ww.  j  ava 2  s  . c  om*/
    rootNode = new DefaultMutableTreeNode(null);
    model = new DefaultTreeModel(rootNode);
    if (groups == null)
        log.debug("no Groups found");
    else {
        log.debug(".createTreeModel Groups found:" + groups.size());
        for (Group group : groups)
            rootNode.add(new DefaultMutableTreeNode(group));
    }
    return model;
}

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

public void add(FortEntity entity) {
    if (getDefaultModelObject() != null) {
        //List<Group> groups = ((List<Group>) getDefaultModelObject());
        //groups.add( ( Group ) entity );
        treeModel.insertNodeInto(new DefaultMutableTreeNode(entity), rootNode, 0);
    }/* w w  w .ja v  a 2s.  c  om*/
}