basenode.java

来自「Hibernate开发及整合应用大全 蔡雪焘编著 本书用典型的示例剖析Hiber」· Java 代码 · 共 98 行

JAVA
98
字号
/* * Created on 03-08-2003 * * To change the template for this generated file go to * Window - Preferences - Java - Code Generation - Code and Comments */package net.sf.hibernate.console.node;import java.util.ArrayList;import java.util.Collections;import java.util.Enumeration;import java.util.List;import javax.swing.Icon;import javax.swing.tree.TreeNode;/** * @author MAX * * To change the template for this generated type comment go to * Window - Preferences - Java - Code Generation - Code and Comments */public abstract class BaseNode implements TreeNode {        BaseNode parent;	NodeFactory factory;	List children = new ArrayList();	protected String name = "!";    Icon icon = NodeFactory.unmappedClassIcon;        abstract protected void checkChildren();        public Icon getIcon() {        return icon;    }    BaseNode(NodeFactory f, BaseNode parent) {        factory = f;        this.parent = parent;    }            public TreeNode getChildAt(int childIndex) {    	checkChildren();        return (TreeNode) children.get(childIndex);    }    public int getChildCount() {    	checkChildren();        return children.size();    }    public TreeNode getParent() {    	       return parent;    }    public int getIndex(TreeNode node) {    	checkChildren();        return children.indexOf(node);    }    public boolean getAllowsChildren() {        return true;    }    public boolean isLeaf() {    	checkChildren();    	return getChildCount()==0;    }    public Enumeration children() {    	checkChildren();        return Collections.enumeration(children);    }	public abstract String getHQL();	public String getName() {        return name;	}        final public String toString() {        return renderLabel(true);    }        static String getLabel(String name, boolean fullyQualifiedName) {    	if(!fullyQualifiedName && name!=null && name.length()>1 && name.indexOf('.')>=0) {    		return name.substring(name.lastIndexOf('.')+1);    	} else {    		return name;    	}    }        public String renderLabel(boolean fullyQualifiedNames) {    	return getLabel(getName(), fullyQualifiedNames);    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?