Author: julien(a)jboss.com
Date: 2008-07-09 09:12:32 -0400 (Wed, 09 Jul 2008)
New Revision: 11365
Modified:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/PresentationClientAgent.java
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/dnd/Draggable.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/PresentationClientAgent.java
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/PresentationClientAgent.java 2008-07-09
12:16:31 UTC (rev 11364)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/PresentationClientAgent.java 2008-07-09
13:12:32 UTC (rev 11365)
@@ -29,6 +29,8 @@
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.Window;
import org.jboss.portal.presentation.ajax.client.model.update.ModelUpdate;
import org.jboss.portal.presentation.ajax.client.model.AjaxObject;
import org.jboss.portal.presentation.ajax.client.util.Bootstrap;
@@ -61,20 +63,15 @@
public void onModuleLoad()
{
- VerticalPanel main = new VerticalPanel();
-
- //
- RootPanel.get().add(main);
-
- //
AppenderWidget appender = new AppenderWidget();
- main.add(appender);
+ RootPanel.get().add(appender, 0, Window.getClientHeight() - 128);
+ DOM.setIntStyleAttribute(appender.getElement(), "zIndex", 1);
Logger.registerAppender(appender);
log.info("Added logger");
//
final AbsolutePanel bottom = new AbsolutePanel();
- main.add(bottom);
+ RootPanel.get().add(bottom);
//
Bootstrap.init();
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-09
12:16:31 UTC (rev 11364)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/dnd/DnDContext.java 2008-07-09
13:12:32 UTC (rev 11365)
@@ -34,6 +34,7 @@
Draggable findDraggableByHandle(Panel panel, Element element);
- Object findDroppable(Element element);
+ Object findDroppable(Element element, int x, int y);
+
}
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-09
12:16:31 UTC (rev 11364)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/dnd/DnDPanel.java 2008-07-09
13:12:32 UTC (rev 11365)
@@ -141,10 +141,10 @@
" on element " + element);
//
- Object droppable = context.findDroppable(element);
+ Object droppable = context.findDroppable(element, x, y);
if (droppable != null)
{
- Window.alert("Found droppable " + droppable);
+ log.debug("Found droppable " + droppable);
}
}
Modified:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/dnd/Draggable.java
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/dnd/Draggable.java 2008-07-09
12:16:31 UTC (rev 11364)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/dnd/Draggable.java 2008-07-09
13:12:32 UTC (rev 11365)
@@ -38,4 +38,8 @@
*/
Element getContainer();
+ // void enter(Droppable droppable);
+
+ // void leave(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-09
12:16:31 UTC (rev 11364)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxLayout.java 2008-07-09
13:12:32 UTC (rev 11365)
@@ -27,6 +27,7 @@
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.Element;
+import com.google.gwt.user.client.DOM;
import java.util.Iterator;
import java.util.Map;
@@ -114,17 +115,36 @@
this.layout = layout;
}
- protected Object doFindDroppable(Element element)
+ protected Object doFindDroppable(int x, int y)
{
- if (element == layout.getElement())
+ int left = layout.getAbsoluteLeft();
+ int right = left + layout.getOffsetWidth();
+ int top = layout.getAbsoluteTop();
+ int bottom = top + layout.getOffsetHeight();
+ if (x >= left && x <= right && y >= top && y <=
bottom)
{
return this;
}
//
- return null;
+ return null;
}
+ private boolean contains(Element container, Element contained)
+ {
+ if (container == contained)
+ {
+ return true;
+ }
+ for (int i = DOM.getChildCount(container) - 1;i >= 0;i--)
+ {
+ if (contains(DOM.getChild(container, i), contained))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
protected Draggable doFindDraggable(Element element)
{
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-09
12:16:31 UTC (rev 11364)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxObject.java 2008-07-09
13:12:32 UTC (rev 11365)
@@ -129,38 +129,41 @@
}
}
- public final Object findDroppable(Element element)
+ public final Draggable findDraggabble(Element element)
{
- Object droppable = doFindDroppable(element);
+ Draggable draggable = doFindDraggable(element);
//
- for (Iterator i = getChildren().iterator();i.hasNext() && droppable ==
null;)
+ for (Iterator i = getChildren().iterator();i.hasNext() && draggable ==
null;)
{
AjaxObject child = (AjaxObject)i.next();
//
- droppable = child.findDroppable(element);
+ draggable = child.findDraggabble(element);
}
-
+
//
- return droppable;
+ return draggable;
}
- public final Draggable findDraggabble(Element element)
+ public final Object findDroppable(int x, int y)
{
- Draggable draggable = doFindDraggable(element);
-
- //
- for (Iterator i = getChildren().iterator();i.hasNext() && draggable ==
null;)
+ for (Iterator i = getChildren().iterator();i.hasNext();)
{
AjaxObject child = (AjaxObject)i.next();
//
- draggable = child.findDraggabble(element);
+ Object droppable = child.findDroppable(x, y);
+
+ //
+ if (droppable != null)
+ {
+ return droppable;
+ }
}
-
+
//
- return draggable;
+ return doFindDroppable(x, y);
}
public final void refresh(boolean force)
@@ -226,6 +229,11 @@
return parent;
}
+ public String toString()
+ {
+ return "AjaxObject[id=" + id + "]";
+ }
+
protected abstract void doCreateWidget();
protected abstract void doRefresh(boolean force);
@@ -238,7 +246,7 @@
protected abstract Draggable doFindDraggable(Element element);
- protected abstract Object doFindDroppable(Element element);
+ protected abstract Object doFindDroppable(int x, int y);
public abstract Widget getWidget();
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-09
12:16:31 UTC (rev 11364)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxPage.java 2008-07-09
13:12:32 UTC (rev 11365)
@@ -95,9 +95,10 @@
{
return findDraggabble(element);
}
- public Object findDroppable(Element element)
+
+ public Object findDroppable(Element element, int x, int y)
{
- return AjaxPage.this.findDroppable(element);
+ return AjaxPage.this.findDroppable(x, y);
}
};
}
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-09
12:16:31 UTC (rev 11364)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxWindow.java 2008-07-09
13:12:32 UTC (rev 11365)
@@ -96,11 +96,6 @@
}
}
- protected Object doFindDroppable(Element element)
- {
- return null;
- }
-
protected void doCreateWidget()
{
//
@@ -242,6 +237,11 @@
{
}
+ protected Object doFindDroppable(int x, int y)
+ {
+ return null;
+ }
+
protected void doRemoveChild(AjaxObject child)
{
throw new UnsupportedOperationException();