1 16 package org.apache.jetspeed.modules.actions.controllers; 17 18 import java.util.List ; 19 import java.util.Map ; 20 21 import javax.servlet.ServletRequest ; 22 23 import org.apache.jetspeed.om.profile.psml.PsmlEntry; 24 import org.apache.jetspeed.portal.Portlet; 25 import org.apache.jetspeed.portal.PortletController; 26 import org.apache.jetspeed.services.rundata.JetspeedRunData; 27 import org.apache.jetspeed.services.statemanager.SessionState; 28 import org.apache.jetspeed.util.template.JetspeedTool; 29 import org.apache.jetspeed.util.template.JspTemplate; 30 import org.apache.jetspeed.util.StringUtils; 31 import org.apache.turbine.util.RunData; 32 import org.apache.velocity.context.Context; 33 34 40 public class XMultiColumnControllerAction extends MultiColumnControllerAction 41 { 42 protected void buildCustomizeContext( 43 PortletController controller, 44 Context context, 45 RunData rundata 46 ) 47 { 48 super.buildCustomizeContext(controller, context, rundata); 49 context.put("template", "x-multicolumn-customize.vm"); 50 context.put("action", "controllers.XMultiColumnControllerAction"); 51 52 context.put("includedContent", new JspTemplate(rundata, "/controllers/html/x-multicolumn-customize.jsp")); 53 ServletRequest request = rundata.getRequest(); 54 request.setAttribute("jspContext", context); 55 56 Object [] columns = (Object []) context.get("portlets"); 58 Map portletTitleMap = (Map ) context.get("titles"); 59 for (int i = 0; i < columns.length; i++) 60 { 61 List portletList = (List ) columns[i]; 62 for (int j = 0; j < portletList.size(); j++) 63 { 64 PsmlEntry entry = (PsmlEntry) portletList.get(j); 65 String portletTitle = (String ) portletTitleMap.get(entry.getId()); 66 String portletSkinName = entry.getSkin() == null ? "-- Default --" : entry.getSkin().getName(); 67 String portletSecurityId = 68 entry.getSecurityRef() == null ? 69 "-- Default --" : 70 entry.getSecurityRef().getParent(); 71 String controlListBox = 72 (entry.getControl() != null && entry.getControl().getName() != null) ? 73 JetspeedTool.getPortletParameter(rundata, 74 (Portlet) rundata.getUser().getTemp("customizer"), 75 "control", entry.getControl().getName()) : 76 JetspeedTool.getPortletParameter(rundata, (Portlet) rundata.getUser().getTemp("customizer"), "control"); 77 controlListBox = controlListBox.substring(12); 78 controlListBox = controlListBox.replace('\n', ' '); 79 controlListBox = controlListBox.replace('\r', ' '); 80 int z = 0; 81 } 82 } 83 } 84 85 public void doSave(RunData data, Context context) 86 { 87 applyModelChanges(data, context); 88 super.doSave(data, context); 89 } 90 91 public void doDelete(RunData data, Context context) 92 { 93 applyModelChanges(data, context); 94 super.doDelete(data, context); 95 } 96 97 public void doControl(RunData data, Context context) 98 { 99 applyModelChanges(data, context); 100 super.doControl(data, context); 101 } 102 103 protected void applyModelChanges(RunData data, Context context) 104 { 105 ServletRequest request = data.getRequest(); 106 String [] modelChangeList = request.getParameterValues("modelChangeList"); 107 if (modelChangeList != null) 108 { 109 String [] moves = StringUtils.stringToArray(modelChangeList[0], ";"); 110 111 SessionState customizationState = ((JetspeedRunData) data).getPageSessionState(); 112 List [] columns = (List []) customizationState.getAttribute("customize-columns"); 113 114 for (int i = 0; i < moves.length; i++) 115 { 116 String [] values = StringUtils.stringToArray(moves[i], ","); 117 int originCol = Integer.parseInt(values[0]); 118 int originRow = Integer.parseInt(values[1]); 119 int destCol = Integer.parseInt(values[2]); 120 int destRow = Integer.parseInt(values[3]); 121 122 Object portletEntry = columns[originCol].get(originRow); 123 columns[originCol].remove(originRow); 124 columns[destCol].add(destRow, portletEntry); 125 } 126 } 127 } 128 } 129 130 | Popular Tags |