예제 #1
0
  /** Constructs a new instance of this widget. */
  public TextBox() {

    setEnabled(true);
    m_textbox.setStyleName(CSS.textBox());
    m_textbox.getElement().setId("CmsTextBox_" + (idCounter++));

    TextBoxHandler handler = new TextBoxHandler("");
    m_textbox.addMouseOverHandler(handler);
    m_textbox.addMouseOutHandler(handler);
    m_textbox.addFocusHandler(handler);
    m_textbox.addBlurHandler(handler);
    m_textbox.addValueChangeHandler(handler);
    m_textbox.addKeyPressHandler(handler);

    m_handler = handler;

    m_textboxContainer.setStyleName(CSS.textBoxPanel());
    m_textboxContainer.addStyleName(I_LayoutBundle.INSTANCE.generalCss().cornerAll());
    m_textboxContainer.addStyleName(I_LayoutBundle.INSTANCE.generalCss().textMedium());
    m_panel.add(m_textboxContainer);
    m_panel.add(m_error);
    m_textboxContainer.add(m_textbox);
    m_textboxContainer.setPaddingX(4);
    sinkEvents(Event.ONPASTE);
    initWidget(m_panel);
  }
예제 #2
0
  /**
   * Enables or disables read-only mode.
   *
   * <p>
   *
   * @param readOnly if true, enables read-only mode, else disables it
   */
  public void setReadOnly(boolean readOnly) {

    m_textbox.setReadOnly(readOnly);
    if (readOnly) {
      addStyleName(CSS.textBoxReadOnly());
    } else {
      removeStyleName(CSS.textBoxReadOnly());
    }
  }
예제 #3
0
  /**
   * Enables or disables the "ghost mode" style.
   *
   * <p>This *only* changes the style, not the actual mode.
   *
   * @param enabled true if the ghost mode style should be enabled, false if it should be disabled
   */
  public void setGhostStyleEnabled(boolean enabled) {

    if (enabled) {
      m_textbox.addStyleName(CSS.textboxGhostMode());
    } else {
      m_textbox.removeStyleName(CSS.textboxGhostMode());
      if (m_clearOnChangeMode) {
        setText("");
      }
    }
  }
예제 #4
0
  /** @see com.alkacon.geranium.client.ui.input.I_FormWidget#setErrorMessage(java.lang.String) */
  public void setErrorMessage(String errorMessage) {

    if (ClientStringUtil.isNotEmptyOrWhitespaceOnly(errorMessage)) {
      if (ClientStringUtil.isNotEmptyOrWhitespaceOnly(m_errorMessageWidth)) {
        m_error.setWidth(m_errorMessageWidth);
      } else {
        m_error.setWidth((getOffsetWidth() - 8) + Unit.PX.toString());
      }
      m_textboxContainer.removeStyleName(CSS.textBoxPanel());
      m_textboxContainer.addStyleName(CSS.textBoxPanelError());
    } else {
      m_textboxContainer.removeStyleName(CSS.textBoxPanelError());
      m_textboxContainer.addStyleName(CSS.textBoxPanel());
    }
    m_error.setText(errorMessage);
  }
예제 #5
0
  /** @see com.alkacon.geranium.client.ui.input.I_FormWidget#setEnabled(boolean) */
  public void setEnabled(boolean enabled) {

    if (!m_enabled && enabled) {
      // if the state changed to enable then add the stored handlers
      // copy the stored handlers into a new list to avoid concurred access to the list
      List<ClickHandler> handlers = new ArrayList<ClickHandler>(m_clickHandlers);
      m_clickHandlers.clear();
      for (ClickHandler handler : handlers) {
        addClickHandler(handler);
      }
      m_textboxContainer.removeStyleName(CSS.textBoxPanelDisabled());
      m_enabled = true;
    } else if (m_enabled && !enabled) {
      // if state changed to disable then remove all click handlers
      for (HandlerRegistration registration : m_clickHandlerRegistrations) {
        registration.removeHandler();
      }
      m_clickHandlerRegistrations.clear();
      m_textboxContainer.addStyleName(CSS.textBoxPanelDisabled());
      setErrorMessage(null);
      m_enabled = false;
    }
    m_textbox.setEnabled(m_enabled);
  }
예제 #6
0
  /**
   * Sets the changed style on the text box.
   *
   * <p>
   */
  public void setChangedStyle() {

    m_textbox.addStyleName(CSS.changed());
  }