Пример #1
0
  protected void onRender(Element parent, int index) {
    super.onRender(parent, index);

    criteria.addCondition(new Condition(IGoods.DELETED, Condition.EQUALS, "true"));
    BasePagingLoader loader = new PagingListService().getLoader(ModelNames.GOODS, criteria);
    loader.load(0, 10);
    final ListStore<BeanObject> store = new ListStore<BeanObject>(loader);

    toolBar = new PagingToolBar(10);
    toolBar.bind(loader);

    List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
    final CheckBoxSelectionModel<BeanObject> smRowSelection =
        new CheckBoxSelectionModel<BeanObject>();
    columns.add(smRowSelection.getColumn());
    columns.add(new ColumnConfig(IGoods.ID, "ID", 50));
    ColumnConfig col = new ColumnConfig(IGoods.NAME, Resources.constants.Goods_name(), 100);
    columns.add(col);
    col = new ColumnConfig(IGoods.SN, Resources.constants.Goods_SN(), 100);
    columns.add(col);

    col = new ColumnConfig(IGoods.SHOPPRICE, Resources.constants.Goods_shopPrice(), 80);
    col.setAlignment(HorizontalAlignment.RIGHT);
    col.setNumberFormat(NumberFormat.getCurrencyFormat());
    columns.add(col);

    ColumnConfig actcol = new ColumnConfig("Action", Resources.constants.GoodsList_action(), 100);
    //		columns.add(actcol);

    ColumnModel cm = new ColumnModel(columns);

    Grid<BeanObject> grid = new EditorGrid<BeanObject>(store, cm);
    grid.setLoadMask(true);
    grid.setBorders(true);
    grid.setSelectionModel(smRowSelection);
    //      grid.setAutoExpandColumn("forum");

    ActionCellRenderer render = new ActionCellRenderer(grid);
    ActionCellRenderer.ActionInfo act = new ActionCellRenderer.ActionInfo();
    act.setImage("icon_edit.gif");
    act.setAction("editGoods($id)");
    act.setTooltip(Resources.constants.GoodsList_action_edit());
    render.addAction(act);
    act = new ActionCellRenderer.ActionInfo();
    act.setImage("icon_trash.gif");
    act.setAction("deleteGoods($id)");
    act.setTooltip(Resources.constants.GoodsList_action_delete());
    render.addAction(act);

    actcol.setRenderer(render);

    HorizontalPanel header = new HorizontalPanel();
    header.add(Resources.images.icon_search().createImage());
    header.add(new Label("  " + Resources.constants.GoodsList_keyword()));
    header.add(txtKeyword);
    header.add(btnFind);
    add(header);

    btnFind.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          public void componentSelected(ButtonEvent ce) {
            search();
          }
        });

    ContentPanel panel = new ContentPanel();
    panel.setFrame(true);
    panel.setCollapsible(true);
    panel.setAnimCollapse(false);
    panel.setButtonAlign(HorizontalAlignment.CENTER);
    panel.setIconStyle("icon-table");
    //        panel.setHeading("Paging Grid");
    panel.setLayout(new FitLayout());
    panel.add(grid);
    panel.setSize(880, 350);
    panel.setBottomComponent(toolBar);

    panel.setButtonAlign(HorizontalAlignment.CENTER);
    panel.addButton(
        new Button(
            "彻底删除",
            new SelectionListener<ButtonEvent>() {
              public void componentSelected(ButtonEvent ce) {
                List<BeanObject> items = smRowSelection.getSelectedItems();
                purgeGoods(items);
              }
            }));

    panel.addButton(
        new Button(
            "恢复",
            new SelectionListener<ButtonEvent>() {
              public void componentSelected(ButtonEvent ce) {
                List<BeanObject> items = smRowSelection.getSelectedItems();
                restoreGoods(items);
              }
            }));

    add(panel);
  }
Пример #2
0
  /** 初始化界面。 */
  public MagazineManager() {
    curState = new State();

    BasePagingLoader loader = new PagingListService().getLoader(ModelNames.MAILTEMPLATE, criteria);
    loader.load(0, 10);
    store = new ListStore<BeanObject>(loader);
    toolBar = new PagingToolBar(10);
    toolBar.bind(loader);

    List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
    ColumnConfig title = new ColumnConfig(IMailTemplate.SUBJECT, "杂志标题", 200);
    columns.add(title);
    columns.add(new ColumnConfig(IMailTemplate.LASTMODIFY, "杂志上次编辑时间", 160));
    columns.add(new ColumnConfig(IMailTemplate.LASTSEND, "杂志上次发送时间", 160));
    ColumnConfig insert = new ColumnConfig("insert", "插入发送队列", 160);
    columns.add(insert);
    ColumnConfig actcol = new ColumnConfig("Action", "操作", 100);
    columns.add(actcol);
    ColumnModel cm = new ColumnModel(columns);

    grid = new Grid<BeanObject>(store, cm);
    grid.setLoadMask(true);
    grid.setBorders(true);

    ActionCellRenderer render = new ActionCellRenderer(grid);
    ActionCellRenderer insertRender = new ActionCellRenderer(grid);
    ActionCellRenderer.ActionInfo act = new ActionCellRenderer.ActionInfo();
    act.setImage("icon_edit.gif");
    act.setAction("editMagazine($id)");
    act.setTooltip("编辑");
    render.addAction(act);
    act = new ActionCellRenderer.ActionInfo();
    act.setImage("icon_trash.gif");
    act.setAction("deleteMagazine($id)");
    act.setTooltip("删除");
    render.addAction(act);
    act = new ActionCellRenderer.ActionInfo();
    act.setText("插入队列");
    act.setAction("insertMagazine($id)");
    act.setTooltip("插入队列");
    insertRender.addAction(act);

    actcol.setRenderer(render);
    insert.setRenderer(insertRender);

    ContentPanel panel = new ContentPanel();
    panel.setFrame(true);
    panel.setCollapsible(true);
    panel.setAnimCollapse(false);
    panel.setButtonAlign(HorizontalAlignment.CENTER);
    panel.setIconStyle("icon-table");
    panel.setLayout(new FitLayout());
    panel.add(grid);
    panel.setSize(850, 350);
    panel.setBottomComponent(toolBar);
    panel.setHeading("邮件杂志列表");
    panel.setButtonAlign(HorizontalAlignment.LEFT);

    // 添加新杂志
    final com.extjs.gxt.ui.client.widget.button.Button addMagazine =
        new com.extjs.gxt.ui.client.widget.button.Button("添加新杂志");
    addMagazine.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          public void componentSelected(ButtonEvent ce) {
            // add new magazine function
            NewMagazine.State state = new NewMagazine.State();
            state.execute();
          }
        });
    panel.addButton(addMagazine);

    add(panel);
    initJS(this);
  }