Examples of TextBox


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

  /**
   * This is the entry point method.
   */
  public void onModuleLoad() {
    final Button sendButton = new Button("Send");
    final TextBox nameField = new TextBox();
    nameField.setText("GWT User");
    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("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 textToServer = nameField.getText();
        if (!FieldVerifier.isValidName(textToServer)) {
          errorLabel.setText("Please enter at least four characters");
          return;
        }
       
        // Then, we send the input to the server.
        sendButton.setEnabled(false);
        textToServerLabel.setText(textToServer);
        serverResponseLabel.setText("");
        greetingService.greetServer(textToServer, 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

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

    /**
     * {@inheritDoc}
     */
    protected Object createComponentInstance(Object parent, DomNode element)
    {
        TextBox tb = new TextBox();
        return tb;
    }
View Full Code Here

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

  /** displays a popup to prompt the user for the URI or revert to default assignment
   * @param left
   * @param top
  */
  void promptUserUri(int left, int top) {
    final TextBoxBase textBox = new TextBox();
    final MyDialog popup = new MyDialog(textBox) {
      public boolean onKeyUpPreview(char key, int modifiers) {
        // avoid ENTER from closing the popup without proper reaction
        if ( key == KeyboardListener.KEY_ESCAPE ) {
          hide();      // only ESCAPE keystroke closes the popup
          return false;
        }
       
        if ( key == KeyboardListener.KEY_ENTER ) {
          String str = textBox.getText().trim();
          _processAccept(str, this);
        }
          return true;
        }
    };
    popup.setText("Specify the namespace root for the ontology URI");
   
    textBox.setWidth("300");
    if ( namespaceRoot != null ) {
      textBox.setText(namespaceRoot);
    }

    popup.getButtonsPanel().insert(
        new PushButton("OK", new ClickListener() {
          public void onClick(Widget sender) {
            String str = textBox.getText().trim();
            _processAccept(str, popup);
          }
        })
        , 0
    );

    if ( userGiven ) {
      popup.getButtonsPanel().insert(
          new PushButton("Revert to default", new ClickListener() {
            public void onClick(Widget sender) {
              userGiven = false;
              namespaceRoot = defaultNameSpace;
              update();
              popup.hide();
            }
          })
          , 0
      );
    }
   
    popup.setPopupPosition(left, top + 20);
    new Timer() { @Override
      public void run() {
        textBox.setFocus(true);
      }
    }.schedule(180);
   
    popup.show();

View Full Code Here

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

//      infoImg.addClickListener(new ClickListener() {
//        public void onClick(Widget sender) {
//          _pickedForInfo();        }
//      });
     
      textBox = new TextBox();
      textBox.setStylePrimaryName("SearchResultsTable-TextBox");
     
      String str = VineMain.getCodedTerm(entity.getUri());
     
      textBox.setText(str);
View Full Code Here

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

 
  private Widget _createWidgetForValue(final GuiInfo gui, String value) {
    int visLines = readOnly ? Math.min(gui.numLines, _countLines(value)) : gui.numLines;
    TextBoxBase tb;
    if ( visLines == 1 ) {
      tb = new TextBox();
    }
    else {
      TextArea ta = new TextArea();
      ta.setVisibleLines(visLines);
      tb = ta;
View Full Code Here

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

    LDCLabel = new Label("Light-duty commercial (LDC)");
    HDCLabel = new Label("Heavy-duty commercial (HDC)");
    MDBLabel = new Label("Medium-duty minibuses (MDB)");
    HDBLabel = new Label("Heavy-duty buses (HDB)")
   
    date = new TextBox();
   
    // force them to use the calendar widget
    // otherwise the startTime/endTime functions don't work
    date.setReadOnly(true);
    date.setStyleName(style.textBoxSmall());
   
    dayType = new ListBox();
    dayType.addItem("Weekday", TrafficCountRecord.DAYTYPE_WEEKDAY);
    dayType.addItem("Saturday", TrafficCountRecord.DAYTYPE_SATURDAY);
    dayType.addItem("Sunday/Holiday", TrafficCountRecord.DAYTYPE_SUNDAY_HOLIDAY);
   
    startTime = new TextBox();
    startTime.setStyleName(style.textBoxSmall());
   
    endTime = new TextBox();
    endTime.setStyleName(style.textBoxSmall());
   
    tag = new SuggestBox(tagSuggestions);
   
    W2 = new TextBox();
    W2.setStyleName(style.textBoxSmall());
   
    W3 = new TextBox();
    W3.setStyleName(style.textBoxSmall());
   
    PC = new TextBox();
    PC.setStyleName(style.textBoxSmall());
   
    TX = new TextBox();
    TX.setStyleName(style.textBoxSmall());
   
    LDV = new TextBox();
    LDV.setStyleName(style.textBoxSmall());
   
    LDC = new TextBox();
    LDC.setStyleName(style.textBoxSmall());
   
    HDC = new TextBox();
    HDC.setStyleName(style.textBoxSmall());
   
    MDB = new TextBox();
    MDB.setStyleName(style.textBoxSmall());
   
    HDB = new TextBox()
    HDB.setStyleName(style.textBoxSmall());
  }
View Full Code Here

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

//        RegisteredOntologyInfo ontologyInfo = suggestions.get(suggestion);
//        mainPanel.notifyWorkingOntologyAdded(OntologySelection.this, ontologyInfo, popup);
//      }
//    });
   
    final TextBox textBox = createTextBox(suggestions, listBox, popup);
    textBox.setWidth(width);
    hp.add(textBox);
   
//    // we use the star (*) to show the whole list of vocabs. If the user enters something
//    // different, then remove the star:
//    box.addKeyboardListener(new KeyboardListener() {
//      public void onKeyPress(Widget sender, char keyCode, int modifiers) {
//        // FIXME: if the user wants to use the down arrow to pick a suggestion after
//        // entering *, it cannot do it!
//        if ( keyCode != '*' && box.getText().trim().equals("*") ) {
//          box.setText("");
//        }
//      }
//      public void onKeyDown(Widget sender, char keyCode, int modifiers) {}
//     
//      public void onKeyUp(Widget sender, char keyCode, int modifiers) {
//        if ( keyCode == KeyboardListener.KEY_ENTER ) {
//          String selectedUri = box.getText().trim();
//          Orr.log("addVocabulary: ENTER: '" + selectedUri + "'");
//          if (selectedUri.length() > 0) {
//            if ( VineMain.containsWorkingUri(selectedUri) ) {
//              // ignore the Enter
//              return;
//            }
//            BaseOntologyInfo ontologyInfo = VineMain.getOntologyInfo(selectedUri);
//            if (ontologyInfo instanceof RegisteredOntologyInfo) {
//              // It is a registered ontology -- load it as a working one:
//              RegisteredOntologyInfo roi = (RegisteredOntologyInfo) ontologyInfo;
//              mainPanel.notifyWorkingOntologyAdded(OntologySelection.this, roi, popup);
//            }
//            else {
//              // try as an external ontology:
//              OntologySelection.this.mainPanel.addExternalOntology(selectedUri, popup);
//            }
//          }
//        }       
//      }
//    });

    popup.setText("Select an ontology");
//    hp.add(new HTML("Elements are displayed as you type. Enter * to see the full list."));

    listBox.setWidth(width);
    listBox.setVisibleItemCount(Math.min(listBox.getItemCount() + 2, 12));
    hp.add(listBox);

//    listBox.addChangeListener(new ChangeListener () {
//      public void onChange(Widget sender) {
//        String value = listBox.getValue(listBox.getSelectedIndex());
//        RegisteredOntologyInfo ontologyInfo = suggestions.get(value);
//        mainPanel.notifyWorkingOntologyAdded(OntologySelection.this, ontologyInfo, popup);
//      }
//    });

   
   
    // use a timer to request for focus in the suggest-box:
    new Timer() {
      public void run() {
//        box.setFocus(true);
        textBox.setFocus(true);
      }
    }.schedule(500);
       
   
    popup.setPopupPositionAndShow(new PopupPanel.PositionCallback() {
View Full Code Here

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

    });
  }
 
 
  private TextBox createTextBox(final Map<String,RegisteredOntologyInfo> suggestions, final ListBox listBox, final MyDialog popup) {
    final TextBox textBox = new TextBox();
    KeyboardListener kb = new KeyboardListenerAdapter() {
      String[] lastEntered = {""};
      public void onKeyUp(Widget sender, char keyCode, int modifiers) {
        String enteredText = textBox.getText().trim();
        if ( keyCode == KeyboardListener.KEY_ENTER ) {
          Orr.log("ENTER: '" + enteredText + "'");
          if (listBox.getItemCount() > 0) {
            // it means there are items in the listBox that match the entered text.
            // Take the selected item:
            enteredText = listBox.getValue(listBox.getSelectedIndex());
          }
         
          handleEnteredText(enteredText, popup);
       
        else if ( sender == textBox && listBox.getItemCount() > 0 &&
            (keyCode == KeyboardListener.KEY_UP || keyCode == KeyboardListener.KEY_DOWN) ) {
         
          if ( keyCode == KeyboardListener.KEY_UP) {
            if (listBox.getSelectedIndex() > 0) {
              listBox.setSelectedIndex(listBox.getSelectedIndex() - 1);
            }
          }
          else if ( keyCode == KeyboardListener.KEY_DOWN) {
            if (listBox.getSelectedIndex() < listBox.getItemCount() - 1) {
              listBox.setSelectedIndex(listBox.getSelectedIndex() + 1);
            }
          }
        }
        else if (! enteredText.equalsIgnoreCase(lastEntered[0])) {
          lastEntered[0] = enteredText;
          updateListBox(suggestions, listBox, enteredText);
        }
      }
     
    };
   
    textBox.addKeyboardListener(kb);
    listBox.addKeyboardListener(kb);
   
    listBox.addClickListener(new ClickListener() {
      public void onClick(Widget sender) {
        if (listBox.getSelectedIndex() > 0) {
View Full Code Here

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

        if ( rb0.isChecked() ) {
          uploadContainer.add(upload);
        }
        else {
          if ( chooseLabel == null ) {
            chooseLabel = new TextBox();
            chooseLabel.setText("");
            chooseLabel.setEnabled(false);
          }
          uploadContainer.add(chooseLabel);
        }
View Full Code Here

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

        if ( rb0.isChecked() ) {
          uploadContainer.add(upload);
        }
        else {
          if ( chooseLabel == null ) {
            chooseLabel = new TextBox();
            chooseLabel.setText("");
            chooseLabel.setEnabled(false);
          }
          uploadContainer.add(chooseLabel);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.