Author: julien(a)jboss.com
Date: 2008-07-09 15:16:21 -0400 (Wed, 09 Jul 2008)
New Revision: 11384
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/AjaxPane.java
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/protocol/MoveObjectAction.java
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/public/style.css
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/PresentationServerImpl.java
Log:
fix the droppable selection that was not taking in account the window scroll values
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
19:06:06 UTC (rev 11383)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/dnd/DnDContext.java 2008-07-09
19:16:21 UTC (rev 11384)
@@ -32,8 +32,10 @@
public interface DnDContext
{
- Draggable findDraggableByHandle(Panel panel, Element element);
+
+ Draggable findDraggable(int x, int y);
+
Droppable findDroppable(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
19:06:06 UTC (rev 11383)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/dnd/DnDPanel.java 2008-07-09
19:16:21 UTC (rev 11384)
@@ -61,7 +61,9 @@
{
if (DOM.eventGetType(event) == Event.ONMOUSEDOWN)
{
- Object draggable = context.findDraggableByHandle(this,
DOM.eventGetTarget(event));
+ int x = DOM.eventGetClientX(event);
+ int y = DOM.eventGetClientY(event);
+ Draggable draggable = context.findDraggable(x + Window.getScrollLeft(), y +
Window.getScrollTop());
//
if (draggable != null)
@@ -85,7 +87,9 @@
{
case Event.ONMOUSEDOWN:
{
- Draggable draggable = context.findDraggableByHandle(this, element);
+ int x = DOM.eventGetClientX(event);
+ int y = DOM.eventGetClientY(event);
+ Draggable draggable = context.findDraggable(x + Window.getScrollLeft(), y
+ Window.getScrollTop());
//
if (draggable != null)
@@ -93,8 +97,6 @@
Element containerElement = 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;
int deltaY = y - top;
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
19:06:06 UTC (rev 11383)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxLayout.java 2008-07-09
19:16:21 UTC (rev 11384)
@@ -185,11 +185,6 @@
return null;
}
- protected Draggable doFindDraggable(Element element)
- {
- return null;
- }
-
protected void doAddChild(AjaxObject child)
{
}
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
19:06:06 UTC (rev 11383)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxObject.java 2008-07-09
19:16:21 UTC (rev 11384)
@@ -23,7 +23,6 @@
package org.jboss.portal.presentation.ajax.client.model;
import com.google.gwt.user.client.ui.Widget;
-import com.google.gwt.user.client.Element;
import java.util.Map;
import java.util.HashMap;
@@ -134,9 +133,9 @@
}
}
- public final Draggable findDraggabble(Element element)
+ public final Draggable findDraggabble(int x, int y)
{
- Draggable draggable = doFindDraggable(element);
+ Draggable draggable = doFindDraggable(x, y);
//
for (Iterator i = getChildren().iterator();i.hasNext() && draggable ==
null;)
@@ -144,7 +143,7 @@
AjaxObject child = (AjaxObject)i.next();
//
- draggable = child.findDraggabble(element);
+ draggable = child.findDraggabble(x, y);
}
//
@@ -249,7 +248,7 @@
protected abstract void doRemoveChild(AjaxObject child);
- protected abstract Draggable doFindDraggable(Element element);
+ protected abstract Draggable doFindDraggable(int x, int y);
protected abstract Droppable doFindDroppable(int x, int y);
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
19:06:06 UTC (rev 11383)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxPage.java 2008-07-09
19:16:21 UTC (rev 11384)
@@ -25,8 +25,6 @@
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
-import com.google.gwt.user.client.ui.Panel;
-import com.google.gwt.user.client.Element;
import java.util.Map;
@@ -89,12 +87,17 @@
widget = null;
}
+ protected Draggable doFindDraggable(int x, int y)
+ {
+ return null;
+ }
+
/** . */
private final DnDContext dndContext = new DnDContext()
{
- public Draggable findDraggableByHandle(Panel panel, Element element)
+ public Draggable findDraggable(int x, int y)
{
- return findDraggabble(element);
+ return findDraggabble(x, y);
}
public Droppable findDroppable(int x, int y)
Modified:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxPane.java
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxPane.java 2008-07-09
19:06:06 UTC (rev 11383)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxPane.java 2008-07-09
19:16:21 UTC (rev 11384)
@@ -24,9 +24,13 @@
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
+import com.google.gwt.user.client.Element;
import java.util.Map;
+import org.jboss.portal.presentation.ajax.client.dnd.Draggable;
+import org.jboss.portal.presentation.ajax.client.dnd.Droppable;
+
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
* @version $Revision: 630 $
@@ -37,6 +41,41 @@
/** . */
private VerticalPanel widget;
+ /** . */
+ private Draggable draggable = new Draggable()
+ {
+ public Element getContainer()
+ {
+ return widget.getElement();
+ }
+
+ public void startDragging()
+ {
+ widget.addStyleName("dnd-dragged");
+ }
+
+ public void stopDragging()
+ {
+ widget.removeStyleName("dnd-dragged");
+ }
+
+ public void enter(Droppable droppable)
+ {
+ }
+
+ public void leave(Droppable droppable)
+ {
+ }
+
+ public void accepted(Droppable droppable)
+ {
+ }
+
+ public void rejected(Droppable droppable)
+ {
+ }
+ };
+
public AjaxPane(String id, Map properties)
{
super(id, properties);
@@ -51,6 +90,23 @@
this.widget = widget;
}
+ protected Draggable doFindDraggable(int x, int y)
+ {
+// int left = widget.getAbsoluteLeft();
+// int right = left + widget.getOffsetWidth();
+// int top = widget.getAbsoluteTop();
+// int bottom = top + widget.getOffsetHeight();
+// if (x >= left && x <= right && y >= top && y
<= bottom)
+// {
+// return draggable;
+// }
+// else
+// {
+// return null;
+// }
+ return null;
+ }
+
protected void doRefresh(boolean force)
{
doRefresh(widget);
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
19:06:06 UTC (rev 11383)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxWindow.java 2008-07-09
19:16:21 UTC (rev 11384)
@@ -127,9 +127,13 @@
draggable = new DraggableWindow(this);
}
- protected Draggable doFindDraggable(Element element)
+ protected Draggable doFindDraggable(int x, int y)
{
- if (title.getElement() == element)
+ int left = title.getAbsoluteLeft();
+ int right = left + title.getOffsetWidth();
+ int top = title.getAbsoluteTop();
+ int bottom = top + title.getOffsetHeight();
+ if (x >= left && x <= right && y >= top && y <=
bottom)
{
return draggable;
}
Modified:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/protocol/MoveObjectAction.java
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/protocol/MoveObjectAction.java 2008-07-09
19:06:06 UTC (rev 11383)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/protocol/MoveObjectAction.java 2008-07-09
19:16:21 UTC (rev 11384)
@@ -64,4 +64,9 @@
{
this.destinationId = destinationId;
}
+
+ public String toString()
+ {
+ return "MoveObjectAction[sourceId=" + sourceId +
",destinationId=" + destinationId + "]";
+ }
}
Modified:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/public/style.css
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/public/style.css 2008-07-09
19:06:06 UTC (rev 11383)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/public/style.css 2008-07-09
19:16:21 UTC (rev 11384)
@@ -27,6 +27,10 @@
padding: 1px;
}
+.pf-Pane.dnd-dragged {
+background-color: green;
+}
+
.pf-Window {
border: 1px solid black;
padding: 1px;
Modified:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/PresentationServerImpl.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/PresentationServerImpl.java 2008-07-09
19:06:06 UTC (rev 11383)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/PresentationServerImpl.java 2008-07-09
19:16:21 UTC (rev 11384)
@@ -70,7 +70,7 @@
private LayoutStore layoutStore;
/** . */
- private StructuralAdapter structuralAdapter;
+ private StructuralAdapter<Object> structuralAdapter;
/** . */
private StructuralStateContext structuralStateContext;
@@ -80,7 +80,7 @@
public PresentationServerImpl(
PortalNodeManager portalNodeManager,
- StructuralAdapter structuralAdapter,
+ StructuralAdapter<Object> structuralAdapter,
StructuralStateContext structuralStateContext,
ContentHandlerRegistry contentHandlerRegistry,
LayoutStore layoutStore)
@@ -204,9 +204,20 @@
MoveUIObjectAction moveAction = (MoveUIObjectAction)objectAction;
//
- LayoutStructure destinationElt =
(LayoutStructure)structuralAdapter.getNode(moveAction.getDestinationId());
+ Object destination =
structuralAdapter.getNode(moveAction.getDestinationId());
//
+ LayoutStructure destinationElt;
+ if (destination instanceof PortalNode)
+ {
+ destinationElt =
(LayoutStructure)layoutStore.findElementByRef(((PortalNode)destination).getId());
+ }
+ else
+ {
+ destinationElt = (LayoutStructure)destination;
+ }
+
+ //
LayoutElement sourceElt = layoutStore.findElementByRef(targetNode.getId());
//