{
// Must get from store because the one in memory is comtaminated with stylesheet params
// that shouldn't get persisted
//UserPreferences userPrefsFromStore = context.getUserPreferencesFromStore(context.getCurrentUserPreferences().getProfile());
//StructureStylesheetUserPreferences ssup = userPrefsFromStore.getStructureStylesheetUserPreferences();
StructureStylesheetUserPreferences ssup = userPrefs.getStructureStylesheetUserPreferences();
/*
userPrefs is loaded directly from the database not copied from the
UserPreferencesManager's value. As such it does not contain current
session values like the structure stylesheet parameter userLayoutRoot
which tells the rendering engine the node id that should be displayed
in focused mode. While in preferences this node id is the node id of the
preferences channel. That is a session value and should not be preserved.
But the UserPreferencesManager's structure stylesheet user preferences
object is being replaced by the version that we have here so that column
width changes take immediate affect. Therefore, after persisting them we
need to push the value of the userLayoutRoot node back into the
preferences now held by the UserPreferencesManager so that the
preferences channel remains in focus after changing the column widths.
*/
String focusedNode = context.getUserPreferencesManager()
.getUserPreferences().getStructureStylesheetUserPreferences()
.getParameterValue( "userLayoutRoot" );
String activeTab = context.getUserPreferencesManager()
.getUserPreferences().getStructureStylesheetUserPreferences()
.getParameterValue( "activeTab" );
java.util.Set sColWidths = columnWidths.keySet();
java.util.Iterator iterator = sColWidths.iterator();
while(iterator.hasNext())
{
String folderId = (String)iterator.next();
String newWidth = (String)columnWidths.get(folderId);
// Only accept widths that are either percentages or integers (fixed widths)
boolean widthIsValid = true;
try
{
Integer.parseInt(newWidth.endsWith("%") ? newWidth.substring(0, newWidth.indexOf("%")) : newWidth);
}
catch (java.lang.NumberFormatException nfe)
{
widthIsValid = false;
}
if (widthIsValid)
{
ssup.setFolderAttributeValue(folderId, "width", newWidth);
Element folder = ulm.getUserLayoutDOM().getElementById( folderId );
UserPrefsHandler.setUserPreference( folder, "width",
staticData.getPerson() );
}
else
if (log.isDebugEnabled())
log.debug("User id " + staticData.getPerson().getID() + " entered invalid column width: " + newWidth);
}
// Persist structure stylesheet user preferences
saveUserPreferences();
saveLayout(false);
// now push the focused node value back into new rendering prefs object.
ssup.putParameterValue( "userLayoutRoot", focusedNode );
if ( activeTab != null )
ssup.putParameterValue( "activeTab", activeTab );
}