All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gxt-2.1.1-sources.com.extjs.gxt.ui.client.state.StateManager Maven / Gradle / Ivy

There is a newer version: 2.3.1-gwt22
Show newest version
/*
 * Ext GWT - Ext for GWT
 * Copyright(c) 2007-2009, Ext JS, LLC.
 * [email protected]
 * 
 * http://extjs.com/license
 */
package com.extjs.gxt.ui.client.state;

import java.util.Date;
import java.util.Map;

/**
 * This is the global state manager. In order for this class to be useful, it
 * must be initialized with a provider when your application initializes. By
 * default, GXT initializes the StateManager with a CookieProvider. The provider
 * can be replaced as needed.
 * 
 * 
*
Events:
*
StateChange : (manager, name, value)
*
Fires after a state change.
*
    *
  • manager : the state manager
  • *
  • name : the key name
  • *
  • value : the value or null if cleared
  • *
*
*
*/ public class StateManager { private static StateManager instance = new StateManager(); /** * Returns the singleton instance. * * @return the state manager */ public static StateManager get() { return instance; } private Provider provider; /** * Returns the current value for a key. * * @param name the key name * @return the value */ public Object get(String name) { return provider.get(name); } /** * Returns the current value for a key. * * @param name the key name * @return the value as a map */ public Map getMap(String name) { try { return provider.getMap(name); } catch (Exception e) { return null; } } /** * Returns the current value for a key. * * @param name the key name * @return the value */ public Date getDate(String name) { return provider.getDate(name); } /** * Returns the current value for a key. * * @param name the key name * @return the value */ public int getInteger(String name) { return provider.getInteger(name); } /** * Returns the manager's state provider. * * @return the provider */ public Provider getProvider() { return provider; } /** * Returns the current value for a key. * * @param name the key name * @return the value */ public String getString(String name) { return provider.getString(name); } /** * Sets a key. * * @param name the key name * @param value the value */ public void set(String name, Object value) { provider.set(name, value); } /** * Sets the manager's state provider. * * @param stateProvider the provider */ public void setProvider(Provider stateProvider) { provider = stateProvider; provider.bind(this); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy