Adding ToolBar to ContentPanel (Ext GWT) : ToolBar « GWT « Java






Adding ToolBar to ContentPanel (Ext GWT)

Adding ToolBar to ContentPanel (Ext GWT)
 
/*
 * Ext GWT - Ext for GWT
 * Copyright(c) 2007-2009, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */
package com.google.gwt.sample.hello.client;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.extjs.gxt.ui.client.data.BaseModel;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.button.SplitButton;
import com.extjs.gxt.ui.client.widget.button.ToggleButton;
import com.extjs.gxt.ui.client.widget.custom.ThemeSelector;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
import com.extjs.gxt.ui.client.widget.menu.CheckMenuItem;
import com.extjs.gxt.ui.client.widget.menu.DateMenu;
import com.extjs.gxt.ui.client.widget.menu.Menu;
import com.extjs.gxt.ui.client.widget.menu.MenuItem;
import com.extjs.gxt.ui.client.widget.menu.SeparatorMenuItem;
import com.extjs.gxt.ui.client.widget.toolbar.FillToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.RootPanel;

public class Hello implements EntryPoint {

  public void onModuleLoad() {

    RootPanel.get().add(new ToolBarExample());

  }
}
class ToolBarExample extends LayoutContainer {

  @Override
  protected void onRender(Element parent, int pos) {
    super.onRender(parent, pos);
    setLayout(new FlowLayout(10));

    ToolBar toolBar = new ToolBar();

    Button item1 = new Button("Button w/ Menu");
    //item1.setIcon(Resources.ICONS.menu_show());

//    List<Stock> list = getStocks();
    //final ListStore<Stock> store = new ListStore<Stock>();
  //  store.add(list);

    final ComboBox combo = new ComboBox();
    combo.setFieldLabel("Company");
    combo.setDisplayField("name");
    combo.setName("name");
    combo.setValueField("symbol");
    combo.setForceSelection(true);
    //combo.setStore(store);
    combo.setTriggerAction(TriggerAction.ALL);

    Menu menu = new Menu();
    menu.add(combo);

    CheckMenuItem menuItem = new CheckMenuItem("I Like Cats");
    menuItem.setChecked(true);
    menu.add(menuItem);

    menuItem = new CheckMenuItem("I Like Dogs");
    menu.add(menuItem);
    item1.setMenu(menu);

    menu.add(new SeparatorMenuItem());

    MenuItem radios = new MenuItem("Radio Options");
    menu.add(radios);

    Menu radioMenu = new Menu();
    CheckMenuItem r = new CheckMenuItem("Blue Theme");
    r.setGroup("radios");
    r.setChecked(true);
    radioMenu.add(r);
    r = new CheckMenuItem("Gray Theme");
    r.setGroup("radios");
    radioMenu.add(r);
    radios.setSubMenu(radioMenu);

    MenuItem date = new MenuItem("Choose a Date");
    //date.setIcon(Resources.ICONS.calendar());
    menu.add(date);

    date.setSubMenu(new DateMenu());

    toolBar.add(item1);

    toolBar.add(new SeparatorToolItem());

    SplitButton splitItem = new SplitButton("Split Button");
    //splitItem.setIcon(Resources.ICONS.list_items());

    menu = new Menu();
    menu.add(new MenuItem("<b>Bold</b>"));
    menu.add(new MenuItem("<i>Italic</i>"));
    menu.add(new MenuItem("<u>Underline</u>"));
    splitItem.setMenu(menu);

    toolBar.add(splitItem);

    toolBar.add(new SeparatorToolItem());

    ToggleButton toggle = new ToggleButton("Toggle");
    toggle.toggle(true);
    toolBar.add(toggle);

    toolBar.add(new SeparatorToolItem());

    Button scrollerButton = new Button("Scrolling Menu");

    Menu scrollMenu = new Menu();
    scrollMenu.setMaxHeight(200);
    for (int i = 0; i < 40; i++) {
      scrollMenu.add(new MenuItem("Item " + i));
    }

    scrollerButton.setMenu(scrollMenu);

    toolBar.add(scrollerButton);

    toolBar.add(new SeparatorToolItem());

    toolBar.add(new FillToolItem());
    ThemeSelector selector = new ThemeSelector();
    toolBar.add(selector);

    ContentPanel panel = new ContentPanel();
    panel.setCollapsible(true);
    panel.setFrame(true);
    panel.setHeading("ToolBar & Menu Demo");
    panel.setLayout(new FitLayout());
    panel.setSize(500, 300);
    panel.setTopComponent(toolBar);

    LayoutContainer c = new LayoutContainer();
    c.setStyleAttribute("backgroundColor", "white");
    c.setBorders(true);
    panel.add(c);

    add(panel);
  }
 
}

   
  








Ext-GWT.zip( 4,297 k)

Related examples in the same category

1.Tool Strips Sample (Smart GWT)Tool Strips Sample (Smart GWT)
2.Adding ComboBox to ToolBar (Ext GWT)Adding ComboBox to ToolBar (Ext GWT)
3.ToolBar overflow (Ext GWT)
4.ToolBar with Dropdown menu (Ext GWT)ToolBar with Dropdown menu (Ext GWT)
5.Ribbon like ToolBar (Ext GWT)Ribbon like ToolBar (Ext GWT)
6.Multi-column no-title ToolBar (Ext GWT)Multi-column no-title ToolBar (Ext GWT)
7.ToolBar with grouped buttons (Ext GWT)ToolBar with grouped buttons (Ext GWT)
8.Office 2007 style toolbar (Ext GWT)Office 2007 style toolbar (Ext GWT)
9.Adding menu bar to ContentPanel (Ext GWT)Adding menu bar to ContentPanel (Ext GWT)
10.Adding Status to ToolBar (Ext GWT)Adding Status to ToolBar (Ext GWT)
11.Add ToolBar to the bottom of a FormPanel (Ext GWT)Add ToolBar to the bottom of a FormPanel (Ext GWT)
12.Using ButtonBar to hold buttons (Ext GWT)Using ButtonBar to hold buttons (Ext GWT)