private void validateInput(TextBox input) { String inputStr = input.getValue(); boolean valid = inputStr.matches("^\\d+$"); if (valid) { input.getElement().removeClassName("invalid"); } else { input.getElement().addClassName("invalid"); } if (input == widthInput) { widthValid = valid; } else { heightValid = valid; } }
protected void init(){ //Panel information this.setWidget(0,0,url); urlTB = new TextBox(); urlTB.setStyleName("bda-etlpanel-textbox"); this.setWidget(0,1,urlTB); this.setWidget(1,0,user); userTB = new TextBox(); userTB.setStyleName("bda-etlpanel-textbox"); this.setWidget(1,1,userTB); this.setWidget(2,0,password); passwordTB = new TextBox(); passwordTB.setStyleName("bda-etlpanel-textbox"); this.setWidget(2,1,passwordTB); }
private String getConfiguration() { String conf = iConfiguration; for (MatchResult matcher = iRegExp.exec(conf); matcher != null; matcher = iRegExp.exec(conf)) { Element element = DOM.getElementById(matcher.getGroup(1)); String value = ""; if ("select".equalsIgnoreCase(element.getTagName())) { ListBox list = ListBox.wrap(element); for (int i = 0; i < list.getItemCount(); i++) { if (list.isItemSelected(i)) value += (value.isEmpty() ? "" : ",") + list.getValue(i); } } else if ("input".equalsIgnoreCase(element.getTagName())) { TextBox text = TextBox.wrap(element); value = text.getText(); } else { Hidden hidden = Hidden.wrap(element); value = hidden.getValue(); } conf = conf.replace("${" + matcher.getGroup(1) + "}", value); } return conf; }
/** * Helper method called by constructor to initialize the report section */ private void initAppShare() { final HTML sharePrompt = new HTML(); sharePrompt.setHTML(MESSAGES.gallerySharePrompt()); sharePrompt.addStyleName("primary-prompt"); final TextBox urlText = new TextBox(); urlText.addStyleName("action-textbox"); urlText.setText(Window.Location.getHost() + MESSAGES.galleryGalleryIdAction() + app.getGalleryAppId()); urlText.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { urlText.selectAll(); } }); appSharePanel.add(sharePrompt); appSharePanel.add(urlText); }
/** * Creates the GUI components for search tab. * * @param searchApp: the FlowPanel that search tab will reside. */ private void addGallerySearchTab(FlowPanel searchApp) { // Add search GUI FlowPanel searchPanel = new FlowPanel(); final TextBox searchText = new TextBox(); searchText.addStyleName("gallery-search-textarea"); Button sb = new Button(MESSAGES.gallerySearchForAppsButton()); searchPanel.add(searchText); searchPanel.add(sb); searchPanel.addStyleName("gallery-search-panel"); searchApp.add(searchPanel); appSearchContent.addStyleName("gallery-search-results"); searchApp.add(appSearchContent); searchApp.addStyleName("gallery-search"); sb.addClickHandler(new ClickHandler() { // @Override public void onClick(ClickEvent event) { gallery.FindApps(searchText.getText(), 0, NUMAPPSTOSHOW, 0, true); } }); }
/** * Use this TextBox if you want to have text validation while a user is typing * * @param caption caption for leading label * @param validator The validator to use for a specific textBox */ public LabeledTextBox(String caption, Validator validator) { this.validator = validator; HorizontalPanel panel = new HorizontalPanel(); Label label = new Label(caption); panel.add(label); textbox = new TextBox(); defaultTextBoxColor = textbox.getElement().getStyle().getBorderColor(); textbox.setWidth("100%"); panel.add(textbox); panel.setCellWidth(label, "40%"); HorizontalPanel errorPanel = new HorizontalPanel(); errorLabel = new Label(""); errorPanel.add(errorLabel); VerticalPanel vp = new VerticalPanel(); vp.add(panel); vp.add(errorPanel); vp.setHeight("85px"); initWidget(vp); setWidth("100%"); }
private void validateInput() { String value = ""; switch (inputType) { case TEXTBOX: value = ((TextBox)input).getValue(); break; case TEXTAREA: value = ((TextArea)input).getValue(); break; case PASSWORD: value = ((PasswordTextBox)input).getValue(); break; } if (isOptional && value.length() == 0) { setInputValid(true); } else { if (validationStr != null) { setInputValid(value.matches(validationStr)); } else { setInputValid(true); } } }
public Map<String, String> getState() { Map<String, String> state = new HashMap<String, String>(); for (Iterator widIt = widgets.iterator(); widIt.hasNext();) { Widget w = (Widget) widIt.next(); if (w instanceof TextBox) { TextBox t = (TextBox) w; if (t.getText() != null && !t.getText().equals("")) { state.put(t.getName(), t.getText()); } } else if (w instanceof ListBox) { ListBox l = (ListBox) w; state.put(l.getName(), l.getValue(l.getSelectedIndex())); } } return state; }
private Autocomplete createAutoCompleteWithChangeListener(TextBox searchBox) { Element element = searchBox.getElement(); final Autocomplete autoComplete = Autocomplete.newInstance(element, getAutoCompleteOptions()); autoComplete.addPlaceChangeHandler(event -> { PlaceResult result = autoComplete.getPlace(); PlaceGeometry geometry = result.getGeometry(); LatLng center = geometry.getLocation(); getMapWidget().panTo(center); getMapWidget().setZoom(ZOOM); }); return autoComplete; }
public void saveClicked() { // Save the information from the input elements // in the corresponding attribute models // Note: This does not contain any validation since this is done by // every model on its own. for (Map.Entry<Attribute, Object> entry : inputModelMap.entrySet()) { if(entry.getValue() instanceof TextBox){ TextBox text = (TextBox)entry.getValue(); entry.getKey().setValue(text.getText()); } else if(entry.getValue() instanceof Element){ Element checkbox = (Element)entry.getValue(); entry.getKey().setValue(checkbox.getPropertyString("checked")); } } WCEvent event = new WCEvent(this, WCEventType.INSPECTOR_ITEM_CLICK_SAVE); fireEvent(event); }
/** * Swaps a TextBox with an element of the same type for remember password. The text box needs to be within an panel. The styles of the text box are also * copied * * @param textBox * @param elementId * @return */ @SuppressWarnings("unchecked") public static <T extends TextBox> T swap (T textBox, String elementId) { Panel parent = (Panel) textBox.getParent(); T newTextBox = null; if (textBox instanceof PasswordTextBox) { newTextBox = (T) PasswordTextBox .wrap(DOM.getElementById(elementId)); } else if (textBox instanceof TextBox) { newTextBox = (T) TextBox.wrap(DOM.getElementById(elementId)); } newTextBox.getElement().setAttribute("class", textBox.getElement().getAttribute("class")); newTextBox.removeFromParent(); parent.getElement().insertBefore(newTextBox.getElement(), textBox.getElement()); textBox.removeFromParent(); return newTextBox; }
private static HTMLPanel getCronPanel() { HTMLPanel cronPanel = new HTMLPanel(GerritCiPlugin.cronPanel.toString()); TextBox cronCommand = new TextBox(); cronCommand.setName("cronCommand"); cronCommand.setText("./scripts/cron.sh"); TextBox cronSchedule = new TextBox(); cronSchedule.setName("cronJob"); TextBox jobType = new TextBox(); jobType.setText("cron"); jobType.setName("jobType"); jobType.setVisible(false); cronPanel.add(jobType); cronPanel.addAndReplaceElement(cronCommand, "cronCommand"); cronPanel.addAndReplaceElement(cronSchedule, "cronJob"); addCommonFields(cronPanel); return cronPanel; }
public static MessageBox prompt(String caption, String message, boolean asHTML, boolean multiline, int buttons, MessageBoxListener listener) { final MessageBox mb = new MessageBox(); mb.setText(caption); mb.setButtons(buttons, listener); mb._dockPanel.add(asHTML ? new HTML(message) : new Label(message), DockPanel.NORTH); if(multiline) { mb._textArea = new TextArea(); mb._dockPanel.add(mb._textArea, DockPanel.CENTER); mb.center(); mb._textArea.setFocus(true); } else { mb._textBox = new TextBox(); mb._dockPanel.add(mb._textBox, DockPanel.CENTER); mb.center(); mb._textBox.setFocus(true); } return mb; }
private static HTMLPanel getPublishPanel() { HTMLPanel publishPanel = new HTMLPanel(GerritCiPlugin.publishJobPanel.toString()); TextBox publishCommand = new TextBox(); publishCommand.setName("publishCommand"); publishCommand.setText("./scripts/publish.sh"); TextBox publishBranchRegex = new TextBox(); publishBranchRegex.setName("publishBranchRegex"); publishBranchRegex.setText("refs/heads/(develop|master)"); TextBox jobType = new TextBox(); jobType.setText("publish"); jobType.setName("jobType"); jobType.setVisible(false); publishPanel.add(jobType); publishPanel.addAndReplaceElement(publishCommand, "publishCommand"); publishPanel.addAndReplaceElement(publishBranchRegex, "publishBranchRegex"); addCommonFields(publishPanel); return publishPanel; }
private void copy() { TextBox t = new TextBox(); try { t.setText(getText()); content.add(t); t.setFocus(true); t.selectAll(); boolean ok = execCommand("copy"); Tooltip.setLabel(copier, ok ? CopyableLabelText.I.copied() : CopyableLabelText.I.failed()); if (!ok) { // Disable JavaScript clipboard and try flash movie in another instance. UserAgent.disableJavaScriptClipboard(); } } finally { t.removeFromParent(); } }
public ChangeAppNamePopup(PreferencesCompletionCallback settingsChange) { super(); this.settingsChange = settingsChange; appNameBox = new TextBox(); appNameBox.setText(Preferences.getAppName()); FlexTable layout = new FlexTable(); layout.setWidget(0, 0, new HTML("Change ODK 2.0 App Name")); layout.setWidget(1, 0, new HTML("App Name:")); layout.setWidget(1, 1, appNameBox); AggregateButton changeAppNameButton = new AggregateButton(BUTTON_TXT, TOOLTIP_TXT, HELP_BALLOON_TXT); changeAppNameButton.addClickHandler(new ChangeAppNameHandler()); layout.setWidget(3, 0, changeAppNameButton); layout.setWidget(3, 1, new ClosePopupButton(this)); setWidget(layout); }
public FieldLabeler(String strLabel) { if( strLabel == null ) strLabel = ""; label.setText( strLabel ); panel.add( label ); if( "".equals( strLabel ) ) { labelEditor = new TextBox(); labelEditor.addKeyUpHandler( this ); labelEditor.addBlurHandler( this ); panel.add( labelEditor ); panel.showWidget( 1 ); editable = true; } else { panel.showWidget( 0 ); } }
@Inject public UriUtilScreen(PlaceManager placeManager) { super(placeManager); final Label resultLabel = new Label(); resultLabel.getElement().setId(Debug.shortName(getClass()) + "-resultLabel"); final TextBox uriCheckerBox = new TextBox(); uriCheckerBox.getElement().setId(Debug.shortName(getClass()) + "-uriCheckerBox"); uriCheckerBox.addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { if (URIUtil.isValid(uriCheckerBox.getText())) { resultLabel.setText("Not valid."); } else { resultLabel.setText("Valid. Encoded form is <" + URIUtil.encode(uriCheckerBox.getText()) + ">"); } } }); panel.add(new Label("Type URIs into this box to see if they're valid:")); panel.add(uriCheckerBox); panel.add(resultLabel); }
@PostConstruct public void postConstruct() { droppable = dragDropHelper.enableDropForWidget(new TextBox()); textBoxWidget = droppable.getDroppableWidget(); textBox = droppable.getOriginalWidget(); uiBinder.createAndBindUi(this); dropZoneGuardian = new DropZoneGuardian(droppable, mainPanel, styleNames); textBox.addBlurHandler(this); }
@PostConstruct public void postConstruct() { droppable = dragDropHelper.enableDropForWidget(new TextBox()); textBoxWidget = droppable.getDroppableWidget(); textBox = droppable.getOriginalWidget(); uiBinder.createAndBindUi(this); dropZoneGuardian = new DropZoneGuardian(droppable, moduleWidget, styleNames); }
public void bind(DroppableObject<TextBox> listBox, PresenterHandler presenterHandler) { if (presenterHandler != null) { this.presenterHandler = presenterHandler; listBox.getOriginalWidget().addBlurHandler(this); listBox.addDropHandler(this); } }
/** * Init UI * @param editable Wheather is editable */ protected void init(boolean editable){ initGridHead( 3 ); inCountBox = new TextBox(); outCountBox = new TextBox(); inCountBox.setText( "" +widget.getInNodeShapes().size() ); outCountBox.setText( "" + widget.getOutNodeShapes().size()); paramsGrid.setVisible(true); paramsGrid.setWidget( 1 , 0, new Label("Input File Number")); paramsGrid.setWidget( 1, 1, new Label("Int")); paramsGrid.setWidget( 1, 2, inCountBox ); inCountBox.setSize("95%", "100%"); inCountBox.setStyleName("okTextbox"); inCountBox.setEnabled(editable); inCountBox.setTabIndex(0); paramsGrid.setWidget( 2 , 0, new Label("Output File Number")); paramsGrid.setWidget( 2, 1, new Label("Int")); paramsGrid.setWidget( 2 , 2, outCountBox ); outCountBox.setSize("95%", "100%"); outCountBox.setStyleName("okTextbox"); outCountBox.setEnabled(editable); outCountBox.setTabIndex(1); scriptArea = new TextArea(); scriptArea.setText( widget.getProgramConf().getScriptContent()); this.add( paramsGrid ); this.add( new Label("Script")); this.add( scriptArea ); }
public boolean focus() { Widget w = getWidget(); if (w instanceof UniTimeWidget<?>) w = ((UniTimeWidget<?>)w).getWidget(); if (w instanceof Focusable) { ((Focusable)w).setFocus(true); if (w instanceof TextBox) ((TextBox)w).selectAll(); return true; } return false; }
public Integer getExpected(int column) { String text = ((TextBox)iTable.getWidget(4, 1 + column)).getText(); if (text.isEmpty()) return null; try { return Integer.parseInt(text); } catch (Exception e) { return null; } }
public Integer getEnrollment(int column) { String text = ((TextBox)iTable.getWidget(5, 1 + column)).getText(); if (text.isEmpty()) return null; try { return Integer.parseInt(text); } catch (Exception e) { return null; } }
public Integer getLastLike(int column) { String text = ((TextBox)iTable.getWidget(2, 1 + column)).getText(); if (text.isEmpty()) return null; try { return Integer.parseInt(text); } catch (Exception e) { return null; } }
public Integer getProjection(int column) { String text = ((TextBox)iTable.getWidget(3, 1 + column)).getText(); if (text.isEmpty()) return null; try { return Integer.parseInt(text); } catch (Exception e) { return null; } }
public Integer getRequested(int column) { String text = ((TextBox)iTable.getWidget(6, 1 + column)).getText(); if (text.isEmpty()) return null; try { return Integer.parseInt(text); } catch (Exception e) { return null; } }
public Integer getSnapshotExpected(int column) { String text = ((TextBox)iTable.getWidget(7, 1 + column)).getText(); if (text.isEmpty()) return null; try { return Integer.parseInt(text); } catch (Exception e) { return null; } }
public Integer getSnapshotProjection(int column) { String text = ((TextBox)iTable.getWidget(8, 1 + column)).getText(); if (text.isEmpty()) return null; try { return Integer.parseInt(text); } catch (Exception e) { return null; } }
/** * Creates a new TextBox with the given leading caption. * * @param caption caption for leading label */ public LabeledTextBox(String caption) { HorizontalPanel panel = new HorizontalPanel(); Label label = new Label(caption); panel.add(label); textbox = new TextBox(); textbox.setWidth("100%"); panel.add(textbox); panel.setCellWidth(label, "40%"); initWidget(panel); setWidth("100%"); }
/** * Creates a new additional choice dialog. */ protected AdditionalChoicePropertyEditor() { summary = new TextBox(); summary.setReadOnly(true); summary.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { openAdditionalChoiceDialog(); } }); initWidget(summary); }
private Grid createUrlGrid() { TextBox urlTextBox = new TextBox(); urlTextBox.setWidth("100%"); Grid grid = new Grid(2, 1); grid.setWidget(0, 0, new Label("Url:")); grid.setWidget(1, 0, urlTextBox); return grid; }
private void createFilterBox() { textBoxWidget = new TextBox(); textBoxWidget.setText("Search list..."); textBoxWidget.setSize(ComponentConstants.LISTVIEW_PREFERRED_WIDTH + "px", ComponentConstants.LISTVIEW_FILTER_PREFERRED_HEIGHT + "px"); textBoxWidget.setVisible(false); listViewWidget.add(textBoxWidget); }
/** * Creates a new MockTextBox component. * * @param editor editor of source file the component belongs to */ MockTextBoxBase(SimpleEditor editor, String type, ImageResource icon) { super(editor, type, icon); // Initialize mock textbox UI textBoxWidget = new TextBox(); initWrapper(textBoxWidget); }
public void setValue(String value) { switch (inputType) { case TEXTBOX: case PASSWORD: ((TextBox)input).setText(value); break; } }
public String getValue() { String value = ""; switch (inputType) { case TEXTBOX: case PASSWORD: value = ((TextBox)input).getText(); break; } return value; }
@Override public void onFocus(FocusEvent event) { // Force cursor to end of input if (input instanceof TextBox) { TextBox inputBox = (TextBox)input; inputBox.setCursorPos(inputBox.getText().length()); } }
/** * Constructs an empty widget. */ public LatLonWidget() { panel = new Grid(1,3); middle = new VerticalPanel(); rose = new Image(GWT.getModuleBaseURL()+"../images/compass_rose.png"); rose.addStyleName("OL_MAP-middle"); southLat = new TextBox(); northLat = new TextBox(); southLat.setWidth(boxWidth); northLat.setWidth(boxWidth); eastLon = new TextBox(); westLon = new TextBox(); eastLon.setWidth(boxWidth); westLon.setWidth(boxWidth); panel.setWidget(0, 0, westLon); middle.add(northLat); middle.add(rose); middle.add(southLat); panel.setWidget(0, 1, middle); panel.setWidget(0, 2, eastLon); // panel.getFlexCellFormatter().setColSpan(2, 0, 2); initWidget(panel); }
@Override public void onChange(ChangeEvent event) { TextBox w = (TextBox) event.getSource(); Widget wp = w.getParent(); Widget gp = wp.getParent(); if (gp instanceof VariableConstraintWidget) { VariableConstraintWidget vcw = (VariableConstraintWidget) gp; vcw.setApply(true); } setConstraints(); }