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

com.extjs.gxt.ui.client.util.Theme Maven / Gradle / Ivy

There is a newer version: 2.3.1-gwt22
Show newest version
/*
 * Sencha GXT 2.3.1a - Sencha for GWT
 * Copyright(c) 2007-2013, Sencha, Inc.
 * [email protected]
 * 
 * http://www.sencha.com/products/gxt/license/
 */
 package com.extjs.gxt.ui.client.util;

import java.util.Map;

import com.extjs.gxt.ui.client.GXT;
import com.extjs.gxt.ui.client.core.FastMap;
import com.extjs.gxt.ui.client.data.BaseModelData;
import com.extjs.gxt.ui.client.image.gray.GrayImages;
import com.google.gwt.core.client.GWT;

/**
 * A UI theme. Themes should be registered via the @link {@link ThemeManager} as
 * soon as the application module is loaded (onModuleLoad).
 * 
 * @see Theme#BLUE
 * @see Theme#GRAY
 */
public class Theme extends BaseModelData {

  /**
   * Default GXT blue theme.
   */
  public static Theme BLUE;

  /**
   * GXT gray theme (default path is 'gxt/css/gxt-gray.css').
   */
  public static Theme GRAY;

  static {
    BLUE = new Theme("blue", GXT.MESSAGES.themeSelector_blueTheme(), "gxt-all.css");
    GRAY = new Theme("gray", GXT.MESSAGES.themeSelector_grayTheme(), "gxt/css/gxt-gray.css")  {
      @Override
      public void init() {
        super.init();
        GXT.IMAGES = GWT.create(GrayImages.class);
      }
    };
  }

  protected Theme() {

  }

  /**
   * Creates a new theme.
   * 
   * @param id the theme id
   * @param name the theme name
   * @param file the CSS file
   */
  public Theme(String id, String name, String file) {
    set("id", id);
    set("name", name);
    set("file", file);
  }

  /**
   * Returns the theme id.
   * 
   * @return the theme id
   */
  public String getId() {
    return this. get("id");
  }

  /**
   * Returns the theme name.
   * 
   * @return the theme name
   */
  public String getName() {
    return this. get("name");
  }

  /**
   * Returns the theme's CSS file.
   * 
   * @return the file including the path
   */
  public String getFile() {
    return this. get("file");
  }

  public Map asMap() {
    Map map = new FastMap();
    map.put("id", getId());
    map.put("file", getFile());
    return map;
  }

  /**
   * Well be called when theme is initialized. Subclasses should override to
   * perform any theme specific initialization.
   */
  public void init() {

  }

}