Author: julien(a)jboss.com
Date: 2008-07-09 18:42:00 -0400 (Wed, 09 Jul 2008)
New Revision: 11390
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/AjaxWindow.java
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/util/Tools.java
Log:
fix issue where a pane drag would prevent the usage of one of its children
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
21:43:10 UTC (rev 11389)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxPane.java 2008-07-09
22:42:00 UTC (rev 11390)
@@ -27,9 +27,11 @@
import com.google.gwt.user.client.Element;
import java.util.Map;
+import java.util.Iterator;
import org.jboss.portal.presentation.ajax.client.dnd.Draggable;
import org.jboss.portal.presentation.ajax.client.dnd.Droppable;
+import org.jboss.portal.presentation.ajax.client.util.Tools;
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
@@ -116,12 +118,20 @@
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)
+ // Let's not shadow any widget
+ for (Iterator i = getChildren().iterator();i.hasNext();)
{
+ AjaxObject child = (AjaxObject)i.next();
+ Widget childWidget = child.getWidget();
+ if (Tools.contains(childWidget, x, y))
+ {
+ return null;
+ }
+ }
+
+ //
+ if (Tools.contains(widget, x, y))
+ {
return draggable;
}
else
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
21:43:10 UTC (rev 11389)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxWindow.java 2008-07-09
22:42:00 UTC (rev 11390)
@@ -134,11 +134,7 @@
protected Draggable doFindDraggable(int x, int y)
{
- 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)
+ if (Tools.contains(title, x, y))
{
return draggable;
}
Modified:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/util/Tools.java
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/util/Tools.java 2008-07-09
21:43:10 UTC (rev 11389)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/util/Tools.java 2008-07-09
22:42:00 UTC (rev 11390)
@@ -24,6 +24,7 @@
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.ui.Widget;
import java.util.Map;
@@ -37,6 +38,29 @@
{
/**
+ * Returns true if the specified widget does contain the point located at (x,y).
+ *
+ * @param widget the widget
+ * @param x the x value
+ * @param y the y value
+ * @return true is the point is contained within the widget
+ */
+ public static boolean contains(Widget widget, int x, int y)
+ {
+ if (widget == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ int left = widget.getAbsoluteLeft();
+ int right = left + widget.getOffsetWidth();
+ int top = widget.getAbsoluteTop();
+ int bottom = top + widget.getOffsetHeight();
+ return x >= left && x <= right && y >= top && y
<= bottom;
+ }
+
+ /**
* Returns an element tag name.
*
* @param element the element to obtain the tag name from