KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > core > theme > strategy > impl > PortletContextImpl


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7
8 package org.jboss.portal.core.theme.strategy.impl;
9
10 import org.jboss.portal.server.Component;
11 import org.jboss.portal.server.Window;
12 import org.jboss.portal.server.WindowContext;
13 import org.jboss.portal.server.plugins.windowstate.WindowState;
14 import org.jboss.portal.server.theme.strategy.PortletContext;
15 import org.jboss.portal.server.user.UserContext;
16
17 import java.util.Collections JavaDoc;
18 import java.util.Set JavaDoc;
19
20 /**
21  * An implementation of the portlet context.
22  * <p>This implementation currently does not handle region and order changes.</p>
23  *
24  * @author <a HREF="mailto:mholzner@novell.com">Martin Holzner</a>.
25  * @version <tt>$Revision: 1.3 $</tt>
26  * @see PortletContext
27  */

28 public class PortletContextImpl implements PortletContext
29 {
30    private final Component component;
31    private final WindowContext windowContext;
32    private final Window window;
33
34    //+++TODO: implement region and order handling
35

36    /**
37     * Create a new instance.
38     *
39     * @param window a reference to the portlet instance this context should represent
40     * @param userContext a reference to the users state for this portlet instance (preferences)
41     */

42    public PortletContextImpl(Window window, UserContext userContext)
43    {
44       this.window = window;
45       this.component = window.getInstance().getComponent();
46       windowContext = (WindowContext)userContext.getContext(window);
47    }
48
49    /**
50     * @see org.jboss.portal.server.theme.strategy.PortletContext#getPortletName()
51     */

52    public String JavaDoc getPortletName()
53    {
54       return component.getName();
55    }
56
57    /**
58     * @see org.jboss.portal.server.theme.strategy.PortletContext#getWindowState()
59     */

60    public WindowState getWindowState()
61    {
62       return windowContext.getWindowState();
63    }
64
65    /**
66     * @throws IllegalArgumentException if the window state is null
67     * @see PortletContext#isSupportedWindowState(org.jboss.portal.server.plugins.windowstate.WindowState)
68     */

69    public boolean isSupportedWindowState(WindowState windowState)
70    {
71       return window.isSupportedWindowState(windowState);
72    }
73
74    /**
75     * @see org.jboss.portal.server.theme.strategy.PortletContext#getSupportedWindowStates()
76     */

77    public Set JavaDoc getSupportedWindowStates()
78    {
79       return Collections.unmodifiableSet(window.getSupportedWindowStates());
80    }
81
82    /**
83     * @throws UnsupportedOperationException
84     * @see org.jboss.portal.server.theme.strategy.PortletContext#getRegionName()
85     */

86    public String JavaDoc getRegionName()
87    {
88       throw new UnsupportedOperationException JavaDoc("not implemented yet");
89    }
90
91    /**
92     * @throws UnsupportedOperationException
93     * @see PortletContext#setRegionName(String)
94     */

95    public void setRegionName(String JavaDoc regionName)
96    {
97       throw new UnsupportedOperationException JavaDoc("not implemented yet");
98    }
99
100    /**
101     * @throws UnsupportedOperationException
102     * @see org.jboss.portal.server.theme.strategy.PortletContext#getOrder()
103     */

104    public int getOrder()
105    {
106       throw new UnsupportedOperationException JavaDoc("not implemented yet");
107    }
108
109    /**
110     * @throws UnsupportedOperationException
111     * @see PortletContext#setOrder
112     */

113    public void setOrder(int order)
114    {
115       throw new UnsupportedOperationException JavaDoc("not implemented yet");
116    }
117
118    /**
119     * @see java.lang.Object#equals
120     */

121    public boolean equals(Object JavaDoc o)
122    {
123       if (this == o)
124       {
125          return true;
126       }
127       if (!(o instanceof PortletContextImpl))
128       {
129          return false;
130       }
131
132       final PortletContextImpl portletContext = (PortletContextImpl)o;
133
134       if (!window.getID().equals(portletContext.window.getID()))
135       {
136          return false;
137       }
138
139       return true;
140    }
141
142    /**
143     * @see java.lang.Object#hashCode
144     */

145    public int hashCode()
146    {
147       return window.getID().hashCode();
148    }
149
150    /**
151     * @see java.lang.Object#toString
152     */

153    public String JavaDoc toString()
154    {
155       return window.getName();
156    }
157 }
158
Popular Tags