Search in sources :

Example 11 with Treeitem

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);
    }
}
Also used : Treeitem(org.zkoss.zul.Treeitem) SimpleTreeModel(org.adempiere.webui.component.SimpleTreeModel) DefaultTreeNode(org.zkoss.zul.DefaultTreeNode) SimpleListModel(org.adempiere.webui.component.SimpleListModel)

Example 12 with Treeitem

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());
    }
}
Also used : MTreeNode(org.compiere.model.MTreeNode) Treeitem(org.zkoss.zul.Treeitem) Menupopup(org.zkoss.zul.Menupopup) Menuitem(org.zkoss.zul.Menuitem) DefaultTreeNode(org.zkoss.zul.DefaultTreeNode) Event(org.zkoss.zk.ui.event.Event) DropEvent(org.zkoss.zk.ui.event.DropEvent)

Example 13 with Treeitem

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);
        }
    }
}
Also used : DropEvent(org.zkoss.zk.ui.event.DropEvent) Treeitem(org.zkoss.zul.Treeitem) ToolBarButton(org.adempiere.webui.component.ToolBarButton) Component(org.zkoss.zk.ui.Component) IOException(java.io.IOException) Treerow(org.zkoss.zul.Treerow)

Example 14 with 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);
        }
    }
}
Also used : MTreeNode(org.compiere.model.MTreeNode) Treeitem(org.zkoss.zul.Treeitem) Treechildren(org.zkoss.zul.Treechildren)

Example 15 with Treeitem

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();
    }
//
}
Also used : Treeitem(org.zkoss.zul.Treeitem) Component(org.zkoss.zk.ui.Component) Treerow(org.zkoss.zul.Treerow)

Aggregations

Treeitem (org.zkoss.zul.Treeitem)22 DefaultTreeNode (org.zkoss.zul.DefaultTreeNode)8 MTreeNode (org.compiere.model.MTreeNode)7 Treechildren (org.zkoss.zul.Treechildren)7 DeleteEntitiesModel (org.adempiere.util.DeleteEntitiesModel)5 DropEvent (org.zkoss.zk.ui.event.DropEvent)5 Treerow (org.zkoss.zul.Treerow)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 SimpleTreeModel (org.adempiere.webui.component.SimpleTreeModel)3 Component (org.zkoss.zk.ui.Component)3 SQLException (java.sql.SQLException)2 Collection (java.util.Collection)2 AdempiereException (org.adempiere.exceptions.AdempiereException)2 SimpleListModel (org.adempiere.webui.component.SimpleListModel)2 Event (org.zkoss.zk.ui.event.Event)2 IOException (java.io.IOException)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 HashSet (java.util.HashSet)1