/**
 * @author smallufo 
 * Created on 2009/2/5 at 上午 5:11:33
 */ 
package quickstart;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import org.apache.wicket.Application;
import org.apache.wicket.Request;
import org.apache.wicket.Session;
import org.apache.wicket.protocol.http.WebSession;

public class MySession extends WebSession
{
  private Map<String , Boolean> panelShown = Collections.synchronizedMap(new HashMap<String , Boolean>());

  public MySession(Application application, Request request)
  {
    super(request);
    panelShown.put("panel1", Boolean.valueOf(true));  // panel 1 , default visible
    panelShown.put("panel2", Boolean.valueOf(false)); // panel 2 , default invisible
  }
  
  public static MySession get()
  {
    return (MySession) Session.get();
  }

  /**
   * Query this panel is visible or invisible
   */
  public boolean isVisible(String title)
  {
    if (panelShown.get(title) != null)
      return panelShown.get(title).booleanValue();
    else
      return false;
  }
  
  public void setVisible(String title , boolean value)
  {
    panelShown.put(title , Boolean.valueOf(value));
  }
}
