/** * Adds drag/drop support to the items belonging to the specified list box. * * @param lb The list box. * @param dropId The drop id to be used. * @param eventListener The event listener to handle the drag/drop operations. */ private void addDragDropSupport(Listbox lb, String dropId, EventListener<?> eventListener) { for (Object object : lb.getItems()) { Listitem item = (Listitem) object; item.setDraggable(dropId); item.setDroppable(dropId); item.addEventListener(Events.ON_DROP, eventListener); } }
/** * Creates and returns a draggable list item. * * @param associateEvents If true, associate events with this item. * @return New list item. */ private Listitem newListitem(boolean associateEvents) { Listitem item = new Listitem(); if (associateEvents) { associateEvents(item); } String label = "Drop item #" + ++itemCount + (associateEvents ? " *" : ""); item.setLabel(label); // Set to info panel drop id. item.setDraggable(IInfoPanel.DROP_ID); // Create and attach the object to be rendered. DroppedItem dropped = new DroppedItem(label, "This is the detail for drop item #" + itemCount); item.setValue(dropped); // Associate the drop renderer with the item. DropUtil.setDropRenderer(item, dropRenderer); return item; }