public SimpleCombos(String text) { super(text); this.setLayout(new RowLayout()); FormPanel fp = new FormPanel(); ComboBox comboEntryKey = ComboFactory.buildStaticCombo("ERROR_CATEGORY"); comboEntryKey.setFieldLabel("Wybierz"); ComboBox comboId = ComboFactory.buildStaticCombo("ERROR_CATEGORY"); comboId.setFieldLabel("Wybierz"); ComboBox comboValue = ComboFactory.buildStaticCombo("ERROR_CATEGORY"); comboValue.setFieldLabel("Wybierz"); ComboBox comboComment = ComboFactory.buildStaticCombo("ERROR_CATEGORY"); comboComment.setFieldLabel("Wybierz"); TextField entryKey = new TextField(); entryKey.setFieldLabel("entryKey"); TextField id = new TextField(); id.setFieldLabel("id"); TextField value = new TextField(); value.setFieldLabel("value"); TextField comment = new TextField(); comment.setFieldLabel("comment"); fp.add(comboEntryKey); fp.add(comboId); fp.add(comboValue); fp.add(comboComment); fp.add(entryKey); fp.add(id); fp.add(value); fp.add(comment); FormBinding fb = new FormBinding(fp); ModelExample model = new ModelExample(); fb.bind(model); fb.addFieldBinding( new DictionaryComboBindingToStringField( comboEntryKey, "modelEntryKey", DictionaryEntry.EntryProperty.entryKey)); fb.addFieldBinding( new DictionaryComboBindingToStringField( comboId, "modelId", DictionaryEntry.EntryProperty.id)); fb.addFieldBinding( new DictionaryComboBindingToStringField( comboValue, "modelValue", DictionaryEntry.EntryProperty.value)); fb.addFieldBinding( new DictionaryComboBindingToStringField( comboComment, "modelComment", DictionaryEntry.EntryProperty.comment)); fb.addFieldBinding(new FieldBinding(entryKey, "modelEntryKey")); fb.addFieldBinding(new FieldBinding(id, "modelId")); fb.addFieldBinding(new FieldBinding(value, "modelValue")); fb.addFieldBinding(new FieldBinding(comment, "modelComment")); comboEntryKey.setEditable(false); comboEntryKey.setEmptyText("wybierz"); this.add(fp); }
@Override protected void onRender(Element parent, int pos) { super.onRender(parent, pos); setHeaderVisible(false); firstNameField.setFieldLabel("First name"); lastNameField.setFieldLabel("Last name"); add(firstNameField); add(lastNameField); add(saveButton); }
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; }
private TextField<String> getJobnameTextField() { if (jobnameTextField == null) { jobnameTextField = new TextField<String>(); jobnameTextField.setAllowBlank(false); jobnameTextField.setWidth("100"); jobnameTextField.setFieldLabel("Jobname"); jobnameTextField.setValidator( new Validator() { public String validate(Field<?> field, String value) { if (field == jobnameTextField) { if (value.indexOf(" ") >= 0) { return "Jobname contains whitespace"; } if (UserEnvironment.getInstance().getAllJobnames().contains(value)) { return "Jobname already exists."; } } return null; } }); jobnameTextField.addListener( Events.KeyUp, new Listener<BaseEvent>() { public void handleEvent(BaseEvent be) { userTypedInTextField = true; } }); } return jobnameTextField; }
private TextField<String> getEmailTextField() { if (emailTextField == null) { emailTextField = new TextField<String>(); emailTextField.setEnabled(false); emailTextField.setWidth(""); emailTextField.setFieldLabel("Email"); emailTextField.setValidator( new Validator() { public String validate(Field<?> field, String value) { if (field == emailTextField) { if (!emailTextField .getValue() .toLowerCase() .matches( "(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])")) { return "Bad E-mail Address"; } } return null; } }); } return emailTextField; }
public LatestVirtualReportItemsPanel() { setHeading("Virtual Level Monitoring"); setLayout(new FitLayout()); ToolBar toolBar = new ToolBar(); Button reflesh = new Button("Refresh"); reflesh.setIcon(IconHelper.createStyle("icon-email-add")); id = new TextField<String>(); id.setFieldLabel("Virtual ID"); id.setAllowBlank(false); toolBar.add(new LabelToolItem("Virtual ID: ")); toolBar.add(id); toolBar.add(reflesh); setTopComponent(toolBar); reflesh.addSelectionListener( new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { String virtualId = id.getValue(); service = (MonitoringManagerWebServiceAsync) Registry.get("guiservice"); service.getMonitoringResources( "virtual", virtualId, new AsyncCallback<List<MonitoringResource>>() { public void onFailure(Throwable caught) { Dispatcher.forwardEvent(MainEvents.Error, caught); } public void onSuccess(List<MonitoringResource> result) { getVirtualStore().removeAll(); if (result.size() > 0) virtualStore.add(result); } }); } }); virtualStore = new GroupingStore<MonitoringResource>(); virtualStore.groupBy("resource_type"); cm = new ColumnModel(OptimisResource.getColumnConfig()); GroupingView view = new GroupingView(); view.setShowGroupedColumn(true); view.setForceFit(true); view.setGroupRenderer( new GridGroupRenderer() { public String render(GroupColumnData data) { String f = cm.getColumnById(data.field).getHeader(); String l = data.models.size() == 1 ? "Item" : "Items"; return f + ": " + data.group + " (" + data.models.size() + " " + l + ")"; } }); virtualGrid = new Grid<MonitoringResource>(virtualStore, cm); virtualGrid.setTitle(" Service Resources "); virtualGrid.setView(view); virtualGrid.setBorders(true); virtualGrid.getView().setForceFit(true); add(virtualGrid); }
public LatestPhysicalReportItemsPanel() { setHeading("Physical Level Monitoring"); setLayout(new FitLayout()); ToolBar toolBar = new ToolBar(); ToolBar toolBarBottom = new ToolBar(); Button reflesh = new Button("Refresh"); reflesh.setIcon(IconHelper.createStyle("icon-email-add")); id = new TextField<String>(); id.setFieldLabel("Physical ID"); id.setAllowBlank(false); toolBar.add(new LabelToolItem("Physical ID: ")); toolBar.add(id); toolBar.add(reflesh); setTopComponent(toolBar); lt = new LabelField(""); setToolBar4Status(""); toolBarBottom.add(lt); setBottomComponent(toolBarBottom); reflesh.addSelectionListener( new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { setToolBar4Status("Loading data, please wait..."); String physicalId = id.getValue(); service = (MonitoringManagerWebServiceAsync) Registry.get("guiservice"); service.getMonitoringResources( "physical", physicalId, new AsyncCallback<List<MonitoringResource>>() { public void onFailure(Throwable caught) { setToolBar4Status("Connection failed by loading data, please try again."); Dispatcher.forwardEvent(MainEvents.Error, caught); } public void onSuccess(List<MonitoringResource> result) { setToolBar4Status(""); getStore().removeAll(); if (result.size() > 0) { store.add(result); } else { setToolBar4ErrorStatus("No data found."); } } }); } }); cm = new ColumnModel(OptimisResource.getColumnConfig()); store = new ListStore<MonitoringResource>(); grid = new Grid<MonitoringResource>(store, cm); grid.setTitle(" Physical Level Resources "); grid.setBorders(true); grid.getView().setForceFit(true); add(grid); setLayout(new FitLayout()); }
public void addOtherComponent() { fieldSet = new FieldSet(); fieldSet.setHeading("Additional Information"); fieldSet.setCheckboxToggle(true); FormLayout layout = new FormLayout(); layout.setLabelWidth(150); layout.setPadding(10); fieldSet.setLayout(layout); passAdministrationUserRole = new TextField<String>(); passAdministrationUserRole.setAllowBlank(false); passAdministrationUserRole.setFieldLabel("Password Administration"); passAdministrationUserRole.setPassword(true); fieldSet.add(passAdministrationUserRole); repeatPassAdministrationUserRole = new TextField<String>(); repeatPassAdministrationUserRole.setAllowBlank(false); repeatPassAdministrationUserRole.setFieldLabel("Repeat Password"); repeatPassAdministrationUserRole.setPassword(true); repeatPassAdministrationUserRole.setValidator( new Validator<String, Field<String>>() { public String validate(Field<String> field, String value) { if (passAdministrationUserRole.getValue() != null) { if (!field.getValue().equalsIgnoreCase(passAdministrationUserRole.getValue())) return "Attention! The two passwords must match."; } return null; } }); fieldSet.add(repeatPassAdministrationUserRole); this.formPanel.add(fieldSet); }
@Override protected void onRender(Element parent, int pos) { super.onRender(parent, pos); tfTitle.setFieldLabel("Title"); tfTitle.setAllowBlank(false); tfTitle.getMessages().setBlankText("Title is required"); taDescription.setFieldLabel("Description"); taDescription.setAllowBlank(false); taDescription.getMessages().setBlankText("Description is required"); tfLink.setFieldLabel("Link"); tfLink.setAllowBlank(false); tfLink.setRegex("^http\\://[a-zA-Z0-9\\-\\.]+\\.[a-zA-Z]{2,3}(/\\S*)?$"); tfLink.getMessages().setBlankText("Link is required"); tfLink .getMessages() .setRegexText("The link field must be a URL e.g. http://www.example.com/rss.xml"); add(tfTitle); add(taDescription); add(tfLink); }
private final ContentPanel createPropertiesPanel() { FormPanel panel = new FormPanel(); panel.setHeaderVisible(false); panel.setButtonAlign(HorizontalAlignment.RIGHT); panel.setStyleAttribute("padding", "20"); serverName = new TextField<String>(); serverName.setFieldLabel("Server Name"); serverName.setEmptyText("Please enter the server name"); serverName.setAllowBlank(false); serverName.setMinLength(1); panel.add(serverName); return panel; }
private void createFields() { GroupRef groupRef = (GroupRef) groupRefBeanModel.getBean(); nameField = new TextField<String>(); nameField.setName("name"); nameField.setFieldLabel("Name"); nameField.setAllowBlank(false); if (groupRef.getGroup().getName() != null) { nameField.setValue(groupRef.getGroup().getName()); } AdapterField screenField = new AdapterField(createScreenPairList(groupRef)); screenField.setFieldLabel("Screen"); form.add(nameField); form.add(screenField); }
public AttributeForm() { binding = new FormBinding(this); final NumberField idField = new NumberField(); idField.setFieldLabel("ID"); idField.setReadOnly(true); binding.addFieldBinding(new FieldBinding(idField, "id")); add(idField); TextField<String> nameField = new TextField<String>(); nameField.setFieldLabel(I18N.CONSTANTS.name()); nameField.setMaxLength(AttributeDTO.NAME_MAX_LENGTH); binding.addFieldBinding(new OnlyValidFieldBinding(nameField, "name")); add(nameField); hideFieldWhenNull(idField); }
private HorizontalPanel getSearchPanel() { HorizontalPanel searchBox = new HorizontalPanel(); TextField<String> msisdnField = new TextField<String>(); msisdnField.setFieldLabel("MSISDN"); msisdnField.setWidth(200); msisdnField.setEmptyText("Enter MSISDN"); Button searchButton = new Button("Search"); searchBox.setShadow(true); searchBox.setSpacing(5); searchBox.add(msisdnField); searchBox.add(searchButton); searchBox.setHorizontalAlign(HorizontalAlignment.CENTER); searchButton.addSelectionListener( new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) {} }); return searchBox; }
public void populateMainPanel() { this.setHeaderVisible(false); theHeading = new Label("Create New Topic and Message"); theHeading.setStyleName("formHeading"); groupDiscussionsContainer.getGroupDiscussionMainPanel().removeAll(); this.add(theHeading, new MarginData(5, 0, 0, 5)); formPanel.setBodyBorder(false); formPanel.setHeaderVisible(false); formPanel.setWidth("100%"); formPanel.setLabelAlign(LabelAlign.TOP); name = new TextField<String>(); name.setFieldLabel("Topic name"); description = new HtmlEditor() { protected void afterRender() { resize(0, 0); super.afterRender(); }; }; description.setFieldLabel("Message"); formPanel.add(name, new FormData("100%")); formPanel.add(description, new FormData("100%")); saveButton = new Button("Save"); formPanel.setButtonAlign(HorizontalAlignment.CENTER); formPanel.addButton(saveButton); this.add(formPanel, new MarginData(5, 5, 65, 0)); groupDiscussionsContainer.getGroupDiscussionMainPanel().add(this); groupDiscussionsContainer.getGroupDiscussionMainPanel().getBottomComponent().hide(); groupDiscussionsContainer .getGroupDiscussionMainPanel() .setHeight(MainPanel.getInstance().getHeight()); // groupDiscussionsContainer.getGroupDiscussionMainPanel().layout(true); addDefaultListeners(); resize(0, 0); }
private void createForm() { FormLayout layout = new FormLayout(); layout.setLabelAlign(LabelAlign.TOP); fp.setLayout(layout); fp.setFrame(false); fp.setHeaderVisible(false); fp.setAutoWidth(true); fp.setBodyBorder(true); fp.setButtonAlign(HorizontalAlignment.CENTER); eMail = new TextField<String>(); eMail.setFieldLabel("E-mail address"); // ID eMail.setValue("*****@*****.**"); eMail.setAllowBlank(false); eMail.setRegex("^[\\w-]+(\\.[\\w-]+)*@[\\w-]+(\\.[\\w-]+)+$"); fp.add(eMail); pass = new TextField<String>(); pass.setPassword(true); pass.setValue("pass"); pass.setFieldLabel("Password"); fp.add(pass); fp.addButton(loginButton); fp.addButton(newAccountButton); loginButton.addSelectionListener( new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { ArrayList eventData = new ArrayList(); if (!eMail.isValid()) { eventData = new ArrayList(); eventData.add("e-mail is invalid!"); Dispatcher.get().dispatch(MainEvents.login, eventData); return; } else if (eMail.getValue() == null) { eventData = new ArrayList(); eventData.add("Please enter your e-mail address!"); Dispatcher.get().dispatch(MainEvents.login, eventData); return; } else if (pass.getValue() == null) { eventData = new ArrayList(); eventData.add("Please enter the password!"); Dispatcher.get().dispatch(MainEvents.login, eventData); return; } else service = (ServiceManagerWebServiceAsync) Registry.get("guiservice"); String email = eMail.getValue(); String password = pass.getValue(); service.loginUser( email, password, new AsyncCallback<ArrayList<Object>>() { public void onFailure(Throwable caught) { System.out.println("loginUser: error"); } public void onSuccess(ArrayList<Object> result) { System.out.println("loginUser: success; result.get(0) = \n" + result.get(0)); System.out.println("loginUser: session_id = \n" + result.get(1)); session_id = (String) result.get(1); ArrayList eventData = new ArrayList(); if (!result .get(0) .equals( "User/pass are wrong! Please correct input data or register an account")) { eventData.add("Please select the option"); eventData.add(result.get(0)); Dispatcher.get().dispatch(MainEvents.login, eventData); fp.remove(eMail); fp.remove(pass); fp.clear(); remove(fp); FormLayout layout = new FormLayout(); layout.setLabelAlign(LabelAlign.TOP); fp = new FormPanel(); fp.setLayout(layout); fp.setFrame(false); fp.setHeaderVisible(false); fp.setAutoWidth(true); fp.setBodyBorder(true); fp.setButtonAlign(HorizontalAlignment.CENTER); fp.addText((String) result.get(0)); fp.addButton(logoutButton); add(fp); } else { eventData.add("You need to log in"); eventData.add(result.get(0)); Dispatcher.get().dispatch(MainEvents.newAccount, eventData); } layout(true); } }); } }); logoutButton.addSelectionListener( new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { fp.clear(); remove(fp); FormLayout layout = new FormLayout(); layout.setLabelAlign(LabelAlign.TOP); fp = new FormPanel(); fp.setLayout(layout); fp.setFrame(false); fp.setHeaderVisible(false); fp.setAutoWidth(true); fp.setBodyBorder(true); fp.setButtonAlign(HorizontalAlignment.CENTER); fp.add(eMail); fp.add(pass); fp.addButton(loginButton); fp.addButton(newAccountButton); add(fp); layout(true); ArrayList eventData = new ArrayList(); eventData.add("You are logged out!"); eventData.add("You are logged out, " + eMail.getValue() + "!"); Dispatcher.get().dispatch(MainEvents.logout, eventData); service.logoutUser( session_id, eMail.getValue(), new AsyncCallback<Boolean>() { public void onFailure(Throwable caught) { System.out.println("logoutUser: error"); } public void onSuccess(Boolean result) { System.out.println("logoutUser: success"); } }); } }); newAccountButton.addSelectionListener( new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { ArrayList eventData = new ArrayList(); eventData.add("Please select the option"); Dispatcher.get().dispatch(MainEvents.newAccount, eventData); } }); /* skipButton.addSelectionListener(new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { ArrayList eventData = new ArrayList(); eventData.add("Please select the option"); Dispatcher.get().dispatch(MainEvents.login, eventData); } }); */ this.add(fp); }
private FormPanel createForm() { final FormPanel panel = new FormPanel(); panel.setLabelWidth(100); panel.setHeaderVisible(false); TextField<String> code = new TextField<String>(); code.setName("containerNo"); code.setFieldLabel("集装箱号"); code.setAllowBlank(false); panel.add(code); final ComboBox<BeanModel> size = new ComboBox<BeanModel>(); size.setTabIndex(9); size.setName("size"); size.setForceSelection(true); size.setEmptyText("请选择..."); size.setDisplayField("size"); size.setFieldLabel("尺寸"); size.setStore(containerSizeStore); size.setTypeAhead(true); size.setTriggerAction(TriggerAction.ALL); size.setAllowBlank(false); panel.add(size); size.addListener( Events.Blur, new Listener<FieldEvent>() { @Override public void handleEvent(FieldEvent be) { formBindings.getModel().set("valentNum", size.getValue().get("valentNum")); } }); ComboBox<BeanModel> type = new ComboBox<BeanModel>(); type.setTabIndex(9); type.setName("type"); type.setForceSelection(true); type.setEmptyText("请选择..."); type.setDisplayField("code"); type.setFieldLabel("类型"); type.setStore(ironChestStore); type.setTypeAhead(true); type.setTriggerAction(TriggerAction.ALL); panel.add(type); ComboBox<BeanModel> bracket = new ComboBox<BeanModel>(); bracket.setTabIndex(9); bracket.setName("bracket"); bracket.setForceSelection(true); bracket.setEmptyText("请选择..."); bracket.setDisplayField("code"); bracket.setFieldLabel("车架编号"); bracket.setStore(bracketStore); bracket.setTypeAhead(true); bracket.setTriggerAction(TriggerAction.ALL); panel.add(bracket); formBindings = new FormBinding(panel, true); formBindings .getBinding(size) .setConverter( new Converter() { @Override public Object convertFieldValue(Object value) { if (value == null) { return null; } return ((BeanModel) value).get("code").toString(); } @Override public Object convertModelValue(Object value) { if (value != null) { return containerSizeStore.findModel("code", (String) value); } else { return null; } } }); formBindings .getBinding(type) .setConverter( new Converter() { @Override public Object convertFieldValue(Object value) { if (value == null) { return null; } return ((BeanModel) value).get("code").toString(); } @Override public Object convertModelValue(Object value) { if (value != null) { return ironChestStore.findModel("code", (String) value); } else { return null; } } }); formBindings .getBinding(bracket) .setConverter( new Converter() { @Override public Object convertFieldValue(Object value) { if (value == null) { return null; } return ((BeanModel) value).get("code").toString(); } @Override public Object convertModelValue(Object value) { if (value != null) { return bracketStore.findModel("code", (String) value); } else { return null; } } }); formBindings.setStore((Store<BeanModel>) grid.getStore()); panel.setReadOnly(true); panel.setButtonAlign(HorizontalAlignment.CENTER); saveButton = new Button("保存"); saveButton.setVisible(false); saveButton.addSelectionListener( new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { if (!panel.isValid()) return; save(); } }); panel.addButton(saveButton); cancelButton = new Button("取消"); cancelButton.setVisible(false); cancelButton.addSelectionListener( new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { resetState(); } }); panel.addButton(cancelButton); updateButton = new Button("更新"); updateButton.disable(); updateButton.addSelectionListener( new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { if (!panel.isValid()) return; update(); } }); panel.addButton(updateButton); resetButton = new Button("取消"); resetButton.disable(); resetButton.addSelectionListener( new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { store.rejectChanges(); resetState(); } }); panel.addButton(resetButton); panel.setBorders(false); panel.setBodyBorder(false); return panel; }
/** * Remember user/pass implementation <a href= * "http://stackoverflow.com/questions/1245174/is-it-possible-to-implement-cross-browser-username-password-autocomplete-in-gxt" * >based in this</a> and <a href= * "http://www.sencha.com/forum/showthread.php?72027-Auto-complete-login-form" >this</a>. */ public SignInForm(final I18nTranslationService i18n) { final Listener<FieldEvent> enterListener = new Listener<FieldEvent>() { @Override public void handleEvent(final FieldEvent fe) { if (fe.getEvent().getKeyCode() == 13) { onAcceptCallback.onSuccess(); } } }; super.addStyleName("kune-Margin-Large-trbl"); loginNickOrEmailField = new TextField<String>() { @Override protected void onRender(final Element target, final int index) { if (el() == null) { setElement(Document.get().getElementById("usernamerender")); } super.onRender(target, index); } @Override protected void setAriaState(final String stateName, final String stateValue) {} }; loginNickOrEmailField.setFieldLabel(i18n.t("Username")); loginNickOrEmailField.setName(USER_FIELD_ID); loginNickOrEmailField.setWidth(DEF_SMALL_FIELD_WIDTH); loginNickOrEmailField.setAllowBlank(false); loginNickOrEmailField.setValidationDelay(3000); loginNickOrEmailField.setId(USER_FIELD_ID); loginNickOrEmailField.setTabIndex(100); loginNickOrEmailField.addStyleName("k-lower"); loginNickOrEmailField.render(RootPanel.get(LOGIN_ID).getElement()); ComponentHelper.doAttach(loginNickOrEmailField); super.add(loginNickOrEmailField); loginNickOrEmailField.addListener(Events.OnKeyPress, enterListener); loginPassField = new TextField<String>() { @Override protected void onRender(final Element target, final int index) { if (el() == null) { final String elementId = "passwordrender"; setElement(Document.get().getElementById(elementId)); } super.onRender(target, index); } @Override protected void setAriaState(final String stateName, final String stateValue) {} }; loginPassField.setFieldLabel(i18n.t("Password")); loginPassField.setName(PASSWORD_FIELD_ID); loginPassField.setWidth(DEF_MEDIUM_FIELD_WIDTH); loginPassField.setPassword(true); loginPassField.setAllowBlank(false); loginPassField.setValidationDelay(3000); loginPassField.setId(PASSWORD_FIELD_ID); loginPassField.setTabIndex(101); loginPassField.render(RootPanel.get(LOGIN_ID).getElement()); ComponentHelper.doAttach(loginPassField); loginPassField.addListener(Events.OnKeyPress, enterListener); super.add(loginPassField); }
/** * 联系人 * * @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; }
/** * 客户资料 * * @return */ private LayoutContainer CreateCCodeDetailPanel() { LayoutContainer main = new LayoutContainer(); TableLayout tl = new TableLayout(2); main.setLayout(new TableLayout(2)); BaseFormPanel leftpanel = new BaseFormPanel(store); leftpanel.setLayout(new FormLayout()); FormData fd = new FormData(200, 30); leftpanel.setHeaderVisible(false); leftpanel.setBodyBorder(false); BaseFormPanel rightpanel = new BaseFormPanel(store); rightpanel.setBodyBorder(false); rightpanel.setHeaderVisible(false); TextField<String> ccode = new TextField<String>(); ccode.setName("ccode"); ccode.setAllowBlank(false); ccode.setFieldLabel("编码"); TextField<String> name = new TextField<String>(); name.setName("cname"); name.setAllowBlank(false); name.setFieldLabel("名称"); TextField<String> shortcode = new TextField<String>(); shortcode.setName("shortcode"); shortcode.setFieldLabel("简码"); TextField<String> ccodesource = new TextField<String>(); ccodesource.setName("ccodesource"); ccodesource.setFieldLabel("客户来源"); TextField<String> ncode = new TextField<String>(); ncode.setName("ncode"); ncode.setFieldLabel("国别"); TextField<String> httpurl = new TextField<String>(); httpurl.setName("httpurl"); httpurl.setFieldLabel("网址"); DateField setupdate = new DateField(); setupdate.setName("setupdate"); setupdate.setFieldLabel("成立时间"); TextField<String> registercapital = new TextField<String>(); registercapital.setName("registercapital"); registercapital.setFieldLabel("注册资金"); TextField<String> employeenum = new TextField<String>(); employeenum.setName("employeenum"); employeenum.setFieldLabel("雇用人数"); TextField<String> branchorgnum = new TextField<String>(); branchorgnum.setName("branchorgnum"); branchorgnum.setFieldLabel("分支机构数"); TextField<String> artperson = new TextField<String>(); artperson.setName("artperson"); artperson.setFieldLabel("法人代表"); TextField<String> taxno = new TextField<String>(); taxno.setName("taxno"); taxno.setFieldLabel("税务登记号"); TextField<String> partner = new TextField<String>(); partner.setName("partner"); partner.setFieldLabel("合伙人"); /* * TextField<String> artno = new TextField<String>(); * artno.setName("artno"); artno.setFieldLabel("企业代码"); */ TextField<String> comholsdatedesc = new TextField<String>(); comholsdatedesc.setName("comholsdatedesc"); comholsdatedesc.setFieldLabel("公司特殊假日"); BaseGrid gudong = CreateCCodeGudongPanel(); gudong.setAutoHeight(true); gudong.setAutoWidth(true); leftpanel.add(ccode, fd); rightpanel.add(name, fd); leftpanel.add(shortcode, fd); rightpanel.add(ccodesource, fd); leftpanel.add(httpurl, fd); rightpanel.add(setupdate, fd); leftpanel.add(registercapital, fd); rightpanel.add(employeenum, fd); leftpanel.add(branchorgnum, fd); rightpanel.add(artperson, fd); leftpanel.add(taxno, fd); rightpanel.add(partner, fd); leftpanel.add(comholsdatedesc, fd); TableData td = new TableData(); td.setColspan(1); td.setRowspan(1); // 对齐方式 td.setHorizontalAlign(HorizontalAlignment.LEFT); td.setVerticalAlign(VerticalAlignment.TOP); // rightpanel.add(gudong,td2); leftpanel.inited(); rightpanel.inited(); FieldSet fieldSet = new FieldSet(); fieldSet.setHeading("股东占股比例"); fieldSet.add(gudong); main.add(leftpanel, td); main.add(rightpanel, td); main.add(fieldSet, td); return main; }
protected void onRender(Element parent, int index) { super.onRender(parent, index); setLayout(new FitLayout()); setId("network-dhcp-nat"); FormData formData = new FormData(); formData.setWidth(250); m_formPanel = new FormPanel(); m_formPanel.setFrame(false); m_formPanel.setBodyBorder(false); m_formPanel.setHeaderVisible(false); m_formPanel.setLayout(new FlowLayout()); m_formPanel.setStyleAttribute("min-width", "775px"); m_formPanel.setStyleAttribute("padding-left", "30px"); FieldSet fieldSet = new FieldSet(); FormLayout layoutAccount = new FormLayout(); layoutAccount.setLabelWidth(Constants.LABEL_WIDTH_FORM); fieldSet.setLayout(layoutAccount); fieldSet.setBorders(false); // // Tool Tip Box // toolTipField.setText(defaultToolTip); fieldSet.add(toolTipField); // // Router Mode // m_modeCombo = new SimpleComboBox<String>(); m_modeCombo.setName("comboMode"); m_modeCombo.setFieldLabel(MSGS.netRouterMode()); m_modeCombo.setEditable(false); m_modeCombo.setTypeAhead(true); m_modeCombo.setTriggerAction(TriggerAction.ALL); for (GwtNetRouterMode mode : GwtNetRouterMode.values()) { m_modeCombo.add(MessageUtils.get(mode.name())); } m_modeCombo.setSimpleValue(MessageUtils.get(GwtNetRouterMode.netRouterDchpNat.name())); m_modeCombo.setValidator( new Validator() { public String validate(Field<?> field, String value) { if (m_tcpIpConfigTab.isDhcp() && !value.equals(MessageUtils.get(GwtNetRouterMode.netRouterOff.toString()))) { return MSGS.netRouterConfiguredForDhcpError(); } return null; } }); m_modeCombo.addSelectionChangedListener( new SelectionChangedListener<SimpleComboValue<String>>() { @Override public void selectionChanged(SelectionChangedEvent<SimpleComboValue<String>> se) { refreshForm(); } }); m_modeCombo.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netRouterToolTipMode())); m_modeCombo.addStyleName("kura-combobox"); m_modeCombo.addPlugin(m_dirtyPlugin); fieldSet.add(m_modeCombo, formData); // // DHCP Beginning Address // m_dhcpBeginAddressField = new TextField<String>(); m_dhcpBeginAddressField.setAllowBlank(true); m_dhcpBeginAddressField.setName("dhcpBeginAddress"); m_dhcpBeginAddressField.setFieldLabel(MSGS.netRouterDhcpBeginningAddress()); m_dhcpBeginAddressField.setRegex(IPV4_REGEX); m_dhcpBeginAddressField.getMessages().setRegexText(MSGS.netIPv4InvalidAddress()); m_dhcpBeginAddressField.addPlugin(m_dirtyPlugin); m_dhcpBeginAddressField.setStyleAttribute("margin-top", Constants.LABEL_MARGIN_TOP_SEPARATOR); m_dhcpBeginAddressField.addStyleName("kura-textfield"); m_dhcpBeginAddressField.addListener( Events.OnMouseOver, new MouseOverListener(MSGS.netRouterToolTipDhcpBeginAddr())); fieldSet.add(m_dhcpBeginAddressField, formData); // // DHCP Ending Address // m_dhcpEndAddressField = new TextField<String>(); m_dhcpEndAddressField.setAllowBlank(true); m_dhcpEndAddressField.setName("dhcpEndAddress"); m_dhcpEndAddressField.setFieldLabel(MSGS.netRouterDhcpEndingAddress()); m_dhcpEndAddressField.setRegex(IPV4_REGEX); m_dhcpEndAddressField.getMessages().setRegexText(MSGS.netIPv4InvalidAddress()); m_dhcpEndAddressField.addListener( Events.OnMouseOver, new MouseOverListener(MSGS.netRouterToolTipDhcpEndAddr())); m_dhcpEndAddressField.addStyleName("kura-textfield"); ; m_dhcpEndAddressField.addPlugin(m_dirtyPlugin); fieldSet.add(m_dhcpEndAddressField, formData); // // DHCP Subnet Mask // m_dhcpSubnetMaskField = new TextField<String>(); m_dhcpSubnetMaskField.setAllowBlank(true); m_dhcpSubnetMaskField.setName("dhcpSubnetMask"); m_dhcpSubnetMaskField.setFieldLabel(MSGS.netRouterDhcpSubnetMask()); m_dhcpSubnetMaskField.setRegex(IPV4_REGEX); m_dhcpSubnetMaskField.addListener( Events.OnMouseOver, new MouseOverListener(MSGS.netRouterToolTipDhcpSubnet())); m_dhcpSubnetMaskField.getMessages().setRegexText(MSGS.netIPv4InvalidAddress()); m_dhcpSubnetMaskField.addStyleName("kura-textfield"); m_dhcpSubnetMaskField.addPlugin(m_dirtyPlugin); fieldSet.add(m_dhcpSubnetMaskField, formData); // // DHCP Default Lease // m_dhcpLeaseDefaultField = new NumberField(); m_dhcpLeaseDefaultField.setPropertyEditorType(Integer.class); m_dhcpLeaseDefaultField.setAllowDecimals(false); m_dhcpLeaseDefaultField.setAllowNegative(false); m_dhcpLeaseDefaultField.setMaxValue(Integer.MAX_VALUE); m_dhcpLeaseDefaultField.setAllowBlank(true); m_dhcpLeaseDefaultField.setName("dhcpDefaultLease"); m_dhcpLeaseDefaultField.setFieldLabel(MSGS.netRouterDhcpDefaultLease()); m_dhcpLeaseDefaultField.addListener( Events.OnMouseOver, new MouseOverListener(MSGS.netRouterToolTipDhcpDefaultLeaseTime())); m_dhcpLeaseDefaultField.addPlugin(m_dirtyPlugin); fieldSet.add(m_dhcpLeaseDefaultField, formData); // // DHCP Max Lease // m_dhcpLeaseMaxField = new NumberField(); m_dhcpLeaseMaxField.setPropertyEditorType(Integer.class); m_dhcpLeaseMaxField.setAllowDecimals(false); m_dhcpLeaseMaxField.setAllowNegative(false); m_dhcpLeaseMaxField.setMaxValue(Integer.MAX_VALUE); m_dhcpLeaseMaxField.setAllowBlank(true); m_dhcpLeaseMaxField.setName("dhcpMaxLease"); m_dhcpLeaseMaxField.setFieldLabel(MSGS.netRouterDhcpMaxLease()); m_dhcpLeaseMaxField.addListener( Events.OnMouseOver, new MouseOverListener(MSGS.netRouterToolTipDhcpMaxLeaseTime())); m_dhcpLeaseMaxField.addPlugin(m_dirtyPlugin); fieldSet.add(m_dhcpLeaseMaxField, formData); // // Pass DNS // m_passDnsRadioTrue = new Radio(); m_passDnsRadioTrue.setBoxLabel(MSGS.trueLabel()); m_passDnsRadioTrue.setItemId("true"); m_passDnsRadioFalse = new Radio(); m_passDnsRadioFalse.setBoxLabel(MSGS.falseLabel()); m_passDnsRadioFalse.setItemId("false"); m_passDnsRadioGroup = new RadioGroup(); m_passDnsRadioGroup.setName("dhcpPassDns"); m_passDnsRadioGroup.setFieldLabel(MSGS.netRouterPassDns()); m_passDnsRadioGroup.add(m_passDnsRadioTrue); m_passDnsRadioGroup.add(m_passDnsRadioFalse); m_passDnsRadioGroup.addPlugin(m_dirtyPlugin); m_passDnsRadioGroup.addListener( Events.OnMouseOver, new MouseOverListener(MSGS.netRouterToolTipPassDns())); fieldSet.add(m_passDnsRadioGroup, formData); m_formPanel.add(fieldSet); add(m_formPanel); setScrollMode(Scroll.AUTO); m_initialized = true; }
private TabItem createLoginTab() { TabItem tabItem = new TabItem("Login"); FormPanel form = new FormPanel(); form.setHeading("Login using existing user."); form.setWidth(350); form.setLayout(new FlowLayout()); FieldSet fieldSet = new FieldSet(); FormLayout layout = new FormLayout(); layout.setLabelWidth(75); fieldSet.setLayout(layout); final TextField<String> fieldName = new TextField<String>(); fieldName.setFieldLabel("Name"); fieldSet.add(fieldName); final TextField<String> fieldPassword = new TextField<String>(); fieldPassword.setPassword(true); fieldPassword.setFieldLabel("Password"); fieldSet.add(fieldPassword); form.add(fieldSet); form.setButtonAlign(HorizontalAlignment.CENTER); Button loginButton = new Button("Login"); form.addButton(loginButton); loginButton.addListener( Events.Select, new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { final String name = fieldName.getValue(); String pass = fieldPassword.getValue(); if (name == null || pass == null) { Info.display("Loggin in Error!", "Name or password is empty!"); return; } // Sprawdza usera userService.login( name, pass, new AsyncCallback<UserLoginRegisterResponse>() { public void onSuccess(UserLoginRegisterResponse result) { if (!result.isSuccess()) { Info.display("Couldn't log in", result.getMessage()); } else { User user = result.getUser(); Info.display( "Logged in", "Logged in successfuly as " + user.getName() + " level: " + user.getUserType()); hide(); tabs.init(user); } } public void onFailure(Throwable caught) { Info.display("Error while loggin in.", caught.getMessage()); }; }); } }); tabItem.add(form); return tabItem; }
private void createNewUSerDialog() { setButtons(""); setLayout(new FitLayout()); setHeading(HarvesterUI.CONSTANTS.addUser()); setIcon(HarvesterUI.ICONS.add16()); setResizable(false); setModal(true); setSize(600, 200); setBodyBorder(false); FormData formData = new FormData("95%"); newUserFormPanel = new DefaultFormPanel(); newUserFormPanel.setHeaderVisible(false); newUserFormPanel.setLayout(new EditableFormLayout(175)); userNameField = new TextField<String>(); userNameField.setFieldLabel(HarvesterUI.CONSTANTS.username() + HarvesterUI.REQUIRED_STR); userNameField.setId("userNameField"); userNameField.setMinLength(4); userNameField.setAllowBlank(false); newUserFormPanel.add(userNameField, formData); Validator usernameValidator = new Validator() { public String validate(Field<?> field, String s) { if (!s.matches("^[A-Za-z0-9]+(?:[ _-][A-Za-z0-9]+)*$")) return HarvesterUI.CONSTANTS.usernameValidateMessage(); return null; } }; userNameField.setValidator(usernameValidator); emailField = new TextField<String>(); emailField.setFieldLabel(HarvesterUI.CONSTANTS.email() + HarvesterUI.REQUIRED_STR); emailField.setId("emailField"); emailField.setAllowBlank(false); newUserFormPanel.add(emailField, formData); Validator emailValidator = new Validator() { public String validate(Field<?> field, String s) { if (!s.matches("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}")) return HarvesterUI.CONSTANTS.emailValidateMessage(); return null; } }; emailField.setValidator(emailValidator); roleCombo = new SimpleComboBox<String>(); roleCombo.setEditable(false); roleCombo.setFieldLabel(HarvesterUI.CONSTANTS.role() + HarvesterUI.REQUIRED_STR); roleCombo.setTriggerAction(ComboBox.TriggerAction.ALL); for (UserRole userRole : UserRole.values()) { if (userRole != UserRole.ANONYMOUS) roleCombo.add(userRole.name()); } roleCombo.setValue(roleCombo.getStore().getAt(0)); newUserFormPanel.add(roleCombo, formData); saveButton = new Button( HarvesterUI.CONSTANTS.save(), HarvesterUI.ICONS.save_icon(), new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent be) { AsyncCallback<User> callback = new AsyncCallback<User>() { public void onFailure(Throwable caught) { new ServerExceptionDialog( "Failed to get response from server", caught.getMessage()) .show(); } public void onSuccess(User user) { AsyncCallback<ResponseState> callback = new AsyncCallback<ResponseState>() { public void onFailure(Throwable caught) { new ServerExceptionDialog( "Failed to get response from server", caught.getMessage()) .show(); } public void onSuccess(ResponseState result) { unmask(); if (result == ResponseState.USER_ALREADY_EXISTS) { HarvesterUI.UTIL_MANAGER.getErrorBox( HarvesterUI.CONSTANTS.newUser(), HarvesterUI.CONSTANTS.usernameAlreadyExists()); return; } hide(); userManagementGrid.getStore().add(newUser); HarvesterUI.UTIL_MANAGER.getSaveBox( HarvesterUI.CONSTANTS.newUser(), HarvesterUI.CONSTANTS.saveNewUserSuccess()); Dispatcher.get().dispatch(AppEvents.ViewUserManagementForm); } }; mask(HarvesterUI.CONSTANTS.saveUserMask()); newUserFormPanel.submit(); String role = roleCombo.getValue().getValue().trim(); String userName = userNameField.getValue().trim(); String email = emailField.getValue().trim(); String password = "******"; newUser = new User(userName, password, role, email, 15); service.saveNewUser(newUser, callback); } }; String userName = userNameField.getValue(); service.getUser(userName, callback); } }); newUserFormPanel.addButton(saveButton); newUserFormPanel.addButton( new Button( HarvesterUI.CONSTANTS.cancel(), HarvesterUI.ICONS.cancel_icon(), new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent be) { hide(); Dispatcher.get().dispatch(AppEvents.ViewUserManagementForm); } })); newUserFormPanel.setButtonAlign(Style.HorizontalAlignment.CENTER); FormButtonBinding binding = new FormButtonBinding(newUserFormPanel); binding.addButton(saveButton); add(newUserFormPanel); }
private FormPanel setupUserLeftForm(String title, int tabIndex) { FormPanel formPanel = new FormPanel(); formPanel.setTitle(title); formPanel.setHeaderVisible(false); formPanel.setBodyBorder(false); formPanel.setWidth(400); // formPanel.setLabelAlign(LabelAlign.TOP); // default is LEFT formPanel.setLabelWidth(150); // Name fields FieldSet namefieldSet = new FieldSet(); namefieldSet.setHeading("Username"); namefieldSet.setCollapsible(true); namefieldSet.setBorders(false); FormLayout namelayout = new FormLayout(); namelayout.setLabelWidth(150); // namelayout.setDefaultWidth(180); // It is the real function to set the textField width. // Default width is 200 namefieldSet.setLayout(namelayout); userName = new TextField<String>(); userName.setFieldLabel("Username"); userName.setAllowBlank(false); // userName.setReadOnly(true); userName.disable(); userName.setTabIndex(tabIndex++); namefieldSet.add(userName); // Password fields FieldSet passwordfieldSet = new FieldSet(); passwordfieldSet.setHeading("Password"); passwordfieldSet.setCollapsible(true); passwordfieldSet.setBorders(false); FormLayout passwordlayout = new FormLayout(); passwordlayout.setLabelWidth(150); passwordfieldSet.setLayout(passwordlayout); password = new TextField<String>(); password.setFieldLabel("Current Password"); password.setAllowBlank(false); password.setPassword(true); password.setTabIndex(tabIndex++); passwordNew = new TextField<String>(); passwordNew.setFieldLabel("New Password"); passwordNew.setPassword(true); passwordNew.setTabIndex(tabIndex++); passwordConfirm = new TextField<String>(); passwordConfirm.setFieldLabel("Confirm Password"); passwordConfirm.setPassword(true); passwordConfirm.setTabIndex(tabIndex++); passwordHint = new TextField<String>(); passwordHint.setFieldLabel("Password Hint"); passwordHint.setTabIndex(tabIndex++); passwordfieldSet.add(password); passwordfieldSet.add(passwordNew); passwordfieldSet.add(passwordConfirm); passwordfieldSet.add(passwordHint); FieldSet userInfofieldSet = new FieldSet(); userInfofieldSet.setHeading("User Info"); userInfofieldSet.setCollapsible(true); userInfofieldSet.setBorders(false); FormLayout userInfolayout = new FormLayout(); userInfolayout.setLabelWidth(150); userInfofieldSet.setLayout(userInfolayout); firstName = new TextField<String>(); firstName.setFieldLabel("First Name"); firstName.setAllowBlank(false); // firstName.setLabelStyle("font-size:12px; margin-left: 20px"); firstName.setTabIndex(tabIndex++); lastName = new TextField<String>(); lastName.setFieldLabel("Last Name"); lastName.setAllowBlank(false); lastName.setTabIndex(tabIndex++); userInfofieldSet.add(firstName); userInfofieldSet.add(lastName); formPanel.add(namefieldSet); formPanel.add(passwordfieldSet); formPanel.add(userInfofieldSet); return formPanel; }
@Override protected void onRender(Element parent, int index) { super.onRender(parent, index); setStyleAttribute("margin", "10px"); final FormPanel panel = new FormPanel(); panel.setHeading("File Upload Example"); panel.setFrame(true); panel.setAction("myurl"); panel.setEncoding(Encoding.MULTIPART); panel.setMethod(Method.POST); panel.setButtonAlign(HorizontalAlignment.CENTER); panel.setWidth(350); TextField<String> name = new TextField<String>(); name.setFieldLabel("Name"); panel.add(name); FileUploadField file = new FileUploadField(); file.setAllowBlank(false); file.setName("uploadedfile"); file.setFieldLabel("File"); panel.add(file); List<Stock> list = TestData.getStocks(); final ListStore<Stock> store = new ListStore<Stock>(); store.add(list); final ComboBox<Stock> combo = new ComboBox<Stock>(); combo.setFieldLabel("Company"); combo.setDisplayField("name"); combo.setName("name"); combo.setValueField("symbol"); combo.setForceSelection(true); combo.setStore(store); combo.setTriggerAction(TriggerAction.ALL); panel.add(combo); Button btn = new Button("Reset"); btn.addSelectionListener( new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { panel.reset(); } }); panel.addButton(btn); btn = new Button("Submit"); btn.addSelectionListener( new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { if (!panel.isValid()) { return; } // normally would submit the form but for example no server set up to // handle the post // panel.submit(); MessageBox.info("Action", "You file was uploaded", null); } }); panel.addButton(btn); add(panel); }
private void initUI() { long time = new java.util.Date().getTime(); GWT.log("Initializing the UI ", null); container = new LayoutContainer(); container.setLayout(new CenterLayout()); // Rpc Proxy setup pagingToolBar = setupRpcProxy(); // Audit event grid setup grid = setupGrid(); // Panel ContentPanel cp = new ContentPanel(); cp.setHeading("Entity Event Viewer"); cp.setFrame(true); cp.setIcon(IconHelper.create("images/search_icon_16x16.png")); cp.setLayout(new FormLayout()); cp.setSize(1100, 630); // Search Container ContentPanel searchContainer = new ContentPanel(); searchContainer.setHeaderVisible(false); FormLayout searchFormLayout = new FormLayout(); searchFormLayout.setLabelWidth(130); searchFormLayout.setDefaultWidth(770); searchContainer.setLayout(searchFormLayout); selectedEvenyTypes = new TextField<String>(); selectedEvenyTypes.setFieldLabel("Selected Event Types"); selectedEvenyTypes.setReadOnly(true); evenyTypes = new ListView<AuditEventTypeWeb>(); evenyTypes.setDisplayProperty("auditEventTypeName"); evenyTypes.setWidth(220); evenyTypes.setHeight(110); evenyTypes.setStore(eventTypesStore); evenyTypes .getSelectionModel() .addListener( Events.SelectionChange, new Listener<SelectionChangedEvent<AuditEventTypeWeb>>() { public void handleEvent(SelectionChangedEvent<AuditEventTypeWeb> be) { List<AuditEventTypeWeb> selections = be.getSelection(); String selectedTypes = ""; for (AuditEventTypeWeb type : selections) { if (selectedTypes.isEmpty()) { selectedTypes = type.getAuditEventTypeName(); } else { selectedTypes = selectedTypes + ", " + type.getAuditEventTypeName(); } } selectedEvenyTypes.setValue(selectedTypes); if (selectedTypes.isEmpty()) { searchButton.disable(); } else { searchButton.enable(); } } }); DateTimePropertyEditor dateFormat = new DateTimePropertyEditor("yyyy-MM-dd HH:mm"); startDate = new DateField(); startDate.setFieldLabel("Start Date Time"); startDate.setToolTip("yyyy-MM-dd HH:mm"); startDate.setPropertyEditor(dateFormat); endDate = new DateField(); endDate.setFieldLabel("End Date Time"); endDate.setToolTip("yyyy-MM-dd HH:mm"); endDate.setPropertyEditor(dateFormat); LayoutContainer main = new LayoutContainer(); main.setLayout(new ColumnLayout()); LayoutContainer left = new LayoutContainer(); left.setStyleAttribute("paddingRight", "10px"); FormLayout layout = new FormLayout(); layout.setLabelWidth(130); layout.setDefaultWidth(220); // layout.setLabelAlign(LabelAlign.TOP); left.setLayout(layout); left.add(startDate); LayoutContainer right = new LayoutContainer(); right.setStyleAttribute("paddingLeft", "10px"); layout = new FormLayout(); // layout.setLabelAlign(LabelAlign.TOP); layout.setLabelWidth(130); layout.setDefaultWidth(220); right.setLayout(layout); right.add(endDate); main.add(left, new ColumnData(.5)); main.add(right, new ColumnData(.5)); HBoxLayoutData dataSelectedTypes = new HBoxLayoutData(new Margins(5, 0, 0, 0)); searchContainer.add(selectedEvenyTypes, dataSelectedTypes); HBoxLayoutData dataTypes = new HBoxLayoutData(new Margins(5, 0, 5, 135)); searchContainer.add(evenyTypes, dataTypes); searchContainer.add(main); HBoxLayoutData dataButtons = new HBoxLayoutData(new Margins(0, 0, 5, 0)); searchContainer.add(setupButtonPanel(3), dataButtons); cp.add(searchContainer); cp.add(grid); cp.setBottomComponent(pagingToolBar); container.add(cp); LayoutContainer wrapper = (LayoutContainer) Registry.get(Constants.CENTER_PANEL); wrapper.removeAll(); wrapper.add(container); wrapper.layout(); GWT.log("Done Initializing the UI in " + (new java.util.Date().getTime() - time), null); }
private FormPanel setupUserRightForm(String title, int tabIndex) { FormPanel formPanel = new FormPanel(); formPanel.setTitle(title); formPanel.setHeaderVisible(false); formPanel.setBodyBorder(false); formPanel.setWidth(400); // formPanel.setLabelAlign(LabelAlign.RIGHT); // default is LEFT formPanel.setLabelWidth(150); // Address fields FieldSet addressfieldSet = new FieldSet(); addressfieldSet.setHeading("Address"); addressfieldSet.setCollapsible(true); addressfieldSet.setBorders(false); FormLayout addresslayout = new FormLayout(); addresslayout.setLabelWidth(150); addressfieldSet.setLayout(addresslayout); address = new TextField<String>(); address.setFieldLabel("Address"); address.setTabIndex(tabIndex++); city = new TextField<String>(); city.setFieldLabel("City"); city.setAllowBlank(false); city.setTabIndex(tabIndex++); state = new ComboBox<State>(); state.setFieldLabel("State"); state.setEmptyText("Select a state..."); state.setDisplayField("name"); state.setWidth(150); state.setStore(states); state.setTypeAhead(true); state.setTriggerAction(TriggerAction.ALL); state.setTabIndex(tabIndex++); zip = new TextField<String>(); zip.setFieldLabel("Zip Code"); zip.setAllowBlank(false); zip.setTabIndex(tabIndex++); country = new ComboBox<Country>(); country.setFieldLabel("Country"); country.setEmptyText("Select a country..."); country.setDisplayField("name"); country.setTemplate(InputFormat.getFlagTemplate()); country.setWidth(100); country.setStore(countries); country.setTypeAhead(true); country.setTriggerAction(TriggerAction.ALL); country.setTabIndex(tabIndex++); addressfieldSet.add(address); addressfieldSet.add(city); addressfieldSet.add(state); addressfieldSet.add(zip); addressfieldSet.add(country); FieldSet otherfieldSet = new FieldSet(); otherfieldSet.setHeading("Other"); otherfieldSet.setCollapsible(true); otherfieldSet.setBorders(false); FormLayout otherlayout = new FormLayout(); otherlayout.setLabelWidth(150); otherfieldSet.setLayout(otherlayout); phoneNumber = new TextField<String>(); phoneNumber.setFieldLabel("Phone Number"); phoneNumber.setToolTip("xxx-xxxx"); phoneNumber.setTabIndex(tabIndex++); email = new TextField<String>(); email.setFieldLabel("Email"); email.setAllowBlank(false); email.setRegex(InputFormat.EMAIL_FORMATS); email.getMessages().setRegexText("Invalid email format"); // email.setAutoValidate(true); email.setToolTip("*****@*****.**"); email.setTabIndex(tabIndex++); emailConfirm = new TextField<String>(); emailConfirm.setFieldLabel("Confirm Email"); emailConfirm.setRegex(InputFormat.EMAIL_FORMATS); emailConfirm.getMessages().setRegexText("Invalid email format"); // email.setAutoValidate(true); emailConfirm.setToolTip("*****@*****.**"); emailConfirm.setTabIndex(tabIndex++); webSite = new TextField<String>(); webSite.setFieldLabel("Website"); webSite.setTabIndex(tabIndex++); otherfieldSet.add(phoneNumber); otherfieldSet.add(email); otherfieldSet.add(emailConfirm); otherfieldSet.add(webSite); formPanel.add(addressfieldSet); formPanel.add(otherfieldSet); return formPanel; }
private TabItem createRegisterTab() { TabItem tabItem = new TabItem("Register"); FormPanel form = new FormPanel(); form.setFrame(false); form.setHeading("Create a new account."); form.setWidth(350); form.setLayout(new FlowLayout()); FieldSet fieldSet = new FieldSet(); FormLayout layout = new FormLayout(); layout.setLabelWidth(75); fieldSet.setLayout(layout); final TextField<String> nameField = new TextField<String>(); nameField.setFieldLabel("Name"); fieldSet.add(nameField); final TextField<String> passField = new TextField<String>(); passField.setPassword(true); passField.setFieldLabel("Password"); fieldSet.add(passField); final TextField<String> emailField = new TextField<String>(); emailField.setFieldLabel("Email"); fieldSet.add(emailField); form.add(fieldSet); form.setButtonAlign(HorizontalAlignment.CENTER); Button registerButton = new Button("Register"); form.addButton(registerButton); registerButton.addListener( Events.Select, new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { String name = nameField.getValue(); String pass = passField.getValue(); String email = emailField.getValue(); if (name == null || pass == null || email == null) { Info.display( "Incorrect register data", "Name, password and email must not be empty!"); return; } userService.register( name, pass, email, new AsyncCallback<UserLoginRegisterResponse>() { // @Override public void onFailure(Throwable caught) { Info.display("Error while registering account!", caught.getMessage()); } // @Override public void onSuccess(UserLoginRegisterResponse result) { if (!result.isSuccess()) { Info.display("The account not registered!", result.getMessage()); } else { User user = result.getUser(); Info.display( "Registered :)", "Registered successfuly. You've been automaticly logged in as " + user.getName() + " level: " + user.getUserType()); hide(); tabs.init(user); } } }); } }); tabItem.add(form); return tabItem; }
@Override protected void onRender(Element parent, int index) { super.onRender(parent, index); final Stock stock = TestData.getStocks().get(0); HorizontalPanel hp = new HorizontalPanel(); hp.setSpacing(10); StringBuffer sb = new StringBuffer(); sb.append("<div class=text style='line-height: 1.5em'>"); sb.append("<b>Name:</b> {name}<br>"); sb.append("<b>Symbol:</b> {symbol}<br>"); sb.append("<b>Last:</b> {last}<br>"); sb.append("<b>Change:</b> {[new Number(values.change).toFixed(2)]}<br>"); sb.append("<b>Updated:</b> {date:date(\"MM/dd/y\")}<br>"); sb.append("</div>"); final XTemplate template = XTemplate.create(sb.toString()); final HTML html = new HTML(); html.setWidth("160px"); template.overwrite(html.getElement(), Util.getJsObject(stock)); hp.add(html); // update template when model changes stock.addChangeListener( new ChangeListener() { public void modelChanged(ChangeEvent event) { template.overwrite(html.getElement(), Util.getJsObject(stock)); } }); FormPanel panel = new FormPanel(); panel.setHeaderVisible(false); panel.setWidth(350); TextField<String> name = new TextField<String>(); name.setName("nameField"); name.setFieldLabel("Name"); panel.add(name); TextField<String> symbol = new TextField<String>(); symbol.setName("symbol"); symbol.setFieldLabel("Symbol"); panel.add(symbol); NumberField open = new NumberField(); open.setName("last"); open.setFieldLabel("Last"); panel.add(open); NumberField change = new NumberField(); change.setName("change"); change.setFieldLabel("Change"); change.setFormat(NumberFormat.getDecimalFormat()); panel.add(change); DateField last = new DateField(); last.setName("date"); last.setFieldLabel("Updated"); panel.add(last); SimpleComboBox<String> scb = new SimpleComboBox<String>(); for (Stock s : TestData.getStocks()) { scb.add(s.getName()); } scb.setFieldLabel("Name"); scb.setForceSelection(true); scb.setTypeAhead(true); scb.setName("company"); scb.setTriggerAction(TriggerAction.ALL); panel.add(scb); hp.add(panel); FormBinding binding = new FormBinding(panel); // manually add bindings binding.addFieldBinding(new FieldBinding(name, "name")); binding.addFieldBinding(new FieldBinding(symbol, "symbol")); binding.addFieldBinding(new SimpleComboBoxFieldBinding(scb, "name")); // auto bind remaining fields, field name must match model property name binding.autoBind(); binding.bind(stock); add(hp); }