Search in sources :

Example 1 with DropEvent

use of org.zkoss.zk.ui.event.DropEvent 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);
            }
        }
    }
//
}
Also used : DropEvent(org.zkoss.zk.ui.event.DropEvent) Treeitem(org.zkoss.zul.Treeitem) Button(org.adempiere.webui.component.Button) Panelchildren(org.zkoss.zul.Panelchildren) Component(org.zkoss.zk.ui.Component) Image(org.zkoss.zul.Image) Treerow(org.zkoss.zul.Treerow)

Example 2 with DropEvent

use of org.zkoss.zk.ui.event.DropEvent in project spatial-portal by AtlasOfLivingAustralia.

the class ActiveLayerDNDEventListener method onEvent.

@Override
public void onEvent(Event event) throws Exception {
    LOGGER.debug("active layers item drop received");
    MapComposer mapComposer = getMapComposer(event);
    if (mapComposer != null && mapComposer.safeToPerformMapAction()) {
        LOGGER.debug("inside ActiveLayerDNDEventListener.onEvent()");
        if (event instanceof DropEvent) {
            DropEvent dragEvent = (DropEvent) event;
            // we support the treechildren and other list items...
            Component eventType = dragEvent.getDragged();
            if (eventType instanceof Listitem) {
                reorderList(mapComposer, dragEvent);
            } else {
                LOGGER.debug("unsupported dnd event " + eventType.getClass().getName());
            }
        } else {
            LOGGER.debug("event is not a DropEvent instance: " + event.getClass().getName());
        }
    }
}
Also used : DropEvent(org.zkoss.zk.ui.event.DropEvent) MapComposer(au.org.emii.portal.composer.MapComposer) Listitem(org.zkoss.zul.Listitem) Component(org.zkoss.zk.ui.Component)

Example 3 with DropEvent

use of org.zkoss.zk.ui.event.DropEvent 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());
        }
    }
}
Also used : DropEvent(org.zkoss.zk.ui.event.DropEvent) Treeitem(org.zkoss.zul.Treeitem)

Example 4 with DropEvent

use of org.zkoss.zk.ui.event.DropEvent in project adempiere by adempiere.

the class ADSortTab method init.

/**
	 * 	Static Layout
	 * 	@throws Exception
	 */
private void init() throws Exception {
    this.setStyle("height: 100%; width: 100%;");
    //
    noLabel.setValue("No");
    yesLabel.setValue("Yes");
    //yesList.setHeight("100%");
    //noList.setHeight("100%");
    yesList.setVflex(true);
    noList.setVflex(true);
    EventListener mouseListener = new EventListener() {

        public void onEvent(Event event) throws Exception {
            if (Events.ON_DOUBLE_CLICK.equals(event.getName())) {
                migrateValueAcrossLists(event);
            }
        }
    };
    yesList.addDoubleClickListener(mouseListener);
    noList.addDoubleClickListener(mouseListener);
    //
    EventListener actionListener = new EventListener() {

        public void onEvent(Event event) throws Exception {
            migrateValueAcrossLists(event);
        }
    };
    yesList.setSeltype("multiple");
    noList.setSeltype("multiple");
    bAdd.setImage(ServletFns.resolveThemeURL("~./images/Detail24.png"));
    bAdd.addEventListener(Events.ON_CLICK, actionListener);
    bRemove.setImage(ServletFns.resolveThemeURL("~./images/Parent24.png"));
    bRemove.addEventListener(Events.ON_CLICK, actionListener);
    EventListener crossListMouseListener = new DragListener();
    yesList.addOnDropListener(crossListMouseListener);
    noList.addOnDropListener(crossListMouseListener);
    yesList.setItemDraggable(true);
    noList.setItemDraggable(true);
    actionListener = new EventListener() {

        public void onEvent(Event event) throws Exception {
            migrateValueWithinYesList(event);
        }
    };
    bUp.setImage(ServletFns.resolveThemeURL("~./images/Previous24.png"));
    bUp.addEventListener(Events.ON_CLICK, actionListener);
    bDown.setImage(ServletFns.resolveThemeURL("~./images/Next24.png"));
    bDown.addEventListener(Events.ON_CLICK, actionListener);
    EventListener yesListMouseMotionListener = new EventListener() {

        public void onEvent(Event event) throws Exception {
            if (event instanceof DropEvent) {
                DropEvent me = (DropEvent) event;
                ListItem startItem = (ListItem) me.getDragged();
                ListItem endItem = (ListItem) me.getTarget();
                if (startItem.getListbox() == endItem.getListbox() && startItem.getListbox() == yesList) {
                    int startIndex = yesList.getIndexOfItem(startItem);
                    int endIndex = yesList.getIndexOfItem(endItem);
                    Object endElement = yesModel.getElementAt(endIndex);
                    Object element = yesModel.getElementAt(startIndex);
                    yesModel.removeElement(element);
                    endIndex = yesModel.indexOf(endElement);
                    yesModel.add(endIndex, element);
                    yesList.setSelectedIndex(endIndex);
                    if (yesList.getSelectedItem() != null) {
                        AuFocus focus = new AuFocus(yesList.getSelectedItem());
                        Clients.response(focus);
                    }
                    setIsChanged(true);
                }
            }
        }
    };
    yesList.addOnDropListener(yesListMouseMotionListener);
    ListHead listHead = new ListHead();
    listHead.setParent(yesList);
    ListHeader listHeader = new ListHeader();
    listHeader.appendChild(yesLabel);
    listHeader.setParent(listHead);
    listHead = new ListHead();
    listHead.setParent(noList);
    listHeader = new ListHeader();
    listHeader.appendChild(noLabel);
    listHeader.setParent(listHead);
    Span span = new Span();
    span.setParent(this);
    span.setStyle("height: 99%; display: inline-block; width: 40%;");
    span.appendChild(noList);
    Vbox vbox = new Vbox();
    vbox.appendChild(bAdd);
    vbox.appendChild(bRemove);
    span = new Span();
    span.setParent(this);
    span.setStyle("height: 99%; display: inline-block; width: 46px");
    span.appendChild(vbox);
    span = new Span();
    span.setParent(this);
    span.setStyle("height: 99%; display: inline-block; width: 40%");
    span.appendChild(yesList);
    vbox = new Vbox();
    vbox.appendChild(bUp);
    vbox.appendChild(bDown);
    span = new Span();
    span.setParent(this);
    span.setStyle("height: 99%; display: inline-block; width: 46px");
    span.appendChild(vbox);
}
Also used : DropEvent(org.zkoss.zk.ui.event.DropEvent) Span(org.zkoss.zhtml.Span) SQLException(java.sql.SQLException) AuFocus(org.zkoss.zk.au.out.AuFocus) ListHead(org.adempiere.webui.component.ListHead) ListDataEvent(org.zkoss.zul.event.ListDataEvent) Event(org.zkoss.zk.ui.event.Event) DropEvent(org.zkoss.zk.ui.event.DropEvent) ListHeader(org.adempiere.webui.component.ListHeader) EventListener(org.zkoss.zk.ui.event.EventListener) ListItem(org.adempiere.webui.component.ListItem) Vbox(org.zkoss.zul.Vbox)

Example 5 with DropEvent

use of org.zkoss.zk.ui.event.DropEvent 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)

Aggregations

DropEvent (org.zkoss.zk.ui.event.DropEvent)5 Component (org.zkoss.zk.ui.Component)3 Treeitem (org.zkoss.zul.Treeitem)3 Treerow (org.zkoss.zul.Treerow)2 MapComposer (au.org.emii.portal.composer.MapComposer)1 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1 Button (org.adempiere.webui.component.Button)1 ListHead (org.adempiere.webui.component.ListHead)1 ListHeader (org.adempiere.webui.component.ListHeader)1 ListItem (org.adempiere.webui.component.ListItem)1 ToolBarButton (org.adempiere.webui.component.ToolBarButton)1 Span (org.zkoss.zhtml.Span)1 AuFocus (org.zkoss.zk.au.out.AuFocus)1 Event (org.zkoss.zk.ui.event.Event)1 EventListener (org.zkoss.zk.ui.event.EventListener)1 Image (org.zkoss.zul.Image)1 Listitem (org.zkoss.zul.Listitem)1 Panelchildren (org.zkoss.zul.Panelchildren)1 Vbox (org.zkoss.zul.Vbox)1