org.odlabs.wiquery.ui.droppable
Class DroppableBehavior

java.lang.Object
  extended by org.apache.wicket.behavior.Behavior
      extended by org.odlabs.wiquery.core.behavior.WiQueryAbstractBehavior
          extended by org.odlabs.wiquery.ui.droppable.DroppableBehavior
All Implemented Interfaces:
Serializable, org.apache.wicket.IClusterable, org.apache.wicket.IComponentAwareEventSink, org.apache.wicket.markup.html.IComponentAwareHeaderContributor, IWiQueryPlugin

public class DroppableBehavior
extends WiQueryAbstractBehavior

$Id$

Sets the attached component droppable, e.g. it can accept draggable elements.

Since:
1.0
Author:
Lionel Armanet
See Also:
Serialized Form

Nested Class Summary
static class DroppableBehavior.ToleranceEnum
          Enumeration for the tolerance option
 
Field Summary
static String UI_DRAGGABLE
          Properties on the ui parameter (use it into callback functions) : current draggable element, a jQuery object.
static String UI_HELPER
          Properties on the ui parameter (use it into callback functions) : current draggable helper, a jQuery object
static String UI_OFFSET
          Properties on the ui parameter (use it into callback functions) : current absolute position of the draggable helper { top: , left: }
static String UI_POSITION
          Properties on the ui parameter (use it into callback functions) : current position of the draggable helper { top: , left: }
 
Constructor Summary
DroppableBehavior()
           
 
Method Summary
 JsStatement destroy()
          Method to destroy the droppable This will return the element back to its pre-init state.
 void destroy(org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
          Method to destroy the droppable within the ajax request
 void detach(org.apache.wicket.Component component)
           
 JsStatement disable()
          Method to disable the droppable
 void disable(org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
          Method to disable the droppable within the ajax request
 JsStatement enable()
          Method to enable the droppable
 void enable(org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
          Method to enable the droppable within the ajax request
 DroppableAccept getAccept()
           
 String getActiveClass()
           
 String getHoverClass()
           
protected  Options getOptions()
          Method retrieving the options of the component
 String getScope()
           
 DroppableBehavior.ToleranceEnum getTolerance()
           
 boolean isAddClasses()
           
 boolean isDisabled()
           
 boolean isGreedy()
           
 void onBind()
          Called when the component was bound to it's host component.
 void renderHead(org.apache.wicket.Component component, org.apache.wicket.markup.html.IHeaderResponse response)
           
 DroppableBehavior setAccept(DroppableAccept accept)
          All draggables that match the selector will be accepted.
 DroppableBehavior setActivateEvent(JsScopeUiEvent activate)
          Set's the callback when an accepted draggable starts dragging.
 DroppableBehavior setActiveClass(String activeClass)
          If specified, the class will be added to the droppable while an acceptable draggable is being dragged.
 DroppableBehavior setAddClasses(boolean addClasses)
          If true, will prevent event propagation on nested droppables.
 DroppableBehavior setDeactivateEvent(JsScopeUiEvent deactivate)
          Set's the callback when an accepted draggable stops dragging.
 DroppableBehavior setDisabled(boolean disabled)
          Disables (true) or enables (false) the droppable.
 DroppableBehavior setDropEvent(JsScopeUiEvent drop)
          Set's the callback when an accepted draggable is dropped 'over' (within the tolerance of) this droppable.
 DroppableBehavior setGreedy(boolean greedy)
          If true, will prevent event propagation on nested droppables.
 DroppableBehavior setHoverClass(String hoverClass)
          If specified, the class will be added to the droppable while an acceptable draggable is being hovered.
 DroppableBehavior setOutEvent(JsScopeUiEvent out)
          Set's the callback when an accepted draggable is dragged out (within the tolerance of) this droppable.
 DroppableBehavior setOverEvent(JsScopeUiEvent over)
          Set's the callback when an accepted draggable is dragged 'over' (within the tolerance of) this droppable.
 DroppableBehavior setScope(String scope)
          Used to group sets of draggable and droppable items, in addition to droppable's accept option.
 DroppableBehavior setTolerance(DroppableBehavior.ToleranceEnum tolerance)
          Set's the mode to use for testing whether a draggable is 'over' a droppable.
 JsStatement statement()
          Returns the main JsStatement used to create the plugin.
 JsStatement widget()
          Method to returns the .ui-droppable element
 void widget(org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
          Method to returns the .ui-droppable element within the ajax request
 
Methods inherited from class org.odlabs.wiquery.core.behavior.WiQueryAbstractBehavior
bind, getComponent
 
Methods inherited from class org.apache.wicket.behavior.Behavior
afterRender, beforeRender, canCallListenerInterface, canCallListenerInterface, getStatelessHint, isEnabled, isTemporary, onComponentTag, onConfigure, onEvent, onException, unbind
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UI_DRAGGABLE

public static final String UI_DRAGGABLE
Properties on the ui parameter (use it into callback functions) : current draggable element, a jQuery object.

See Also:
Constant Field Values

UI_HELPER

public static final String UI_HELPER
Properties on the ui parameter (use it into callback functions) : current draggable helper, a jQuery object

See Also:
Constant Field Values

UI_POSITION

public static final String UI_POSITION
Properties on the ui parameter (use it into callback functions) : current position of the draggable helper { top: , left: }

See Also:
Constant Field Values

UI_OFFSET

public static final String UI_OFFSET
Properties on the ui parameter (use it into callback functions) : current absolute position of the draggable helper { top: , left: }

See Also:
Constant Field Values
Constructor Detail

DroppableBehavior

public DroppableBehavior()
Method Detail

onBind

public void onBind()
Description copied from class: WiQueryAbstractBehavior
Called when the component was bound to it's host component. You can get the bound host component by calling getComponent.

Overrides:
onBind in class WiQueryAbstractBehavior

detach

public void detach(org.apache.wicket.Component component)
Overrides:
detach in class org.apache.wicket.behavior.Behavior

renderHead

public void renderHead(org.apache.wicket.Component component,
                       org.apache.wicket.markup.html.IHeaderResponse response)
Specified by:
renderHead in interface org.apache.wicket.markup.html.IComponentAwareHeaderContributor
Overrides:
renderHead in class org.apache.wicket.behavior.Behavior

statement

public JsStatement statement()
Description copied from interface: IWiQueryPlugin
Returns the main JsStatement used to create the plugin.

Specified by:
statement in interface IWiQueryPlugin
Specified by:
statement in class WiQueryAbstractBehavior
Returns:
The JsStatement corresponding to this component.

getOptions

protected Options getOptions()
Method retrieving the options of the component

Returns:
the options

setAccept

public DroppableBehavior setAccept(DroppableAccept accept)
All draggables that match the selector will be accepted. If a function is specified, the function will be called for each draggable on the page (passed as the first argument to the function), to provide a custom filter. The function should return true if the draggable should be accepted.

Parameters:
accept -
Returns:
instance of the current behavior

getAccept

public DroppableAccept getAccept()
Returns:
the accept option

setActiveClass

public DroppableBehavior setActiveClass(String activeClass)
If specified, the class will be added to the droppable while an acceptable draggable is being dragged.

Parameters:
activeClass -
Returns:
instance of the current behavior

getActiveClass

public String getActiveClass()
Returns:
the activeClass option

setAddClasses

public DroppableBehavior setAddClasses(boolean addClasses)
If true, will prevent event propagation on nested droppables.

Parameters:
addClasses -
Returns:
instance of the current behavior

isAddClasses

public boolean isAddClasses()
Returns:
the addClasses option

setDisabled

public DroppableBehavior setDisabled(boolean disabled)
Disables (true) or enables (false) the droppable. Can be set when initialising (first creating) the droppable.

Parameters:
disabled -
Returns:
instance of the current behavior

isDisabled

public boolean isDisabled()
Returns:
the disabled option

setGreedy

public DroppableBehavior setGreedy(boolean greedy)
If true, will prevent event propagation on nested droppables.

Parameters:
greedy -
Returns:
instance of the current behavior

isGreedy

public boolean isGreedy()
Returns:
the greedy option

setHoverClass

public DroppableBehavior setHoverClass(String hoverClass)
If specified, the class will be added to the droppable while an acceptable draggable is being hovered.

Parameters:
hoverClass -
Returns:
instance of the current behavior

getHoverClass

public String getHoverClass()
Returns:
the hoverClass option

setScope

public DroppableBehavior setScope(String scope)
Used to group sets of draggable and droppable items, in addition to droppable's accept option. A draggable with the same scope value as a droppable will be accepted.

Parameters:
scope -
Returns:
instance of the current behavior

getScope

public String getScope()
Returns:
the scope option

setTolerance

public DroppableBehavior setTolerance(DroppableBehavior.ToleranceEnum tolerance)
Set's the mode to use for testing whether a draggable is 'over' a droppable. Possible values: 'fit', 'intersect', 'pointer', 'touch'.

Parameters:
tolerance -
Returns:
instance of the current behavior

getTolerance

public DroppableBehavior.ToleranceEnum getTolerance()
Returns:
the tolerance option enum

setActivateEvent

public DroppableBehavior setActivateEvent(JsScopeUiEvent activate)
Set's the callback when an accepted draggable starts dragging. This can be useful if you want to make the droppable 'light up' when it can be dropped on.

Parameters:
activate -
Returns:
instance of the current behavior

setDeactivateEvent

public DroppableBehavior setDeactivateEvent(JsScopeUiEvent deactivate)
Set's the callback when an accepted draggable stops dragging.

Parameters:
deactivate -
Returns:
instance of the current behavior

setDropEvent

public DroppableBehavior setDropEvent(JsScopeUiEvent drop)
Set's the callback when an accepted draggable is dropped 'over' (within the tolerance of) this droppable. In the callback, $(this) represents the droppable the draggable is dropped on. ui.draggable represents the draggable.

Parameters:
drop -
Returns:
instance of the current behavior

setOutEvent

public DroppableBehavior setOutEvent(JsScopeUiEvent out)
Set's the callback when an accepted draggable is dragged out (within the tolerance of) this droppable.

Parameters:
out -
Returns:
instance of the current behavior

setOverEvent

public DroppableBehavior setOverEvent(JsScopeUiEvent over)
Set's the callback when an accepted draggable is dragged 'over' (within the tolerance of) this droppable.

Parameters:
over -
Returns:
instance of the current behavior

destroy

public JsStatement destroy()
Method to destroy the droppable This will return the element back to its pre-init state.

Returns:
the associated JsStatement

destroy

public void destroy(org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
Method to destroy the droppable within the ajax request

Parameters:
ajaxRequestTarget -

disable

public JsStatement disable()
Method to disable the droppable

Returns:
the associated JsStatement

disable

public void disable(org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
Method to disable the droppable within the ajax request

Parameters:
ajaxRequestTarget -

enable

public JsStatement enable()
Method to enable the droppable

Returns:
the associated JsStatement

enable

public void enable(org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
Method to enable the droppable within the ajax request

Parameters:
ajaxRequestTarget -

widget

public JsStatement widget()
Method to returns the .ui-droppable element

Returns:
the associated JsStatement

widget

public void widget(org.apache.wicket.ajax.AjaxRequestTarget ajaxRequestTarget)
Method to returns the .ui-droppable element within the ajax request

Parameters:
ajaxRequestTarget -


Copyright © 2012. All Rights Reserved.