Package com.google.gwt.event.dom.client

Examples of com.google.gwt.event.dom.client.KeyPressHandler


    providerId = new NpTextBox();
    providerId.setVisibleLength(60);
    providerId.setStyleName(OpenIdResources.I.css().identifier());
    providerId.setTabIndex(0);
    providerId.addKeyPressHandler(new KeyPressHandler() {
      @Override
      public void onKeyPress(final KeyPressEvent event) {
        if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
          event.preventDefault();
          form.submit();
View Full Code Here


  protected void createWidgets() {
    nameBox = new HintTextBox();
    nameTxt = new SuggestBox(new ProjectNameSuggestOracle(), nameBox);
    nameBox.setVisibleLength(50);
    nameBox.setHintText(Util.C.defaultProjectName());
    nameBox.addKeyPressHandler(new KeyPressHandler() {
      @Override
      public void onKeyPress(KeyPressEvent event) {
        submitOnSelection = false;

        if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
          if (((DefaultSuggestionDisplay) nameTxt.getSuggestionDisplay())
              .isSuggestionListShowing()) {
            submitOnSelection = true;
          } else {
            doAddNew();
          }
        }
      }
    });
    nameTxt.addSelectionHandler(new SelectionHandler<Suggestion>() {
      @Override
      public void onSelection(SelectionEvent<Suggestion> event) {
        if (submitOnSelection) {
          submitOnSelection = false;
          doAddNew();
        }
      }
    });

    filterTxt = new HintTextBox();
    filterTxt.setVisibleLength(50);
    filterTxt.setHintText(Util.C.defaultFilter());
    filterTxt.addKeyPressHandler(new KeyPressHandler() {
      @Override
      public void onKeyPress(KeyPressEvent event) {
        if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
          doAddNew();
        }
View Full Code Here

      userNameTxt = new NpTextBox();
      userNameTxt.addKeyPressHandler(new UserNameValidator());
      userNameTxt.addStyleName(Gerrit.RESOURCES.css().accountUsername());
      userNameTxt.setVisibleLength(16);
      userNameTxt.addKeyPressHandler(new KeyPressHandler() {
        @Override
        public void onKeyPress(KeyPressEvent event) {
          if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
            doSetUserName();
          }
View Full Code Here

      public void onClick(ClickEvent event) {
        addFood();
      }
    });
    NewFoodItemList = new ListBox();
    NewFoodItemList.addKeyPressHandler(new KeyPressHandler() {
      public void onKeyPress(KeyPressEvent event) {
        if (event.getCharCode() == KeyCodes.KEY_ENTER) {
          addFood();
        }
      }
    });
    MealFlexTable.setWidget(0, 1, NewFoodItemList);
    MealFlexTable.setWidget(0, 2, AddFoodPshBtn);
    AddFoodPshBtn.setWidth("50px");
    FoodsFlexTable = new FlexTable();
    MealVerticalPanel.add(new HTML("<br/><br/>"));
    MealVerticalPanel.add(FoodsFlexTable);
    FoodsFlexTable.setWidth("500px");
    FoodsFlexTable.setText(0, 0, "Food Items");
    FoodsFlexTable.setText(0, 1, "Qty");
    FoodsFlexTable.setText(0, 2, "Cals");
    FoodsFlexTable.setText(0, 3, "Fat Cals");
    FoodsFlexTable.setText(0, 4, "Fat");
    FoodsFlexTable.setText(0, 5, "Carbs");
    FoodsFlexTable.setText(0, 6, "Protein");
    // FoodsFlexTable.setStyleName("cw-FlexTable");
    FoodsFlexTable.getCellFormatter().addStyleName(0, 0,
        "calculatorlistheader");
    FoodsFlexTable.getCellFormatter().addStyleName(0, 1,
        "calculatorlistheader");
    FoodsFlexTable.getCellFormatter().addStyleName(0, 2,
        "calculatorlistheader");
    FoodsFlexTable.getCellFormatter().addStyleName(0, 3,
        "calculatorlistheader");
    FoodsFlexTable.getCellFormatter().addStyleName(0, 4,
        "calculatorlistheader");
    FoodsFlexTable.getCellFormatter().addStyleName(0, 5,
        "calculatorlistheader");
    FoodsFlexTable.getCellFormatter().addStyleName(0, 6,
        "calculatorlistheader");
    FoodsFlexTable.setVisible(false);
    Label lblTotalCalories = new Label("Total Calories:");
    lblTotalCalories.setStylePrimaryName("gwt-TotalCa");
    MealFlexTable.setWidget(3, 0, lblTotalCalories);
    lblTotalCalories.setWidth("103px");
    TotalCalsTextBox = new TextBox();
    TotalCalsTextBox.setReadOnly(true);
    TotalCalsTextBox.setText(Integer.toString(0));
    MealFlexTable.setWidget(3, 1, TotalCalsTextBox);
    Label lblNewLabel = new Label("Meal Name:");
    MealFlexTable.setWidget(4, 0, lblNewLabel);
    MealLabelTextBox = new TextBox();
    MealFlexTable.setWidget(4, 1, MealLabelTextBox);
    SaveMealPshBtn = new Button("Save");
    SaveMealPshBtn.setEnabled(true);
    SaveMealPshBtn.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        if (MealLabelTextBox.getText().trim().equals(""))
          Window.alert("Please name this meal.");
        else {
          newMeal.setLabel(MealLabelTextBox.getText());
          newMeal.setDateOfMeal(new Date());
          meals.add(newMeal);
          saveUserMeal();
        }
      }
    });
    MealFlexTable.setWidget(4, 2, SaveMealPshBtn);
    SaveMealPshBtn.setSize("60px", "25px");

    /* Previously stored Meals */

    MealVerticalPanel.add(new HTML("</br></br>"));
    PreviousMealsFlexTable = new FlexTable();
    PreviousMealsFlexTable.setVisible(false);
    MealVerticalPanel.add(PreviousMealsFlexTable);
    PreviousMealsFlexTable.setText(0, 0, "Previous Meals:");
    PreviousMeals = new ListBox();
    PreviousMeals.setVisible(false);
    PreviousMealsFlexTable.setWidget(0, 1, PreviousMeals);
    PreviousMealsPshBtn = new Button("Copy Meal");
    PreviousMealsPshBtn.setVisible(false);
    PreviousMealsFlexTable.setWidget(0, 2, PreviousMealsPshBtn);
    PreviousMeals.addChangeHandler(new ChangeHandler() {
      @Override
      public void onChange(ChangeEvent event) {
        Meal meal = meals.get(PreviousMeals.getSelectedIndex());
        FlexTable flexTable = new FlexTable();
        flexTable.setWidth("300px");
        MealsListFlexTable.setWidget(0, 0, flexTable);
        flexTable.setText(0, 0, "Items");
        flexTable.setText(0, 1, "Qty");
        flexTable.getCellFormatter().addStyleName(0, 0,
            "calculatorlistheader");
        flexTable.getCellFormatter().addStyleName(0, 1,
            "calculatorlistheader");
        for (int i = 0; i < meal.getFoodItems().size(); i++) {
          flexTable.setText(i + 1, 0,
              "- " + meal.getFoodItems().get(i).getName());
          flexTable.setText(i + 1, 1, "x" + meal.getQuantity(i));
        }
      }
    });
    PreviousMealsPshBtn.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        if (PreviousMeals.getSelectedIndex() == -1
            || PreviousMeals.getValue(PreviousMeals
                .getSelectedIndex()) == null
            || PreviousMeals
                .getValue(PreviousMeals.getSelectedIndex())
                .trim().equals(""))
          return;
        FoodsFlexTable.setVisible(true);
        Meal meal = meals.get(PreviousMeals.getSelectedIndex());
        newMeal = new Meal();
        for (FoodItem foodItem : meal.getFoodItems()) {
          for (int i = 0; i < meal.getQuantity(foodItem); i++)
            newMeal.addFoodItem(foodItem);
          int row = newMeal.indexOfFoodItem(foodItem) + 1;
          int qty = newMeal.getQuantity(foodItem);
          final FoodItem foodItem2 = foodItem;
          FoodsFlexTable.setText(row, 0, foodItem.getName());
          FoodsFlexTable.setText(row, 1, "x" + qty);
          FoodsFlexTable.setText(row, 2,
              Double.toString((int) foodItem.getCalories() * qty));
          FoodsFlexTable.setText(
              row,
              3,
              Double.toString((int) foodItem.getFatCalories()
                  * qty));
          FoodsFlexTable.setText(row, 4,
              Double.toString((int) foodItem.getFatGrams() * qty));
          FoodsFlexTable.setText(
              row,
              5,
              Double.toString((int) foodItem.getCarbohydrates()
                  * qty));
          FoodsFlexTable.setText(row, 6,
              Double.toString((int) foodItem.getProtein() * qty));
          TotalCalsTextBox.setText(Double.toString((int) newMeal
              .totalCalories()));
          Button removeFood = new Button("x");
          removeFood.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
              int removedIndex = newMeal
                  .indexOfFoodItem(foodItem2);
              newMeal.removeFoodItem(removedIndex);
              FoodsFlexTable.removeRow(removedIndex + 1);
              TotalCalsTextBox.setText(Double
                  .toString((int) newMeal.totalCalories()));
            }
          });
          FoodsFlexTable.setWidget(row, 7, removeFood);
        }
      }
    });
    MealsListFlexTable = new FlexTable();
    MealVerticalPanel.add(MealsListFlexTable);
    MealsListFlexTable.setWidth("500px");
    // MealsListFlexTable.setStyleName("cw-FlexTable");

    /* Workout / Exercise */

    WorkoutVerticalPanel = new VerticalPanel();
    tabPanel.add(WorkoutVerticalPanel, " Workout ", false);
    WorkoutVerticalPanel.setSize("6cm", "4cm");
    tabPanel.addStyleName("table-center");
    WorkoutFlexTable = new FlexTable();
    WorkoutVerticalPanel.add(WorkoutFlexTable);
    WorkoutFlexTable.setWidth("500px");
    Label lblExerciseItem = new Label("Exercise Item:");
    WorkoutFlexTable.setWidget(0, 0, lblExerciseItem);
    lblExerciseItem.setWidth("121px");
    AddExercisePshBtn = new Button("Add");
    AddExercisePshBtn.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        addExercise();
      }
    });
    NewExerciseItemList = new ListBox();
    NewExerciseItemList.addKeyPressHandler(new KeyPressHandler() {
      public void onKeyPress(KeyPressEvent event) {
        if (event.getCharCode() == KeyCodes.KEY_ENTER) {
          addExercise();
        }
      }
View Full Code Here

     * numeric conventions - it will also allow formulas (a formula is when the
     * first value is a "=" which means it is meant to be taken as the user
     * typed)
     */
    public static KeyPressHandler getNumericFilter(final TextBox box) {
        return new KeyPressHandler() {

            public void onKeyPress(KeyPressEvent event) {
                TextBox w = (TextBox) event.getSource();
                char c = event.getCharCode();
                if ( Character.isLetter( c ) && c != '=' && !(box.getText().startsWith( "=" )) ) {
View Full Code Here

    // box, except that the input is visually masked by the browser.
    PasswordTextBox ptb = new PasswordTextBox();
    TextBox tb = new TextBox();

    // TODO(ECC) must be tested.
    tb.addKeyPressHandler(new KeyPressHandler() {

      public void onKeyPress(KeyPressEvent event) {
        if (!Character.isDigit(event.getCharCode())) {
          ((TextBox) event.getSource()).cancelKey();
        }
View Full Code Here

        event.isMetaKeyDown();
        assert event.getNativeKeyCode() > 0;
        passTest(event.getNativeEvent());
      }
    });
    textBox.addKeyPressHandler(new KeyPressHandler() {
      public void onKeyPress(KeyPressEvent event) {
        event.isAltKeyDown();
        event.isControlKeyDown();
        event.isShiftKeyDown();
        event.isMetaKeyDown();
View Full Code Here

      public void onClick(ClickEvent e) {
        setStepSize();
      }
    });
   
    mStepSizeTextBox.addKeyPressHandler(new KeyPressHandler() {
      public void onKeyPress(KeyPressEvent e) {
        if (e.getCharCode() == KeyCodes.KEY_ENTER) {
          setStepSize();
        }
      }
View Full Code Here

         public void onKeyUp(KeyUpEvent event)
         {
            maybeInvalidateSelection();
         }
      });
      filename_.addKeyPressHandler(new KeyPressHandler()
      {
         public void onKeyPress(KeyPressEvent event)
         {
            maybeInvalidateSelection();
         }
View Full Code Here

        addPanel = new HorizontalPanel();
        addPanel.addStyleName("addPanel");
        mainPanel.add(addPanel);
        {
          newSymbolTextBox = new TextBox();
          newSymbolTextBox.addKeyPressHandler(new KeyPressHandler() {
            public void onKeyPress(KeyPressEvent event) {
              if (event.getCharCode() == KeyCodes.KEY_ENTER){
                addStock();
              }
            }
View Full Code Here

TOP

Related Classes of com.google.gwt.event.dom.client.KeyPressHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.