Example #1
0
 @Override
 public void onMouseMove(MouseMoveEvent event) {
   parent.setWidgetTopHeight(widget, event.getClientY() - offsetY, Unit.PX, height, Unit.PX);
   parent.setWidgetLeftWidth(widget, event.getClientX() - offsetX, Unit.PX, width, Unit.PX);
   parent.forceLayout();
   if (mouseMoveHandler != null) {
     mouseMoveHandler.onMouseMove(event);
   }
 }
Example #2
0
    PageSelectorItem(final WizardPageInfo pageInfo, ClickHandler clickHandler) {
      WizardResources res = WizardResources.INSTANCE;
      WizardResources.Styles styles = res.styles();

      LayoutPanel layoutPanel = new LayoutPanel();
      layoutPanel.addStyleName(styles.wizardPageSelectorItem());

      ImageResource pageImageResource = pageInfo.getImage();
      Image image = null;
      if (pageImageResource != null) {
        image = new Image(pageImageResource);
        layoutPanel.add(image);
        layoutPanel.setWidgetLeftWidth(image, 10, Unit.PX, image.getWidth(), Unit.PX);
        layoutPanel.setWidgetTopHeight(
            image, 40 - (image.getHeight() / 2), Unit.PX, image.getHeight(), Unit.PX);
      }

      FlowPanel captionPanel = new FlowPanel();
      Label titleLabel = new Label(pageInfo.getTitle());
      titleLabel.addStyleName(styles.headerLabel());
      captionPanel.add(titleLabel);
      Label subTitleLabel = new Label(pageInfo.getSubTitle());
      subTitleLabel.addStyleName(styles.subcaptionLabel());
      captionPanel.add(subTitleLabel);
      layoutPanel.add(captionPanel);
      layoutPanel.setWidgetLeftWidth(
          captionPanel, 10 + (image == null ? 0 : image.getWidth()) + 12, Unit.PX, 450, Unit.PX);
      layoutPanel.setWidgetTopHeight(captionPanel, 19, Unit.PX, 55, Unit.PX);

      Image arrowImage = new Image(res.wizardDisclosureArrow());
      layoutPanel.add(arrowImage);
      layoutPanel.setWidgetRightWidth(arrowImage, 20, Unit.PX, arrowImage.getWidth(), Unit.PX);
      layoutPanel.setWidgetTopHeight(
          arrowImage, 40 - (arrowImage.getHeight() / 2), Unit.PX, arrowImage.getHeight(), Unit.PX);

      layoutPanel.addDomHandler(clickHandler, ClickEvent.getType());

      initWidget(layoutPanel);
    }
Example #3
0
  public void attachWidgetToMouse(
      MouseDownEvent event,
      Widget w,
      MouseMoveHandler mouseMoveHandler,
      MouseUpHandler mouseUpHandler) {
    this.mouseMoveHandler = mouseMoveHandler;
    this.mouseUpHandler = mouseUpHandler;
    if (widget == w) return;

    clearWidgetFromMouse();
    widget = w;

    if (widget != null) {
      height = w.getOffsetHeight();
      width = w.getOffsetWidth();
      offsetX = event.getRelativeX(w.getElement());
      offsetY = event.getRelativeY(w.getElement());
      parent.add(widget);
      parent.setWidgetTopHeight(widget, event.getClientY() - offsetY, Unit.PX, height, Unit.PX);
      parent.setWidgetLeftWidth(widget, event.getClientX() - offsetX, Unit.PX, width, Unit.PX);
      attachHandlers();
    }
  }
Example #4
0
  public SongView() {
    LayoutPanel panel = new LayoutPanel();
    initWidget(panel);

    InlineLabel songNameLabel = new InlineLabel("Song name:");
    panel.add(songNameLabel);
    panel.setWidgetLeftWidth(songNameLabel, 0.0, Unit.PX, 90.0, Unit.PX);
    panel.setWidgetTopHeight(songNameLabel, 55.0, Unit.PX, 18.0, Unit.PX);

    songNameDisplayLabel = new InlineLabel("");
    panel.add(songNameDisplayLabel);
    panel.setWidgetLeftWidth(songNameDisplayLabel, 109.0, Unit.PX, 311.0, Unit.PX);
    panel.setWidgetTopHeight(songNameDisplayLabel, 55.0, Unit.PX, 18.0, Unit.PX);

    final TextBox searchBox = new TextBox();
    panel.add(searchBox);
    panel.setWidgetLeftWidth(searchBox, 96.0, Unit.PX, 173.0, Unit.PX);
    panel.setWidgetTopHeight(searchBox, 0.0, Unit.PX, 34.0, Unit.PX);

    InlineLabel searchBoxLabel = new InlineLabel("Search Song:");
    panel.add(searchBoxLabel);
    panel.setWidgetLeftWidth(searchBoxLabel, 0.0, Unit.PX, 90.0, Unit.PX);
    panel.setWidgetTopHeight(searchBoxLabel, 0.0, Unit.PX, 18.0, Unit.PX);

    Button searchButton = new Button("Search");
    searchButton.setText("Search");
    panel.add(searchButton);
    panel.setWidgetLeftWidth(searchButton, 275.0, Unit.PX, 81.0, Unit.PX);
    panel.setWidgetTopHeight(searchButton, 4.0, Unit.PX, 30.0, Unit.PX);

    Button BackButton = new Button("Back");
    panel.add(BackButton);
    panel.setWidgetLeftWidth(BackButton, 369.0, Unit.PX, 81.0, Unit.PX);
    panel.setWidgetTopHeight(BackButton, 0.0, Unit.PX, 30.0, Unit.PX);

    BackButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            TabberWebApp.setView(new MainView());
          }
        });

    searchButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            String songName = searchBox.getText();
            RPC.songService.findSong(
                "username",
                songName,
                new AsyncCallback<Song>() {

                  @Override
                  public void onSuccess(Song result) {
                    // Display the song in the view
                    setModel(result);
                  }

                  @Override
                  public void onFailure(Throwable caught) {
                    Util.alertWidget("Error", "Could not load song: " + caught.getMessage())
                        .center();
                  }
                });
          }
        });

    //		searchBox.addKeyPressHandler(new KeyPressHandler() {
    //
    //		      public void onKeyPress(KeyPressEvent event) {
    //		        if (!Character.isDigit(event.getCharCode())) {
    //		          ((TextBox) event.getSource()).cancelKey();
    //		        }
    //		      }
    //		    });
    //
    //
  }