/** * Display a Prompting Message to enter some text in the Application. The OK button will be * enabled iff the text is not empty or blank. * * @param title * @param message * @param callback */ public static MessageBox promptMessage( String title, String message, Listener<MessageBoxEvent> callback) { final MessageBox box = MessageBox.prompt(title, message, callback); final Button okButton = box.getDialog().getButtonById(Dialog.OK); okButton.disable(); final TextField<String> textBox = box.getTextBox(); textBox.addKeyListener( new KeyListener() { @Override public void componentKeyPress(ComponentEvent event) { if (okButton.isEnabled() && event.getKeyCode() == KeyCodes.KEY_ENTER) { box.getDialog().hide(okButton); } } }); box.addListener( Events.OnKeyUp, new Listener<MessageBoxEvent>() { @Override public void handleEvent(MessageBoxEvent be) { String value = textBox.getValue(); if (value == null || value.trim().equals("")) { okButton.disable(); } else { okButton.enable(); } } }); return box; }
private final ContentPanel createPropertiesContent() { FormPanel panel = new FormPanel(); panel.setHeaderVisible(false); panel.setButtonAlign(HorizontalAlignment.RIGHT); panel.setStyleAttribute("padding", "20"); KeyListener keyListener = new KeyListener() { public void componentKeyUp(ComponentEvent event) { editor.markDirty(); } }; name = new TextField<String>(); name.setFieldLabel(constants.name()); name.setEmptyText(constants.groupName()); name.setAllowBlank(false); name.setMinLength(2); name.addKeyListener(keyListener); name.setStyleAttribute("marginTop", "5"); name.setStyleAttribute("marginBottom", "5"); panel.add(name); description = new TextArea(); description.setPreventScrollbars(true); description.setFieldLabel(constants.description()); description.addKeyListener(keyListener); description.setStyleAttribute("marginTop", "5"); description.setStyleAttribute("marginBottom", "5"); panel.add(description); return panel; }
/** * 联系人 * * @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; }
private List<ColumnConfig> createColumns() { List<ColumnConfig> configs = new ArrayList<ColumnConfig>(); ColumnConfig column = new ColumnConfig(); column = new ColumnConfig(); column.setId("nome"); column.setHeader("Nominativo"); column.setWidth(140); ListStore<PersonaleModel> store = new ListStore<PersonaleModel>(); cmbxPersonale = new ComboBox<PersonaleModel>(); cmbxPersonale.setStore(store); cmbxPersonale.setDisplayField("nomeCompleto"); cmbxPersonale.setEmptyText("Selezionare.."); cmbxPersonale.setEditable(true); cmbxPersonale.setVisible(true); cmbxPersonale.setTriggerAction(TriggerAction.ALL); cmbxPersonale.setForceSelection(true); cmbxPersonale.setAllowBlank(false); cmbxPersonale.addListener( Events.OnClick, new Listener<BaseEvent>() { @Override public void handleEvent(BaseEvent be) { getAllDipendenti(); } private void getAllDipendenti() { AdministrationService.Util.getInstance() .getListaDipendentiModel( "", new AsyncCallback<List<PersonaleModel>>() { @Override public void onFailure(Throwable caught) { Window.alert("Errore connessione on getListaDipendentiModel();"); caught.printStackTrace(); } @Override public void onSuccess(List<PersonaleModel> result) { if (result != null) { ListStore<PersonaleModel> lista = new ListStore<PersonaleModel>(); lista.setStoreSorter(new StoreSorter<PersonaleModel>()); lista.setDefaultSort("nomeCompleto", SortDir.ASC); lista.add(result); cmbxPersonale.clear(); cmbxPersonale.setStore(lista); } else Window.alert("error: Errore durante l'accesso ai dati Personale."); } }); } }); cmbxPersonale.addListener( Events.Select, new Listener<BaseEvent>() { @Override public void handleEvent(BaseEvent be) { int idPersonale = cmbxPersonale.getValue().get("idPersonale"); csm.getSelectedItem().set("idPersonale", idPersonale); } }); CellEditor editor = new CellEditor(cmbxPersonale) { @Override public Object preProcessValue(Object value) { if (value == null) { return value; } return cmbxPersonale.getValue(); } @Override public Object postProcessValue(Object value) { if (value == null) { return value; } return ((ModelData) value).get("nomeCompleto"); } }; column.setEditor(editor); configs.add(column); column = new ColumnConfig(); column.setId("tipoOrario"); column.setHeader("Orario Giornaliero"); column.setWidth(50); configs.add(column); column = new ColumnConfig(); column.setId("costoAnnuo"); column.setHeader("Costo Annuo"); column.setWidth(100); txtfldcostoAnno = new TextField<String>(); txtfldcostoAnno.setValue("0.00"); txtfldcostoAnno.setRegex("^([0-9]+).([0-9]{1,2})$"); txtfldcostoAnno.addKeyListener( new KeyListener() { public void componentKeyDown(ComponentEvent event) { int keyCode = event.getKeyCode(); if (keyCode == 9) { if (txtfldcostoAnno.getValue() == null) txtfldcostoAnno.setValue("0.00"); else { String valore = txtfldcostoAnno.getValue().toString(); if (valore.compareTo("") == 0) valore = "0.00"; else if (valore.indexOf(".") == -1) valore = valore + ".00"; else { int index = valore.indexOf("."); int length = valore.length(); if (valore.substring(index + 1, length).length() == 1) valore = valore + "0"; else if (valore.substring(index + 1, length).length() == 0) valore = valore + "00"; } txtfldcostoAnno.setValue(valore); } } } }); column.setEditor(new CellEditor(txtfldcostoAnno)); configs.add(column); column = new ColumnConfig(); column.setId("orePreviste"); column.setHeader("Ore Previste"); column.setWidth(100); txtfldoreAnno = new TextField<String>(); txtfldoreAnno.setValue("0"); txtfldoreAnno.setRegex("^([0-9]+)"); txtfldoreAnno.addKeyListener( new KeyListener() { public void componentKeyDown(ComponentEvent event) { int keyCode = event.getKeyCode(); if (keyCode == 9) { if (txtfldoreAnno.getValue() == null) txtfldoreAnno.setValue("0"); else { String valore = txtfldoreAnno.getValue().toString(); if (valore.compareTo("") == 0) valore = "0"; txtfldoreAnno.setValue(valore); } } } }); column.setEditor(new CellEditor(txtfldoreAnno)); configs.add(column); column = new ColumnConfig(); column.setId("costoOrario"); column.setHeader("Costo Orario"); column.setWidth(100); txtfldcostoOrario = new TextField<String>(); txtfldcostoOrario.setValue("0.00"); txtfldcostoOrario.setRegex("^([0-9]+).([0-9]{1,2})$"); txtfldcostoOrario.addKeyListener( new KeyListener() { /* public void componentKeyUp(ComponentEvent event) { txtfldNumeroOreResidue.setValue(txtfldNumeroOre.getValue()); } */ public void componentKeyDown(ComponentEvent event) { int keyCode = event.getKeyCode(); if (keyCode == 9) { if (txtfldcostoOrario.getValue() == null) txtfldcostoOrario.setValue("0.00"); else { String valore = txtfldcostoOrario.getValue().toString(); if (valore.compareTo("") == 0) valore = "0.00"; else if (valore.indexOf(".") == -1) valore = valore + ".00"; else { int index = valore.indexOf("."); int length = valore.length(); if (valore.substring(index + 1, length).length() == 1) valore = valore + "0"; else if (valore.substring(index + 1, length).length() == 0) valore = valore + "00"; } txtfldcostoOrario.setValue(valore); } } } }); column.setEditor(new CellEditor(txtfldcostoOrario)); configs.add(column); column = new ColumnConfig(); column.setId("costoTrasferta"); column.setHeader("Costo Trasferta"); column.setWidth(100); txtfldcostoTrasferta = new TextField<String>(); txtfldcostoTrasferta.setValue("0.00"); txtfldcostoTrasferta.setRegex("^([0-9]+).([0-9]{1,2})$"); txtfldcostoTrasferta.addKeyListener( new KeyListener() { public void componentKeyDown(ComponentEvent event) { int keyCode = event.getKeyCode(); if (keyCode == 9) { if (txtfldcostoTrasferta.getValue() == null) txtfldcostoTrasferta.setValue("0.00"); else { String valore = txtfldcostoTrasferta.getValue().toString(); if (valore.compareTo("") == 0) valore = "0.00"; else if (valore.indexOf(".") == -1) valore = valore + ".00"; else { int index = valore.indexOf("."); int length = valore.length(); if (valore.substring(index + 1, length).length() == 1) valore = valore + "0"; else if (valore.substring(index + 1, length).length() == 0) valore = valore + "00"; } txtfldcostoTrasferta.setValue(valore); } } } }); column.setEditor(new CellEditor(txtfldcostoTrasferta)); configs.add(column); column = new ColumnConfig(); column.setId("costoStruttura"); column.setHeader("Costo Struttura"); column.setWidth(100); txtfldCostoStruttura = new TextField<String>(); txtfldCostoStruttura.setValue("0.00"); txtfldCostoStruttura.setRegex("^([0-9]+).([0-9]{1,2})$"); txtfldCostoStruttura.addKeyListener( new KeyListener() { /* public void componentKeyUp(ComponentEvent event) { txtfldNumeroOreResidue.setValue(txtfldNumeroOre.getValue()); } */ public void componentKeyDown(ComponentEvent event) { int keyCode = event.getKeyCode(); if (keyCode == 9) { if (txtfldCostoStruttura.getValue() == null) txtfldCostoStruttura.setValue("0.00"); else { String valore = txtfldCostoStruttura.getValue().toString(); if (valore.compareTo("") == 0) valore = "0.00"; else if (valore.indexOf(".") == -1) valore = valore + ".00"; else { int index = valore.indexOf("."); int length = valore.length(); if (valore.substring(index + 1, length).length() == 1) valore = valore + "0"; else if (valore.substring(index + 1, length).length() == 0) valore = valore + "00"; } txtfldCostoStruttura.setValue(valore); } } } }); column.setEditor(new CellEditor(txtfldCostoStruttura)); configs.add(column); column = new ColumnConfig(); column.setId("costoOneri"); column.setHeader("Costo Oneri"); column.setWidth(100); txtfldCostoOneri = new TextField<String>(); txtfldCostoOneri.setValue("0.00"); txtfldCostoOneri.setRegex("^([0-9]+).([0-9]{1,2})$"); txtfldCostoOneri.addKeyListener( new KeyListener() { /* public void componentKeyUp(ComponentEvent event) { txtfldNumeroOreResidue.setValue(txtfldNumeroOre.getValue()); } */ public void componentKeyDown(ComponentEvent event) { int keyCode = event.getKeyCode(); if (keyCode == 9) { if (txtfldCostoOneri.getValue() == null) txtfldCostoOneri.setValue("0.00"); else { String valore = txtfldCostoOneri.getValue().toString(); if (valore.compareTo("") == 0) valore = "0.00"; else if (valore.indexOf(".") == -1) valore = valore + ".00"; else { int index = valore.indexOf("."); int length = valore.length(); if (valore.substring(index + 1, length).length() == 1) valore = valore + "0"; else if (valore.substring(index + 1, length).length() == 0) valore = valore + "00"; } txtfldCostoOneri.setValue(valore); } } } }); column.setEditor(new CellEditor(txtfldCostoOneri)); configs.add(column); column = new ColumnConfig(); column.setId("costoSw"); column.setHeader("Costo SW"); column.setWidth(100); txtfldCostoSoftware = new TextField<String>(); txtfldCostoSoftware.setValue("0.00"); txtfldCostoSoftware.setRegex("^([0-9]+).([0-9]{1,2})$"); txtfldCostoSoftware.addKeyListener( new KeyListener() { public void componentKeyDown(ComponentEvent event) { int keyCode = event.getKeyCode(); if (keyCode == 9) { if (txtfldCostoSoftware.getValue() == null) txtfldCostoSoftware.setValue("0.00"); else { String valore = txtfldCostoSoftware.getValue().toString(); if (valore.compareTo("") == 0) valore = "0.00"; else if (valore.indexOf(".") == -1) valore = valore + ".00"; else { int index = valore.indexOf("."); int length = valore.length(); if (valore.substring(index + 1, length).length() == 1) valore = valore + "0"; else if (valore.substring(index + 1, length).length() == 0) valore = valore + "00"; } txtfldCostoSoftware.setValue(valore); } } } }); column.setEditor(new CellEditor(txtfldCostoSoftware)); configs.add(column); column = new ColumnConfig(); column.setId("costoHw"); column.setHeader("Costo HW"); column.setWidth(100); txtfldCostoHardware = new TextField<String>(); txtfldCostoHardware.setValue("0.00"); txtfldCostoHardware.setRegex("^([0-9]+).([0-9]{1,2})$"); txtfldCostoHardware.addKeyListener( new KeyListener() { /* public void componentKeyUp(ComponentEvent event) { txtfldNumeroOreResidue.setValue(txtfldNumeroOre.getValue()); } */ public void componentKeyDown(ComponentEvent event) { int keyCode = event.getKeyCode(); if (keyCode == 9) { if (txtfldCostoHardware.getValue() == null) txtfldCostoHardware.setValue("0.00"); else { String valore = txtfldCostoHardware.getValue().toString(); if (valore.compareTo("") == 0) valore = "0.00"; else if (valore.indexOf(".") == -1) valore = valore + ".00"; else { int index = valore.indexOf("."); int length = valore.length(); if (valore.substring(index + 1, length).length() == 1) valore = valore + "0"; else if (valore.substring(index + 1, length).length() == 0) valore = valore + "00"; } txtfldCostoHardware.setValue(valore); } } } }); column.setEditor(new CellEditor(txtfldCostoHardware)); configs.add(column); column = new ColumnConfig(); column.setId("costoHwSw"); column.setHeader("Costo HwSw"); column.setWidth(100); configs.add(column); column = new ColumnConfig(); column.setId("costoOrarioTotale"); column.setHeader("CostoTot/h"); column.setWidth(100); configs.add(column); column = new ColumnConfig(); column.setId("gruppoLavoro"); column.setHeader("Area"); column.setWidth(160); configs.add(column); return configs; }