Java 类com.google.gwt.user.client.ui.ValueBoxBase 实例源码

项目:gwt-material    文件:MaterialValueBoxTest.java   
@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"));
}
项目:dhcalc    文件:BasePanel.java   
@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();
                }
            });
        }
    }
}
项目:gwt-bean-validators    文件:ExtendedValueBoxEditor.java   
@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;
}
项目:unitimes    文件:ClassificationsEdit.java   
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();
}
项目:unitimes    文件:CurriculaCourses.java   
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();
}
项目:unitimes    文件:UniTimeTextBox.java   
public UniTimeTextBox(int maxWidth, int width, ValueBoxBase.TextAlignment align) {
    this();
    setWidth(width + "px");
    setMaxLength(maxWidth);
    if (align != null)
        setAlignment(align);
}
项目:gerrit    文件:ValueEditor.java   
@UiChild(limit = 1, tagname = "editor")
public void setEditor(ValueBoxBase<T> widget) {
  editChild = widget;
  editPanel.add(editChild);
  editProxy = null;
}
项目:gerrit    文件:OnEditEnabler.java   
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);
  }
}
项目:unitime    文件:ClassificationsEdit.java   
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();
}
项目:unitime    文件:CurriculaCourses.java   
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();
}
项目:unitime    文件:UniTimeTextBox.java   
public UniTimeTextBox(int maxWidth, int width, ValueBoxBase.TextAlignment align) {
    this();
    setWidth(width + "px");
    setMaxLength(maxWidth);
    if (align != null)
        setAlignment(align);
}
项目:blogwt    文件:EditPostPage.java   
/**
 * @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);
}
项目:appformer    文件:ValueBoxEditorView.java   
@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);
}
项目:gwt-bean-validators    文件:ExtendedValueBoxEditor.java   
/**
 * 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();
  }
}
项目:dashbuilder    文件:ValueBoxEditorView.java   
@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);
}
项目:putnami-web-toolkit    文件:MaskValueBoxHelper.java   
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);
}
项目:gwtutil    文件:ClientUtils.java   
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());
    }
}
项目:gwtutil    文件:ClientUtils.java   
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;
}
项目:unitimes    文件:AriaSuggestBox.java   
public ValueBoxBase<String> getValueBox() {
    return iText;
}
项目:unitimes    文件:UniTimeTextBox.java   
public UniTimeTextBox(int maxWidth, ValueBoxBase.TextAlignment align) {
    this(maxWidth, 10 * maxWidth, align);
}
项目:unitimes    文件:UniTimeTextBox.java   
public UniTimeTextBox(int maxWidth, ValueBoxBase.TextAlignment align, boolean editable) {
    this(maxWidth, align);
    setReadOnly(!editable);
}
项目:unitimes    文件:FilterBox.java   
public ValueBoxBase<String> getValueBox() {
    return iFilter;
}
项目:gwt-material    文件:MaterialValueBox.java   
private MaterialValueBoxEditor(ValueBoxBase<V> valueBoxBase) {
    super(valueBoxBase);
    this.valueBoxBase = valueBoxBase;
}
项目:gwt-material    文件:MaterialValueBox.java   
public MaterialValueBox(ValueBoxBase<T> tValueBox) {
    this();
    setup(tValueBox);
}
项目:gwt-material    文件:MaterialValueBox.java   
public void setup(ValueBoxBase<T> tValueBox) {
    valueBoxBase = tValueBox;
    add(valueBoxBase);
}
项目:gwt-material    文件:MaterialValueBox.java   
@Deprecated
@UiChild(limit = 1)
public void addValueBox(ValueBoxBase<T> widget) {
    setup(widget);
}
项目:gwt-material    文件:MaterialValueBox.java   
@Editor.Ignore
public ValueBoxBase<T> asValueBoxBase() {
    return valueBoxBase;
}
项目:gwt-material    文件:MaterialValueBox.java   
@Ignore
public ValueBoxBase<T> getValueBoxBase() {
    return valueBoxBase;
}
项目:gwt-material    文件:MaterialValueBox.java   
protected ReadOnlyMixin<MaterialValueBox, ValueBoxBase> getReadOnlyMixin() {
    if (readOnlyMixin == null) {
        readOnlyMixin = new ReadOnlyMixin<>(this, valueBoxBase);
    }
    return readOnlyMixin;
}
项目:che    文件:ContributePartViewImpl.java   
@Override
public void onKeyUp(KeyUpEvent event) {
  if (event.getSource() instanceof ValueBoxBase) {
    handler.onTextChanged(((ValueBoxBase) event.getSource()).getText());
  }
}
项目:umlet    文件:MySuggestBox.java   
public MySuggestBox(final MySuggestOracle oracle, ValueBoxBase<String> textArea) {
    this(oracle, textArea, new MySuggestionDisplay());
}
项目:unitime    文件:AriaSuggestBox.java   
public ValueBoxBase<String> getValueBox() {
    return iText;
}
项目:unitime    文件:UniTimeTextBox.java   
public UniTimeTextBox(int maxWidth, ValueBoxBase.TextAlignment align) {
    this(maxWidth, 10 * maxWidth, align);
}
项目:unitime    文件:UniTimeTextBox.java   
public UniTimeTextBox(int maxWidth, ValueBoxBase.TextAlignment align, boolean editable) {
    this(maxWidth, align);
    setReadOnly(!editable);
}
项目:unitime    文件:FilterBox.java   
public ValueBoxBase<String> getValueBox() {
    return iFilter;
}
项目:appformer    文件:ValueBoxEditor.java   
@UiChild(limit = 1, tagname = "valuebox")
void setValueBox(final ValueBoxBase<T> widget);
项目:suggestfield    文件:VSuggestField.java   
public ValueBoxBase<String> getValueBox() {
    return box;
}
项目:sigmah    文件:LoginView.java   
/**
 * {@inheritDoc}
 */
@Override
public ValueBoxBase<String> getLoginField() {
    return loginTextBox;
}
项目:sigmah    文件:LoginView.java   
/**
 * {@inheritDoc}
 */
@Override
public ValueBoxBase<String> getPasswordField() {
    return passwordTextBox;
}
项目:sigmah    文件:ResetPasswordView.java   
/**
 * {@inheritDoc}
 */
@Override
public ValueBoxBase<String> getEmailField() {
    return emailTextBox;
}