All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.airlenet.repo.domain.TreeImpl Maven / Gradle / Ivy

The newest version!
package com.airlenet.repo.domain;

import java.util.List;
import java.util.Set;

import org.apache.commons.beanutils.PropertyUtils;

import com.google.common.base.Strings;

public class TreeImpl> implements Tree {

	private List> roots;
	private Set checked;
	private boolean checkable = false;
	private boolean expendAll = false;

	public TreeImpl(List> roots) {
		this.roots = roots;
	}

	@Override
	public List> getRoots() {
		return roots;
	}

	@Override
	public Set getChecked() {
		return checked;
	}

	@Override
	public void setChecked(Set checked) {
		this.checked = checked;
	}

	@Override
	public boolean isCheckable() {
		return checkable;
	}

	@Override
	public boolean isExpandAll() {
		return expendAll;
	}

	@Override
	public void makeCheckable() {
		this.checkable = true;
	}

	@Override
	public void makeExpandAll() {
		this.expendAll = true;
	}

	@Override
	public Tree setTextProperty(String textProperty) {
		if (!Strings.isNullOrEmpty(textProperty)) {
			Tree.visitNodes(roots, node -> {
				try {
					node.setText((String) PropertyUtils.getProperty(node.getData(), textProperty));
				} catch (Exception e) {
					e.printStackTrace();
				}
			});
		}
		return this;
	}

	@Override
	public Tree setIconClsProperty(String iconClsProperty) {
		if (!Strings.isNullOrEmpty(iconClsProperty)) {
			Tree.visitNodes(roots, node -> {
				try {
					node.setIconCls((String) PropertyUtils.getProperty(node.getData(), iconClsProperty));
				} catch (Exception e) {
					e.printStackTrace();
				}
			});
		}
		return this;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy