Exemplo n.º 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);
  }
Exemplo n.º 2
0
  protected void showEditor() {
    if (myTextEditor == null) {
      myTextEditor = new TextBox();
      myTextEditor.setStylePrimaryName("field_edit");
      myTextEditor.addValueChangeHandler(
          new ValueChangeHandler<String>() {
            public void onValueChange(ValueChangeEvent<String> aEvent) {
              hideEditor(true);
            }
          });
      myTextEditor.addBlurHandler(
          new BlurHandler() {

            public void onBlur(BlurEvent aEvent) {
              hideEditor(false);
            }
          });
    }
    if (allowHtml) {
      myTextEditor.setText(myHtmlView.getHTML());
      myOuterPanel.remove(myHtmlView);
    } else {
      myTextEditor.setText(myTextView.getText());
      myOuterPanel.remove(myTextView);
    }
    myOuterPanel.add(myTextEditor);
    myTextEditor.setFocus(true);
  }
Exemplo n.º 3
0
  /**
   * Internal method which is called when the user clicks on an editable title field.
   *
   * <p>
   */
  protected void editTitle() {

    m_title.setVisible(false);
    final TextBox box = new TextBox();
    box.setText(m_title.getText());
    box.getElement().setAttribute("size", "45");
    box.addStyleName(I_CmsInputLayoutBundle.INSTANCE.inputCss().labelInput());
    box.addStyleName(I_CmsLayoutBundle.INSTANCE.listItemWidgetCss().titleInput());
    final String originalTitle = m_title.getText();
    // wrap the boolean flag in an array so we can change it from the event handlers
    final boolean[] checked = new boolean[] {false};

    box.addBlurHandler(
        new BlurHandler() {

          /**
           * @see
           *     com.google.gwt.event.dom.client.BlurHandler#onBlur(com.google.gwt.event.dom.client.BlurEvent)
           */
          public void onBlur(BlurEvent event) {

            if (checked[0]) {
              return;
            }

            onEditTitleTextBox(box);
            checked[0] = true;
          }
        });

    box.addKeyPressHandler(
        new KeyPressHandler() {

          /**
           * @see
           *     com.google.gwt.event.dom.client.KeyPressHandler#onKeyPress(com.google.gwt.event.dom.client.KeyPressEvent)
           */
          public void onKeyPress(KeyPressEvent event) {

            if (checked[0]) {
              return;
            }

            int keycode = event.getNativeEvent().getKeyCode();

            if ((keycode == 10) || (keycode == 13)) {
              onEditTitleTextBox(box);
              checked[0] = true;
            }
            if (keycode == 27) {
              box.setText(originalTitle);
              onEditTitleTextBox(box);
              checked[0] = true;
            }
          }
        });
    m_titleRow.insert(box, 1);
    box.setFocus(true);
  }
Exemplo n.º 4
0
 protected void addListeners() {
   textbox.addKeyPressHandler(this);
   textbox.addKeyUpHandler(this);
   textbox.addKeyDownHandler(this);
   textbox.addBlurHandler(this);
   textbox.addFocusHandler(this);
   textbox.addClickHandler(this);
 }
Exemplo n.º 5
0
  private void setupPatternNameField() {
    patternNameField.setStyleName("patternNameField");
    patternNameField.setVisible(false);

    PatternNameFieldEventHandler handler = new PatternNameFieldEventHandler();
    patternNameField.addKeyPressHandler(handler);
    patternNameField.addClickHandler(handler);
    patternNameField.addBlurHandler(handler);
  }
Exemplo n.º 6
0
  public DeleteContentPopup() {
    super(false);
    add(binder.createAndBindUi(this));
    this.setGlassEnabled(true);

    h3Panel.setVisible(false);
    lblRemoving.setVisible(false);
    lblRemoving.getElement().getStyle().setMargin(26, Unit.PX);
    txtConfirmAction.setVisible(false);
    setButtonVisibility(true);
    setElementId();

    txtConfirmAction.addKeyUpHandler(new ValidateConfirmText());
    txtConfirmAction.getElement().getStyle().setColor("#515151");
    txtConfirmAction.addClickHandler(
        new ClickHandler() {

          @Override
          public void onClick(ClickEvent event) {
            if (!txtConfirmAction.getText().isEmpty()) {
              if (txtConfirmAction
                  .getText()
                  .toLowerCase()
                  .equalsIgnoreCase(i18n.GL1175().toLowerCase())) {
                txtConfirmAction.setText("");
                txtConfirmAction.getElement().getStyle().setColor("#000000");
              }
            }
          }
        });

    txtConfirmAction.addBlurHandler(
        new BlurHandler() {

          @Override
          public void onBlur(BlurEvent event) {
            if (txtConfirmAction.getText().isEmpty()) {
              txtConfirmAction.getElement().getStyle().setColor("#515151");
            }
          }
        });
    StringUtil.setAttributes(txtConfirmAction, true);
    btnNegitive.setText(StringUtil.generateMessage(i18n.GL0142()));
    btnNegitive.getElement().setAttribute("alt", StringUtil.generateMessage(i18n.GL0142()));
    btnNegitive.getElement().setAttribute("title", StringUtil.generateMessage(i18n.GL0142()));

    btnPositive.setText(StringUtil.generateMessage(i18n.GL0190()));
    btnPositive.getElement().setAttribute("alt", StringUtil.generateMessage(i18n.GL0190()));
    btnPositive.getElement().setAttribute("title", StringUtil.generateMessage(i18n.GL0190()));

    /*lblDeleteText.setText(i18n.GL2189());
    StringUtil.setAttributes(lblDeleteText.getElement(), "lblDeleteText", null, "lblDeleteText");*/

    Window.enableScrolling(false);
    AppClientFactory.fireEvent(new SetHeaderZIndexEvent(98, false));
    this.center();
  }
  @Inject
  public EditDocumentModelPlaceView(EventBus eventBus) {
    super(eventBus);
    initWidget(uiBinder.createAndBindUi(this));
    this.setPlaceTitle("Éditeur de modèle");
    this.setHelpFromFlowPanel(helpContainer);
    toolbar = new RichTextToolbar(new RichTextToolbarView());
    toolbar.setTextArea(richTextArea);
    richTextArea.setHeight("100%");
    toolbar.bind();
    toolbarContainer.add(toolbar.getView().asWidget());

    name.addStyleName(style.nameDefaultText());
    name.addFocusHandler(this);
    name.addBlurHandler(this);
    resizer = new ToBottomResizer(textContainer, eventBus);
  }
  public EditClassContentView() {
    setWidget(uiBinder.createAndBindUi(this));
    setId();
    saveBtn.setEnabled(false);
    saveBtn.addStyleName(CssTokens.DISABLED);
    coursePanel.setVisible(false);
    errorLabel.setVisible(false);

    scoreTextBox.addBlurHandler(
        new BlurHandler() {

          @Override
          public void onBlur(BlurEvent event) {
            String score = scoreTextBox.getText();
            if (!scoreTextBox.isReadOnly()) {
              if (score.isEmpty()) {
                errorLabel.setText("Please enter the minimum score");
                errorLabel.getElement().getStyle().setColor("orange");
                errorLabel.setVisible(true);
                saveEnabled(false);
                saveBtn.addStyleName(CssTokens.DISABLED);
              } else if (score != null || score != "") {
                if (Integer.parseInt(score) > 100 || Integer.parseInt(score) < 0) {
                  errorLabel.setText(i18n.GL3425());
                  errorLabel.getElement().getStyle().setColor("orange");
                  errorLabel.setVisible(true);
                  saveEnabled(false);
                  saveBtn.addStyleName(CssTokens.DISABLED);
                } else {
                  miniScore = Integer.valueOf(score);
                  saveEnabled(true);
                  saveBtn.removeStyleName(CssTokens.DISABLED);
                  errorLabel.setVisible(false);
                }
              }
            }
          }
        });
    scoreTextBox.setMaxLength(3);
    scoreTextBox.getElement().setAttribute("maxlength", "3");
    scoreTextBox.addKeyPressHandler(new NumbersOnly());
    createCourseBtn.addClickHandler(new AddCourseHandler());
  }
Exemplo n.º 9
0
  /**
   * Create a new date box.
   *
   * @param date the default date.
   * @param picker the picker to drop down from the date box
   * @param format to use to parse and format dates
   */
  public DateBox(DatePicker picker, Date date, Format format) {
    this.picker = picker;
    this.popup = new PopupPanel(true);
    assert format != null : "You may not construct a date box with a null format";
    this.format = format;

    popup.addAutoHidePartner(box.getElement());
    popup.setWidget(picker);
    popup.setStyleName("dateBoxPopup");

    initWidget(box);
    setStyleName(DEFAULT_STYLENAME);

    handler = new DateBoxHandler();
    picker.addValueChangeHandler(handler);
    box.addFocusHandler(handler);
    box.addBlurHandler(handler);
    box.addClickHandler(handler);
    box.addKeyDownHandler(handler);
    box.setDirectionEstimator(false);
    popup.addCloseHandler(handler);
    setValue(date);
  }
  public NewClasspagePopupView() {

    this.res = NewClasspagePopupCBundle.INSTANCE;
    res.css().ensureInjected();
    setWidget(uiBinder.createAndBindUi(this));
    // this.getElement().getStyle().setWidth(450,Unit.PX);
    btnCancel.addClickHandler(new CloseExistsClickHandler());
    btnAdd.addClickHandler(new AddExistsClickHandler());
    classpageTitleTxt.getElement().setAttribute("placeholder", i18n.GL1124());
    classpageTitleTxt.getElement().setAttribute("maxlength", "50");
    classpageTitleTxt.getElement().setId("txtClassPageTitle");
    StringUtil.setAttributes(classpageTitleTxt, true);
    bodyConatiner.getElement().getStyle().setPadding(15, Unit.PX);
    titlePanel.getElement().getStyle().setMarginBottom(10, Unit.PX);

    btnAdd.getElement().setId("btnAdd");
    btnAdd.setText(i18n.GL0745());
    btnAdd.getElement().setAttribute("alt", i18n.GL0745());
    btnAdd.getElement().setAttribute("title", i18n.GL0745());

    btnCancel.setText(i18n.GL0142());
    btnCancel.getElement().setId("btnCancel");
    btnCancel.getElement().setAttribute("alt", i18n.GL0142());
    btnCancel.getElement().setAttribute("title", i18n.GL0142());

    titlePanel.getElement().setInnerText(i18n.GL0318());
    titlePanel.getElement().setId("pnlTitle");
    titlePanel.getElement().setAttribute("alt", i18n.GL0318());
    titlePanel.getElement().setAttribute("title", i18n.GL0318());

    headerPanel.getElement().setInnerText(i18n.GL0747());
    headerPanel.getElement().setId("pnlHeader");
    headerPanel.getElement().setAttribute("alt", i18n.GL0747());
    headerPanel.getElement().setAttribute("title", i18n.GL0747());
    mandatoryClasspageTitleLbl.setText(i18n.GL0746());
    mandatoryClasspageTitleLbl.getElement().setId("lblMandatoryClasspageTitle");
    mandatoryClasspageTitleLbl.getElement().setAttribute("alt", i18n.GL0746());
    mandatoryClasspageTitleLbl.getElement().setAttribute("title", i18n.GL0746());

    classpageTitleTxt.addBlurHandler(
        new BlurHandler() {

          @Override
          public void onBlur(BlurEvent event) {
            Map<String, String> parms = new HashMap<String, String>();
            parms.put("text", classpageTitleTxt.getText());
            AppClientFactory.getInjector()
                .getResourceService()
                .checkProfanity(
                    parms,
                    new SimpleAsyncCallback<Boolean>() {

                      @Override
                      public void onSuccess(Boolean value) {
                        boolean isHavingBadWords = value;
                        if (value) {
                          classpageTitleTxt.getElement().getStyle().setBorderColor("orange");
                          mandatoryClasspageTitleLbl.setText(i18n.GL0554());
                          mandatoryClasspageTitleLbl.setVisible(true);
                        } else {
                          classpageTitleTxt.getElement().getStyle().clearBackgroundColor();
                          classpageTitleTxt.getElement().getStyle().setBorderColor("#ccc");
                          mandatoryClasspageTitleLbl.setVisible(false);
                        }
                      }
                    });
          }
        });

    classpageTitleTxt.addKeyUpHandler(new TitleKeyUpHandler());
    setModal(true);
    Window.enableScrolling(false);
    AppClientFactory.fireEvent(new SetHeaderZIndexEvent(98, false));
    mandatoryClasspageTitleLbl.setVisible(false);
    //		panelLoading.setVisible(false);
    panelPleaseWait.setVisible(false);
    panelLoading.setText(i18n.GL0122());
    panelControls.setVisible(true);
    show();
    center();
    classpageTitleTxt.setFocus(true);
    panelLoading.getElement().setId("pnlLoading");
    panelControls.getElement().setId("pnlControls");
  }
Exemplo n.º 11
0
  /**
   * Instantiates a new location field.
   *
   * @param form is the form or other HasComponents element that contains the field.
   * @param permission that controls the visibility of the field.
   * @param fieldLabel is the optional text to identify the field.
   * @param buttonLabel the text on the field refresh button.
   * @param tab index of the field.
   */
  public LocationField(
      HasComponents form, short[] permission, String fieldLabel, String buttonLabel, int tab) {

    initialize(panel, form, permission, CSS.cbtLocationField());

    if (fieldLabel != null) {
      this.label = new Label(fieldLabel);
      this.label.addStyleName(CSS.cbtLocationFieldLabel());
      this.label.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              showHelp();
            }
          });
      panel.add(this.label);
    }

    field.addStyleName(CSS.cbtLocationFieldField());
    field.setText(Model.BLANK);
    field.setTabIndex(tab);
    panel.add(field);

    if (buttonLabel != null) {
      this.button =
          new Button(
              buttonLabel,
              new ClickHandler() {
                public void onClick(ClickEvent event) {
                  setName(field.getText());
                }
              });
      button.addStyleName(CSS.cbtLocationFieldButton());
      panel.add(button);
    } else {
      field.addBlurHandler(
          new BlurHandler() {
            @Override
            public void onBlur(BlurEvent event) {
              if (nullable && field.getText().isEmpty()) {
                setValueAndFireChange(defaultValue);
              } else {
                setName(field.getText());
              }
            }
          });
    }

    field.addKeyDownHandler(
        new KeyDownHandler() {
          @Override
          public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
              if (nullable && field.getText().isEmpty()) {
                setValueAndFireChange(defaultValue);
              } else {
                setName(field.getText());
              }
            }
          }
        });

    panel.add(lock);
  }
Exemplo n.º 12
0
 public HandlerRegistration addBlurHandler(BlurHandler handler) {
   return textBox.addBlurHandler(handler);
 }