⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pagestatemanager.java

📁 OLAP 的客户端代码
💻 JAVA
字号:
package com.tonbeller.jpivot.tags;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import org.apache.log4j.Logger;

/**
 * @author av
 * @since 15.02.2005
 */
public class PageStateManager implements StateManager {
  Map map = new HashMap();
  State current;
  private static final Logger logger = Logger.getLogger(PageStateManager.class);

  void showCurrent() throws Exception {
    if (current != null)
      current.show();
  }
  
  void hideCurrent() throws Exception {
    if (current != null)
      current.hide();
  }
  
  public void initializeAndShow(State next) throws Exception {
    hideCurrent();
    
    // remove state with same name from map
    State prev = (State) map.get(next.getName());
    if (prev != null)
      prev.destroy();

    map.put(next.getName(), next);
    next.initialize();
    current = next;
    showCurrent();
  }

  /**
   * makes the named state the visible one
   */
  public void showByName(String name) throws Exception {
    State s = (State) map.get(name);
    if (s == null) {
      logger.error("could not find state for " + name);
      return;
    }
    if (current != s) {
      hideCurrent();
      current = s;
      showCurrent();
    }
  }

  /**
   * removes and destroys all states
   */
  public void destroyAll() throws Exception {
    hideCurrent();
    current = null;
    for (Iterator it = map.values().iterator(); it.hasNext();) {
      State s = (State) it.next();
      s.destroy();
    }
    map.clear();
  }

  /**
   * removes and destroys the named state
   */
  public void destroyByName(String name) throws Exception {
    State s = (State) map.get(name);
    if (s == null) {
      logger.error("query " + name + " not found");
      return;
    }
    if (s == current) {
      hideCurrent();
      current = null;
    }
    s.destroy();
    map.remove(name);
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -