use of org.zkoss.zul.Treeitem in project adempiere by adempiere.
the class WTreeMaintenance method onListSelection.
// action_fillTree
/**
* List Selection Listener
* @param e event
*/
private void onListSelection(Event e) {
ListItem selected = null;
try {
SimpleListModel model = (SimpleListModel) centerList.getModel();
int i = centerList.getSelectedIndex();
selected = (ListItem) model.getElementAt(i);
} catch (Exception ex) {
}
log.info("Selected=" + selected);
if (// allow add if not in tree
selected != null) {
SimpleTreeModel tm = (SimpleTreeModel) (TreeModel<?>) centerTree.getModel();
DefaultTreeNode stn = tm.find(tm.getRoot(), selected.id);
if (stn != null) {
int[] path = tm.getPath(stn);
Treeitem ti = centerTree.renderItemByPath(path);
ti.setSelected(true);
}
bAdd.setEnabled(stn == null);
}
}
use of org.zkoss.zul.Treeitem in project adempiere by adempiere.
the class ADTreeOnDropListener method moveNode.
/**
* Move TreeNode
* @param movingNode The node to be moved
* @param toNode The target node
*/
private void moveNode(DefaultTreeNode movingNode, DefaultTreeNode toNode) {
log.info(movingNode.toString() + " to " + toNode.toString());
if (movingNode == toNode)
return;
MTreeNode toMNode = (MTreeNode) toNode.getData();
DefaultTreeNode newParent;
int index;
if (// drop on a child node
!toMNode.isSummary()) {
moveNode(movingNode, toNode, false);
} else // drop on a summary node
{
//prompt user to select insert after or drop into the summary node
int[] path = treeModel.getPath(toNode);
Treeitem toItem = tree.renderItemByPath(path);
tree.setSelectedItem(toItem);
Events.sendEvent(tree, new Event(Events.ON_SELECT, tree));
MenuListener listener = new MenuListener(movingNode, toNode);
//TODO: translation
Menupopup popup = new Menupopup();
Menuitem menuItem = new Menuitem("Insert After");
menuItem.setValue("InsertAfter");
menuItem.setParent(popup);
menuItem.addEventListener(Events.ON_CLICK, listener);
menuItem = new Menuitem("Move Into");
menuItem.setValue("MoveInto");
menuItem.setParent(popup);
menuItem.addEventListener(Events.ON_CLICK, listener);
popup.setPage(tree.getPage());
popup.open(toItem.getTreerow());
}
}
use of org.zkoss.zul.Treeitem in project adempiere by adempiere.
the class NavBarDesktop method onEvent.
public void onEvent(Event event) {
Component comp = event.getTarget();
String eventName = event.getName();
if (eventName.equals(Events.ON_CLICK)) {
if (comp instanceof ToolBarButton) {
ToolBarButton btn = (ToolBarButton) comp;
int menuId = 0;
try {
menuId = Integer.valueOf(btn.getName());
} catch (Exception e) {
}
if (menuId > 0)
onMenuSelected(menuId);
}
} else if (eventName.equals(Events.ON_DROP)) {
DropEvent de = (DropEvent) event;
Component dragged = de.getDragged();
if (dragged instanceof Treerow) {
Treerow treerow = (Treerow) dragged;
Treeitem treeitem = (Treeitem) treerow.getParent();
favPanel.addItem(treeitem);
}
}
}
use of org.zkoss.zul.Treeitem in project adempiere by adempiere.
the class MenuPanel method generateMenu.
private void generateMenu(Treechildren treeChildren, MTreeNode mNode) {
Enumeration<?> nodeEnum = mNode.children();
while (nodeEnum.hasMoreElements()) {
MTreeNode mChildNode = (MTreeNode) nodeEnum.nextElement();
Treeitem treeitem = new Treeitem();
treeChildren.appendChild(treeitem);
treeitem.setLabel(mChildNode.getName());
treeitem.setTooltiptext(mChildNode.getDescription());
if (mChildNode.getChildCount() != 0) {
treeitem.setOpen(false);
Treechildren treeItemChildren = new Treechildren();
generateMenu(treeItemChildren, mChildNode);
if (treeItemChildren.getChildren().size() != 0)
treeitem.appendChild(treeItemChildren);
treeitem.getTreerow().addEventListener(Events.ON_CLICK, this);
} else {
treeitem.setValue(String.valueOf(mChildNode.getNode_ID()));
if (mChildNode.isReport())
treeitem.setImage(ServletFns.resolveThemeURL("~./images/mReport.png"));
else if (mChildNode.isProcess() || mChildNode.isTask())
treeitem.setImage(ServletFns.resolveThemeURL("~./images/mProcess.png"));
else if (mChildNode.isWorkFlow())
treeitem.setImage(ServletFns.resolveThemeURL("~./images/mWorkFlow.png"));
else
treeitem.setImage(ServletFns.resolveThemeURL("~./images/mWindow.png"));
// Elaine 2008/07/24
treeitem.getTreerow().setDraggable("favourite");
treeitem.getTreerow().addEventListener(Events.ON_CLICK, this);
}
}
}
use of org.zkoss.zul.Treeitem in project adempiere by adempiere.
the class MenuPanel method onEvent.
public void onEvent(Event event) {
Component comp = event.getTarget();
String eventName = event.getName();
if (eventName.equals(Events.ON_CLICK)) {
if (comp instanceof Treerow) {
Treeitem selectedItem = (Treeitem) comp.getParent();
if (selectedItem.getValue() != null) {
fireMenuSelectedEvent(selectedItem);
} else {
selectedItem.setOpen(!selectedItem.isOpen());
}
}
} else // Elaine 2009/02/27 - expand tree
if (eventName.equals(Events.ON_CHECK) && event.getTarget() == chkExpand) {
expandOnCheck();
}
//
}
Aggregations