View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.jetspeed.om.window.impl;
18  
19  import java.io.Serializable;
20  
21  import org.apache.pluto.om.window.PortletWindow;
22  import org.apache.pluto.om.window.PortletWindowCtrl;
23  import org.apache.pluto.om.window.PortletWindowListCtrl;
24  import org.apache.pluto.om.entity.PortletEntity;
25  import org.apache.pluto.om.common.ObjectID;
26  import org.apache.jetspeed.util.JetspeedObjectID;
27  
28  /***
29   * <P>
30   * The <CODE>PortletWindow</CODE> implementation represents a single window
31   * of an portlet instance as it can be shown only once on a single page. 
32   * Adding the same portlet e.g. twice on a page results in two different windows.
33   * </P>
34   *
35   * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
36   * @version $Id: PortletWindowImpl.java 553014 2007-07-03 23:10:53Z ate $
37   **/
38  public class PortletWindowImpl implements PortletWindow, PortletWindowCtrl, Serializable
39  {
40      private ObjectID objectId = null;
41      private transient PortletEntity portletEntity = null;
42  
43      public PortletWindowImpl(String id)
44      {
45          this.objectId = JetspeedObjectID.createFromString(id);
46      }
47  
48      public PortletWindowImpl(ObjectID oid)
49      {
50          this.objectId = oid;
51      }
52  
53      public PortletWindowImpl()
54      {
55          super();
56      }
57  
58      /***
59      * Returns the identifier of this portlet instance window as object id
60      *
61      * @return the object identifier
62      **/
63      public ObjectID getId()
64      {
65          return objectId;
66      }
67      /***
68       * Returns the portlet entity
69       *
70       * @return the portlet entity
71       **/
72      public PortletEntity getPortletEntity()
73      {
74          return portletEntity;
75      }
76  
77      // controller impl
78      /***
79       * binds an identifier to this portlet window
80       *
81       * @param id the new identifier
82       */
83      public void setId(String id)
84      {
85          objectId = JetspeedObjectID.createFromString(id);
86      }
87  
88      /***
89       * binds a portlet instance to this portlet window
90       * 
91       * @param portletEntity a portlet entity object
92       **/
93      public void setPortletEntity(PortletEntity portletEntity)
94      {
95          this.portletEntity = portletEntity;
96          ((PortletWindowListCtrl)portletEntity.getPortletWindowList()).add(this);
97      }
98  
99  }