@Override
 public void addAltTextHandler(TextBoxHandler handler) {
   tbAlt.addKeyPressHandler(handler);
   tbAlt.addKeyDownHandler(handler);
   tbAlt.addKeyUpHandler(handler);
   tbAlt.addFocusHandler(handler);
   tbAlt.addClickHandler(handler);
   tbAlt.addValueChangeHandler(handler);
 }
  /** This is the entry point method. */
  public void onModuleLoad() {
    sendButton = new Button("Send");
    nameField = new TextBox();
    nameField.setText("GWT User");
    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("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
    dialogBox = new DialogBox();
    dialogBox.setText("Remote Procedure Call");
    dialogBox.setAnimationEnabled(true);
    closeButton = new Button("Close");
    // We can set the id of a widget by accessing its Element
    closeButton.getElement().setId("closeButton");
    textToServerLabel = new Label();
    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
    final ClickHandler buttonClickHandler =
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            dialogBox.hide();
            sendButton.setEnabled(true);
            sendButton.setFocus(true);
          }
        };
    closeButton.addClickHandler(buttonClickHandler);

    // Add a handler to send the name to the server
    ChangeEventHandler handler = new ChangeEventHandler();
    sendButton.addClickHandler(handler);
    nameField.addKeyUpHandler(handler);
  }
Esempio n. 3
0
 private void initTitleEditor() {
   final RootPanel titlePanel = RootPanel.get("title");
   title.setVisibleLength(60);
   titlePanel.add(title);
   title.addKeyUpHandler(
       new KeyUpHandler() {
         @Override
         public void onKeyUp(final KeyUpEvent event) {
           userEditedTitle = true;
           updateOutputLocation();
         }
       });
   titleChangeListener = new TitleChangeListener();
   title.addChangeHandler(titleChangeListener);
 }
Esempio n. 4
0
  private void setupSessionNumberTextBox() {
    stopTypingSessionIdsTimer =
        new Timer() {

          @Override
          public void run() {
            final String currentContent = sessionIdsTextBox.getText().trim();

            // If session ID text box is empty then load all sessions
            if (currentContent == null || currentContent.isEmpty()) {
              sessionDataProvider.addDataDisplayIfNotExists(sessionsDataGrid);
              sessionDataForSessionIdsAsyncProvider.removeDataDisplayIfNotExists(sessionsDataGrid);

              return;
            }

            Set<String> sessionIds = new HashSet<String>();
            if (currentContent.contains(",")
                || currentContent.contains(";")
                || currentContent.contains("/")) {
              sessionIds.addAll(Arrays.asList(currentContent.split("\\s*[,;/]\\s*")));
            } else {
              sessionIds.add(currentContent);
            }

            sessionDataForSessionIdsAsyncProvider.setSessionIds(sessionIds);

            sessionDataProvider.removeDataDisplayIfNotExists(sessionsDataGrid);
            sessionDataForDatePeriodAsyncProvider.removeDataDisplayIfNotExists(sessionsDataGrid);
            sessionDataForSessionIdsAsyncProvider.addDataDisplayIfNotExists(sessionsDataGrid);
          }
        };

    sessionIdsTextBox.addKeyUpHandler(
        new KeyUpHandler() {
          @Override
          public void onKeyUp(KeyUpEvent event) {
            sessionsFrom.setValue(null);
            sessionsTo.setValue(null);
            stopTypingSessionIdsTimer.schedule(500);
          }
        });
  }