001: /*
002: * GWT-Ext Widget Library
003: * Copyright(c) 2007-2008, GWT-Ext.
004: * licensing@gwt-ext.com
005: *
006: * http://www.gwt-ext.com/license
007: */
008:
009: package com.gwtext.client.dd;
010:
011: import com.google.gwt.core.client.JavaScriptObject;
012: import com.google.gwt.user.client.Element;
013: import com.gwtext.client.core.EventObject;
014: import com.gwtext.client.widgets.Component;
015:
016: public class DropTarget extends DDTarget {
017:
018: static {
019: init();
020: }
021:
022: private static native void init() /*-{
023:
024: $wnd.Ext.dd.DropTarget.prototype.notifyDrop = function(source, e, data) {
025: var ddJ = this.ddJ;
026: if(ddJ != null) {
027: var eJ = @com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(e);
028: var sourceJ = @com.gwtext.client.dd.DragSource::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(source);
029: var dataJ = data == null || data == undefined ? null : @com.gwtext.client.dd.DragData::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(data);
030: return ddJ.@com.gwtext.client.dd.DropTarget::notifyDrop(Lcom/gwtext/client/dd/DragSource;Lcom/gwtext/client/core/EventObject;Lcom/gwtext/client/dd/DragData;)(sourceJ, eJ, dataJ);
031: }
032: }
033:
034: $wnd.Ext.dd.DropTarget.prototype.notifyEnter = function(source, e, data) {
035: var ddJ = this.ddJ;
036: if(ddJ != null) {
037: var eJ = @com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(e);
038: var sourceJ = @com.gwtext.client.dd.DragSource::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(source);
039: var dataJ = data == null || data == undefined ? null : @com.gwtext.client.dd.DragData::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(data);
040: return ddJ.@com.gwtext.client.dd.DropTarget::notifyEnter(Lcom/gwtext/client/dd/DragSource;Lcom/gwtext/client/core/EventObject;Lcom/gwtext/client/dd/DragData;)(sourceJ, eJ, dataJ);
041: }
042: }
043:
044: $wnd.Ext.dd.DropTarget.prototype.notifyOut = function(source, e, data) {
045: var ddJ = this.ddJ;
046: if(ddJ != null) {
047: var eJ = @com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(e);
048: var sourceJ = @com.gwtext.client.dd.DragSource::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(source);
049: var dataJ = data == null || data == undefined ? null : @com.gwtext.client.dd.DragData::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(data);
050: ddJ.@com.gwtext.client.dd.DropTarget::notifyOut(Lcom/gwtext/client/dd/DragSource;Lcom/gwtext/client/core/EventObject;Lcom/gwtext/client/dd/DragData;)(sourceJ, eJ, dataJ);
051: }
052: }
053:
054: $wnd.Ext.dd.DropTarget.prototype.notifyOver = function(source, e, data) {
055: var ddJ = this.ddJ;
056: if(ddJ != null) {
057: var eJ = @com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(e);
058: var sourceJ = @com.gwtext.client.dd.DragSource::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(source);
059: var dataJ = data == null || data == undefined ? null : @com.gwtext.client.dd.DragData::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(data);
060: return ddJ.@com.gwtext.client.dd.DropTarget::notifyOver(Lcom/gwtext/client/dd/DragSource;Lcom/gwtext/client/core/EventObject;Lcom/gwtext/client/dd/DragData;)(sourceJ, eJ, dataJ);
061: }
062: }
063:
064: }-*/;
065:
066: public DropTarget(JavaScriptObject jsObj) {
067: super (jsObj);
068: }
069:
070: public DropTarget(String id, String sGroup, DragDropConfig config) {
071: super (id, sGroup, config);
072: }
073:
074: public DropTarget(Element element, String sGroup,
075: DragDropConfig config) {
076: super (element, sGroup, config);
077: }
078:
079: public DropTarget(Component component, String sGroup,
080: DragDropConfig config) {
081: super (component, sGroup, config);
082: }
083:
084: protected native JavaScriptObject create(String id, String sGroup,
085: JavaScriptObject config)/*-{
086: return new $wnd.Ext.dd.DropTarget(id, sGroup, config);
087: }-*/;
088:
089: protected native JavaScriptObject create(Element element,
090: String sGroup, JavaScriptObject config)/*-{
091: return new $wnd.Ext.dd.DropTarget(element, sGroup, config);
092: }-*/;
093:
094: /**
095: * The function {@link DragSource} calls once to notify this drop target that the dragged item has been dropped on it.
096: * This method has no default implementation and returns false, so you must provide an implementation that does something
097: * to process the drop event and returns true so that the drag source's repair action does not run.
098: *
099: * @param source the drag source
100: * @param e the event object
101: * @param data an object containing arbitrary data supplied by the drag source
102: * @return true if the drop was valid, else false
103: */
104: public boolean notifyDrop(DragSource source, EventObject e,
105: DragData data) {
106: return false;
107: }
108:
109: /**
110: * The function a {@link DragSource} calls once to notify this drop target that the source is now over the target. This
111: * default implementation adds the CSS class specified by overClass (if any) to the drop element and
112: * returns the dropAllowed config value. This method should be overridden if drop validation is required.
113: *
114: * @param source The drag source that was dragged over this drop target
115: * @param e The event
116: * @param data An object containing arbitrary data supplied by the drag source
117: * @return The CSS class that communicates the drop status back to the source so that the underlying {@link StatusProxy} can be updated
118: */
119: public String notifyEnter(DragSource source, EventObject e,
120: DragData data) {
121: return "";
122: }
123:
124: /**
125: * The function a Ext.dd.DragSource calls once to notify this drop target that the source has been dragged out of the target
126: * without dropping. This default implementation simply removes the CSS class specified by overClass (if any) from the drop element.
127: *
128: * @param source
129: * @param e
130: * @param data
131: */
132: public void notifyOut(DragSource source, EventObject e,
133: DragData data) {
134: }
135:
136: public String notifyOver(DragSource source, EventObject e,
137: DragData data) {
138: return "";
139: }
140:
141: }
|