use of org.zkoss.zul.Treeitem in project adempiere by adempiere.
the class WDeleteEntity method createNodes.
// dynInit
/**
* Create Nodes
* @param root
*/
private void createNodes(DeleteEntitiesModel currentNode, Treechildren root) {
// Load from parent
loadChilds(currentNode, root);
@SuppressWarnings("unchecked") Collection<Treeitem> collItemChild = (Collection<Treeitem>) root.getItems();
Iterator<Treeitem> it = collItemChild.iterator();
//
while (it.hasNext()) {
Treeitem node = (Treeitem) it.next();
Treeitem rootOfNode = node.getParentItem();
if (rootOfNode != null && rootOfNode.getParentItem() != null && rootOfNode.getParentItem().equals(node)) {
log.log(Level.WARNING, "Loop detected, escaping.");
break;
} else if (((DeleteEntitiesModel) node.getValue()).isMandatoryLink()) {
DeleteEntitiesModel itemTableData = (DeleteEntitiesModel) node.getValue();
Treechildren nodeChild = new Treechildren();
createNodes(itemTableData, nodeChild);
//
if (nodeChild.getItemCount() != 0) {
node.appendChild(nodeChild);
}
}
}
}
use of org.zkoss.zul.Treeitem in project adempiere by adempiere.
the class WDeleteEntity method addToNode.
@Override
public void addToNode(DeleteEntitiesModel data, Object rootNode) {
Treeitem treeitem = new Treeitem();
((Treechildren) rootNode).appendChild(treeitem);
treeitem.setLabel(data.toString());
treeitem.setValue(data);
}
use of org.zkoss.zul.Treeitem in project adempiere by adempiere.
the class DPFavourites method onEvent.
public void onEvent(Event event) {
Component comp = event.getTarget();
String eventName = event.getName();
if (eventName.equals(Events.ON_CLICK)) {
if (comp instanceof Button) {
Button btn = (Button) comp;
int menuId = 0;
try {
menuId = Integer.valueOf(btn.getName());
} catch (NumberFormatException e) {
}
if (menuId > 0)
SessionManager.getAppDesktop().onMenuSelected(menuId);
}
} else // Elaine 2008/07/24
if (eventName.equals(Events.ON_DROP)) {
DropEvent de = (DropEvent) event;
Component dragged = de.getDragged();
if (comp instanceof Panelchildren) {
if (dragged instanceof Treerow) {
Treerow treerow = (Treerow) dragged;
Treeitem treeitem = (Treeitem) treerow.getParent();
addItem(treeitem);
}
} else if (comp instanceof Image) {
if (dragged instanceof Button) {
Button btn = (Button) dragged;
removeLink(btn);
}
}
}
//
}
use of org.zkoss.zul.Treeitem in project adempiere by adempiere.
the class TreeSearchPanel method onEvent.
/**
* @param event
* @see EventListener#onEvent(Event)
*/
public void onEvent(Event event) {
if (cmbSearch.equals(event.getTarget()) && ((event.getName().equals(Events.ON_CHANGE) || event.getName().equals(Events.ON_OK)))) {
String value = cmbSearch.getValue();
if (value != null && value.trim().length() > 0 && value.substring(0, 1).equals(PREFIX_DOCUMENT_SEARCH)) {
DocumentSearch search = new DocumentSearch();
if (search.openDocumentsByDocumentNo(value.substring(1)))
cmbSearch.setText(null);
return;
}
Object node = treeNodeItemMap.get(value);
Treeitem treeItem = null;
if (node == null) {
return;
} else if (node instanceof Treeitem) {
treeItem = (Treeitem) node;
} else {
DefaultTreeNode<?> sNode = (DefaultTreeNode<?>) node;
int[] path = tree.getModel().getPath(sNode);
treeItem = tree.renderItemByPath(path);
tree.setSelectedItem(treeItem);
}
if (treeItem != null) {
select(treeItem);
Clients.showBusy(Msg.getMsg(Env.getCtx(), "Loading"));
Events.echoEvent("onPostSelect", this, null);
}
}
}
use of org.zkoss.zul.Treeitem in project adempiere by adempiere.
the class TreeSearchPanel method refreshSearchList.
private void refreshSearchList() {
treeNodeItemMap.clear();
if (tree.getModel() == null) {
TreeUtils.traverse(tree, new TreeItemAction() {
public void run(Treeitem treeItem) {
addTreeItem(treeItem);
}
});
} else {
TreeUtils.traverse(tree.getModel(), new TreeNodeAction() {
public void run(DefaultTreeNode<?> treeNode) {
addTreeItem(treeNode);
}
});
}
treeValues = new String[treeNodeItemMap.size()];
treeDescription = new String[treeNodeItemMap.size()];
int i = -1;
for (Object value : treeNodeItemMap.values()) {
i++;
if (value instanceof Treeitem) {
Treeitem treeItem = (Treeitem) value;
treeValues[i] = treeItem.getLabel();
treeDescription[i] = treeItem.getTooltiptext();
} else if (value instanceof DefaultTreeNode) {
DefaultTreeNode<?> sNode = (DefaultTreeNode<?>) value;
MTreeNode mNode = (MTreeNode) sNode.getData();
treeValues[i] = mNode.getName();
treeDescription[i] = mNode.getDescription();
}
}
cmbSearch.setDescription(treeDescription);
cmbSearch.setDict(treeValues);
}
Aggregations