📄 sampletreebuilder.java
字号:
package netstore.framework.util.tree;
/*
* Copyright 2002,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.net.URLEncoder;
import java.util.Locale;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.Action;
import org.apache.struts.util.MessageResources;
import javax.servlet.ServletContext;
import org.apache.log4j.*;
/**
* Implementation of <code>TreeBuilder</code> that adds the nodes required
* for administering the user database.
*
* @author Craig R. McClanahan
* @version $Revision: 1.4 $ $Date: 2004/03/04 18:44:52 $
* @since 4.1
*/
public class SampleTreeBuilder {
private static Logger logger = Logger.getLogger(SampleTreeBuilder.class.getName());
// ----------------------------------------------------- Instance Variables
// ---------------------------------------------------- TreeBuilder Methods
/**
* Add the required nodes to the specified <code>treeControl</code>
* instance.
*
* @param treeControl The <code>TreeControl</code> to which we should
* add our nodes
* @param servlet The controller servlet for the admin application
* @param request The servlet request we are processing
*/
public void buildTree(TreeControl treeControl,
MessageResources resources, Locale locale
) {
addSubtree(treeControl.getRoot(), resources, locale);
}
// ------------------------------------------------------ Protected Methods
/**
* Add the subtree of nodes required for user administration.
*
* @param root The root node of our tree control
* @param resources The MessageResources for our localized messages
* messages
*/
protected void addSubtree(TreeControlNode root,
MessageResources resources, Locale locale) {
String databaseName = "Users:type=UserDatabase,database=UserDatabase";
logger.info("开始生成子树");
logger.info(resources.getMessage(locale, "users.treeBuilder.subtreeNode"));
logger.info(resources.getMessage(locale, "users.treeBuilder.groupsNode"));
logger.info(resources.getMessage(locale, "users.treeBuilder.rolesNode"));
TreeControlNode subtree = new TreeControlNode
("User Manager",
"folder_16_pad.gif",
"黄勇锋",
"users/listGroups.do?databaseName=",
"content",
true, "Users");
TreeControlNode groups = new TreeControlNode
("Groups",
"Groups.gif",
resources.getMessage(locale, "users.treeBuilder.groupsNode"),
"users/listGroups.do?databaseName=",
"content",
false, "Users");
TreeControlNode roles = new TreeControlNode
("Roles",
"Roles.gif",
resources.getMessage(locale, "users.treeBuilder.rolesNode"),
"users/listGroups.do?databaseName=",
"content",
false, "Users");
TreeControlNode users = new TreeControlNode
("Users",
"Users.gif",
resources.getMessage(locale, "users.treeBuilder.usersNode"),
"users/listGroups.do?databaseName=",
"content",
false, "Users");
root.addChild(subtree);
subtree.addChild(users);
subtree.addChild(groups);
groups.addChild(roles);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -