Package com.google.gwt.user.client.ui

Examples of com.google.gwt.user.client.ui.TextBox


        verify(input).setValue(null);
    }

    /** Test fillInputMultiple() for ValueBoxBase, list (not empty). */
    @Test public void testFillInputMultipleValueBoxListNotEmpty() {
        TextBox input = mock(TextBox.class);
        List<String> list = new ArrayList<String>();
        list.add("hello");
        list.add("goodbye");
        ViewDataUtils.fillInputMultiple(input, list);
        verify(input).setValue("hello, goodbye");
View Full Code Here


        assertEquals(expected, ViewDataUtils.getCriteriaList(input));
    }

    /** Test getCriteriaListMultiple() for ValueBoxBase. */
    @Test public void testGetCriteriaListMultipleValueBox() {
        TextBox input = mock(TextBox.class);

        when(input.getValue()).thenReturn(null);
        when(input.getText()).thenReturn("");
        assertEquals(null, ViewDataUtils.getCriteriaListMultiple(input));

        when(input.getValue()).thenReturn(null);
        when(input.getText()).thenReturn("");
        assertEquals(null, ViewDataUtils.getCriteriaListMultiple(input));

        when(input.getValue()).thenReturn("");
        when(input.getText()).thenReturn(null);
        assertEquals(null, ViewDataUtils.getCriteriaListMultiple(input));

        when(input.getValue()).thenReturn("hello");
        when(input.getText()).thenReturn(null);
        assertEquals(null, ViewDataUtils.getCriteriaListMultiple(input));

        when(input.getValue()).thenReturn("hello");
        when(input.getText()).thenReturn("");
        assertEquals(null, ViewDataUtils.getCriteriaListMultiple(input));

        List<String> expected = new ArrayList<String>();
        expected.add("hello");
        when(input.getValue()).thenReturn("hello");
        when(input.getText()).thenReturn("text");
        assertEquals(expected, ViewDataUtils.getCriteriaListMultiple(input));

        expected = new ArrayList<String>();
        expected.add("hello");
        expected.add("goodbye");
        expected.add("farewell");
        when(input.getValue()).thenReturn("hello,goodbye,farewell");
        when(input.getText()).thenReturn("text");
        assertEquals(expected, ViewDataUtils.getCriteriaListMultiple(input));

        expected = new ArrayList<String>();
        expected.add("hello");
        expected.add("goodbye");
        expected.add("farewell");
        when(input.getValue()).thenReturn("hello, goodbye, farewell");
        when(input.getText()).thenReturn("text");
        assertEquals(expected, ViewDataUtils.getCriteriaListMultiple(input));

        expected = new ArrayList<String>();
        expected.add("hello");
        expected.add("goodbye");
        expected.add("farewell");
        when(input.getValue()).thenReturn(",hello, goodbye,,farewell, ");
        when(input.getText()).thenReturn("text");
        assertEquals(expected, ViewDataUtils.getCriteriaListMultiple(input));
    }
View Full Code Here

  /**
   * This is the entry point method.
   */
  public void onModuleLoad() {
    final Button sendButton = new Button("Login");
    final TextBox nameField = new TextBox();
    nameField.setWidth("100px");
    final PasswordTextBox passwordField = new PasswordTextBox();
    passwordField.setWidth("100px");
    final Label errorLabel = new Label();

    // We can add style names to widgets
    sendButton.addStyleName("sendButton");

    // Add the nameField and sendButton to the RootPanel
    // Use RootPanel.get() to get the entire body element
    RootPanel.get("nameFieldContainer").add(nameField);
    RootPanel.get("loginFieldContainer").add(passwordField);
    RootPanel.get("sendButtonContainer").add(sendButton);
    RootPanel.get("errorLabelContainer").add(errorLabel);

    // Focus the cursor on the name field when the app loads
    nameField.setFocus(true);
    nameField.selectAll();

    // Create the popup dialog box
    final DialogBox dialogBox = new DialogBox();
    dialogBox.setText("Remote Procedure Call");
    dialogBox.setAnimationEnabled(true);
    final Button closeButton = new Button("Close");
    // We can set the id of a widget by accessing its Element
    closeButton.getElement().setId("closeButton");
    final Label textToServerLabel = new Label();
    final HTML serverResponseLabel = new HTML();
    VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.addStyleName("dialogVPanel");
    dialogVPanel.add(new HTML("<b>Sending name to the server:</b>"));
    dialogVPanel.add(textToServerLabel);
    dialogVPanel.add(new HTML("<br><b>Server replies:</b>"));
    dialogVPanel.add(serverResponseLabel);
    dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
    dialogVPanel.add(closeButton);
    dialogBox.setWidget(dialogVPanel);

    // Add a handler to close the DialogBox
    closeButton.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        dialogBox.hide();
        sendButton.setEnabled(true);
        sendButton.setFocus(true);
      }
    });

    // Create a handler for the sendButton and nameField
    class MyHandler implements ClickHandler, KeyUpHandler {
      /**
       * Fired when the user clicks on the sendButton.
       */
      public void onClick(ClickEvent event) {
        sendNameToServer();
      }

      /**
       * Fired when the user types in the nameField.
       */
      public void onKeyUp(KeyUpEvent event) {
        if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
          sendNameToServer();
        }
      }

      /**
       * Send the name from the nameField to the server and wait for a response.
       */
      private void sendNameToServer() {
        // First, we validate the input.
        errorLabel.setText("");
        String username = nameField.getText();
        String password = passwordField.getText();
        if (!FieldVerifier.isValidName(username)) {
          errorLabel.setText("Please enter at least four characters");
          return;
        }
       
        if(!("admin".equals(username) && "admin".equals(password)))
        {
          errorLabel.setText("Invalid username and password");
          return;
        }

        // Then, we send the input to the server.
        sendButton.setEnabled(false);
        textToServerLabel.setText(username);
        serverResponseLabel.setText("");
        greetingService.greetServer(username,
            new AsyncCallback<String>() {
              public void onFailure(Throwable caught) {
                // Show the RPC error message to the user
                dialogBox
                    .setText("Remote Procedure Call - Failure");
                serverResponseLabel
                    .addStyleName("serverResponseLabelError");
                serverResponseLabel.setHTML(SERVER_ERROR);
                dialogBox.center();
                closeButton.setFocus(true);
              }

              public void onSuccess(String result) {
                dialogBox.setText("Remote Procedure Call");
                serverResponseLabel
                    .removeStyleName("serverResponseLabelError");
                serverResponseLabel.setHTML(result);
                dialogBox.center();
                closeButton.setFocus(true);
              }
            });
      }
    }

    // Add a handler to send the name to the server
    MyHandler handler = new MyHandler();
    sendButton.addClickHandler(handler);
    nameField.addKeyUpHandler(handler);
  }
View Full Code Here

  }

  public void testInsertMultipleTimes() {
    TabLayoutPanel p = new TabLayoutPanel(2, Unit.EM);

    TextBox tb = new TextBox();
    p.add(tb, "Title");
    p.add(tb, "Title");
    p.add(tb, "Title3");

    assertEquals(1, p.getWidgetCount());
    assertEquals(0, p.getWidgetIndex(tb));
    Iterator<Widget> i = p.iterator();
    assertTrue(i.hasNext());
    assertTrue(tb.equals(i.next()));
    assertFalse(i.hasNext());

    Label l = new Label();
    p.add(l, "Title");
    p.add(l, "Title");
View Full Code Here

   * Tests to ensure that arbitrary widgets can be added/inserted effectively.
   */
  public void testInsertWithWidgets() {
    TabLayoutPanel p = new TabLayoutPanel(2, Unit.EM);

    TextBox wa = new TextBox();
    CheckBox wb = new CheckBox();
    VerticalPanel wc = new VerticalPanel();
    wc.add(new Label("First"));
    wc.add(new Label("Second"));

View Full Code Here

    final FormPanel form = new FormPanel();
    form.setAction("#");
    Panel formElements = new FlowPanel();
    Label label = new Label("Search for an address:");
    formElements.add(label);
    final TextBox addressBox = new TextBox();
    addressBox.setVisibleLength(40);
    formElements.add(addressBox);
    Button submit = new Button("Search");
    submit.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        form.submit();
      }
    });
    formElements.add(submit);
    form.add(formElements);
    form.addSubmitHandler(new SubmitHandler() {
      public void onSubmit(SubmitEvent event) {
        showAddress(addressBox.getText());
        event.cancel();
      }
    });
    panel.add(form);

    map = new MapWidget(LatLng.newInstance(34, 0), 1);
    map.setSize("100%", "480px");
    panel.add(map);

    Grid grid = new Grid((sampleAddresses.length / NUM_ADDRESS_COLUMNS) + 1,
        NUM_ADDRESS_COLUMNS);

    for (int i = 0; i < sampleAddresses.length; i++) {
      final String address = sampleAddresses[i];
      Button link = new Button(address);
      // Hyperlink link = new Hyperlink(address, true,
      // "Extracting Structured Address Information");
      link.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
          addressBox.setText(address);
          form.submit();
        }
      });
      grid.setWidget(i / NUM_ADDRESS_COLUMNS, i % NUM_ADDRESS_COLUMNS, link);
    }
View Full Code Here

    Panel panel = new FlowPanel();
    final FormPanel form = new FormPanel();
    form.setAction("#");

    Panel formElements = new FlowPanel();
    final TextBox address = new TextBox();
    address.setVisibleLength(60);
    address.setText("10 10th Street, Atlanta, GA");
    formElements.add(address);
    formElements.add(buildLatLngPanel());
    this.displayLatLng(ATLANTA);

    Button submit = new Button("Go!");
    submit.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        form.submit();
      }
    });
    formElements.add(submit);
    form.add(formElements);
    form.addSubmitHandler(new SubmitHandler() {
      public void onSubmit(SubmitEvent event) {
        showAddress(address.getText());
        event.cancel();
      }
    });
    panel.add(form);
View Full Code Here

      }
    });

    HorizontalPanel controls = new HorizontalPanel();
    RichTextToolbar tb = new RichTextToolbar(this.bodyWidget);
    name = new TextBox();
    name.setText("default");
    name.setEnabled(false);
    nameEdit = new PushButton("Edit");
    nameEdit.addClickListener(new ClickListener() {
      public void onClick(Widget sender) {
View Full Code Here

     
      //label clan
      //lblNewLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
     
      //nom du clan a rechercher
      final TextBox nameClan = new TextBox();
      rootPanel.add(nameClan, 300, posTop);
      nameClan.setText("NOVA SNAIL");
      nameClan.setSize("125px", "18px");
      nameClan.addFocusHandler(new FocusHandler() {
       
        @Override
        public void onFocus(FocusEvent event) {
          // TODO Auto-generated method stub
          offsetClan = 0;
          limitClan = 100;
        }
      });
      // Focus the name clan
      nameClan.setFocus(true);
     
      //bouton login for admin functions
      final Button loginAdminButton = new Button("Admin login");
      rootPanel.add(loginAdminButton, 700, posTop);
      loginAdminButton.setSize("125px", "28px");
      loginAdminButton.setEnabled(true);
     
      //nom du login
      final TextBox nameLogin = new TextBox();
      rootPanel.add(nameLogin, 850, posTop);
      nameLogin.setText("t..");
      nameLogin.setSize("125px", "18px");
     
      nameLogin.addFocusHandler(new FocusHandler() {
       
        @Override
        public void onFocus(FocusEvent event) {
          // TODO Auto-generated method stub
          passSaving = 0;
          nbUsersToTreat = 30;
        }
      });
     
      final Button persistStatsButton = new Button("Save stats");
      rootPanel.add(persistStatsButton, 1000, posTop);
      persistStatsButton.setSize("125px", "28px");
      persistStatsButton.setEnabled(false);
     
      // Add a handler to set admin login true
      loginAdminButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
          if (nameLogin.getText().equalsIgnoreCase("thleconn")){
            persistStatsButton.setEnabled(true);
            adminLogin = true;
          }else {
            persistStatsButton.setEnabled(false);
            adminLogin = false;
View Full Code Here

     
      //label clan
      //lblNewLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
     
      //nom du clan a rechercher
      final TextBox nameClan = new TextBox();
      rootPanel.add(nameClan, 300, posTop);
      nameClan.setText("NOVA SNAIL");
      nameClan.setSize("125px", "18px");
      nameClan.addFocusHandler(new FocusHandler() {
       
        @Override
        public void onFocus(FocusEvent event) {
          // TODO Auto-generated method stub
          offsetClan = 0;
          limitClan = 100;
        }
      });
      // Focus the name clan
      nameClan.setFocus(true);
     
      //bouton login for admin functions
      final Button loginAdminButton = new Button("Admin login");
      rootPanel.add(loginAdminButton, 700, posTop);
      loginAdminButton.setSize("125px", "28px");
      loginAdminButton.setEnabled(true);
     
      //nom du login
      final TextBox nameLogin = new TextBox();
      rootPanel.add(nameLogin, 850, posTop);
      nameLogin.setText("t..");
      nameLogin.setSize("125px", "18px");
     
      nameLogin.addFocusHandler(new FocusHandler() {
       
        @Override
        public void onFocus(FocusEvent event) {
          // TODO Auto-generated method stub
          passSaving = 0;
          nbUsersToTreat = 30;
        }
      });
     
      final Button persistStatsButton = new Button("Save stats");
      rootPanel.add(persistStatsButton, 1000, posTop);
      persistStatsButton.setSize("125px", "28px");
      persistStatsButton.setEnabled(false);
     
      // Add a handler to set admin login true
      loginAdminButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
          if (nameLogin.getText().equalsIgnoreCase("thleconn")){
            persistStatsButton.setEnabled(true);
            adminLogin = true;
          }else {
            persistStatsButton.setEnabled(false);
            adminLogin = false;
View Full Code Here

TOP

Related Classes of com.google.gwt.user.client.ui.TextBox

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.