1 16 package org.apache.cocoon.portal.pluto; 17 18 import javax.portlet.PortletMode; 19 import javax.portlet.WindowState; 20 21 import org.apache.cocoon.portal.coplet.CopletInstanceData; 22 import org.apache.cocoon.portal.pluto.om.PortletEntityImpl; 23 import org.apache.pluto.om.window.PortletWindow; 24 import org.apache.pluto.services.information.PortletActionProvider; 25 26 33 public class PortletActionProviderImpl implements PortletActionProvider { 34 35 36 protected PortletWindow portletWindow; 37 38 public PortletActionProviderImpl(PortletWindow portletWindow) { 39 this.portletWindow = portletWindow; 40 } 41 42 45 public void changePortletMode(PortletMode mode) { 46 if ( mode != null ) { 47 final CopletInstanceData cid = ((PortletEntityImpl)portletWindow.getPortletEntity()).getCopletInstanceData(); 48 PortletMode pm = (PortletMode) cid.getTemporaryAttribute("portlet-mode"); 49 if ( (pm == null && !mode.equals(PortletMode.VIEW)) 50 || (pm != null && !pm.equals(mode)) ) { 51 if ( pm != null ) { 52 cid.setTemporaryAttribute("previous-portlet-mode", pm); 53 } 54 cid.setTemporaryAttribute("portlet-mode", mode); 55 } 56 } 57 } 58 59 62 public void changePortletWindowState(WindowState state) { 63 if ( state != null ) { 64 final CopletInstanceData cid = ((PortletEntityImpl)portletWindow.getPortletEntity()).getCopletInstanceData(); 65 WindowState ws = (WindowState) cid.getTemporaryAttribute("window-state"); 66 if ( (ws == null && !state.equals(WindowState.NORMAL)) 67 || (ws != null && !ws.equals(state)) ) { 68 if ( ws != null ) { 69 cid.setTemporaryAttribute("previous-window-state", ws); 70 } 71 cid.setTemporaryAttribute("window-state", state); 72 } 73 } 74 } 75 76 } 77 | Popular Tags |