org.cafesip.gwtcomp.client.ui
Class DroppableList

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.google.gwt.user.client.ui.Composite
              extended by org.cafesip.gwtcomp.client.ui.DroppableList
All Implemented Interfaces:
HasHandlers, EventListener, HasName

public class DroppableList
extends Composite
implements HasName

A list object where a draggable item can be dropped into. As explained in the documentation for Draggable, any visual widget can be converted into a draggable object which can be dragged by the user and dropped to this object. Alternatively, applications can use the DraggableLabel. In addition, the users can delete any item in the list.This object implements the GWT HasName interface. Therefore it can be used with a GWT FormPanel. When used with a FormPanel, it behaves like a ListBox with all its items selected.

The draggable/droppable classes use the scriptaculous javascript library for providing the functionality. Therefore, you must add the following segment to your application HTML file (see the GWTCompExamples.html for an example).

       <script src="gwtcomp-scripts/scriptaculous/prototype.js" type="text/javascript"></script>
       <script src="gwtcomp-scripts/scriptaculous/scriptaculous.js" type="text/javascript"></script>
       <script src="gwtcomp-scripts/scriptaculous/dragdrop.js" type="text/javascript"></script>
 

CSS Style Rules:

Screen-Shots:

Screen-Shots:

Author:
Amit Chatterjee

Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
 
Field Summary
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
DroppableList(String id, String clazz)
          A constructor for this class.
 
Method Summary
 void addItem(String name)
          Add an item to the list.
 void addItem(String name, boolean fireEvents)
          Adds an items to the list and invokes listeners if registered.
 void addListener(DroppableListListener listener)
          Adds a listener for listening to drop events.
 void deleteItem(int index)
          Deletes an item at the specified index.
 void deleteItem(String name)
          Delete an item from the list.
 String getBasketEmptyIcon()
          Returns the currently-set icon that is displayed when the list is empty.
 String getBasketFullIcon()
          Returns the currently-set icon that is displayed when the list has items.
 String getClazz()
           
 String getId()
           
 String getItem(int index)
          Get the item at a specified index.
 int getItemCount()
          Get the number of items in the list.
 String[] getItems()
          Gets all the items in the list.
 String getName()
           
protected  void onLoad()
           
 void removeListener(DroppableListListener listener)
          Removes a listener.
 void setBasketEmptyIcon(String basketEmptyIcon)
          Sets the URL for the icon that is displayed when the list is empty.
 void setBasketFullIcon(String basketFullIcon)
          Sets the URL for the icon that is displayed when the list has items.
 void setName(String name)
           
 
Methods inherited from class com.google.gwt.user.client.ui.Composite
getWidget, initWidget, isAttached, onAttach, onBrowserEvent, onDetach, setWidget
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
addDomHandler, addHandler, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, onUnload, removeFromParent, setLayoutData, sinkEvents
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, toString, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DroppableList

public DroppableList(String id,
                     String clazz)
A constructor for this class.

Parameters:
id - DOM id of the list.
clazz - the class of items it accepts. See Draggable for details.
Method Detail

addItem

public void addItem(String name)
Add an item to the list.

Parameters:
name - the name of the item.

addItem

public void addItem(String name,
                    boolean fireEvents)
Adds an items to the list and invokes listeners if registered.

Parameters:
name - name of the item.
fireEvents - listeners are invoked if set to true.

deleteItem

public void deleteItem(String name)
Delete an item from the list.

Parameters:
name - name of the item.

getItemCount

public int getItemCount()
Get the number of items in the list.

Returns:
item count.

getItem

public String getItem(int index)
Get the item at a specified index.

Parameters:
index - index
Returns:
the name of the item.

deleteItem

public void deleteItem(int index)
Deletes an item at the specified index.

Parameters:
index -

getItems

public String[] getItems()
Gets all the items in the list.

Returns:
the items

onLoad

protected void onLoad()
Overrides:
onLoad in class Widget

getName

public String getName()
Specified by:
getName in interface HasName
See Also:
HasName.getName()

setName

public void setName(String name)
Specified by:
setName in interface HasName
See Also:
HasName.setName(java.lang.String)

addListener

public void addListener(DroppableListListener listener)
Adds a listener for listening to drop events.

Parameters:
listener -

removeListener

public void removeListener(DroppableListListener listener)
Removes a listener.

Parameters:
listener -

getBasketEmptyIcon

public String getBasketEmptyIcon()
Returns the currently-set icon that is displayed when the list is empty.

Returns:
Returns the URL for the basketEmptyIcon.

setBasketEmptyIcon

public void setBasketEmptyIcon(String basketEmptyIcon)
Sets the URL for the icon that is displayed when the list is empty.

Parameters:
basketEmptyIcon - The URL for basketEmptyIcon to set.

getBasketFullIcon

public String getBasketFullIcon()
Returns the currently-set icon that is displayed when the list has items.

Returns:
Returns the URL for the basketFullIcon.

setBasketFullIcon

public void setBasketFullIcon(String basketFullIcon)
Sets the URL for the icon that is displayed when the list has items.

Parameters:
basketFullIcon - The URL for the basketFullIcon to set.

getId

public String getId()
Returns:
Returns the id.

getClazz

public String getClazz()
Returns:
Returns the clazz.


Copyright © 2010 Cafesip.org. All Rights Reserved.