use of org.zkoss.zul.Treeitem in project adempiere by adempiere.
the class TreeSearchPanel method select.
private void select(Treeitem selectedItem) {
Treeitem parent = selectedItem.getParentItem();
while (parent != null) {
if (!parent.isOpen())
parent.setOpen(true);
parent = parent.getParentItem();
}
selectedItem.getTree().setSelectedItem(selectedItem);
}
use of org.zkoss.zul.Treeitem in project adempiere by adempiere.
the class WDeleteEntity method loadView.
/**
* Load View
* @param clientId
* @param tableId
*/
private void loadView() {
//
DeleteEntitiesModel data = new DeleteEntitiesModel(getClientId(), getTableId());
//
tree.clear();
if ((tree.getChildren()).size() > 1) {
@SuppressWarnings("rawtypes") List treePreviousChild = tree.getChildren();
tree.removeChild((Treechildren) treePreviousChild.get(1));
}
//
Treechildren rootTreeChild = new Treechildren();
Treeitem rootTreeItem = new Treeitem();
rootTreeItem.setValue(data);
rootTreeItem.setLabel(data.toString());
Treechildren rootTreeItemChild = new Treechildren();
createNodes(data, rootTreeItemChild);
rootTreeItem.appendChild(rootTreeItemChild);
rootTreeChild.appendChild(rootTreeItem);
tree.appendChild(rootTreeChild);
}
use of org.zkoss.zul.Treeitem in project adempiere by adempiere.
the class TreeUtils method traverse.
/**
* Traverse treechildren and execution action on Treeitem
* @param treechildren
* @param action
*/
public static void traverse(Treechildren treechildren, TreeItemAction action) {
List<?> list = treechildren.getChildren();
for (int index = 0; index < list.size(); index++) {
Object o = list.get(index);
if (o instanceof Treechildren) {
Treechildren treechild = (Treechildren) o;
traverse(treechild, action);
} else if (o instanceof Treeitem) {
Treeitem treeitem = (Treeitem) o;
action.run(treeitem);
List<?> treeitemChildren = treeitem.getChildren();
for (int childIndex = 0; childIndex < treeitemChildren.size(); childIndex++) {
Object child = treeitemChildren.get(childIndex);
if (child instanceof Treechildren) {
Treechildren treechild = (Treechildren) child;
traverse(treechild, action);
}
}
}
}
}
use of org.zkoss.zul.Treeitem in project adempiere by adempiere.
the class WTreeMaintenance method action_treeAdd.
// propertyChange
/**
* Action: Add Node to Tree
* @param item item
*/
private void action_treeAdd(ListItem item) {
log.info("Item=" + item);
if (item != null) {
SimpleTreeModel model = (SimpleTreeModel) (TreeModel<?>) centerTree.getModel();
DefaultTreeNode stn = model.find(model.getRoot(), item.id);
if (stn != null) {
MTreeNode tNode = (MTreeNode) stn.getData();
tNode.setName(item.name);
tNode.setAllowsChildren(item.isSummary);
tNode.setImageIndicator(item.imageIndicator);
model.nodeUpdated(stn);
Treeitem ti = centerTree.renderItemByPath(model.getPath(stn));
ti.setTooltiptext(item.description);
} else {
stn = new DefaultTreeNode(new MTreeNode(item.id, 0, item.name, item.description, 0, item.isSummary, item.imageIndicator, false, null), new ArrayList<Object>());
model.addNode(stn);
}
// May cause Error if in tree
addNode(item);
}
}
use of org.zkoss.zul.Treeitem in project adempiere by adempiere.
the class ADTreeOnDropListener method onEvent.
/**
* @param event
*/
public void onEvent(Event event) throws Exception {
if (event instanceof DropEvent) {
DropEvent de = (DropEvent) event;
log.fine("Source=" + de.getDragged() + " Target=" + de.getTarget());
if (de.getDragged() != de.getTarget()) {
Treeitem src = (Treeitem) ((Treerow) de.getDragged()).getParent();
Treeitem target = (Treeitem) ((Treerow) de.getTarget()).getParent();
moveNode((DefaultTreeNode) src.getValue(), (DefaultTreeNode) target.getValue());
}
}
}
Aggregations