01: //WebOnSwing - Web Application Framework
02: //Copyright (C) 2003 Fernando Damian Petrola
03: //
04: //This library is free software; you can redistribute it and/or
05: //modify it under the terms of the GNU Lesser General Public
06: //License as published by the Free Software Foundation; either
07: //version 2.1 of the License, or (at your option) any later version.
08: //
09: //This library is distributed in the hope that it will be useful,
10: //but WITHOUT ANY WARRANTY; without even the implied warranty of
11: //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: //Lesser General Public License for more details.
13: //
14: //You should have received a copy of the GNU Lesser General Public
15: //License along with this library; if not, write to the Free Software
16: //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17:
18: package net.ar.webonswing.managers.state;
19:
20: import java.io.*;
21: import java.util.*;
22:
23: /**
24: * Maneja el estado de cada componente que este dentro del arbol de componentes de una ventana dada.
25: * Cada componente tiene varios "estados" asociados a el, y estos estan diferenciados por una cadena que los nombra.
26: * Por ejemplo podria tener los estados "cache", "contribution"; para "cache" el camino seria:
27: * Map(nombre_de_ventana):Map(nombre_de_componente):String("cache")= valor guardado
28: * y para el "contribution" seria lo mismo pero variaria la ultima rama por String("contribution").
29: *
30: * @author Fernando Damian Petrola
31: */
32: public class WindowTreeStateManager implements Serializable {
33: protected Map theWindowsState;
34:
35: public WindowTreeStateManager() {
36: theWindowsState = new Hashtable();
37: }
38:
39: public Map getTheWindowState() {
40: return theWindowsState;
41: }
42:
43: public void setTheWindowState(Map anTheWindowState) {
44: theWindowsState = anTheWindowState;
45: }
46:
47: public Object getComponentState(String aWindowName,
48: String aComponentName, String theStateName) {
49: Object theResult = null;
50: Map aWindowState = (Map) theWindowsState.get(aWindowName);
51:
52: if (aWindowState != null) {
53: Map theStates = (Map) aWindowState.get(aComponentName);
54:
55: if (theStates != null)
56: theResult = theStates.get(theStateName);
57: }
58:
59: return theResult;
60: }
61:
62: public Object setComponentState(String aWindowName,
63: String aComponentName, String theStateName, Object theValue) {
64: Map aWindowState = (Map) theWindowsState.get(aWindowName);
65: if (aWindowState == null)
66: theWindowsState.put(aWindowName,
67: aWindowState = new Hashtable());
68:
69: Map theStates = (Map) aWindowState.get(aComponentName);
70: if (theStates == null)
71: aWindowState.put(aComponentName,
72: theStates = new Hashtable());
73:
74: theStates.put(theStateName, theValue);
75:
76: return theValue;
77: }
78: }
|