Exemple #1
0
  private ContentPanel CreateGcode() {
    ContentPanel panel = new ContentPanel();
    //		panel.setSize(400, 400);
    panel.setAutoHeight(true);
    panel.setAutoWidth(true);
    CheckBoxSelectionModel cbs = new CheckBoxSelectionModel();
    List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
    columns.add(cbs.getColumn());
    ColumnConfig gcode = new ColumnConfig("gcode", "商品大类编码", 100);
    TextField<String> gcodetext = new TextField<String>();
    gcode.setEditor(new CellEditor(gcodetext));
    columns.add(gcode);
    ColumnConfig gname = new ColumnConfig("gname", "商品大类名称", 100);
    TextField<String> gnametext = new TextField<String>();
    gname.setEditor(new CellEditor(gnametext));
    columns.add(gname);

    ColumnConfig attrcode = new ColumnConfig("attrcode", "商品大类属性", 100);
    TextField<String> attrcodetext = new TextField<String>();
    attrcode.setEditor(new CellEditor(attrcodetext));
    columns.add(attrcode);

    ModelType type = new ModelType();
    type.setRoot("records");
    type.setRecordName("record");

    type.addField("gcode");
    type.addField("gname");
    type.addField("attrcode");

    StoreInfo info = new StoreInfo();

    info.setTablename("gcode");
    info.setKeyname(new String[] {"gcode"});
    info.setSql("select * from gcode");
    //		info.setParent(store);// 关联主表
    //		info.setAutoinccolumn("idx"); // 自增字段,如果子表一定需要
    //		info.setLinkparentcolumns(new String[] { "ccode" }); // 关联主表字段
    gcodestore = new BaseStore<JDBCModelData>(type, info);
    //		gudong.setName("gudong");
    //		gudong.setKeyname(new String[] { "ccode", "idx" }); // 主键
    ColumnModel cm = new ColumnModel(columns);
    gcodeegrid = new BaseGrid(gcodestore, cm);

    cbs.setSelectionMode(SelectionMode.SINGLE);

    gcodeegrid.setSelectionModel(cbs);
    gcodeegrid.setAutoHeight(true);
    gcodeegrid.setAutoWidth(true);
    gcodeegrid
        .getSelectionModel()
        .addSelectionChangedListener(
            new SelectionChangedListener() {

              @Override
              public void selectionChanged(SelectionChangedEvent se) {
                if (se.getSelection().size() > 0) {
                  //					attrgroupgrid.getModel()
                  attrgroupgrid.getSelectionModel().deselectAll();
                  //	int attr =
                  // ((BaseModelData)gcodeegrid.getSelectionModel().getSelectedItems().get(0)).get("attrcode");
                  //	System.out.println("size="+attrgroupgrid.getStore().getModels().size());
                  //	for(int i=0;i<((BaseModelData)attrgroupgrid.getModel()).getProperties().size())

                  int size = attrgroupgrid.getStore().getModels().size();
                  int attr =
                      Integer.parseInt(
                          ((BaseModelData) gcodeegrid.getSelectionModel().getSelectedItems().get(0))
                              .get("attrcode")
                              .toString());

                  for (int i = 0; i < size; i++) {
                    int attrcode =
                        Integer.parseInt(attrgroupgrid.getValue(i, "attrcode").toString());
                    if ((attrcode & attr) == attrcode) {
                      attrgroupgrid.getSelectionModel().select(i, true);
                    }
                  }

                } else {
                  attrgroupgrid.getSelectionModel().deselectAll();
                }
              }
            });

    registerStore(gcodestore);
    panel.add(gcodeegrid);
    panel.setScrollMode(Scroll.AUTO);
    return panel;
  }
  @Override
  protected void onRender(Element parent, int index) {
    super.onRender(parent, index);

    final ExampleServiceAsync service = (ExampleServiceAsync) Registry.get(Examples.SERVICE);

    RpcProxy<List<Photo>> proxy =
        new RpcProxy<List<Photo>>() {
          @Override
          protected void load(Object loadConfig, AsyncCallback<List<Photo>> callback) {
            service.getPhotos(callback);
          }
        };

    ListLoader<ListLoadResult<Photo>> loader =
        new BaseListLoader<ListLoadResult<Photo>>(proxy, new BeanModelReader());
    ListStore<BeanModel> store = new ListStore<BeanModel>(loader);
    loader.load();

    final ContentPanel panel = new ContentPanel();
    panel.setCollapsible(true);
    panel.setAnimCollapse(false);
    panel.setFrame(true);
    panel.setHeading("CheckBox ListView (0 items selected)");
    panel.setWidth(300);
    panel.setAutoHeight(true);
    panel.setBodyBorder(false);

    final CheckBoxListView<BeanModel> view =
        new CheckBoxListView<BeanModel>() {
          @Override
          protected BeanModel prepareData(BeanModel model) {
            String s = model.get("name");
            model.set("shortName", Format.ellipse(s, 15));
            return model;
          }
        };

    view.setStore(store);
    view.setDisplayProperty("name");
    view.getSelectionModel()
        .addListener(
            Events.SelectionChange,
            new Listener<SelectionChangedEvent<BeanModel>>() {

              public void handleEvent(SelectionChangedEvent<BeanModel> be) {
                panel.setHeading(
                    "CheckBox ListView (" + be.getSelection().size() + " items selected)");
              }
            });
    panel.add(view);

    panel.addButton(
        new Button(
            "get checked items",
            new SelectionListener<ButtonEvent>() {

              @Override
              public void componentSelected(ButtonEvent ce) {
                Info.display(
                    "Checked Items", "There are " + view.getChecked().size() + " items checked!");
              }
            }));
    add(panel);
  }
Exemple #3
0
  /**
   * 联系人
   *
   * @return
   */
  public ContentPanel createLinkManPanel() {

    CheckBoxSelectionModel cbs = new CheckBoxSelectionModel();

    List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
    columns.add(cbs.getColumn());

    ColumnConfig lname = new ColumnConfig("lname", "姓名", 80);
    TextField<String> text = new TextField<String>();
    lname.setEditor(new CellEditor(text));
    columns.add(lname);

    ColumnConfig dept = new ColumnConfig("dept", "部门", 80);
    TextField<String> depttext = new TextField<String>();
    dept.setEditor(new CellEditor(depttext));
    columns.add(dept);

    ColumnConfig headship = new ColumnConfig("headship", "职务", 80);
    TextField<String> headshiptext = new TextField<String>();
    headship.setEditor(new CellEditor(headshiptext));
    columns.add(headship);

    ColumnConfig passportcode = new ColumnConfig("passportcode", "护照号", 80);
    TextField<String> passportcodetext = new TextField<String>();
    passportcode.setEditor(new CellEditor(passportcodetext));
    columns.add(passportcode);

    ColumnConfig postcode1 = new ColumnConfig("postcode", "邮编", 80);
    TextField<String> postcodetext = new TextField<String>();
    postcode1.setEditor(new CellEditor(postcodetext));
    columns.add(postcode1);
    ColumnModel cm = new ColumnModel(columns);

    ModelType type = new ModelType();
    type.setRoot("records");
    type.setRecordName("record");
    type.setTotalName("totle");
    type.addField("ccode", "ccode");

    type.addField("lname");
    type.addField("headship");
    type.addField("dept");
    type.addField("idx");
    type.addField("addr");
    type.addField("headship");
    type.addField("passportcode");

    type.addField("postcode");
    type.addField("telephone");
    type.addField("mobil");
    type.addField("privatemobil");
    type.addField("fax");
    type.addField("addrtype");

    StoreInfo info = new StoreInfo();

    info.setTablename("ccodelinkman_info");
    info.setSql("select * from ccodelinkman_info");
    info.setParent(store);
    info.setAutoinccolumn("idx");
    info.setLinkparentcolumns(new String[] {"ccode"});
    info.setKeyname(new String[] {"ccode", "idx"});

    BaseStore<JDBCModelData> branchorgadd = new BaseStore<JDBCModelData>(type, info);
    branchorgadd.setName("ccodelinkman_info");
    BaseGrid branchorgaddgrid = new BaseGrid(branchorgadd, cm);
    cbs.setSelectionMode(SelectionMode.SINGLE);
    branchorgaddgrid.setSelectionModel(cbs);
    //   officegrid.setAutoExpandColumn("ccode");
    //  panel.setLayout(new BorderLayout());

    // ----------------------------
    final BaseFormPanel formpanel = new BaseFormPanel(branchorgadd);

    TextField<String> branchtelephone = new TextField<String>();
    branchtelephone.setName("telephone");
    branchtelephone.setFieldLabel("办公电话");

    formpanel.add(branchtelephone);
    final TextField<String> mobil = new TextField<String>();
    mobil.setName("mobil");
    mobil.setFieldLabel("移动电话");

    formpanel.add(mobil);

    final TextField<String> privatemobil = new TextField<String>();
    privatemobil.setName("privatemobil");
    privatemobil.setFieldLabel("私人电话");
    formpanel.add(privatemobil);

    privatemobil.addKeyListener(
        new KeyListener() {
          public void componentKeyUp(ComponentEvent event) {
            mobil.setValue(privatemobil.getValue());
          }
        });

    TextField<String> fax = new TextField<String>();
    fax.setName("fax");
    fax.setFieldLabel("传真");

    formpanel.add(fax);

    TextField<String> addrtype = new TextField<String>();
    addrtype.setName("addrtype");
    addrtype.setFieldLabel("地址类型");

    formpanel.add(addrtype);

    final TextField<String> postcode = new TextField<String>();
    postcode.setName("postcode");
    postcode.setFieldLabel("邮编");

    formpanel.add(postcode);

    TextField<String> addr = new TextField<String>();
    addr.setName("addr");
    addr.setFieldLabel("通讯地址");

    formpanel.add(addr);

    formpanel.setScrollMode(Scroll.AUTO);
    formpanel.inited();

    // 设置联系人界面上半部分的布局
    LayoutContainer top = new LayoutContainer();
    TableLayout tl = new TableLayout(2);
    top.setLayout(tl);
    TableData td = new TableData();
    td.setColspan(1);

    td.setRowspan(1);
    td.setVerticalAlign(VerticalAlignment.TOP);
    //			TableData td2 = new TableData();
    //			td2.setColspan(1);
    //			td2.setRowspan(1);

    //		    branchorgaddgrid.setSize(300, 200);
    //   branchorgaddgrid.setAutoWidth(true);
    branchorgaddgrid.setWidth(420);
    branchorgaddgrid.setAutoHeight(true);
    // formpanel.setSize(300, 380);
    formpanel.setHeaderVisible(false);

    top.add(branchorgaddgrid, td);
    top.add(formpanel, td);

    // ----------------家庭成员ccodecustomersolicitude

    List<ColumnConfig> customercolumns = new ArrayList<ColumnConfig>();

    CheckBoxSelectionModel cbs2 = new CheckBoxSelectionModel();

    customercolumns.add(cbs2.getColumn());
    ColumnConfig leaguertype = new ColumnConfig("leaguertype", "家庭成员", 80);
    TextField<String> leaguertext = new TextField<String>();
    leaguertype.setEditor(new CellEditor(leaguertext));
    customercolumns.add(leaguertype);
    ColumnConfig leaguername = new ColumnConfig("leaguername", "姓名", 80);
    TextField<String> leaguernametext = new TextField<String>();
    leaguername.setEditor(new CellEditor(leaguernametext));
    customercolumns.add(leaguername);

    ColumnModel customercm = new ColumnModel(customercolumns);

    ModelType customertype = new ModelType();
    customertype.setRoot("records");
    customertype.setRecordName("record");

    customertype.addField("ccode", "ccode");
    customertype.addField("leaguertype");
    customertype.addField("leaguername");
    customertype.addField("idx");
    customertype.addField("birthday");
    customertype.addField("commemorateday");
    customertype.addField("religion");
    customertype.addField("bekeenon");
    customertype.addField("tourexperience");
    customertype.addField("workexperience");
    customertype.addField("occupation");
    customertype.addField("workheadship");
    customertype.addField("remark");

    StoreInfo customerinfo = new StoreInfo();

    customerinfo.setTablename("ccodecustomersolicitude");
    customerinfo.setSql("select * from ccodecustomersolicitude");
    customerinfo.setParent(store);
    customerinfo.setAutoinccolumn("idx");
    customerinfo.setLinkparentcolumns(new String[] {"ccode"});
    customerinfo.setKeyname(new String[] {"ccode", "idx"});

    BaseStore<JDBCModelData> customertypestore =
        new BaseStore<JDBCModelData>(customertype, customerinfo);
    customertypestore.setName("ccodecustomersolicitude");
    BaseGrid customertypegrid = new BaseGrid(customertypestore, customercm);

    cbs2.setSelectionMode(SelectionMode.SINGLE);
    customertypegrid.setSelectionModel(cbs2);
    // ---------------------
    // --
    BaseFormPanel formcustomerpanel = new BaseFormPanel(customertypestore);
    formcustomerpanel.setHeaderVisible(false);

    TextField<String> birthdayc = new TextField<String>();
    birthdayc.setName("birthday");
    birthdayc.setFieldLabel("生日");

    formcustomerpanel.add(birthdayc);

    TextField<String> commemorateday = new TextField<String>();
    commemorateday.setName("commemorateday");
    commemorateday.setFieldLabel("纪念日");

    formcustomerpanel.add(commemorateday);

    TextField religion = new TextField();
    religion.setName("religion");
    religion.setFieldLabel("信仰");
    formcustomerpanel.add(religion);

    TextField bekeenon = new TextField();
    bekeenon.setName("bekeenon");
    bekeenon.setFieldLabel("主要爱好");

    formcustomerpanel.add(bekeenon);

    TextField tourexperience = new TextField();
    tourexperience.setName("tourexperience");
    tourexperience.setFieldLabel("旅游经历");

    formcustomerpanel.add(tourexperience);

    TextField workexperience = new TextField();
    workexperience.setName("workexperience");
    workexperience.setFieldLabel("工作经历");

    formcustomerpanel.add(workexperience);

    TextField occupation = new TextField();
    occupation.setName("occupation");
    occupation.setFieldLabel("职业");

    formcustomerpanel.add(occupation);

    TextField workheadship = new TextField();
    workheadship.setName("workheadship");
    workheadship.setFieldLabel("工作职位");

    formcustomerpanel.add(workheadship);

    TextField remark = new TextField();
    remark.setName("remark");
    remark.setFieldLabel("备注");

    formcustomerpanel.add(remark);
    formcustomerpanel.setScrollMode(Scroll.AUTO);
    formcustomerpanel.inited();
    //			    FormBinding formcustomerBindings = new FormBinding(formcustomerpanel, true);
    //			    formcustomerBindings.setStore(customertypestore);

    // --end

    ContentPanel panel = new ContentPanel();

    panel.setLayout(new TableLayout(2));
    panel.setHeaderVisible(false);

    TableData td1 = new TableData();
    td1.setColspan(2);

    //   panel.add(formpanel,td2);
    customertypegrid.setAutoHeight(true);
    //		    customertypegrid.setAutoWidth(true);
    customertypegrid.setWidth(420);
    //  formcustomerpanel.setSize(300, 300);

    TableData td2 = new TableData();
    td2.setColspan(1);
    td2.setRowspan(1);

    LayoutContainer bottom = new LayoutContainer();

    TableLayout bottomtl = new TableLayout(2);
    bottom.setLayout(bottomtl);
    TableData bottomtd = new TableData();
    bottomtd.setVerticalAlign(VerticalAlignment.TOP);
    bottomtd.setColspan(1);
    bottomtd.setRowspan(1);

    bottom.add(customertypegrid, bottomtd);
    bottom.add(formcustomerpanel, bottomtd);
    FieldSet fieldset = new FieldSet();
    fieldset.setHeading("联系人");
    FieldSet fieldset2 = new FieldSet();
    fieldset2.setHeading("联系人家庭成员信息");
    fieldset.add(top);
    fieldset2.add(bottom);

    panel.add(fieldset, td1);
    panel.add(fieldset2, td1);
    panel.setScrollMode(Scroll.AUTO);
    panel.setAutoHeight(true);
    panel.setAutoWidth(true);
    return panel;
  }
Exemple #4
0
  public Widget aa() {
    int armStatus = ArmWrapper.FAILED;
    try {
      ArmWrapper.startTransaction(
          this, "com.base.myproject.client.busi.b2c.manager.ChartTest", "aa", new Object[] {});
      ContentPanel panel = new ContentPanel();
      panel.setAutoHeight(true);
      ToolBar tb = new ToolBar();
      Button addsuit = new Button("从商品库里添加套装商品");
      addsuit.setIconStyle("b2csuit");
      panel.setHeading("商品库,如果加入套装你必须先选择一行(必选)");
      tb.add(addsuit);
      panel.setTopComponent(tb);
      // addsuit.addListener(Events.Select, this);
      panel.setAutoWidth(true);
      CheckBoxSelectionModel cbs = new CheckBoxSelectionModel();
      List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
      columns.add(cbs.getColumn());
      ColumnConfig gcode = new ColumnConfig("gcode", "商品大类编码", 100);
      TextField<String> gcodetext = new TextField<String>();
      gcode.setEditor(new CellEditor(gcodetext));
      columns.add(gcode);
      ColumnConfig gname = new ColumnConfig("discountprice", "商品大类名称", 100);
      TextField<String> gnametext = new TextField<String>();
      gname.setEditor(new CellEditor(gnametext));
      columns.add(gname);

      ColumnConfig treecode = new ColumnConfig("price", "商品分类树编码", 100);

      TextField<String> treecodetext = new TextField<String>();
      treecode.setEditor(new CellEditor(treecodetext));
      columns.add(treecode);

      ColumnConfig b2cgcodecolumn = new ColumnConfig("b2cgcode", "商品编码", 100);
      TextField<String> b2cgcodetext = new TextField<String>();
      b2cgcodecolumn.setEditor(new CellEditor(b2cgcodetext));
      columns.add(b2cgcodecolumn);
      ColumnConfig b2cgname = new ColumnConfig("b2cgname", "商品名称", 100);
      TextField<String> b2cgnametext = new TextField<String>();
      b2cgname.setEditor(new CellEditor(b2cgnametext));
      columns.add(b2cgname);

      ModelType type = new ModelType();
      type.setRoot("records");
      type.setRecordName("record");

      type.addField("gcode");
      type.addField("gname");
      type.addField("b2cgcode");
      type.addField("price");
      type.addField("discountprice");
      type.addField("b2cgname");
      type.addField("mainimagepath");
      type.addField("treecode");
      type.addField("detailimage");

      StoreInfo info = new StoreInfo();

      info.setTablename("b2cgcode");
      info.setKeyname(new String[] {"b2cgcode"});
      info.setSql("select * from b2cgcode");
      BaseStore<JDBCModelData> store = new BaseStore<JDBCModelData>(type, info);

      ChartModel model =
          new ChartModel(
              "Team Sales by Month", "font-size: 14px; font-family: Verdana; text-align: center;");
      model.setBackgroundColour("#fefefe");
      model.setLegend(new Legend(Position.TOP, true));
      model.setScaleProvider(ScaleProvider.ROUNDED_NEAREST_SCALE_PROVIDER);

      BarChart bar = new BarChart(BarStyle.GLASS);
      bar.setColour("#00aa00");
      BarDataProvider barProvider = new BarDataProvider("price", "b2cgname");
      barProvider.bind(store);
      bar.setDataProvider(barProvider);
      //  bar.addChartListener(listener);
      model.addChartConfig(bar);

      bar = new BarChart(BarStyle.GLASS);
      bar.setColour("#ff6600");
      barProvider = new BarDataProvider("discountprice");
      barProvider.bind(store);
      bar.setDataProvider(barProvider);
      // bar.addChartListener(listener);
      model.addChartConfig(bar);

      LineChart line = new LineChart();
      line.setAnimateOnShow(true);
      line.setText("Average");
      line.setColour("#FF0000");
      LineDataProvider lineProvider = new LineDataProvider("discountprice");
      lineProvider.bind(store);
      line.setDataProvider(lineProvider);
      model.addChartConfig(line);

      /*	    PieChart pie = new PieChart();
      PieDataProvider piedataprovider = new PieDataProvider("discountprice");
      piedataprovider.bind(store);
      pie.setDataProvider(piedataprovider);
      model.addChartConfig(pie);*/

      String url = "chart/open-flash-chart.swf";
      final Chart chart = new Chart(url);
      chart.setChartModel(model);
      chart.setHeight("300px");
      ContentPanel cp = new ContentPanel();
      cp.setHeading("Chart");
      cp.add(chart);
      ColumnModel cm = new ColumnModel(columns);
      BaseGrid grid = new BaseGrid(store, cm);
      grid.setHeight("300px");
      cp.add(grid);
      armStatus = ArmWrapper.GOOD;
      return cp;
    } finally {
      ArmWrapper.stopTransaction(
          "com.base.myproject.client.busi.b2c.manager.ChartTest", "aa", armStatus);
    }
  }