private List CreateTree(List all)
{
if(all==null||all.size()==0)
return null;
int count=all.size();
Base_sysfunc bi=new Base_sysfunc();
Base_sysfunc bj=new Base_sysfunc();
//组织好父子之间的关系 填充layer与parentname这两个字段的内容
for(int i=0;i<count;i++)
{
bi=(Base_sysfunc)all.get(i);
bi.setLayer(0);
bi.setFullname(bi.getFuncname());
boolean trans=false;
for(int j=i+1;j<count;j++)
{
bj=(Base_sysfunc)all.get(j);
if(bi.getParentid()==bj.getFuncid())
{
//是父子关系
all.set(i,bj);
all.set(j, bi); //父在前面子在后面
trans=true;
}
}
if(trans)
i--;
}
for (int i=0;i<count;i++)
{
bi=(Base_sysfunc)all.get(i);
boolean trans=false;
for(int j=i+1;j<count;j++)
{
bj=(Base_sysfunc)all.get(j);
if(bj.getParentid()==bi.getFuncid())
{
bj.setLayer(bi.getLayer()+1);
bj.setFullname(bi.getFullname()+">>"+bj.getFuncname());
}
}
}
//组织在vector中的存放顺序
for(int i=0;i<count;i++)
{
bi=(Base_sysfunc)all.get(i);
boolean trans=false;
for(int j=i+1;j<count;j++)
{
bj=(Base_sysfunc)all.get(j);
if(bi.getFuncid()==bj.getParentid())
{
all.remove(j);
all.add(i+1,bj);
}
}
}
for(int i=0;i<count;i++)
{
bi=(Base_sysfunc)all.get(i);
boolean trans=false;
for(int j=i+1;j<count;j++)
{
bj=(Base_sysfunc)all.get(j);
if(bi.getFuncid()==bj.getParentid())
{
all.remove(j);
all.add(i+1,bj);
}
}
}
return all;
}
private List CreateTree(List all,int topid)
{
all=CreateTree(all);
int count=all.size();
Base_sysfunc bj=new Base_sysfunc();
//把不在这一顶层的其它项都删除掉
// 查找ID=topid所在的位置
int topidj=0;
int topidlayer=0;
//查找ID=topid所在的位置
for(int j=0;j<count;j++)
{
bj=(Base_sysfunc)all.get(j);
//找到TopID对应的对象
if(bj.getFuncid()==topid)
{
topidj=j;
topidlayer=bj.getLayer();
break;
}
}
Vector reslut=new Vector();
for(int j=topidj;j<count;j++)
{
bj=(Base_sysfunc)all.get(j);
//找到TopID对应的对象
if(bj.getLayer()<=topidlayer&&j>topidj)
{
break;
}
else
{
bj.setLayer(bj.getLayer()-topidlayer);
reslut.add(bj);
}
}
return reslut;
}
//
public class Base_sysfunc implements java.io.Serializable {
// Fields
private long funcid;
private long parentid;
private long funcstatus;
private String funcversion;
private String funcname;
private long showorder;
private long menuflag;
private String entranceurl;
private String comments;
// set/getMethod..........
}