Exemplo n.º 1
0
        @Override
        public void onKeyPress(KeyPressEvent event) {

          if (isReadOnly() || !isEnabled()) {
            return;
          }

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

          switch (keyCode) {
            case KeyCodes.KEY_LEFT:
            case KeyCodes.KEY_RIGHT:
            case KeyCodes.KEY_BACKSPACE:
              // case KeyCodes.KEY_DELETE:
            case KeyCodes.KEY_TAB:
            case KeyCodes.KEY_UP:
            case KeyCodes.KEY_DOWN:
              return;
          }

          char charCode = event.getCharCode();

          // check for decimal ','
          if (('.' == charCode || ',' == charCode)
              && (getValue() == null || (!getText().contains(",") && !getText().contains(".")))) {
            return;
          }

          // filter out non-digits
          if (Character.isDigit(charCode)) {
            return;
          }

          cancelKey();
        }
    @Override
    public void onKeyPress(KeyPressEvent event) {

      if (!Character.isDigit(event.getCharCode())) {
        ((TextBox) event.getSource()).cancelKey();
      }
    }
Exemplo n.º 3
0
    @Override
    public void onKeyPress(KeyPressEvent event) {
      if (isReadOnly()
          || !isEnabled()
          || event.getNativeEvent().getCtrlKey()
          || event.getNativeEvent().getAltKey()) {
        return;
      }

      switch (event.getNativeEvent().getKeyCode()) {
        case KeyCodes.KEY_LEFT:
        case KeyCodes.KEY_RIGHT:
        case KeyCodes.KEY_BACKSPACE:
        case KeyCodes.KEY_DELETE:
        case KeyCodes.KEY_UP:
        case KeyCodes.KEY_PAGEUP:
        case KeyCodes.KEY_DOWN:
        case KeyCodes.KEY_PAGEDOWN:
        case KeyCodes.KEY_TAB:
          return;
      }

      String newText = getNewText(event.getCharCode());
      if ("-".equals(newText)
          || numberType == NumberType.DECIMAL
              && newText.endsWith(".")
              && newText.length() > 1
              && !newText.substring(0, newText.length() - 1).contains(".")) {
        return;
      }

      cancelKey();
      setValue(newText, true);
    }
Exemplo n.º 4
0
    /**
     * @see
     *     com.google.gwt.event.dom.client.KeyPressHandler#onKeyPress(com.google.gwt.event.dom.client.KeyPressEvent)
     */
    public void onKeyPress(KeyPressEvent event) {

      if (event.getSource() == m_box) {
        onDateBoxKeyPress(event);
      } else if (event.getSource() == m_time) {
        onTimeKeyPressed(event);
      }
    }
Exemplo n.º 5
0
 public void onKeyPress(KeyPressEvent event) {
   for (KeyPressPreviewHandler handler : keyPressPreviewHandlers_) {
     if (handler.previewKeyPress(event.getCharCode())) {
       event.preventDefault();
       event.stopPropagation();
       return;
     }
   }
 }
Exemplo n.º 6
0
 @UiHandler("message")
 void onMessageKey(KeyPressEvent event) {
   if ((event.getCharCode() == '\n' || event.getCharCode() == KeyCodes.KEY_ENTER)
       && event.isControlKeyDown()) {
     event.preventDefault();
     event.stopPropagation();
     onSend(null);
   }
 }
 @Override
 public void onKeyPress(KeyPressEvent event) {
   // if the key is enter in the search box, search
   if (event.getSource() == searchBox
       && event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER
       && !event.isAnyModifierKeyDown()) {
     // should send the correct sender
     onClick(null);
   }
 }
Exemplo n.º 8
0
 @Override
 public void onKeyPress(KeyPressEvent event) {
   // for default text
   if (moreInfoText.equals(textbox.getText())
       && !(event.getNativeEvent().getKeyCode() == KeyCodes.KEY_TAB)) {
     hidePrompt();
   }
   if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
     enterKeyPressed(event);
   }
 }
Exemplo n.º 9
0
  /**
   * Fired when a keyboard action generates a character. This occurs after onKeyDown and onKeyUp are
   * fired for the physical key that was pressed.
   *
   * <p>It should be noted that many browsers do not generate keypress events for non-printing
   * keyCode values, such as KEY_ENTER or arrow keys. These keyCodes can be reliably captured either
   * with onKeyDown(Widget, char, int) or onKeyUp(Widget, char, int).
   *
   * <p>Subclasses that override this method must call <tt>super.onKeyPress(sender, keyCode,
   * modifiers)</tt> to ensure that the Widget recieves its events.
   *
   * @param sender the widget that was focused when the event occurred.
   * @see com.google.gwt.user.client.ui.KeyboardListener
   */
  public void onKeyPress(KeyPressEvent event) {
    Widget sender = (Widget) event.getSource();
    char keyCode = event.getCharCode();

    if (sender == tbHexColor) {
      // Disallow non-hex in hexadecimal boxes
      if ((!Character.isDigit(keyCode))
          && (keyCode != 'A')
          && (keyCode != 'a')
          && (keyCode != 'B')
          && (keyCode != 'b')
          && (keyCode != 'C')
          && (keyCode != 'c')
          && (keyCode != 'D')
          && (keyCode != 'd')
          && (keyCode != 'E')
          && (keyCode != 'e')
          && (keyCode != 'F')
          && (keyCode != 'f')
          && (keyCode != (char) KeyCodes.KEY_TAB)
          && (keyCode != (char) KeyCodes.KEY_BACKSPACE)
          && (keyCode != (char) KeyCodes.KEY_DELETE)
          && (keyCode != (char) KeyCodes.KEY_ENTER)
          && (keyCode != (char) KeyCodes.KEY_HOME)
          && (keyCode != (char) KeyCodes.KEY_END)
          && (keyCode != (char) KeyCodes.KEY_LEFT)
          && (keyCode != (char) KeyCodes.KEY_UP)
          && (keyCode != (char) KeyCodes.KEY_RIGHT)
          && (keyCode != (char) KeyCodes.KEY_DOWN)) {
        ((TextBox) sender).cancelKey();
      }
    } else {
      // Disallow non-numerics in numeric boxes
      if ((!Character.isDigit(keyCode))
          && (keyCode != (char) KeyCodes.KEY_TAB)
          && (keyCode != (char) KeyCodes.KEY_BACKSPACE)
          && (keyCode != (char) KeyCodes.KEY_DELETE)
          && (keyCode != (char) KeyCodes.KEY_ENTER)
          && (keyCode != (char) KeyCodes.KEY_HOME)
          && (keyCode != (char) KeyCodes.KEY_END)
          && (keyCode != (char) KeyCodes.KEY_LEFT)
          && (keyCode != (char) KeyCodes.KEY_UP)
          && (keyCode != (char) KeyCodes.KEY_RIGHT)
          && (keyCode != (char) KeyCodes.KEY_DOWN)) {
        ((TextBox) sender).cancelKey();
      }
    }
  }
Exemplo n.º 10
0
      public void onKeyPress(KeyPressEvent event) {
        if (event.getCharCode() == KeyCodes.KEY_ENTER) {
          hideSuggestionList();
        }

        delegateEvent(SuggestTextBox_v3.this, event);
      }
Exemplo n.º 11
0
  /**
   * The date box on key down action.
   *
   * <p>
   *
   * <ul>
   *   <li>If enter or tab is pressed in the date box the date time picker should be updated with
   *       the value from the date box.
   *   <li>If the escape key is pressed the picker should be hided.
   *   <li>If the up key is pressed the value should be taken from the date box.
   *   <li>If the down key is pressed the picker should be hided.
   * </ul>
   *
   * @param event the key down event
   */
  protected void onDateBoxKeyPress(KeyPressEvent event) {

    switch (event.getNativeEvent().getKeyCode()) {
      case KeyCodes.KEY_ENTER:
      case KeyCodes.KEY_TAB:
      case KeyCodes.KEY_ESCAPE:
      case KeyCodes.KEY_UP:
        updateFromTextBox();
        hidePopup();
        break;
      case KeyCodes.KEY_DOWN:
        showPopup();
        break;
      default:
        hidePopup();
        Scheduler.get()
            .scheduleDeferred(
                new ScheduledCommand() {

                  public void execute() {

                    updateCloseBehavior();
                    if (isValideDateBox()) {
                      setErrorMessage(null);
                    }
                  }
                });
        break;
    }
  }
 @Override
 public void onKeyPress(com.google.gwt.event.dom.client.KeyPressEvent event) {
   if (event.getCharCode() != KeyCodes.KEY_ENTER) {
     return;
   }
   // TODO: figure out why this event is being sent twice
   // hiddenItem.setValue(searchBarItem.getSearchBar().getValue());
   fetchFilteredCarouselData();
 }
Exemplo n.º 13
0
 /**
  * The onKeyPress method handles all keys that were held down and then lifted up, after the
  * KeyDown and KeyUp events are triggered
  */
 @Override
 public void onKeyPress(KeyPressEvent event) {
   code = new Code(event);
   if (code.getCharCode() > 31 && code.getCharCode() < 127) {
     processCode(code);
     event.getNativeEvent().stopPropagation();
     event.getNativeEvent().preventDefault();
   }
 }
Exemplo n.º 14
0
  public void onKeyPress(KeyPressEvent event) {
    Widget sender = (Widget) event.getSource();

    if (sender == tbS1) {
      countCharacters(3, tbS1);
    } else if (sender == tbS2) {
      countCharacters(4, tbS2);
    }
  }
Exemplo n.º 15
0
    public void onKeyPress(KeyPressEvent event) {
      // hide pattern field/label, turn off star
      if (event.getCharCode() == KeyCodes.KEY_ENTER) {
        return;
      }

      patternNameLabel.setText("");
      patternNameLabel.setVisible(false);
      patternNameField.setValue("", true);
      patternNameField.setVisible(false);
      currentSearchId = 0;
      starImage.setUrl(STAR_OFF_URL);

      if (event.getCharCode() == KeyCodes.KEY_ESCAPE) {
        autoCompletePatternField.hideSuggestionList();
        event.preventDefault();
        event.stopPropagation();
      }
    }
Exemplo n.º 16
0
 public void onKeyPress(KeyPressEvent ev) {
   final char keyCode = ev.getCharCode();
   if (keyCode == KeyCodes.KEY_ENTER) {
     DeferredCommand.addCommand(
         new Command() {
           public void execute() {
             checkForChange();
           }
         });
   }
 }
Exemplo n.º 17
0
 @Override
 public void onKeyPress(KeyPressEvent event) {
   Event nativeEvent = (Event) event.getNativeEvent();
   if (!ignoreNextKeyPress) {
     if (!nativeEvent.isCancelled()) {
       handleRepeatableKey(nativeEvent);
     }
   } else if (cancelNextKeyPress) {
     nativeEvent.xPreventDefault();
   }
   ignoreNextKeyPress = false;
   cancelNextKeyPress = false;
 }
Exemplo n.º 18
0
    public void onKeyPress(KeyPressEvent e) {
      // iOS: we do receive the event but nothing is actually printed
      // because focus moved from dummy textarea into editor

      final String charcode = e.getCharCode() + "";
      if (MyCellEditorW.this.allowAutoEdit) {
        app.getGuiManager()
            .invokeLater(
                new Runnable() {

                  public void run() {
                    String text = autoCompleteTextField.getText();
                    if (text == null || text.length() == 0) {
                      autoCompleteTextField.setText(charcode);
                    }
                  }
                });
        MyCellEditorW.this.allowAutoEdit = false;
      }

      // stopping propagation is needed to prevent
      // the prevention of the default action at another place
      e.stopPropagation();
    }
Exemplo n.º 19
0
 protected void allowDigitsOnly(KeyPressEvent event) {
   event.getNativeEvent().getKeyCode();
   // This is for support for firefox for special characters like enter,tab,etc...
   if (event.getUnicodeCharCode() == 0) {
     return;
   }
   if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_BACKSPACE
       || event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER
       || event.getNativeEvent().getKeyCode() == KeyCodes.KEY_TAB
       || event.getNativeEvent().getKeyCode() == 46 /*dot symbol*/
       || event.getUnicodeCharCode() == 46 /*firefox dot symbol*/
       || event.getNativeEvent().getKeyCode() == 45 /*minus symbol*/
       || event.getUnicodeCharCode() == 45 /*firefox minus symbol*/) {
     return;
   }
   if (!Character.isDigit(event.getCharCode())) {
     setMessage("invalid value");
     textbox.cancelKey();
   } else {
     clearMessage();
   }
 }
Exemplo n.º 20
0
    /**
     * @see
     *     com.google.gwt.event.dom.client.KeyPressHandler#onKeyPress(com.google.gwt.event.dom.client.KeyPressEvent)
     */
    public void onKeyPress(KeyPressEvent event) {

      int keyCode = event.getNativeEvent().getKeyCode();
      if (!isNavigationKey(keyCode)) {
        setGhostMode(false);
      }
      if (isTriggerChangeOnKeyPress()) {
        Scheduler.get()
            .scheduleDeferred(
                new ScheduledCommand() {

                  public void execute() {

                    checkForChange();
                  }
                });
      }
    }
Exemplo n.º 21
0
  /**
   * If the user presses enter in the time field the value of the picker should be updated and the
   * the popup should be closed.
   *
   * <p>In any other case the popup should be prevented to being closed.
   *
   * <p>
   *
   * @param event the key pressed event
   */
  protected void onTimeKeyPressed(KeyPressEvent event) {

    switch (event.getCharCode()) {
      case KeyCodes.KEY_ENTER:
        updateFromPicker();
        hidePopup();
        break;
      default:
        Scheduler.get()
            .scheduleDeferred(
                new ScheduledCommand() {

                  public void execute() {

                    executeTimeAction();
                  }
                });
        break;
    }
  }
Exemplo n.º 22
0
    @Override
    public void onKeyPress(KeyPressEvent event) {

      if (!scoreTextBox.isReadOnly()) {
        if (!Character.isDigit(event.getCharCode())
            && event.getNativeEvent().getKeyCode() != KeyCodes.KEY_TAB
            && event.getNativeEvent().getKeyCode() != KeyCodes.KEY_BACKSPACE
            && event.getNativeEvent().getKeyCode() != KeyCodes.KEY_SHIFT
            && event.getNativeEvent().getKeyCode() != KeyCodes.KEY_ENTER
            && event.getNativeEvent().getKeyCode() != KeyCodes.KEY_LEFT
            && event.getNativeEvent().getKeyCode() != KeyCodes.KEY_RIGHT
            && event.getNativeEvent().getKeyCode() != KeyCodes.KEY_DELETE) {
          ((TextBox) event.getSource()).cancelKey();

        } else if (event.getNativeEvent().getKeyCode() == 46) {
          ((TextBox) event.getSource()).cancelKey();
        } else {
          saveEnabled(true);
          saveBtn.removeStyleName(CssTokens.DISABLED);
          errorLabel.setVisible(false);
        }
      }
    }
Exemplo n.º 23
0
 @Override
 public void onKeyPress(KeyPressEvent event) {
   if (event.getSource() == btnFilter) {
     handleFields();
   }
 }
Exemplo n.º 24
0
 @Override
 public HandlerRegistration addKeyPressHandler(final KeyPressHandler handler) {
   return handlers.addHandler(KeyPressEvent.getType(), handler);
 }
Exemplo n.º 25
0
  /**
   * @see
   *     com.google.gwt.event.dom.client.HasKeyPressHandlers#addKeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler)
   */
  public HandlerRegistration addKeyPressHandler(KeyPressHandler handler) {

    return m_box.addHandler(handler, KeyPressEvent.getType());
  }
Exemplo n.º 26
0
 public final void onKeyPress(final KeyPressEvent event) {
   if (event.getCharCode() == KeyCodes.KEY_ENTER) {
     scheduleEvent(event);
   }
 }
Exemplo n.º 27
0
  @Override
  public Widget asWidget() {
    ENTITY_NAME = "Zone";
    ZonePropertiesAccess propertiesAccess = GWT.create(ZonePropertiesAccess.class);
    listStore = new ListStore<Zone>(propertiesAccess.key());
    IdentityValueProvider<Zone> identity = new IdentityValueProvider<Zone>();
    numberer = new RowNumberer<Zone>(identity);
    list = new ArrayList<ColumnConfig<Zone, ?>>();
    List<ColumnConfig<Zone, ?>> list = new ArrayList<ColumnConfig<Zone, ?>>();
    ColumnConfig<Zone, Long> entityIdColumn =
        new ColumnConfig<Zone, Long>(propertiesAccess.entityId(), 30, messages.id());
    list.add(entityIdColumn);
    ColumnConfig<Zone, String> nomColumn =
        new ColumnConfig<Zone, String>(propertiesAccess.nom(), 100, messages.nom());
    list.add(nomColumn);
    columnModel = new ColumnModel<Zone>(list);
    widget = gxtUiBinder.createAndBindUi(this);
    panel.addDomHandler(
        new KeyPressHandler() {
          @Override
          public void onKeyPress(KeyPressEvent event) {
            formUpdated();
          }
        },
        KeyPressEvent.getType());
    showInfoBanner(bannerInfoIsShowed);
    // Apply editor to grid
    final GridEditing<Zone> editing = new GridInlineEditing<Zone>(grid);
    editing.addBeforeStartEditHandler(
        new BeforeStartEditHandler<Zone>() {
          @Override
          public void onBeforeStartEdit(BeforeStartEditEvent<Zone> event) {
            editing.completeEditing();
            int row = event.getEditCell().getRow();
            Zone model = listStore.get(row);
            model.setUpdating(true);
          }
        });
    editing.addCompleteEditHandler(
        new CompleteEditHandler<Zone>() {
          @Override
          public void onCompleteEdit(CompleteEditEvent<Zone> event) {
            int row = event.getEditCell().getRow();
            Zone model = listStore.get(row);
            model.setUpdating(false);
          }
        });

    TextField nomField = new TextField();
    nomField.addValidator(new MaxLengthValidator(100));
    nomField.setAllowBlank(false);
    editing.addEditor(nomColumn, nomField);

    toolBarArea.setHeaderVisible(false);
    toolsBar = new EditableGridToolsBar();
    toolsBar.getElement().getStyle().setProperty("borderBottom", "none");
    toolsBar.setPageSize(50);
    toolsBar.initialize(toolsBarAction);
    ToolTipConfig config = new ToolTipConfig();
    config = new ToolTipConfig();
    config.setBodyHtml("Prints the current document");
    config.setTitleHtml("Template Tip");
    config.setMouseOffset(new int[] {0, 0});
    config.setAnchor(Side.LEFT);
    config.setRenderer(renderer);
    config.setCloseable(true);
    config.setMaxWidth(415);
    //
    toolsBar.setToolTipConfig(config);
    toolBarArea.add(toolsBar);
    filters = new GridFilters<Zone>();
    listStore.addStoreRecordChangeHandler(
        new StoreRecordChangeHandler<Zone>() {
          @Override
          public void onRecordChange(StoreRecordChangeEvent<Zone> event) {
            Zone changedModel = event.getRecord().getModel();
            if (changedModel != null && !"REMOVE".equalsIgnoreCase(changedModel.getSTATUS())) {
              if (changedModel.getEntityId() == null) {
                changedModel.setSTATUS("INSERT");
              } else {
                changedModel.setSTATUS("MERGE");
              }
            }
          }
        });

    filters.initPlugin(grid);
    // Add Filters

    StringFilter<Zone> nomFilter = new StringFilter<Zone>(propertiesAccess.nom());
    filters.addFilter(nomFilter);
    numberer.initPlugin(grid);
    grid.setLoadMask(true);
    grid.setColumnReordering(true);
    grid.getView().setStripeRows(true);
    grid.getView().setTrackMouseOver(false);
    grid.getView().setAutoFill(true);
    GridDropTarget<Zone> target = new GridDropTarget<Zone>(grid);
    target.setAllowSelfAsSource(true);
    target.setFeedback(Feedback.INSERT);

    ViewUtils.unNotify(htmlMessage);
    grid.addCellClickHandler(
        new CellClickHandler() {
          @Override
          public void onCellClick(CellClickEvent event) {
            Zone model = grid.getSelectionModel().getSelectedItem();
            ViewUtils.showAuditInfos(htmlMessage, model.getGlobalAuditInfo());
          }
        });
    grid.getView()
        .setViewConfig(
            new GridViewConfig<Zone>() {
              @Override
              public String getColStyle(
                  Zone model,
                  ValueProvider<? super Zone, ?> valueProvider,
                  int rowIndex,
                  int colIndex) {
                return null;
              }

              @Override
              public String getRowStyle(Zone model, int rowIndex) {
                if (model.getErrorMessage() != null
                    && model.getErrorMessage().getMessage() != null
                    && !model.getErrorMessage().getMessage().trim().isEmpty()) {
                  return "errorGridRow";
                } else if ("REMOVE".equalsIgnoreCase(model.getSTATUS())) {
                  return "removedGridRow";
                } else {
                  return "gridRow";
                }
              }
            });
    panel.setHeadingText(
        messages.commune() + " (" + messages.noHeaderSelected(messages.commune()) + ")");
    return widget;
  }
Exemplo n.º 28
0
  public TextEditor(TextEntry1Space parentWidget, int userNo, int nbTextEntry) {
    super();
    parent = parentWidget;
    logVector = new Vector<String>();
    this.userNo = userNo;
    this.nbTextEntry = nbTextEntry;
    if (parentWidget instanceof AbsolutePanel) isAPanel = true;

    if (nbTextEntry == 1) // if it's training
    {
      wordlist = traininglist;
    }

    text = new Label(wordlist[0]);
    text.getElement().getStyle().setColor("#fff");
    text.getElement().getStyle().setFontSize(20, Unit.PT);
    text.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    hPanel.setWidth("100%");
    hPanel.add(text);
    this.add(hPanel);

    MultiFocus.setVisible(true);
    MultiFocus.setWidth("100%");
    MultiFocus.setHeight("100px");
    MultiFocus.setWidth("250px");

    MultiFocus.getElement().getStyle().setBackgroundColor("#fff");

    // this.add(ta);
    this.add(MultiFocus);
    this.setBorderWidth(1);

    MultiFocus.addDomHandler(
        new KeyPressHandler() { // Listen for KeyPress events on MultiFocusTextBox
          @Override
          public void onKeyPress(KeyPressEvent event) {

            if (!isStarted) {
              startTime = System.currentTimeMillis();

              if (!isSetStarted) {
                setStartTime = startTime; // set experiment start time
                isSetStarted = true;
              }

              isStarted = true;
            }
            typedText = typedText + event.getCharCode();
          }
        },
        KeyPressEvent.getType());

    MultiFocus.addDomHandler(
        new KeyUpHandler() {

          @Override
          public void onKeyUp(KeyUpEvent event) {

            if (event.getNativeEvent().getKeyCode() == 13) {

              if (isSetFinished && !isLast) { // for the second set

                log(typedText, ta.getText());
                parent.setLoggedData(logVector, false, true); // done with experiment

                iteration++;
                text.setText(secondwordlist[iteration]);

                typedText = "";
                isStarted = false;
              }

              if (isLast) {
                log(typedText, ta.getText());
                parent.setLoggedData(logVector, true, true); // done with experiment

                text.setText(secondwordlist[0]);
                typedText = "";
                isStarted = false;

                iteration = 0;
                isLast = false;
              }

              if (!isSetFinished) {

                if (!isLast) {
                  iteration++;
                  text.setText(wordlist[iteration]);

                  log(typedText, ta.getText()); // log for wordlist[iteration-1]
                  typedText = "";
                  isStarted = false;

                  if ((iteration == (wordlist.length - 1))) { // last element
                    isSetFinished = true;
                    isLast = true;
                  }
                }
              }
            }

            if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_BACKSPACE) {

              typedText = typedText + "~";
            }
          }
        },
        KeyUpEvent.getType());
  }
Exemplo n.º 29
0
 public void onKeyPress(KeyPressEvent event) {
   if (event.getCharCode() == KeyCodes.KEY_ENTER) {
     Log.debug("key press pattern name field");
     turnNameFieldIntoLabel();
   }
 }
Exemplo n.º 30
0
 @Override
 public HandlerRegistration addKeyPressHandler(KeyPressHandler handler) {
   return peer.addHandler(handler, KeyPressEvent.getType());
 }