private ContentPanel getStageFileList() { if (stageFileList == null) { stageFileList = new ContentPanel(); stageFileList.setBodyBorder(false); stageFileList.setBorders(true); stageFileList.setSize("177px", "195px"); stageFileList.setHideCollapseTool(true); stageFileList.setLayout(new FitLayout()); stageFileList.add(getListView(), new FitData(10)); stageFileList.setHeading("Job directory"); stageFileList.setCollapsible(true); stageFileList.addButton(getRemoveFileButton()); stageFileList.addButton(getAddFileButton()); } return stageFileList; }
@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); }
@Override protected void onRender(Element parent, int index) { super.onRender(parent, index); setLayout(new CenterLayout()); List<ColumnConfig> configs = new ArrayList<ColumnConfig>(); configs.add(sm.getColumn()); ColumnConfig column = new ColumnConfig(); column.setId("ragioneSociale"); column.setHeader("Ragione Sociale"); column.setWidth(120); TextField<String> text = new TextField<String>(); // text.setAllowBlank(false); column.setEditor(new CellEditor(text)); configs.add(column); column = new ColumnConfig(); column.setId("cognome"); column.setHeader("Cognome"); column.setWidth(120); text = new TextField<String>(); // text.setAllowBlank(false); column.setEditor(new CellEditor(text)); configs.add(column); column = new ColumnConfig(); column.setId("nome"); column.setHeader("Nome"); column.setWidth(120); text = new TextField<String>(); // text.setAllowBlank(false); column.setEditor(new CellEditor(text)); configs.add(column); column = new ColumnConfig(); column.setId("cf"); column.setHeader("Codice Fiscale"); column.setWidth(120); text = new TextField<String>(); // text.setAllowBlank(false); column.setEditor(new CellEditor(text)); configs.add(column); column = new ColumnConfig(); column.setId("piva"); column.setHeader("Partita IVA"); column.setWidth(120); text = new TextField<String>(); text.setAllowBlank(false); column.setEditor(new CellEditor(text)); configs.add(column); column = new ColumnConfig(); column.setId("denominazione"); column.setHeader("Denominazione"); column.setWidth(120); text = new TextField<String>(); text.setAllowBlank(false); column.setEditor(new CellEditor(text)); configs.add(column); caricaDati(); ColumnModel cm = new ColumnModel(configs); ContentPanel cp = new ContentPanel(); cp.setHeading("Anagrafica aziende"); cp.setFrame(true); // cp.setIcon(Resources.ICONS.table()); cp.setSize(Consts.LarghezzaFinestra, Consts.AltezzaFinestra); cp.setLayout(new FitLayout()); final EditorGrid<BeanModel> grid = new EditorGrid<BeanModel>(store, cm); grid.setSelectionModel(sm); grid.setAutoExpandColumn("nome"); grid.setBorders(true); grid.setClicksToEdit(EditorGrid.ClicksToEdit.TWO); cp.add(grid); ToolBar toolBar = new ToolBar(); Button addButton = new Button("Aggiungi azienda"); addButton.setIcon( IconHelper.create( "/resources/grafica/x16/add2.png", Consts.ICON_WIDTH_SMALL, Consts.ICON_HEIGHT_SMALL)); addButton.addSelectionListener( new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { BeanModelFactory factory = BeanModelLookup.get().getFactory(Azienda.class); Azienda azienda = new Azienda( "NuovoNome", "NuovoCognome", "nuovaRS", "nuovoCF", "nuovaPIVA", "NuovaDenominazione"); BeanModel model = factory.createModel(azienda); grid.stopEditing(); aziende.add(azienda); store.insert(model, 0); grid.startEditing(store.indexOf(model), 0); } }); toolBar.add(addButton); toolBar.add(new SeparatorToolItem()); Button remove = new Button("Rimuovi selezionati"); remove.setIcon( IconHelper.create( "/resources/grafica/x16/delete2.png", Consts.ICON_WIDTH_SMALL, Consts.ICON_HEIGHT_SMALL)); remove.addSelectionListener( new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { if (!(sm.getSelectedItems()).isEmpty()) { MessageBox.confirm( "Confirm", "Sei sicuro di voler eliminare gli elemtni selezionati?", cancellazione); } else { MessageBox.alert("Errore", "Selezionare uno o più elementi", cancellazione); } } // conferma per l'eliminazione final Listener<MessageBoxEvent> cancellazione = new Listener<MessageBoxEvent>() { @Override public void handleEvent(MessageBoxEvent ce) { Button btn = ce.getButtonClicked(); if (btn.getText().equals("Yes")) { List<BeanModel> modelsDaRimuovere = sm.getSelectedItems(); ArrayList<Azienda> aziendeDaRimuovere = new ArrayList(); if (modelsDaRimuovere != null) { Iterator it = modelsDaRimuovere.iterator(); while (it.hasNext()) { Object model = it.next(); store.remove((BeanModel) model); Azienda azienda = ((BeanModel) model).getBean(); aziendeDaRimuovere.add(azienda); aziende.remove(azienda); } cancellaDati(aziendeDaRimuovere); } } } }; }); toolBar.add(remove); cp.setTopComponent(toolBar); ToolBar statusBar = new ToolBar(); status.setWidth(350); statusBar.add(status); cp.setBottomComponent(statusBar); cp.setButtonAlign(HorizontalAlignment.CENTER); Button resetButton = new Button( "Reset", new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { store.rejectChanges(); } }); resetButton.setIcon( IconHelper.create( "/resources/grafica/x16/undo.png", Consts.ICON_WIDTH_SMALL, Consts.ICON_HEIGHT_SMALL)); cp.addButton(resetButton); Button saveButton = new Button( "Save", new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { store.commitChanges(); salvaDati(aziende); } }); saveButton.setIcon( IconHelper.create( "/resources/grafica/x16/save.png", Consts.ICON_WIDTH_SMALL, Consts.ICON_HEIGHT_SMALL)); cp.addButton(saveButton); add(cp); }
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); }
/** 初始化界面。 */ 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); }