View Javadoc

1   /**
2    * Copyright (C) 2005-2009 Alfresco Software Limited.
3    *
4    * This file is part of the Spring Surf Extension project.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *  http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  package org.springframework.extensions.surf.studio;
20  
21  import java.io.Serializable;
22  import java.util.HashMap;
23  
24  import org.apache.commons.logging.Log;
25  import org.apache.commons.logging.LogFactory;
26  
27  /**
28   * Manages client side state for the Web Studio application
29   * 
30   * @author muzquiano
31   */
32  public class WebStudioStateBean implements Serializable
33  {
34      private static Log logger = LogFactory.getLog(WebStudioStateBean.class);
35  
36      protected HashMap<String, ApplicationStateBean> applications = null;
37      protected HashMap<String, AppletStateBean> applets = null;
38  
39      public WebStudioStateBean()
40      {
41      }
42  
43      /**
44       * Returns an array of application ids for Web Studio
45       * 
46       * @return array of ids
47       */
48      public String[] getApplicationIds()
49      {
50          return applications.values().toArray(new String[applications.size()]);
51      }
52  
53      /**
54       * Retrieves the application state for a given application id
55       * 
56       * @param id
57       * 
58       * @return application state
59       */
60      public ApplicationStateBean getApplicationState(String id)
61      {
62          return (ApplicationStateBean) applications.get(id);
63      }
64  
65      /**
66       * Returns an array of applet ids for Web Studio
67       * 
68       * @return array of ids
69       */
70      public String[] getAppletIds()
71      {
72          return applets.values().toArray(new String[applications.size()]);
73      }
74  
75      /**
76       * Retrives the applet state for a given applet id
77       * 
78       * @param id
79       * 
80       * @return applet state
81       */
82      public AppletStateBean getAppletState(String id)
83      {
84          return (AppletStateBean) applets.get(id);
85      }
86  }