Package net.helipilot50.stocktrade.client

Source Code of net.helipilot50.stocktrade.client.CustomerHoldingsPanel

package net.helipilot50.stocktrade.client;

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

import net.helipilot50.stocktrade.model.Holding;

import com.extjs.gxt.ui.client.data.BeanModel;
import com.extjs.gxt.ui.client.data.BeanModelFactory;
import com.extjs.gxt.ui.client.data.BeanModelLookup;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.grid.Grid;
import com.extjs.gxt.ui.client.widget.layout.FormData;

public class CustomerHoldingsPanel extends FormPanel {
 
  ListStore holdings;

  public CustomerHoldingsPanel() {
    holdings = new ListStore();
   
//    final NumberFormat currency = NumberFormat.getCurrencyFormat(); 
//      final NumberFormat number = NumberFormat.getFormat("0.00"); 
//      final NumberCellRenderer<Grid<Holding>> numberRenderer = new NumberCellRenderer<Grid<Holding>>(currency); 
//   
//      GridCellRenderer<Holding> change = new GridCellRenderer<Holding>() { 
//        public String render(Stock model, String property, ColumnData config, int rowIndex, int colIndex, 
//            ListStore<Holding> store, Grid<Holding> grid) { 
//          double val = (Double) model.get(property); 
//          String style = val < 0 ? "red" : GXT.isHighContrastMode ? "#00ff5a" : "green"; 
//          String v = number.format(val); 
//   
//          return "<span qtitle='" + cm.getColumnById(property).getHeader() + "' qtip='" + v 
//              + "' style='font-weight: bold;color:" + style + "'>" + v + "</span>"; 
//        } 
//      }; 
   
    setHeading("Holdings");
    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
   
    ColumnConfig clmncnfgStockName = new ColumnConfig("stockName", "Stock", 150);
    configs.add(clmncnfgStockName);
   
    ColumnConfig clmncnfgQuantity = new ColumnConfig("quantity", "Quantity", 150);
    configs.add(clmncnfgQuantity);
   
    ColumnConfig clmncnfgPrice = new ColumnConfig("price", "Price", 150);
    configs.add(clmncnfgPrice);

    Grid grid = new Grid(holdings, new ColumnModel(configs));
    add(grid, new FormData("100%"));
    grid.setBorders(true);
   
  }
  public void setHoldings(List<Holding> holdings){
    this.holdings.removeAll();
    BeanModelFactory beanModelFactory = BeanModelLookup.get().getFactory(Holding.class);
    List<BeanModel> models = beanModelFactory.createModel(holdings);
    this.holdings.add(models);
  }

}
TOP

Related Classes of net.helipilot50.stocktrade.client.CustomerHoldingsPanel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.