Author: julien(a)jboss.com
Date: 2008-07-08 13:48:19 -0400 (Tue, 08 Jul 2008)
New Revision: 11354
Modified:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/dnd/DnDContext.java
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/dnd/DnDPanel.java
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxLayout.java
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxObject.java
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxPage.java
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxWindow.java
Log:
start to implement drag and drop
Modified:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/dnd/DnDContext.java
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/dnd/DnDContext.java 2008-07-08
16:44:15 UTC (rev 11353)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/dnd/DnDContext.java 2008-07-08
17:48:19 UTC (rev 11354)
@@ -34,4 +34,6 @@
Draggable findDraggableByHandle(Panel panel, Element element);
+ Object findDroppable(Element element);
+
}
Modified:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/dnd/DnDPanel.java
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/dnd/DnDPanel.java 2008-07-08
16:44:15 UTC (rev 11353)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/dnd/DnDPanel.java 2008-07-08
17:48:19 UTC (rev 11354)
@@ -27,6 +27,7 @@
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.EventPreview;
+import com.google.gwt.user.client.Window;
import org.jboss.portal.presentation.ajax.client.util.logging.Logger;
/**
@@ -87,8 +88,8 @@
if (draggable != null)
{
Element containerElement = draggable.getContainer();
- int left = DOM.getAbsoluteLeft(draggable.getContainer());
- int top = DOM.getAbsoluteTop(draggable.getContainer());
+ int left = DOM.getAbsoluteLeft(draggable.getContainer()) -
Window.getScrollLeft();
+ int top = DOM.getAbsoluteTop(draggable.getContainer()) -
Window.getScrollTop();
int x = DOM.eventGetClientX(event);
int y = DOM.eventGetClientY(event);
int deltaX = x - left;
@@ -136,7 +137,16 @@
int newY = y - drag.deltaY;
DOM.setIntStyleAttribute(drag.draggable.getContainer(),
"left", newX);
DOM.setIntStyleAttribute(drag.draggable.getContainer(),
"top", newY);
- log.debug("Dragging at position (" + newX + "," +
newY + ") with draggable " + drag.draggable);
+ log.debug("Dragging at position (" + newX + "," +
newY + ") with draggable " + drag.draggable +
+ " on element " + element);
+
+ //
+ Object droppable = context.findDroppable(element);
+ if (droppable != null)
+ {
+ Window.alert("Found droppable " + droppable);
+ }
+
}
//
Modified:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxLayout.java
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxLayout.java 2008-07-08
16:44:15 UTC (rev 11353)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxLayout.java 2008-07-08
17:48:19 UTC (rev 11354)
@@ -114,6 +114,18 @@
this.layout = layout;
}
+ protected Object doFindDroppable(Element element)
+ {
+ if (element == layout.getElement())
+ {
+ return this;
+ }
+
+ //
+ return null;
+ }
+
+
protected Draggable doFindDraggable(Element element)
{
return null;
Modified:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxObject.java
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxObject.java 2008-07-08
16:44:15 UTC (rev 11353)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxObject.java 2008-07-08
17:48:19 UTC (rev 11354)
@@ -129,6 +129,23 @@
}
}
+ public final Object findDroppable(Element element)
+ {
+ Object droppable = doFindDroppable(element);
+
+ //
+ for (Iterator i = getChildren().iterator();i.hasNext() && droppable ==
null;)
+ {
+ AjaxObject child = (AjaxObject)i.next();
+
+ //
+ droppable = child.findDroppable(element);
+ }
+
+ //
+ return droppable;
+ }
+
public final Draggable findDraggabble(Element element)
{
Draggable draggable = doFindDraggable(element);
@@ -221,6 +238,8 @@
protected abstract Draggable doFindDraggable(Element element);
+ protected abstract Object doFindDroppable(Element element);
+
public abstract Widget getWidget();
public final static class Context
Modified:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxPage.java
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxPage.java 2008-07-08
16:44:15 UTC (rev 11353)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxPage.java 2008-07-08
17:48:19 UTC (rev 11354)
@@ -95,5 +95,9 @@
{
return findDraggabble(element);
}
+ public Object findDroppable(Element element)
+ {
+ return AjaxPage.this.findDroppable(element);
+ }
};
}
Modified:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxWindow.java
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxWindow.java 2008-07-08
16:44:15 UTC (rev 11353)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxWindow.java 2008-07-08
17:48:19 UTC (rev 11354)
@@ -96,6 +96,11 @@
}
}
+ protected Object doFindDroppable(Element element)
+ {
+ return null;
+ }
+
protected void doCreateWidget()
{
//