Author: smilek
Date: Wed Feb 21 12:47:51 2007
New Revision: 510195
URL: http://svn.apache.org/viewvc?view=rev&rev=510195
Log:
added support for moving layout fragments
Modified:
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/MovePortletAction.java
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/PortletPlacementContextImpl.java
Modified:
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/MovePortletAction.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/MovePortletAction.java?view=diff&rev=510195&r1=510194&r2=510195
==============================================================================
---
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
Wed Feb 21 12:47:51 2007
@@ -141,13 +141,13 @@
{
resultMap.put(ACTION, sMoveType);
// Get the necessary parameters off of the request
- String portletId = getActionParameter(requestContext, PORTLETID);
+ String moveFragmentId = getActionParameter(requestContext,
FRAGMENTID);
String layoutId = getActionParameter(requestContext, LAYOUTID);
- if (portletId == null)
- {
- throw new Exception("portlet id not provided");
+ if ( moveFragmentId == null )
+ {
+ throw new Exception( FRAGMENTID + " not provided; must specify
portlet or layout id" );
}
- resultMap.put(PORTLETID, portletId);
+ resultMap.put(FRAGMENTID, moveFragmentId);
Fragment currentLayoutFragment = null;
Fragment moveToLayoutFragment = null;
@@ -170,7 +170,7 @@
Fragment childFrag = (Fragment)layoutChildIter.next();
if ( childFrag != null )
{
- if ( portletId.equals( childFrag.getId() ) )
+ if ( moveFragmentId.equals( childFrag.getId() ) )
{
moveToLayoutFragment = null;
break;
@@ -182,20 +182,20 @@
// figure out the current layout fragment - must know
to be able to find the portlet
// fragment by row/col when a new page is created
Fragment root =
requestContext.getPage().getRootFragment();
- currentLayoutFragment =
getParentFragmentById(portletId, root);
+ currentLayoutFragment =
getParentFragmentById(moveFragmentId, root);
}
}
if ( currentLayoutFragment == null )
{
// report error
- throw new Exception("parent layout id not found for
portlet id:" + portletId );
+ throw new Exception("parent layout id not found for
portlet id:" + moveFragmentId );
}
}
if (false == checkAccess(requestContext, JetspeedActions.EDIT))
{
Page page = requestContext.getPage();
- Fragment fragment = page.getFragmentById(portletId);
+ Fragment fragment = page.getFragmentById(moveFragmentId);
if (fragment == null)
{
success = false;
@@ -234,10 +234,10 @@
if (newFragment == null)
{
success = false;
- resultMap.put( REASON, "Failed to find new fragment for
portlet id: " + portletId );
+ resultMap.put( REASON, "Failed to find new fragment for
portlet id: " + moveFragmentId );
return success;
}
- portletId = newFragment.getId();
+ moveFragmentId = newFragment.getId();
if ( currentLayoutFragment != null )
{
@@ -245,7 +245,7 @@
if (newFragment == null)
{
success = false;
- resultMap.put( REASON, "Failed to find new parent
layout fragment id: " + currentLayoutFragment.getId() + " for portlet id: " +
portletId );
+ resultMap.put( REASON, "Failed to find new parent
layout fragment id: " + currentLayoutFragment.getId() + " for portlet id: " +
moveFragmentId );
return success;
}
currentLayoutFragment = newFragment;
@@ -255,7 +255,7 @@
if (newFragment == null)
{
success = false;
- resultMap.put( REASON, "Failed to find new move-to
layout fragment id: " + moveToLayoutFragment.getId() + " for portlet id: " +
portletId );
+ resultMap.put( REASON, "Failed to find new move-to
layout fragment id: " + moveToLayoutFragment.getId() + " for portlet id: " +
moveFragmentId );
return success;
}
moveToLayoutFragment = newFragment;
@@ -269,7 +269,7 @@
pageManager,
batch,
resultMap,
- portletId,
+ moveFragmentId,
moveToLayoutFragment,
currentLayoutFragment ) ;
}
@@ -282,11 +282,11 @@
{
placement = new
PortletPlacementContextImpl(requestContext);
}
- Fragment fragment = placement.getFragmentById(portletId);
+ Fragment fragment = placement.getFragmentById(moveFragmentId);
if (fragment == null)
{
success = false;
- resultMap.put(REASON, "Failed to find fragment for portlet
id: " + portletId );
+ resultMap.put(REASON, "Failed to find fragment for portlet
id: " + moveFragmentId );
return success;
}
Coordinate returnCoordinate = null;
@@ -301,7 +301,7 @@
if ( fragmentProperties == null )
{
success = false;
- resultMap.put(REASON, "Failed to acquire fragment
properties map for portlet id: " + portletId );
+ resultMap.put(REASON, "Failed to acquire fragment
properties map for portlet id: " + moveFragmentId );
return success;
}
String oldDeskExt = (String)fragmentProperties.get(
DESKTOP_EXTENDED );
@@ -412,7 +412,7 @@
}
}
resultMap.put(STATUS, status);
- resultMap.put(PORTLETID, portletId);
+ resultMap.put(FRAGMENTID, moveFragmentId);
}
catch (Exception e)
{
@@ -426,17 +426,6 @@
return success;
}
- /*
-
- Fragment placeFragment = placement.getFragmentById(portletId);
- if (placeFragment == null)
- {
- success = false;
- resultMap.put(REASON, "Failed to find fragment to move to another
layout for portlet id: " + portletId );
- return success;
- }
-
- */
protected boolean moveFragment( RequestContext requestContext,
PageManager pageManager,
boolean batch,
@@ -459,6 +448,9 @@
resultMap.put( REASON, "Failed to find fragment to move to
another layout for fragment id: " + moveFragmentId );
return success;
}
+ placement.remove( placeFragment );
+ Page page = placement.syncPageFragments();
+ page.removeFragmentById( moveFragmentId );
}
if ( placeFragment != null )
{
Modified:
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/PortletPlacementContextImpl.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/PortletPlacementContextImpl.java?view=diff&rev=510195&r1=510194&r2=510195
==============================================================================
---
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/PortletPlacementContextImpl.java
(original)
+++
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/PortletPlacementContextImpl.java
Wed Feb 21 12:47:51 2007
@@ -119,27 +119,26 @@
this.containerFragment = container;
// Recursively process each fragment
- processFragment(container, maxdepth);
+ processFragment( container, maxdepth, 0 );
// The final step is to populate the array with the fragments
populateArray();
- //debugFragments("init");
+ //debugFragments( "init" );
}
/**
* Evaluate each portlet fragment and populate the internal data
* structures
*/
- protected void processFragment(Fragment fragment, int remainingDepth)
+ protected int processFragment( Fragment fragment, int remainingDepth,
int rowCount )
throws PortletPlacementException
{
- int rowCount = 0;
- // Process this fragment, then its children
+ // Process this fragment, then its children
if(fragment != null)
{
// Only process portlet fragments
- if(fragment.getType().equalsIgnoreCase("portlet"))
+ //if(fragment.getType().equalsIgnoreCase("portlet"))
{
// Get the column and row of this fragment
int col = getFragmentCol(fragment);
@@ -158,38 +157,40 @@
{
// Process the children
List children = fragment.getFragments();
+ int childRowCount = 0;
for(int ix = 0; ix < children.size(); ix++)
{
Fragment childFrag = (Fragment)children.get(ix);
if(childFrag != null)
{
- processFragment(childFrag, ((remainingDepth ==
NO_DEPTH_LIMIT) ? NO_DEPTH_LIMIT : remainingDepth-1) );
+ childRowCount = processFragment(childFrag,
((remainingDepth == NO_DEPTH_LIMIT) ? NO_DEPTH_LIMIT : remainingDepth-1),
childRowCount );
}
}
}
- }
+ }
+ return rowCount;
}
public Fragment debugFragments(String debug)
{
- System.out.println("*** " + debug);
+ StringBuffer out = new StringBuffer();
+ out.append( "PortletPlacementContext - " ).append( debug ).append( " -
container: " ).append( containerFragment == null ? "<null>" : (
containerFragment.getId() + " / " + containerFragment.getType() ) ).append(
"\n" );
for (int ix = 0; ix < this.columnsList.length; ix++)
{
Vector column = this.columnsList[ix];
- System.out.println("+++ Column " + ix);
+ out.append( " column " ).append( ix ).append( "\n" );
Iterator frags = column.iterator();
- while (frags.hasNext())
+ while ( frags.hasNext() )
{
Fragment f = (Fragment)frags.next();
- System.out.println("\tportlet = "
- + f.getId()
- + ", [" + f.getLayoutColumn()
- + "," + f.getLayoutRow()
- + "]");
- //root.getFragments().add(fragment);
+ out.append( " frag " ).append( f == null ? "<null>" :
f.getId() );
+ if ( f != null )
+ out.append( " / " ).append( f.getType() ).append( " col="
).append( f.getLayoutColumn() ).append( " row=" ).append( f.getLayoutRow() );
+ out.append( "\n" );
}
}
+ log.debug( out.toString() );
return containerFragment;
}
@@ -216,6 +217,7 @@
row++;
}
}
+ //debugFragments( "syncPageFragments" );
return page;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]