コード例 #1
0
  /** 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);
  }
コード例 #2
0
 private Button buildRemoveParameterButton(final HorizontalPanel entry) {
   Button remButton = new Button();
   remButton.setStyleName(removeParamButton.getStyleName());
   remButton.setHTML(removeParamButton.getHTML());
   remButton.addClickHandler(
       new ClickHandler() {
         public void onClick(ClickEvent event) {
           removeParameter(entry);
           enableSaveButton();
         }
       });
   return remButton;
 }
コード例 #3
0
  private void initHandlers() {
    // Listen for mouse events on the Add button.
    addStockButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            addStock();
          }
        });

    // Listen for keyboard events in the input box.
    newSymbolTextBox.addKeyDownHandler(
        new KeyDownHandler() {
          @Override
          public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
              addStock();
            }
          }
        });
  }
コード例 #4
0
  public DescriptionCellEditor() {
    super();

    ensureResources();
    setStyleName("");

    addCloseHandler(
        new CloseHandler<PopupPanel>() {
          @Override
          public void onClose(CloseEvent<PopupPanel> event) {
            if (event.isAutoClosed()) {
              commit();
              hide();
            }
          }
        });

    VerticalPanel verticalPanel = new VerticalPanel();

    textArea = new RichTextArea();
    textArea.setTabIndex(0);
    textArea.addStyleName(resources.style().bDescriptionCellEditor__editor());
    textArea.addKeyDownHandler(
        new KeyDownHandler() {
          @Override
          public void onKeyDown(KeyDownEvent event) {
            int keyCode = event.getNativeKeyCode();
            if (keyCode == KeyCodes.KEY_ESCAPE) {
              cancelButton.setFocus(true); // or grid did not get back focus
              hide();
            } else if (keyCode == KeyCodes.KEY_ENTER && event.isControlKeyDown()) {
              okButton.setFocus(true); // or grid did not get back focus
              okButton.click();
            }
          }
        });
    VerticalPanel textAreaPanel = new VerticalPanel();
    textAreaPanel.add(textArea);

    HorizontalPanel buttonPanel = new HorizontalPanel();

    okButton = new Button(strings.ok());
    okButton.addStyleName(resources.style().bDescriptionCellEditor__ok());
    okButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            commit();
            hide();
          }
        });
    buttonPanel.add(okButton);

    cancelButton = new Button(strings.cancel());
    cancelButton.addStyleName(resources.style().bDescriptionCellEditor__cancel());
    cancelButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            hide();
          }
        });
    buttonPanel.add(cancelButton);

    textAreaPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    textAreaPanel.add(buttonPanel);

    RichTextToolbar textToolbar = new RichTextToolbar(textArea);
    SimplePanel toolBarPanel = new SimplePanel(textToolbar);
    toolBarPanel.addStyleName(resources.style().bDescriptionCellEditor__toolbar());

    verticalPanel.add(toolBarPanel);
    verticalPanel.add(textAreaPanel);

    add(verticalPanel);
  }
コード例 #5
0
  public MediaSourcePanel(
      final DeviceAudioOutServiceAsync service, final MediaSourcePanelListener listener) {
    this.service = service;
    this.listener = listener;

    source = new ListBox(false);
    source.addChangeHandler(
        new ChangeHandler() {
          @Override
          public void onChange(ChangeEvent event) {
            int selectedIndex = source.getSelectedIndex();

            if (selectedIndex >= 0)
              service.setMediaSource(
                  source.getItemText(selectedIndex),
                  new AsyncCallback<Void>() {
                    @Override
                    public void onFailure(Throwable caught) {}

                    @Override
                    public void onSuccess(Void result) {
                      updateNavItem();
                    }
                  });
          }
        });
    add(source);
    navigation = new ListBox(true);
    add(navigation);

    add = new Button("Add to queue");
    add.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            service.addToQueue(
                getSelectedNavItem(),
                new AsyncCallback<Void>() {
                  @Override
                  public void onFailure(Throwable caught) {}

                  @Override
                  public void onSuccess(Void result) {
                    listener.itemAddedToQueue();
                  }
                });
          }
        });

    open = new Button("Open");
    open.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            selectNavItem(getSelectedNavItem());
          }
        });

    back = new Button("Back");
    back.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            moveBackToParent();
          }
        });

    HorizontalPanel buttonPanel = new HorizontalPanel();
    buttonPanel.add(add);
    buttonPanel.add(open);
    buttonPanel.add(back);
    add(buttonPanel);
  }
コード例 #6
0
 @UiHandler("addParamButton")
 void onAddParamClicked(ClickEvent event) {
   addParameter("", "");
   addParamButton.setFocus(true);
   enableSaveButton();
 }
コード例 #7
0
 private void disableDeleteButton() {
   deleteButton.setEnabled(false);
 }
コード例 #8
0
 private void enableDeleteButton() {
   deleteButton.setEnabled(true);
 }
コード例 #9
0
 private void disableSaveButton() {
   saveButton.setEnabled(false);
 }
コード例 #10
0
 private void enableSaveButton() {
   if (!isConfigListEmpty()) saveButton.setEnabled(true);
 }