示例#1
0
  @Override
  public void onModuleLoad() {
    ButtonBar bar = new ButtonBar();

    //    TextButton btn = new TextButton("test");
    //    btn.setMinWidth(175);
    //    btn.setIcon(ExampleImages.INSTANCE.add24());
    //    btn.setScale(ButtonScale.MEDIUM);
    //    btn.setWidth(100);
    //    bar.add(btn);

    TextButton btn2 = new TextButton("sfd");
    btn2.setScale(ButtonScale.MEDIUM);
    bar.add(btn2);

    ToggleButton toggle = new ToggleButton("toggle");
    bar.add(toggle);

    RootPanel.get().add(bar);
    //    ButtonCellResources ba = GWT.create(ButtonCellResources.class);
    //    ba.buttonStyle().ensureInjected();
    //
    //    Scheduler.get().scheduleDeferred(new ScheduledCommand() {
    //
    //      @Override
    //      public void execute() {
    //        final ButtonBar bar = new ButtonBar();
    //        bar.setPosition(50, 50);
    //
    //        final Button btn = new Button();
    //        // btn.setText("Click Me");
    //        // btn.setWidth(55);
    //        btn.setScale(ButtonScale.LARGE);
    //        // btn.setPixelSize(200, 100);
    //
    //        btn.setIcon(ExampleImages.INSTANCE.add24());
    //
    //        // btn.setIconAlign(IconAlign.BOTTOM);
    //        bar.add(btn);
    //
    //        Button menuButton = new Button("Split Button Baby");
    //        menuButton.setArrowAlign(ButtonArrowAlign.RIGHT);
    //
    //        Menu menu = new Menu();
    //        menu.add(new MenuItem("Foo"));
    //        menuButton.setMenu(menu);
    //
    //        bar.add(menuButton);
    //
    //        bar.add(new ToggleButton("toggle me"));
    //
    //        SplitButton split = new SplitButton("Split Button");
    //        split.setArrowAlign(ButtonArrowAlign.BOTTOM);
    //        split.setIcon(ExampleImages.INSTANCE.add32());
    //        split.setScale(ButtonScale.LARGE);
    //        split.setMenu(new Menu());
    //        bar.add(split);
    //
    //        // btn = new Button();
    //        // btn.setText("Click Me");
    //        // btn.setIcon(ExampleImages.INSTANCE.add16());
    //        // bar.add(btn);
    //
    //        RootPanel.get().add(bar);
    //
    //      }
    //
    //    });

  }
示例#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;
  }
示例#3
0
  public Widget asWidget() {
    FlowLayoutContainer con = new FlowLayoutContainer();
    con.addStyleName("margin-10");

    TreeStore<BaseDto> store = new TreeStore<BaseDto>(new KeyProvider());

    FolderDto root = TestData.getMusicRootFolder();
    for (BaseDto base : root.getChildren()) {
      store.add(base);
      if (base instanceof FolderDto) {
        processFolder(store, (FolderDto) base);
      }
    }

    StoreFilterField<BaseDto> filter =
        new StoreFilterField<BaseDto>() {

          @Override
          protected boolean doSelect(
              Store<BaseDto> store, BaseDto parent, BaseDto item, String filter) {
            if (item instanceof FolderDto) {
              return false;
            }

            String name = item.getName();
            name = name.toLowerCase();
            if (name.startsWith(filter.toLowerCase())) {
              return true;
            }
            return false;
          }
        };
    filter.bind(store);

    final Tree<BaseDto, String> tree =
        new Tree<BaseDto, String>(
            store,
            new ValueProvider<BaseDto, String>() {

              @Override
              public String getValue(BaseDto object) {
                return object.getName();
              }

              @Override
              public void setValue(BaseDto object, String value) {}

              @Override
              public String getPath() {
                return "name";
              }
            });
    tree.setWidth(300);
    tree.getStyle().setLeafIcon(ExampleImages.INSTANCE.music());
    ButtonBar buttonBar = new ButtonBar();

    buttonBar.add(
        new TextButton(
            "Expand All",
            new SelectHandler() {

              @Override
              public void onSelect(SelectEvent event) {
                tree.expandAll();
              }
            }));
    buttonBar.add(
        new TextButton(
            "Collapse All",
            new SelectHandler() {
              @Override
              public void onSelect(SelectEvent event) {
                tree.collapseAll();
              }
            }));

    buttonBar.setLayoutData(new MarginData(4));
    con.add(filter);
    con.add(buttonBar);
    con.add(tree);
    return con;
  }