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

com.sencha.gxt.theme.base.client.widget.CollapsePanelBaseAppearance Maven / Gradle / Ivy

/**
 * Ext GWT 3.0.0-beta2 - Ext for GWT
 * Copyright(c) 2007-2011, Sencha, Inc.
 * [email protected]
 *
 * http://sencha.com/license
 */
package com.sencha.gxt.theme.base.client.widget;

import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.StyleInjector;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.CssResource;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.sencha.gxt.core.client.Style.LayoutRegion;
import com.sencha.gxt.core.client.dom.XElement;
import com.sencha.gxt.widget.core.client.CollapsePanel.CollapsePanelAppearance;

public class CollapsePanelBaseAppearance implements CollapsePanelAppearance {

  public interface CollapsePanelResources extends ClientBundle {
    
    @Source("CollapsePanel.css")
    CollapsePanelStyle style();
  }
  
  public interface CollapsePanelStyle extends CssResource {
    String panel();
    
    String iconWrap();
    
    String west(); 
    
    String east();
    
    String north();
    
    String south();
  }
  
  private final CollapsePanelResources resources;
  private final CollapsePanelStyle style;
  private static boolean injected;
  
  public CollapsePanelBaseAppearance() {
    this(GWT.create(CollapsePanelResources.class));
  }
  
  public CollapsePanelBaseAppearance(CollapsePanelResources resources) {
    this.resources = resources;
    this.style = this.resources.style();
    
    if (!injected) {
      injected = true;
      StyleInjector.inject(style.getText(), true);
    }
  }
  
  
  @Override
  public void render(SafeHtmlBuilder sb, LayoutRegion region) {
    String cls = style.panel();
    
    switch (region) {
      case WEST:
        cls += " " + style.west();
        break;
      case EAST:
        cls += " " + style.east();
        break;
      case NORTH:
        cls += " " + style.north();
        break;
      case SOUTH:
        cls += " " + style.south();
        break;
    }
    
    sb.appendHtmlConstant("
"); sb.appendHtmlConstant("
"); sb.appendHtmlConstant("
"); } @Override public XElement iconWrap(XElement parent) { return parent.getFirstChildElement().cast(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy