List of usage examples for com.google.gwt.user.client.ui TextBox setMaxLength
public void setMaxLength(int length)
From source file:com.google.sampling.experiential.client.FeedbackChooserPanel.java
License:Open Source License
private Widget createStaticMessagePanel() { VerticalPanel container = new VerticalPanel(); container.setWidth(SHORT_TEXTBOX_WIDTH); container.add(makeIOSIncompatibleStaticMessage()); final TextBox textBox = new TextBox(); textBox.setWidth(SHORT_TEXTBOX_WIDTH); textBox.setMaxLength(MAXIMUM_SHORT_TEXT_LENGTH); String feedbackText = experiment.getFeedback()[0].getText(); textBox.setText(feedbackText);/*from ww w.j a v a 2s.c o m*/ textBox.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { experiment.getFeedback()[0].setText(textBox.getText()); } }); container.add(textBox); return container; }
From source file:com.threerings.gwt.ui.Widgets.java
License:Open Source License
/** * Configures a text box with all of the configuration that you're bound to want to do. This is * useful for configuring a PasswordTextBox. *//*from ww w . ja v a 2 s . c om*/ public static TextBox initTextBox(TextBox box, String text, int maxLength, int visibleLength) { if (text != null) { box.setText(text); } box.setMaxLength(maxLength > 0 ? maxLength : 255); if (visibleLength > 0) { box.setVisibleLength(visibleLength); } return box; }
From source file:de.metanome.frontend.client.datasources.FileInputEditForm.java
License:Apache License
/** * Creates a UI element for one-character user input * * @return a TextBox with width and input length limited to 2 (>1 to allow for escape characters) *///from w w w.ja v a 2 s . co m private TextBox getNewOneCharTextbox() { TextBox textbox = new TextBox(); textbox.setMaxLength(1); textbox.setWidth("2em"); return textbox; }
From source file:de.novanic.gwteventservice.demo.conversationapp.client.conversation.ui.GWTConversationChannelCreatorDialog.java
License:Open Source License
private Panel createContentPanel() { final Button theCreateChannelButton = new Button("Create"); final Button theCancelButton = new Button("Cancel"); final TextBox theChannelNameText = new TextBox(); theChannelNameText.setMaxLength(30); theChannelNameText.addKeyUpHandler(new KeyUpHandler() { public void onKeyUp(KeyUpEvent aKeyUpEvent) { switch (aKeyUpEvent.getNativeKeyCode()) { case 13: theCreateChannelButton.click(); break; case 27: theCancelButton.click(); }/*from www . j av a 2 s. c om*/ } }); theChannelNameText.setFocus(true); theCreateChannelButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent aClickEvent) { String theChannelName = theChannelNameText.getText(); close(theChannelName); } }); theCancelButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent aClickEvent) { close(null); } }); HorizontalPanel theActionPanel = new HorizontalPanel(); theActionPanel.setSpacing(5); theActionPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); theActionPanel.add(theCreateChannelButton); theActionPanel.add(theCancelButton); VerticalPanel theContentPanel = new VerticalPanel(); theContentPanel.setSpacing(5); theContentPanel.add(theChannelNameText); theContentPanel.add(theActionPanel); return theContentPanel; }
From source file:net.opentsdb.tsd.client.DateTimeBox.java
License:Open Source License
public DateTimeBox() { super(new DateTimePicker(), null, DATE_FORMAT); ((DateTimePicker) getDatePicker()).setDateTimeBox(this); final TextBox textbox = getTextBox(); // Chrome 7.0.5xx versions, Safari 5.0.x and similar render a text box // that's too small for 19 characters (WTF?). So we ask for space for // an extra 2 characters. On Firefox the text box's width is computed // properly, so it simply appears slightly wider than necessary. textbox.setVisibleLength(19 + 2);/*from w w w.j av a 2 s . c o m*/ textbox.setMaxLength(19); }
From source file:org.bonitasoft.forms.client.view.widget.FormFieldWidget.java
License:Open Source License
/** * Create a {@link TextBox} widget//from ww w . ja v a 2s .co m * * @param widgetData * the widget data object * @param fieldValue * the widget value * @return a {@link TextBox} */ @SuppressWarnings("unchecked") protected TextBox createTextBox(final ReducedFormWidget widgetData, final FormFieldValue fieldValue) { final TextBox textBox = new TextBox(); textBox.addChangeHandler(this); textBox.addValueChangeHandler(this); if (widgetData.getMaxLength() != 0) { textBox.setMaxLength(widgetData.getMaxLength()); } if (SupportedFieldTypes.JAVA_DATE_CLASSNAME.equals(valueType)) { textBox.setValue(getDateAsText(fieldValue)); } else { textBox.setValue(getStringValue(fieldValue)); } textBox.setEnabled(!widgetData.isReadOnly()); return textBox; }
From source file:org.gwtlib.client.table.ui.PagingBar.java
License:Apache License
protected Widget createGotoWidget() { final TextBox gotoPage = new TextBox(); int maxlen = String.valueOf(computeNumPages()).length(); gotoPage.setMaxLength(maxlen); gotoPage.setVisibleLength(maxlen);//w w w . jav a 2 s.c o m final PushButton go = new PushButton(); go.setStylePrimaryName(STYLE_GOTO_BUTTON); go.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { setPage(Integer.parseInt(gotoPage.getText()) - 1); gotoPage.setText(""); go.setEnabled(false); fireChange(); } }); go.setEnabled(false); gotoPage.addKeyDownHandler(new KeyDownHandler() { public void onKeyDown(final KeyDownEvent event) { final int keyCode = event.getNativeKeyCode(); DeferredCommand.addCommand(new Command() { public void execute() { int page = -1; try { page = Integer.parseInt(gotoPage.getText()) - 1; } catch (NumberFormatException e) { } go.setEnabled(page >= 0 && page < computeNumPages()); if (keyCode == KeyCodes.KEY_ENTER && go.isEnabled()) { setPage(Integer.parseInt(gotoPage.getText()) - 1); gotoPage.setText(""); go.setEnabled(false); fireChange(); } } }); } }); HorizontalPanel panel = new HorizontalPanel(); panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); panel.add(new HTML(_messages.go())); panel.add(gotoPage); panel.add(go); panel.setStylePrimaryName(STYLE_GOTO); return panel; }
From source file:org.gwtlib.client.table.ui.PagingBar.java
License:Apache License
protected void updateGotoWidget(Widget widget) { widget.setVisible(computeNumPages() > 1); // Update allowed number of characters in the goto page textbox in case page size has changed (Yuck!) if (widget instanceof HorizontalPanel) { HorizontalPanel panel = (HorizontalPanel) widget; if (panel.getWidgetCount() == 3 && panel.getWidget(1) instanceof TextBox) { TextBox gotoPage = (TextBox) panel.getWidget(1); int maxlen = String.valueOf(computeNumPages()).length(); gotoPage.setMaxLength(maxlen); gotoPage.setVisibleLength(maxlen); }/*from w ww . j a v a 2s . co m*/ } }
From source file:org.gwtlib.client.table.ui.renderer.TextBoxRenderer.java
License:Apache License
public Widget render(Row row, Column column, Object value) { if (value == null || !(value instanceof String)) { return null; } else {/*from www . j a va2 s.c o m*/ TextBox textbox = new TextBox(); textbox.setText((String) value); if (_maxLength > 0) textbox.setMaxLength(_maxLength); if (_visibleLength > 0) textbox.setVisibleLength(_visibleLength); if (_title != null) textbox.setTitle(_title); return textbox; } }
From source file:org.jboss.as.console.client.shared.hosts.ConfigurationChangesEditor.java
License:Open Source License
private ToolStrip toolstripButtons() { final TextBox filter = new TextBox(); filter.setMaxLength(30); filter.setVisibleLength(20);/*from w w w . j av a 2 s. c om*/ filter.getElement().setAttribute("style", "float:right; width:120px;"); filter.addKeyUpHandler(keyUpEvent -> { String word = filter.getText(); if (word != null && word.trim().length() > 0) { filter(word); } else { clearFilter(); } }); ToolStrip topLevelTools = new ToolStrip(); final HTML label = new HTML(Console.CONSTANTS.commom_label_filter() + ": "); label.getElement().setAttribute("style", "padding-top:8px;"); topLevelTools.addToolWidget(label); topLevelTools.addToolWidget(filter); enableBtn = new ToolButton(Console.CONSTANTS.common_label_enable(), event -> presenter.enable()); disableBtn = new ToolButton(Console.CONSTANTS.common_label_disable(), event -> presenter.disable()); refreshBtn = new ToolButton(Console.CONSTANTS.common_label_refresh(), event -> presenter.loadChanges()); topLevelTools.addToolButtonRight(enableBtn); topLevelTools.addToolButtonRight(disableBtn); topLevelTools.addToolButtonRight(refreshBtn); return topLevelTools; }