Example #1
0
 public FlexTable createTable() {
   if (!currentRow.cells.isEmpty()) nextRow();
   FlexTable table = new FlexTable();
   table.setStyleName(styleName);
   table.setCellSpacing(cellSpacing);
   table.setCellPadding(cellPadding);
   if (centered) table.getElement().setAttribute("align", "center");
   String widthAsString = width == null ? "" : width;
   table.setWidth(widthAsString);
   table.getElement().setAttribute("width", widthAsString);
   if (columnWidths != null) {
     ColumnFormatter columnFormatter = table.getColumnFormatter();
     for (int i = 0; i < columnWidths.length; i++) {
       columnFormatter.setWidth(i, columnWidths[i]);
     }
   }
   int rowIndex = 0;
   for (Row row : rows) {
     int colIndex = 0;
     for (Cell cell : row.cells) {
       table.setWidget(rowIndex, colIndex, cell.widget);
       if (cell.colspan > 1)
         table.getFlexCellFormatter().setColSpan(rowIndex, colIndex, cell.colspan);
       if (cell.align != null) {
         table.getCellFormatter().setHorizontalAlignment(rowIndex, colIndex, cell.align);
       }
       colIndex += cell.colspan;
     }
     rowIndex++;
   }
   return table;
 }
  public SelectUserOrRoleDialog(
      ArrayList<String> existing, final IUserRoleSelectedCallback callback) {
    super(
        Messages.getString("selectUserOrRole"),
        Messages.getString("ok"),
        Messages.getString("cancel"),
        false,
        true,
        contentTable); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    usersListBox.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            rolesListBox.setSelectedIndex(-1);
            okButton.setEnabled(true);
          }
        });
    rolesListBox.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            usersListBox.setSelectedIndex(-1);
            okButton.setEnabled(true);
          }
        });

    setCallback(
        new IDialogCallback() {

          public void cancelPressed() {}

          public void okPressed() {
            if (getSelectedUser() != null) {
              callback.userSelected(getSelectedUser());
            } else {
              callback.roleSelected(getSelectedRole());
            }
          }
        });

    // Unique ids are important for test automation
    contentTable.getElement().setId("userOrRoleDialogContentTable");
    usersListBox.getElement().setId("userOrRoleDialogUsersList");
    rolesListBox.getElement().setId("userOrRoleDialogRolesList");
    okButton.getElement().setId("userOrRoleDialogOkButton");
    okButton.setEnabled(false);
    cancelButton.getElement().setId("userOrRoleDialogCancelButton");

    usersListBox.setVisibleItemCount(5);
    rolesListBox.setVisibleItemCount(5);
    rolesListBox.setWidth("100%"); // $NON-NLS-1$
    usersListBox.setWidth("100%"); // $NON-NLS-1$
    contentTable.clear();
    contentTable.setWidth("100%"); // $NON-NLS-1$
    contentTable.setWidget(0, 0, new Label(Messages.getString("users"))); // $NON-NLS-1$
    contentTable.setWidget(1, 0, usersListBox);
    contentTable.setWidget(2, 0, new Label(Messages.getString("roles"))); // $NON-NLS-1$
    contentTable.setWidget(3, 0, rolesListBox);
    fetchAllUsers(existing);
    fetchAllRoles(existing);
    setWidth("200px"); // $NON-NLS-1$
  }
Example #3
0
 public RentAdminView() {
   table = new FlexTable();
   table.getElement().addClassName("rental-list");
   container = new ScrollPanel();
   registerButton = new Button();
   container.add(table);
   startTable();
 }
  /** Show the calendar container, and positione it in the provided coordinates. */
  public void show(int left, int top) {
    if (needsRedraw) refresh();

    if (calendarDlg == null) {
      assert outer.isAttached()
          : "Calendar has not been attached, even though it is not configured as a popup.";
      outer.setVisible(true);
    } else {
      if (top >= 0 && left >= 0) {
        calendarDlg.setPopupPosition(left, top);
        calendarDlg.show();
        moveIntoVisibleArea();
        DOM.scrollIntoView(calendarGrid.getElement());
      } else {
        calendarDlg.center();
      }
    }
    todayBtn.setFocus(true);
  }
  @Override
  public final Updatable update() {
    log.debug("update()");

    table = null;
    wrapper = null;
    rows = null;
    columns = new ArrayList<AColumn>();

    table = new FlexTable();
    table.getElement().setId(getId() + "_table");
    table.setStyleName("goon-ObjectTable");

    wrapper = new BuilderPanel();
    if (isCardStyle()) wrapper.setStyleCard();
    wrapper.setId(getId());
    // wrapper.setSpacing(0);
    if (getColorForMarker() != null) wrapper.addColorMarker(getColorForMarker());
    init(wrapper);
    wrapper.add(table);
    initWrapperAfterTable(wrapper);

    for (AColumn column : columns) {
      column.formatColumn(table.getColumnFormatter());
    }

    onTableAdded(wrapper, table);

    reverseSort = isReverseSort();
    try {
      onUpdate();
    } catch (Exception ex) {
      throw new RuntimeException(Str.getSimpleName(getClass()) + ".onUpdate() failed", ex);
    }

    asWidgetWrapper.clear();
    asWidgetWrapper.add(wrapper);

    return this;
  }
  @UiFactory
  public FlexTable createFlexTable() {
    FlexTable table = new FlexTable();
    table.getElement().getStyle().setProperty("margin", "10px");
    table.setCellSpacing(8);
    table.setCellPadding(4);

    for (int i = 0; i < LayoutRegion.values().length; i++) {
      final LayoutRegion r = LayoutRegion.values()[i];
      if (r == LayoutRegion.CENTER) {
        continue;
      }

      SelectHandler handler =
          new SelectHandler() {
            @Override
            public void onSelect(SelectEvent event) {
              TextButton btn = (TextButton) event.getSource();
              String txt = btn.getText();
              if (txt.equals("Expand")) {
                con.expand(r);
              } else if (txt.equals("Collapse")) {
                con.collapse(r);
              } else if (txt.equals("Show")) {
                con.show(r);
              } else {
                con.hide(r);
              }
            }
          };

      table.setHTML(i, 0, "<div style='font-size: 12px; width: 100px'>" + r.name() + ":</span>");
      table.setWidget(i, 1, new TextButton("Expand", handler));
      table.setWidget(i, 2, new TextButton("Collapse", handler));
      table.setWidget(i, 3, new TextButton("Show", handler));
      table.setWidget(i, 4, new TextButton("Hide", handler));
    }
    return table;
  }
 protected void setupLoadingContainer() {
   loadingContainter = new FlexTable();
   loadingContainter.getElement().setAttribute("align", "center");
   loadingContainter.setWidget(0, 0, new Label("loading..."));
 }
  protected void onRender(Element target, int index) {
    super.onRender(target, index);
    final BorderLayout layout = new BorderLayout();
    setLayout(layout);
    setStyleAttribute("padding", "10px");

    ContentPanel north = new ContentPanel();
    ContentPanel west = new ContentPanel();
    ContentPanel center = new ContentPanel();
    center.setHeading("BorderLayout Example");
    center.setScrollMode(Scroll.AUTOX);

    FlexTable table = new FlexTable();
    table.getElement().getStyle().setProperty("margin", "10px");
    table.setCellSpacing(8);
    table.setCellPadding(4);

    for (int i = 0; i < LayoutRegion.values().length; i++) {
      final LayoutRegion r = LayoutRegion.values()[i];
      if (r == LayoutRegion.CENTER) {
        continue;
      }
      SelectionListener<ButtonEvent> sl =
          new SelectionListener<ButtonEvent>() {

            @Override
            public void componentSelected(ButtonEvent ce) {
              String txt = ce.getButton().getText();
              if (txt.equals("Expand")) {
                layout.expand(r);
              } else if (txt.equals("Collapse")) {
                layout.collapse(r);
              } else if (txt.equals("Show")) {
                layout.show(r);
              } else {
                layout.hide(r);
              }
            }
          };
      table.setHTML(i, 0, "<div style='font-size: 12px; width: 100px'>" + r.name() + ":</span>");
      table.setWidget(i, 1, new Button("Expand", sl));
      table.setWidget(i, 2, new Button("Collapse", sl));
      table.setWidget(i, 3, new Button("Show", sl));
      table.setWidget(i, 4, new Button("Hide", sl));
    }
    center.add(table);

    ContentPanel east = new ContentPanel();
    ContentPanel south = new ContentPanel();

    BorderLayoutData northData = new BorderLayoutData(LayoutRegion.NORTH, 100);
    northData.setCollapsible(true);
    northData.setFloatable(true);
    northData.setHideCollapseTool(true);
    northData.setSplit(true);
    northData.setMargins(new Margins(0, 0, 5, 0));

    BorderLayoutData westData = new BorderLayoutData(LayoutRegion.WEST, 150);
    westData.setSplit(true);
    westData.setCollapsible(true);
    westData.setMargins(new Margins(0, 5, 0, 0));

    BorderLayoutData centerData = new BorderLayoutData(LayoutRegion.CENTER);
    centerData.setMargins(new Margins(0));

    BorderLayoutData eastData = new BorderLayoutData(LayoutRegion.EAST, 150);
    eastData.setSplit(true);
    eastData.setCollapsible(true);
    eastData.setMargins(new Margins(0, 0, 0, 5));

    BorderLayoutData southData = new BorderLayoutData(LayoutRegion.SOUTH, 100);
    southData.setSplit(true);
    southData.setCollapsible(true);
    southData.setFloatable(true);
    southData.setMargins(new Margins(5, 0, 0, 0));

    add(north, northData);
    add(west, westData);
    add(center, centerData);
    add(east, eastData);
    add(south, southData);
  }