public ChartModel getChartModel(int segments) {
   ChartModel cm =
       new ChartModel(
           "Sales by Month 2008", "font-size: 14px; font-family: Verdana; color:#ffff00;");
   cm.setBackgroundColour("#000077");
   XAxis xa = new XAxis();
   xa.setLabels(TestData.getShortMonths(segments));
   xa.getLabels().setColour("#ffff00");
   xa.setGridColour("-1");
   xa.setColour("#aa5500");
   xa.setZDepth3D(5);
   cm.setXAxis(xa);
   YAxis ya = new YAxis();
   ya.setSteps(16);
   ya.setMax(160);
   ya.setGridColour("#000099");
   ya.setColour("#ffff00");
   cm.setYAxis(ya);
   cm.setYAxisLabelStyle(10, "#ffff00");
   BarChart bchart = new BarChart(BarStyle.THREED);
   bchart.setColour("#CC6600");
   bchart.setTooltip("$#val#");
   for (int t = 0; t < segments; t++) {
     bchart.addValues(Random.nextInt(50) + 50);
   }
   cm.addChartConfig(bchart);
   return cm;
 }
 public ChartModel getChartModel(int segments) {
   ChartModel cm =
       new ChartModel("Sales by Month 2007", "font-size: 14px; font-family: Verdana;");
   cm.setBackgroundColour("-1");
   XAxis xa = new XAxis();
   for (String m : TestData.getMonths()) {
     Label l = new Label(m, 45);
     l.setSize(10);
     l.setColour("#000000");
     xa.addLabels(l);
   }
   xa.setGridColour("-1");
   cm.setXAxis(xa);
   YAxis ya = new YAxis();
   ya.setSteps(16);
   ya.setMax(160);
   ya.setGridColour("#8888FF");
   cm.setYAxis(ya);
   BarChart bchart = new BarChart(BarStyle.GLASS);
   bchart.setColour("#FF00CC");
   bchart.setTooltip("$#val#");
   for (int t = 0; t < 12; t++) {
     if (t == segments - 1) {
       bchart.addBars(new BarChart.Bar(Random.nextInt(50) + 50, "#8888FF"));
     } else {
       bchart.addValues(Random.nextInt(50) + 50);
     }
   }
   cm.addChartConfig(bchart);
   return cm;
 }
 public ChartModel getChartModel(int segments) {
   ChartModel cm =
       new ChartModel(
           "Sales by Month",
           "font-size: 16px; font-weight: bold; font-family: Verdana; color:#008800;");
   cm.setBackgroundColour("#eeffee");
   cm.setDecimalSeparatorComma(true);
   XAxis xa = new XAxis();
   xa.setLabels(TestData.getShortMonths(segments));
   xa.getLabels().setColour("#009900");
   xa.setGridColour("#eeffee");
   xa.setColour("#009900");
   cm.setXAxis(xa);
   YAxis ya = new YAxis();
   ya.setRange(5000, 20000);
   ya.setSteps(1000);
   ya.setGridColour("#eeffee");
   ya.setColour("#009900");
   cm.setYAxisLabelStyle(10, "#009900");
   cm.setYAxis(ya);
   FilledBarChart bchart = new FilledBarChart("#6666ff", "#000066");
   bchart.setTooltip("$#val#");
   for (int t = 0; t < segments; t++) {
     bchart.addValues(Random.nextInt(5000) + 10000);
   }
   cm.addChartConfig(bchart);
   return cm;
 }
    public ChartModel getChartModel(int segments) {
      ChartModel cd = new ChartModel("Sales per Month", "font-size: 14px; font-family: Verdana;");
      cd.setBackgroundColour("#fffff0");
      PieChart pie = new PieChart();
      pie.setAlpha(0.5f);
      pie.setTooltip("#label# $#val#<br>#percent#");
      pie.setAnimate(false);
      pie.setAlphaHighlight(true);
      pie.setGradientFill(true);
      pie.setColours("#ff0000", "#00aa00", "#0000ff", "#ff9900", "#ff00ff");

      for (int n = 0; n < segments; n++) {
        pie.addSlices(new PieChart.Slice(Random.nextInt(110) * 100, TestData.getMonths()[n]));
      }
      cd.addChartConfig(pie);
      return cd;
    }
  @Override
  protected void onRender(Element parent, int index) {
    super.onRender(parent, index);

    setLayout(new FlowLayout(10));

    Folder model = TestData.getTreeModel();

    TreeStore<ModelData> store = new TreeStore<ModelData>();

    store.add(model.getChildren(), true);

    ColumnConfig name = new ColumnConfig("name", "Name", 100);
    name.setRenderer(new TreeGridCellRenderer<ModelData>());

    ColumnConfig date = new ColumnConfig("author", "Author", 100);

    ColumnConfig size = new ColumnConfig("genre", "Genre", 100);

    ColumnModel cm = new ColumnModel(Arrays.asList(name, date, size));

    ContentPanel cp = new ContentPanel();
    cp.setBodyBorder(false);
    cp.setHeading("TreeGrid");
    cp.setButtonAlign(HorizontalAlignment.CENTER);
    cp.setLayout(new FitLayout());
    cp.setFrame(true);
    cp.setSize(600, 300);

    TreeGrid<ModelData> tree = new TreeGrid<ModelData>(store, cm);
    tree.setBorders(true);
    tree.getStyle().setLeafIcon(Resources.ICONS.music());
    tree.setAutoExpandColumn("name");
    tree.setTrackMouseOver(false);

    cp.add(tree);

    add(cp);

    StoreFilterField<ModelData> filter =
        new StoreFilterField<ModelData>() {

          @Override
          protected boolean doSelect(
              Store<ModelData> store,
              ModelData parent,
              ModelData record,
              String property,
              String filter) {
            // only match leaf nodes
            if (record instanceof Folder) {
              return false;
            }
            String name = record.get("name");
            name = name.toLowerCase();
            if (name.startsWith(filter.toLowerCase())) {
              return true;
            }
            return false;
          }
        };
    filter.bind(store);

    ToolBar toolBar = new ToolBar();
    toolBar.setBorders(true);
    toolBar.add(new LabelToolItem("Filter:"));
    toolBar.add(filter);

    cp.setTopComponent(toolBar);
  }
  @Override
  protected void onRender(Element parent, int index) {
    super.onRender(parent, index);
    setStyleAttribute("margin", "10px");

    final FormPanel panel = new FormPanel();
    panel.setHeading("File Upload Example");
    panel.setFrame(true);
    panel.setAction("myurl");
    panel.setEncoding(Encoding.MULTIPART);
    panel.setMethod(Method.POST);
    panel.setButtonAlign(HorizontalAlignment.CENTER);
    panel.setWidth(350);

    TextField<String> name = new TextField<String>();
    name.setFieldLabel("Name");
    panel.add(name);

    FileUploadField file = new FileUploadField();
    file.setAllowBlank(false);
    file.setName("uploadedfile");
    file.setFieldLabel("File");
    panel.add(file);

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

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

    Button btn = new Button("Reset");
    btn.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            panel.reset();
          }
        });
    panel.addButton(btn);

    btn = new Button("Submit");
    btn.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            if (!panel.isValid()) {
              return;
            }
            // normally would submit the form but for example no server set up to
            // handle the post
            // panel.submit();
            MessageBox.info("Action", "You file was uploaded", null);
          }
        });
    panel.addButton(btn);

    add(panel);
  }
  private void createGrid(boolean widget) {
    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();

    ColumnConfig column = new ColumnConfig();
    column.setId("name");
    column.setHeader("Company");
    column.setWidth(200);
    configs.add(column);

    column = new ColumnConfig();
    column.setId("symbol");
    column.setHeader("Symbol");
    column.setWidth(100);
    configs.add(column);

    column = new ColumnConfig();
    column.setId("last");
    column.setHeader("Last");
    column.setAlignment(HorizontalAlignment.RIGHT);
    column.setWidth(75);
    column.setRenderer(gridNumber);
    configs.add(column);

    column = new ColumnConfig("change", "Change", 100);
    column.setAlignment(HorizontalAlignment.RIGHT);
    column.setRenderer(change);
    configs.add(column);

    column = new ColumnConfig("date", 125);
    if (widget) {
      Button btn = new Button("Updated");
      btn.addListener(
          Events.OnClick,
          new Listener<ButtonEvent>() {
            public void handleEvent(ButtonEvent be) {
              // stop column from getting click and causing sort
              be.cancelBubble();
            }
          });
      btn.setStyleAttribute("float", "left");
      column.setWidget(btn, "Last Updated");
    } else {
      column.setAlignment(HorizontalAlignment.RIGHT);
      column.setHeader("Last Updated");
    }

    column.setDateTimeFormat(DateTimeFormat.getFormat("MM/dd/yyyy"));
    configs.add(column);

    ListStore<Stock> store = new ListStore<Stock>();
    store.add(TestData.getStocks());

    ColumnModel cm = new ColumnModel(configs);

    cm.addHeaderGroup(0, 0, new HeaderGroupConfig("Header Grouping Example", 1, 5));
    cm.addHeaderGroup(1, 2, new HeaderGroupConfig("Stock Performance", 1, 2));

    if (widget) {
      Slider s = new Slider();
      s.setWidth(100);

      // ugly, but centers slider
      FlexTable tbl = new FlexTable();
      tbl.setWidth("100%");
      tbl.setHTML(0, 0, "&nbsp;");
      tbl.setHTML(
          0, 1, "<span style='white-space: nowrap;font-size: 11px'>Slide Me: &nbsp;</span>");
      tbl.setWidget(0, 2, s);
      tbl.setHTML(0, 3, "&nbsp;");
      tbl.getCellFormatter().setWidth(0, 0, "50%");
      tbl.getCellFormatter().setWidth(0, 3, "50%");
      cm.addHeaderGroup(1, 0, new HeaderGroupConfig(tbl, 1, 2));
    } else {
      cm.addHeaderGroup(1, 0, new HeaderGroupConfig("Stock Information", 1, 2));
    }

    ContentPanel cp = new ContentPanel();
    cp.setBodyBorder(false);
    cp.setIcon(Resources.ICONS.table());
    cp.setHeading(widget ? "Column Grouping with Widget" : "Column Grouping");
    cp.setButtonAlign(HorizontalAlignment.CENTER);
    cp.setLayout(new FitLayout());
    cp.setSize(600, 300);

    Grid<Stock> grid = new Grid<Stock>(store, cm);
    grid.setStyleAttribute("borderTop", "none");
    grid.getView().setForceFit(true);
    grid.setBorders(true);
    cp.add(grid);

    vp.add(cp);
  }