@Override public void testTabIndex() { ValueBoxBase widget = getWidget().getValueBoxBase(); final int INITIAL_TAB_INDEX = 0; final int FINAL_TAB_INDEX = 1; // when / then widget.setTabIndex(INITIAL_TAB_INDEX); assertEquals(INITIAL_TAB_INDEX, widget.getTabIndex()); assertEquals(String.valueOf(INITIAL_TAB_INDEX), widget.getElement().getPropertyString("tabIndex")); // when / then widget.setTabIndex(FINAL_TAB_INDEX); assertEquals(FINAL_TAB_INDEX, widget.getTabIndex()); assertEquals(String.valueOf(FINAL_TAB_INDEX), widget.getElement().getPropertyString("tabIndex")); }
@Override protected void onLoad() { Field[] fields = getFields(); for (Field f : fields) { if (f.field instanceof ValueBoxBase) { final ValueBoxBase<?> tf = (ValueBoxBase<?>) f.field; tf.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { tf.selectAll(); } }); } } }
@Override public T getValue() { T value = null; if (this.takesValues instanceof ValueBoxBase<?>) { try { value = ((ValueBoxBase<T>) this.takesValues).getValueOrThrow(); } catch (final ParseException e) { final String entryAsText = ((ValueBoxBase<T>) this.takesValues).getText(); final String localizedMessage = this.messages.parseExceptionMessage(entryAsText); if (this.delegate != null) { this.delegate.recordError(localizedMessage, entryAsText, e); } } } else { value = this.takesValues.getValue(); } return value; }
public MyCell(CurriculumInterface curriculum, CurriculumClassificationInterface classification) { iCurriculum = curriculum; iClasf = classification; iPanel = new HorizontalPanel(); iTextBox = new UniTimeTextBox(6, ValueBoxBase.TextAlignment.RIGHT); iTextBox.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { try { if (iTextBox.getText().isEmpty()) { iClasf.setExpected(null); } else { iClasf.setExpected(Integer.valueOf(iTextBox.getText())); } } catch (Exception e) { iClasf.setExpected(null); } update(); for (MySumCell sum: iSums) sum.update(); } }); iRearLabel = new HTML("", false); iRearLabel.setWidth("50px"); iRearLabel.setStyleName("unitime-Label"); iRearLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); iPanel.add(iTextBox); iPanel.setCellVerticalAlignment(iTextBox, HasVerticalAlignment.ALIGN_MIDDLE); iPanel.add(iRearLabel); iPanel.setCellVerticalAlignment(iRearLabel, HasVerticalAlignment.ALIGN_MIDDLE); initWidget(iPanel); update(); }
public ShareTextBox(int column, Float share, Float defaultShare) { super(6, ValueBoxBase.TextAlignment.RIGHT); iColumn = column; iShare = share; iDefaultShare = defaultShare; addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { try { if (getText().isEmpty()) { iShare = null; } else if (getText().endsWith("%")) { iShare = (float)NF.parse(getText().substring(0, getText().length() - 1)) / 100.0f; if (iShare > 1.0f) iShare = 1.0f; if (iShare <= 0.0f) iShare = 0.0f; } else { Integer exp = iClassifications.getExpected(iColumn); if (exp == null || exp == 0) iShare = (float)NF.parse(getText()) / 100.0f; else iShare = (float)NF.parse(getText()) / iClassifications.getExpected(iColumn); if (iShare > 1.0f) iShare = 1.0f; if (iShare < 0.0f) iShare = 0.0f; } } catch (Exception e) { iShare = null; } update(); } }); update(); }
public UniTimeTextBox(int maxWidth, int width, ValueBoxBase.TextAlignment align) { this(); setWidth(width + "px"); setMaxLength(maxWidth); if (align != null) setAlignment(align); }
@UiChild(limit = 1, tagname = "editor") public void setEditor(ValueBoxBase<T> widget) { editChild = widget; editPanel.add(editChild); editProxy = null; }
private void on(GwtEvent<?> e) { if (widget.isEnabled() || !(e.getSource() instanceof FocusWidget) || !((FocusWidget) e.getSource()).isEnabled()) { if (e.getSource() instanceof ValueBoxBase) { final TextBoxBase box = ((TextBoxBase) e.getSource()); Scheduler.get() .scheduleDeferred( new ScheduledCommand() { @Override public void execute() { if (box.getValue().trim().equals(originalValue)) { widget.setEnabled(false); } } }); } return; } if (e.getSource() instanceof TextBoxBase) { onTextBoxBase((TextBoxBase) e.getSource()); } else { // For many widgets, we can assume that a change is an edit. If // a widget does not work that way, it should be special cased // above. widget.setEnabled(true); } }
/** * @param text * @return */ private String markup (ValueBoxBase<String> valueBox) { StringBuffer markdown = new StringBuffer(valueBox.getValue()); markdown.insert(valueBox.getCursorPos(), CARET_BEFORE); return PostHelper.makeMarkup(markdown.toString()) .replace(CARET_BEFORE, CARET_FINALLY) .replace(CARET_AFTER, CARET_FINALLY); }
@Override public void setValueBox(final ValueBoxBase<T> widget) { this.widget = widget; widget.addValueChangeHandler(new ValueChangeHandler<T>() { @Override public void onValueChange(final ValueChangeEvent<T> event) { presenter.onValueChanged(event.getValue()); } }); contents.add(widget); }
/** * constructor uses widget as base. * * @param ptakesValues widget which is able to set and get value from/to * @param pdecorator corresponding decorator */ public ExtendedValueBoxEditor(final TakesValue<T> ptakesValues, final AbstractDecorator<T> pdecorator) { super(null); this.messages = GWT.create(ExtendedValueBoxEditorMessages.class); this.takesValues = ptakesValues; this.decorator = pdecorator; if (this.takesValues instanceof ValueBoxBase<?>) { this.delegate = ((ValueBoxBase<T>) this.takesValues).asEditor().getDelegate(); } }
public MaskValueBoxHelper(ValueBoxBase<String> valueBox) { this.valueBox = valueBox; valueBox.addKeyDownHandler(this); valueBox.addKeyUpHandler(this); valueBox.addKeyPressHandler(this); valueBox.addBlurHandler(this); valueBox.addFocusHandler(this); valueBox.addMouseUpHandler(this); }
public static void setTextboxValueBySelectionModel(ValueBoxBase<String> textBox, SingleSelectionModel<? extends HasListboxValue> selectionModel) { HasListboxValue selected = selectionModel.getSelectedObject(); if (selected == null) { textBox.setValue(""); } else { textBox.setValue(selected.getListboxValue()); } }
public static <T> T tryValueBoxValue(ValueBoxBase<T> valueBox, String onEmptyFailText, ValueCondition<T> condition) { T result = valueBox.getValue(); if (result == null || result instanceof String && ((String) result).isEmpty()) { valueBox.setFocus(true); throw new ValueBoxEmptyException(onEmptyFailText); } if (condition != null) { condition.test(result); } return result; }
public ValueBoxBase<String> getValueBox() { return iText; }
public UniTimeTextBox(int maxWidth, ValueBoxBase.TextAlignment align) { this(maxWidth, 10 * maxWidth, align); }
public UniTimeTextBox(int maxWidth, ValueBoxBase.TextAlignment align, boolean editable) { this(maxWidth, align); setReadOnly(!editable); }
public ValueBoxBase<String> getValueBox() { return iFilter; }
private MaterialValueBoxEditor(ValueBoxBase<V> valueBoxBase) { super(valueBoxBase); this.valueBoxBase = valueBoxBase; }
public MaterialValueBox(ValueBoxBase<T> tValueBox) { this(); setup(tValueBox); }
public void setup(ValueBoxBase<T> tValueBox) { valueBoxBase = tValueBox; add(valueBoxBase); }
@Deprecated @UiChild(limit = 1) public void addValueBox(ValueBoxBase<T> widget) { setup(widget); }
@Editor.Ignore public ValueBoxBase<T> asValueBoxBase() { return valueBoxBase; }
@Ignore public ValueBoxBase<T> getValueBoxBase() { return valueBoxBase; }
protected ReadOnlyMixin<MaterialValueBox, ValueBoxBase> getReadOnlyMixin() { if (readOnlyMixin == null) { readOnlyMixin = new ReadOnlyMixin<>(this, valueBoxBase); } return readOnlyMixin; }
@Override public void onKeyUp(KeyUpEvent event) { if (event.getSource() instanceof ValueBoxBase) { handler.onTextChanged(((ValueBoxBase) event.getSource()).getText()); } }
public MySuggestBox(final MySuggestOracle oracle, ValueBoxBase<String> textArea) { this(oracle, textArea, new MySuggestionDisplay()); }
@UiChild(limit = 1, tagname = "valuebox") void setValueBox(final ValueBoxBase<T> widget);
public ValueBoxBase<String> getValueBox() { return box; }
/** * {@inheritDoc} */ @Override public ValueBoxBase<String> getLoginField() { return loginTextBox; }
/** * {@inheritDoc} */ @Override public ValueBoxBase<String> getPasswordField() { return passwordTextBox; }
/** * {@inheritDoc} */ @Override public ValueBoxBase<String> getEmailField() { return emailTextBox; }