Пример #1
0
 private void go() {
   target.clear();
   switch (demoList.getSelectedIndex()) {
     case 0:
       demoButtonsAndBody();
       break;
     case 1:
       demoSidebarAndMargin();
       break;
     case 2:
       demoBorder();
       break;
   }
   target.layout();
 }
Пример #2
0
  private void demoBorder() {
    target.setLayout(new RowLayout());

    LayoutPanel inner = new LayoutPanel(false); // row
    inner.add(new Thing("West"), 0.2f);
    inner.add(new Thing("Center"));
    inner.add(new Thing("East"), 0.2f);

    target.add(new Thing("North"), 0.2f);
    target.add(inner, LayoutConstraints.HIDDEN);
    target.add(new Thing("South"), 0.2f);
  }
Пример #3
0
  public RowLayoutPortlet() {
    LayoutPanel panel = new LayoutPanel();
    initWidget(panel);

    final CheckBox column = new CheckBox("Column");
    column.addValueChangeHandler(
        new ValueChangeHandler<Boolean>() {
          public void onValueChange(ValueChangeEvent<Boolean> event) {
            getTargetLayout().setColumn(column.getValue());
            target.layout();
          }
        });

    final TextBox spacing = new TextBox();
    spacing.setVisibleLength(4);
    spacing.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            try {
              getTargetLayout().setSpacing(Integer.parseInt(spacing.getText()));
            } catch (NumberFormatException e) {
              // ignore
            }
            target.layout();
          }
        });

    final Label bounds = new Label();
    target.addLayoutHandler(
        new LayoutHandler() {
          public void onLayoutUpdated(LayoutEvent layoutEvent) {
            bounds.setText(LDOM.getBounds(target).toString());
            column.setValue(getTargetLayout().isColumn());
            spacing.setText(Integer.toString(getTargetLayout().getSpacing()));
          }
        });

    demoList.addItem("Buttons & Body");
    demoList.addItem("Sidebar & Margin");
    demoList.addItem("Border Layout");
    demoList.setSelectedIndex(0);

    Button add =
        new CssButton(
            "Add Widget",
            new ClickHandler() {
              public void onClick(ClickEvent event) {
                target.add(new Thing("Widget-" + (target.getWidgetCount() + 1)));
                target.layout();
              }
            },
            "Add a new widget to the layout");

    final Button go =
        new CssButton(
            "Go",
            new ClickHandler() {
              public void onClick(ClickEvent event) {
                go();
              }
            },
            "Reset the layout to the selected state");

    demoList.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            go.click();
          }
        });

    FormBuilder b = new FormBuilder();
    b.add(add)
        .label("Spacing")
        .field(spacing)
        .field(column)
        .add("")
        .field(bounds)
        .wrap()
        .width("100%")
        .add(demoList)
        .add(go)
        .endRow();

    panel.add(b.getForm(), 22);
    panel.add(target, LayoutConstraints.HIDDEN);

    go();
  }
Пример #4
0
 private void demoSidebarAndMargin() {
   target.setLayout(new RowLayout(false));
   target.add(new Thing("Sidebar"), 0.2f);
   target.add(new Thing("Body"));
   target.add(new Thing("Margin"), 50);
 }
Пример #5
0
 private void demoButtonsAndBody() {
   target.setLayout(new RowLayout());
   target.add(new Thing("Buttons"), 50);
   target.add(new Thing("Body"));
 }
Пример #6
0
 private RowLayout getTargetLayout() {
   return (RowLayout) target.getLayout();
 }