You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by ta...@apache.org on 2006/03/24 07:48:52 UTC
svn commit: r388411 - in
/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout:
ajax-xml/xmove.vm impl/Constants.java impl/MovePortletAction.java
Author: taylor
Date: Thu Mar 23 22:48:50 2006
New Revision: 388411
URL: http://svn.apache.org/viewcvs?rev=388411&view=rev
Log:
http://issues.apache.org/jira/browse/JS2-514
support for move action (x,y,z,width,height)
Added:
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/xmove.vm
Modified:
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/Constants.java
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/MovePortletAction.java
Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/xmove.vm
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/xmove.vm?rev=388411&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/xmove.vm (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/xmove.vm Thu Mar 23 22:48:50 2006
@@ -0,0 +1,39 @@
+<js>
+ <status>$status</status>
+ <action>$action</action>
+ <id>$id</id>
+ <old_position>
+#if ($oldx)
+ <x>$oldx</x>
+#end
+#if ($oldy)
+ <y>$oldy</y>
+#end
+#if ($oldz)
+ <y>$oldz</y>
+#end
+#if ($oldwidth)
+ <width>$oldwidth</width>
+#end
+#if ($oldheight)
+ <height>$oldheight</height>
+#end
+ </old_position>
+ <new_position>
+#if ($x)
+ <x>$x</x>
+#end
+#if ($y)
+ <y>$y</y>
+#end
+#if ($z)
+ <y>$z</y>
+#end
+#if ($width)
+ <width>$width</width>
+#end
+#if ($height)
+ <height>$height</height>
+#end
+ </new_position>
+</js>
\ No newline at end of file
Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/Constants.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/Constants.java?rev=388411&r1=388410&r2=388411&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/Constants.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/Constants.java Thu Mar 23 22:48:50 2006
@@ -34,6 +34,17 @@
public static final String NEWROW = "newrow";
public static final String COL = "col";
public static final String ROW = "row";
+ public static final String X = "x";
+ public static final String Y = "y";
+ public static final String Z = "z";
+ public static final String WIDTH = "width";
+ public static final String HEIGHT = "height";
+ public static final String OLD_X = "oldx";
+ public static final String OLD_Y = "oldy";
+ public static final String OLD_Z = "oldz";
+ public static final String OLD_WIDTH = "oldwidth";
+ public static final String OLD_HEIGHT = "oldheight";
+
public static final String FILTER = "filter";
public static final String PORTLETS = "portlets";
public static final String PAGES = "pages";
@@ -46,6 +57,5 @@
public static final int DOWN = 3;
public static final int LEFT = 4;
public static final int RIGHT = 5;
-
-
+ public static final int CARTESIAN = 6;
}
Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/MovePortletAction.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/MovePortletAction.java?rev=388411&r1=388410&r2=388411&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/MovePortletAction.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/MovePortletAction.java Thu Mar 23 22:48:50 2006
@@ -82,19 +82,28 @@
if (p_sMoveType.equalsIgnoreCase("moveabs"))
{
iMoveType = ABS;
- } else if (p_sMoveType.equalsIgnoreCase("moveup"))
+ }
+ else if (p_sMoveType.equalsIgnoreCase("moveup"))
{
iMoveType = UP;
- } else if (p_sMoveType.equalsIgnoreCase("movedown"))
+ }
+ else if (p_sMoveType.equalsIgnoreCase("movedown"))
{
iMoveType = DOWN;
- } else if (p_sMoveType.equalsIgnoreCase("moveleft"))
+ }
+ else if (p_sMoveType.equalsIgnoreCase("moveleft"))
{
iMoveType = LEFT;
- } else if (p_sMoveType.equalsIgnoreCase("moveright"))
+ }
+ else if (p_sMoveType.equalsIgnoreCase("moveright"))
{
iMoveType = RIGHT;
- } else
+ }
+ else if (p_sMoveType.equalsIgnoreCase("move"))
+ {
+ iMoveType = CARTESIAN;
+ }
+ else
{
throw new AJAXException("invalid move type of:" + p_sMoveType);
}
@@ -146,6 +155,9 @@
PortletPlacementContext placement = new PortletPlacementContextImpl(requestContext);
Fragment fragment = placement.getFragmentById(portletId);
Coordinate returnCoordinate = null;
+ float oldX = 0f, oldY = 0f, oldZ = 0f, oldWidth = 0f, oldHeight = 0f;
+ float x = -1f, y = -1f, z = -1f, width = -1f, height = -1f;
+
// Only required for moveabs
if (iMoveType == ABS)
{
@@ -176,7 +188,44 @@
{
returnCoordinate = placement.moveDown(fragment);
}
-
+ else if (iMoveType == CARTESIAN)
+ {
+ String sx = requestContext.getRequestParameter(X);
+ String sy = requestContext.getRequestParameter(Y);
+ String sz = requestContext.getRequestParameter(Z);
+ String sWidth = requestContext.getRequestParameter(WIDTH);
+ String sHeight = requestContext.getRequestParameter(HEIGHT);
+ if (sx != null)
+ {
+ oldX = fragment.getLayoutX();
+ x = Float.parseFloat(sx);
+ fragment.setLayoutX(x);
+ }
+ if (sy != null)
+ {
+ oldY = fragment.getLayoutY();
+ y = Float.parseFloat(sy);
+ fragment.setLayoutY(y);
+ }
+ if (sz != null)
+ {
+ oldZ = fragment.getLayoutZ();
+ z = Float.parseFloat(sz);
+ fragment.setLayoutZ(z);
+ }
+ if (sWidth != null)
+ {
+ oldWidth = fragment.getLayoutWidth();
+ width = Float.parseFloat(sWidth);
+ fragment.setLayoutWidth(width);
+ }
+ if (sHeight != null)
+ {
+ oldHeight = fragment.getLayoutHeight();
+ height = Float.parseFloat(sHeight);
+ fragment.setLayoutHeight(height);
+ }
+ }
// synchronize back to the page layout root fragment
Page page = placement.syncPageFragments();
@@ -185,16 +234,27 @@
resultMap.put(STATUS, status);
resultMap.put(PORTLETID, portletId);
- // Need to determine what the old col and row were
- resultMap.put(OLDCOL, String.valueOf(returnCoordinate
- .getOldCol()));
- resultMap.put(OLDROW, String.valueOf(returnCoordinate
- .getOldRow()));
- // Need to determine what the new col and row were
- resultMap.put(NEWCOL, String.valueOf(returnCoordinate
- .getNewCol()));
- resultMap.put(NEWROW, String.valueOf(returnCoordinate
- .getNewRow()));
+ if (iMoveType == CARTESIAN)
+ {
+ putCartesianResult(resultMap, x, oldX, X, OLD_X);
+ putCartesianResult(resultMap, y, oldY, Y, OLD_Y);
+ putCartesianResult(resultMap, z, oldZ, Z, OLD_Z);
+ putCartesianResult(resultMap, width, oldWidth, WIDTH, OLD_WIDTH);
+ putCartesianResult(resultMap, height, oldHeight, HEIGHT, OLD_HEIGHT);
+ }
+ else
+ {
+ // Need to determine what the old col and row were
+ resultMap.put(OLDCOL, String.valueOf(returnCoordinate
+ .getOldCol()));
+ resultMap.put(OLDROW, String.valueOf(returnCoordinate
+ .getOldRow()));
+ // Need to determine what the new col and row were
+ resultMap.put(NEWCOL, String.valueOf(returnCoordinate
+ .getNewCol()));
+ resultMap.put(NEWROW, String.valueOf(returnCoordinate
+ .getNewRow()));
+ }
}
catch (Exception e)
{
@@ -207,5 +267,13 @@
return success;
}
-
+
+ protected void putCartesianResult(Map resultMap, float value, float oldValue, String name, String oldName)
+ {
+ if (value != -1F)
+ {
+ resultMap.put(oldName, new Float(oldValue));
+ resultMap.put(name, new Float(value));
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org