⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 treebean.java

📁 该源代码实现乐拖拽树的功能
💻 JAVA
字号:
package com.dt.test.beans;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.servlet.http.HttpServletRequest;

import org.richfaces.event.DropEvent;
import com.dt.test.mytree.MyTree;
import com.dt.test.pojo.Dir;
import com.dt.test.pojo.Point;

public class TreeBean {
	
	private Long deleteID;
	private List<Point> recycleSet;
	
	public Long getDeleteID() {
		return deleteID;
	}

	public void setDeleteID(Long deleteID) {
		this.deleteID = deleteID;
	}

	public TreeBean(){
		System.out.println("***TreeBean()***");
		recycleSet=new ArrayList<Point>(0);
		new MyTree().constructMyTree();
	}
	
	public void dropProcess(DropEvent e){
		Point drag=(Point) e.getDragValue();
		Dir drop=(Dir)e.getDropValue();
		MyTree.updatePoint(drag.getId(), drop.getId());
		new MyTree().constructMyTree();
	}
	
	public List<Point> getPoints(){
		return MyTree.root.getPoints();
	}
	
	public void deleteProcess(ActionEvent e){
		System.out.println("deleteID: "+deleteID);
		Boolean isDelete=MyTree.deletePointInDB(deleteID);
		if(isDelete){
			System.out.println("delete success");
		}else{
			System.out.println("fail to delete");
		}
		new MyTree().constructMyTree();
	}
	
	public void newProcess(ActionEvent e){
		
	}
	
	public void clickProcess(ActionEvent e){
		FacesContext context=FacesContext.getCurrentInstance();
		HttpServletRequest req=(HttpServletRequest) context.getExternalContext().getRequest();
		System.out.println(req.getParameter("name"));
	}
	
	public void recycleClearProcess(ActionEvent e){
		recycleSet.clear();
	}
	
	public void recycleSubmitProcess(ActionEvent e){
		for(Point p:recycleSet){
			if(!MyTree.deletePointInDB(p.getId())){
				System.out.println("error");
			}
		}
		recycleSet.clear();
		new MyTree().constructMyTree();
	}
	
	public void recycleProcess(DropEvent e){
		Point drag=(Point) e.getDragValue();
		recycleSet.add(drag);
		System.out.println("recycle "+drag.getName());
	}

	public List<Point> getRecycleSet() {
		return recycleSet;
	}

	public void setRecycleSet(List<Point> recycleSet) {
		this.recycleSet = recycleSet;
	}
	
}


⌨️ 快捷键说明

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