Exemplo n.º 1
0
  private void setIcon(CellButtonBase<?> btn, ButtonScale scale) {
    switch (scale) {
      case SMALL:
        btn.setIcon(Resources.IMAGES.add16());
        break;
      case MEDIUM:
        btn.setIcon(Resources.IMAGES.add24());
        break;

      case LARGE:
        btn.setIcon(Resources.IMAGES.add32());
        break;
    }
  }
Exemplo n.º 2
0
  @Override
  public Widget asWidget() {
    if (buttons == null) {
      // Simple
      final Dialog simple = new Dialog();
      simple.setHeadingText("Dialog Test");
      simple.setPredefinedButtons(PredefinedButton.YES, PredefinedButton.NO);
      simple.setBodyStyleName("pad-text");
      simple.add(new Label(TestData.DUMMY_TEXT_SHORT));
      simple.getBody().addClassName("pad-text");
      simple.setHideOnButtonClick(true);
      simple.setWidth(300);

      // Layout
      final Dialog complex = new Dialog();
      complex.setBodyBorder(false);
      complex.getHeader().setIcon(Resources.IMAGES.side_list());
      complex.setHeadingText("BorderLayout Dialog");
      complex.setWidth(400);
      complex.setHeight(225);
      complex.setHideOnButtonClick(true);

      BorderLayoutContainer layout = new BorderLayoutContainer();
      complex.add(layout);

      // Layout - west
      ContentPanel panel = new ContentPanel();
      panel.setHeadingText("West");
      BorderLayoutData data = new BorderLayoutData(150);
      data.setMargins(new Margins(0, 5, 0, 0));
      panel.setLayoutData(data);
      layout.setWestWidget(panel);

      // Layout - center
      panel = new ContentPanel();
      panel.setHeadingText("Center");
      layout.setCenterWidget(panel);

      // Auto Size - See the JavaDoc for Window for more information on auto size
      final FlowLayoutContainer flc = new FlowLayoutContainer();
      flc.add(new HTML("Press Add or Remove to modify content"));
      final Dialog autoSize = new Dialog();
      autoSize.setBodyBorder(false);
      autoSize.setHeadingText("Auto Size Dialog");
      autoSize.setHideOnButtonClick(true);
      autoSize.setWidget(flc);
      autoSize.setPixelSize(-1, -1);
      autoSize.setMinWidth(0);
      autoSize.setMinHeight(0);
      autoSize.setResizable(false);
      autoSize.setShadow(true);
      autoSize.addButton(
          new TextButton(
              "Add",
              new SelectHandler() {
                @Override
                public void onSelect(SelectEvent event) {
                  addAutoSizeContent(flc);
                  autoSize.forceLayout();
                }
              }));
      autoSize.addButton(
          new TextButton(
              "Remove",
              new SelectHandler() {
                @Override
                public void onSelect(SelectEvent event) {
                  int lastWidget = flc.getWidgetCount() - 1;
                  if (lastWidget > 0) {
                    flc.remove(lastWidget);
                    autoSize.forceLayout();
                  }
                }
              }));

      // Buttons
      buttons = new ButtonBar();
      buttons.setWidth(400);
      buttons.getElement().setMargins(10);

      TextButton b = new TextButton("Simple");
      b.addSelectHandler(
          new SelectHandler() {
            @Override
            public void onSelect(SelectEvent event) {
              simple.show();
            }
          });
      buttons.add(b);

      b = new TextButton("Layout");
      b.addSelectHandler(
          new SelectHandler() {
            @Override
            public void onSelect(SelectEvent event) {
              complex.show();
            }
          });
      buttons.add(b);

      b = new TextButton("Auto Size");
      b.addSelectHandler(
          new SelectHandler() {
            @Override
            public void onSelect(SelectEvent event) {
              autoSize.show();
            }
          });

      buttons.add(b);

      // Add some basic content to begin with
      for (int i = 0; i < 5; i++) {
        addAutoSizeContent(flc);
      }
    }

    return buttons;
  }