01: /*
02: * GWT-Ext Widget Library
03: * Copyright(c) 2007-2008, GWT-Ext.
04: * licensing@gwt-ext.com
05: *
06: * http://www.gwt-ext.com/license
07: */
08: package com.gwtext.client.dd;
09:
10: import com.google.gwt.core.client.JavaScriptObject;
11: import com.google.gwt.user.client.Element;
12: import com.gwtext.client.core.JsObject;
13: import com.gwtext.client.util.JavaScriptObjectHelper;
14: import com.gwtext.client.widgets.grid.GridDragData;
15: import com.gwtext.client.widgets.tree.TreeDragData;
16: import com.gwtext.client.widgets.PanelDragData;
17:
18: /**
19: * Base DragData class that is passed to the drop target when the source is draggable.
20: *
21: * @see com.gwtext.client.widgets.tree.event.TreePanelListener#doBeforeNodeDrop(com.gwtext.client.widgets.tree.TreePanel , com.gwtext.client.widgets.tree.TreeNode , com.gwtext.client.dd.DragData, String, com.gwtext.client.dd.DragDrop, com.gwtext.client.widgets.tree.TreeNode , com.gwtext.client.widgets.tree.DropNodeCallback)
22: * @see com.gwtext.client.widgets.tree.event.TreePanelListener#onNodeDrop(com.gwtext.client.widgets.tree.TreePanel , com.gwtext.client.widgets.tree.TreeNode , com.gwtext.client.dd.DragData, String, com.gwtext.client.dd.DragDrop, com.gwtext.client.widgets.tree.TreeNode)
23: */
24: public class DragData extends JsObject {
25:
26: protected DragData(JavaScriptObject jsObj) {
27: super (jsObj);
28: }
29:
30: public int getPropertyAsInt(String property) {
31: return JavaScriptObjectHelper
32: .getAttributeAsInt(jsObj, property);
33: }
34:
35: public boolean getPropertyAsBoolean(String property) {
36: return JavaScriptObjectHelper.getAttributeAsBoolean(jsObj,
37: property);
38: }
39:
40: public String getProperty(String property) {
41: return JavaScriptObjectHelper.getAttribute(jsObj, property);
42: }
43:
44: public JavaScriptObject getPropertyAsJavaScriptObject(
45: String property) {
46: return JavaScriptObjectHelper.getAttributeAsJavaScriptObject(
47: jsObj, property);
48: }
49:
50: public Element getPropertyAsElement(String property) {
51: return JavaScriptObjectHelper.getAttributeAsElement(jsObj,
52: property);
53: }
54:
55: /**
56: * Retrun the DragDrop element. ie the Element displayed when the source is being dragged.
57: *
58: * @return the element being droppped
59: */
60: public Element getDDEl() {
61: return getPropertyAsElement("ddel");
62: }
63:
64: private static DragData instance(JavaScriptObject jsObj) {
65: if (JavaScriptObjectHelper.getAttributeAsJavaScriptObject(
66: jsObj, "grid") != null) {
67: return new GridDragData(jsObj);
68: } else if (JavaScriptObjectHelper
69: .getAttributeAsJavaScriptObject(jsObj, "node") != null) {
70: return new TreeDragData(jsObj);
71: } else if (JavaScriptObjectHelper
72: .getAttributeAsJavaScriptObject(jsObj, "panel") != null) {
73: return new PanelDragData(jsObj);
74: }
75: return new DragData(jsObj);
76: }
77: }
|