KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > portal > pluto > PortletActionProviderImpl


1 /*
2  * Copyright 2004,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

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 /**
27  *
28  *
29  * @author <a HREF="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
30  *
31  * @version CVS $Id: PortletActionProviderImpl.java 123794 2004-12-31 14:22:25Z antonio $
32  */

33 public class PortletActionProviderImpl implements PortletActionProvider {
34
35     /** The target */
36     protected PortletWindow portletWindow;
37
38     public PortletActionProviderImpl(PortletWindow portletWindow) {
39         this.portletWindow = portletWindow;
40     }
41
42     /* (non-Javadoc)
43      * @see org.apache.pluto.services.information.PortletActionProvider#changePortletMode(PortletWindow, PortletMode)
44      */

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     /* (non-Javadoc)
60      * @see org.apache.pluto.services.information.PortletActionProvider#changePortletWindowState(PortletWindow, WindowState)
61      */

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