View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  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,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.myfaces.trinidad.context;
20  
21  import java.io.Serializable;
22  
23  import java.util.Map;
24  
25  /**
26   * Represents a Window in the current user's Session.  Windows are created and vended
27   * by the Session's WindowManager and the Window for the current request is
28   * available from <code>WindowManager.getCurrentWindow</code>
29   * @see WindowManager#getCurrentWindow
30   */
31  public abstract class Window implements Serializable
32  {
33    /**
34     * <p>
35     * Represents the current state of the Window.  Windows start out <code>OPEN</code>,
36     * when the current window's document is being unloaded, they move to the <code>UNLOADING</code>
37     * state and then either move back to the <code>OPEN</code> state if the Window's content
38     * is populated with a new document from the same application, or to the <code>CLOSED</code>
39     * state if it is not.
40     * </p><p>
41     * This represents the framework's best guess at the current status of the Window.
42     * </p>
43     */
44    public enum LifecycleState
45    {
46      /** The Window is currently open */
47      OPEN,
48  
49      /** The Window is being unloaded */
50      UNLOADING,
51  
52      /** The Window is believed to be closed, either because the window was explicitly closed
53       *  or because the window is suspected to have been closed
54       */
55      CLOSED
56    }
57   
58    /**
59     * Represents how the window is used in the application
60     */
61    public enum Usage
62    {
63      /** Used as a top-level application window */
64      FRAME,
65  
66      /** Used as a dialog */
67      DIALOG
68    }
69   
70    /**
71     * @return The unique identifier for this Window within the Session
72     */
73    public abstract String getId();
74  
75    /**
76     * @return The current state of the Window
77     */
78    public abstract LifecycleState getLifecycleState();
79  
80    /**
81     * Returns the Usage of the Window--either a top-level frame or a dialog
82     * @return how the window is used
83     */
84    public abstract Usage getUsage();
85    
86    /**
87     * @return <code>true</code> if the window's document hasn't been rendered since the Window
88     * was created.
89     */
90    public abstract boolean isNew();
91  
92    /**
93     * Returns the Map for storing data associated with this Window object.  If the environment is
94     * configured for fail-over, the contents of this Map must be Serializable.
95     * @return The client data storage Map.
96     */
97    public abstract Map<String, Object> getWindowMap();
98  
99    private static final long serialVersionUID = 1L;
100 }