コード例 #1
0
  private void insertTableRows(final Table type, final Integer r) {
    final int rows = r.intValue();

    if (Table.GRID.equals(type)) {
      final Grid grid = (Grid) table;

      for (int i = 0; i < rows; i++) {
        final Number num = new Integer(i);
        grid.resizeRows(i + 1);
        for (int j = i; j > 0; j--) {
          grid.setWidget(j, 0, grid.getWidget(j - 1, 0));
        }
        grid.setWidget(0, 0, makeLabel(num));
      }

    } else if (Table.FLEX_TABLE.equals(type)) {
      final FlexTable flexTable = (FlexTable) table;

      for (int i = 0; i < rows; i++) {
        final Number num = new Integer(i);
        flexTable.insertRow(0);
        flexTable.setWidget(0, 0, makeLabel(num));
      }

    } else if (Table.OBJECT_LIST_TABLE.equals(type)) {
      final ObjectListTable olt = (ObjectListTable) table;

      for (int i = 0; i < rows; i++) {
        final Number num = new Integer(i);
        olt.getObjects().add(0, num);
      }
    }
  }
コード例 #2
0
  private void addAssignmentRow(final Assignment assignment, int insertrow) {
    int j = 0;
    int row =
        (insertrow <= assignmentsTable.getRowCount())
            ? assignmentsTable.insertRow(insertrow)
            : insertrow;

    Image delIcon = getDeleteIcon(assignment);
    // assignment
    assignmentsTable.setWidget(row, j++, delIcon);

    Image icon = new Image();
    icon.setUrl(getIconFile(assignment.getIconFileName()));
    assignmentsTable.setWidget(row, j++, icon);
    assignmentsTable.setWidget(row, j++, new Label(assignment.getToolName()));

    final TextBox textForSolvedAssignment = getHintTextBox(assignment, Result.CORRECT);

    assignmentsTable.setWidget(row, j++, textForSolvedAssignment);

    final ListBox fractions = getFractionsLB(assignment, Result.CORRECT);
    assignmentsTable.setWidget(row, j++, fractions);

    Image editIcon = new Image(GuiResources.INSTANCE.menu_icon_edit());
    editIcon.addClickHandler(
        new ClickHandler() {

          public void onClick(ClickEvent event) {
            handleEditClick(assignment);
          }
        });
    assignmentsTable.setWidget(row, j++, editIcon);
  }
コード例 #3
0
 /**
  * Displays a set of Google Contacts group entries in a tabular fashion with the help of a GWT
  * FlexTable widget. The data fields Title and ID are displayed.
  *
  * @param entries The Google Contacts group entries to display.
  */
 private void showData(ContactGroupEntry[] entries) {
   mainPanel.clear();
   String[] labels = new String[] {"Title", "ID"};
   mainPanel.insertRow(0);
   for (int i = 0; i < labels.length; i++) {
     mainPanel.addCell(0);
     mainPanel.setWidget(0, i, new Label(labels[i]));
     mainPanel.getFlexCellFormatter().setStyleName(0, i, "hm-tableheader");
   }
   for (int i = 0; i < entries.length; i++) {
     ContactGroupEntry entry = entries[i];
     int row = mainPanel.insertRow(i + 1);
     mainPanel.addCell(row);
     mainPanel.setWidget(row, 0, new Label(entry.getTitle().getText()));
     mainPanel.addCell(row);
     mainPanel.setWidget(row, 1, new Label(entry.getId().getValue()));
   }
 }
コード例 #4
0
 /**
  * Displays a status message to the user.
  *
  * @param message The message to display.
  * @param isError Indicates whether the status is an error status.
  */
 private void showStatus(String message, boolean isError) {
   mainPanel.clear();
   mainPanel.insertRow(0);
   mainPanel.addCell(0);
   Label msg = new Label(message);
   if (isError) {
     msg.setStylePrimaryName("hm-error");
   }
   mainPanel.setWidget(0, 0, msg);
 }
コード例 #5
0
ファイル: DbFormAdd.java プロジェクト: novaris/novoscan
  private void addHeader() {

    flexTable.insertRow(HEADER_ROW_INDEX);
    flexTable.getRowFormatter().addStyleName(HEADER_ROW_INDEX, "FlexTable-Header");
    addColumn(constants.NameHead());
    addColumn(constants.ValueHead());
    addColumn(constants.Mandatory());
    addColumn(constants.FieldHead());
    flexTable.getColumnFormatter().setWidth(KEY_COLUMN, "0pt");
  }
 /**
  * Displays a set of Google Contacts contact entries in a tabular fashion with the help of a GWT
  * FlexTable widget. The data fields Title, Email and Updated are displayed.
  *
  * @param entries The Google Contacts contact entries to display.
  */
 private void showData(ContactEntry[] entries) {
   mainPanel.clear();
   String[] labels = new String[] {"Title", "Email", "Updated"};
   mainPanel.insertRow(0);
   for (int i = 0; i < labels.length; i++) {
     mainPanel.addCell(0);
     mainPanel.setWidget(0, i, new Label(labels[i]));
     mainPanel.getFlexCellFormatter().setStyleName(0, i, "hm-tableheader");
   }
   for (int i = 0; i < entries.length; i++) {
     ContactEntry entry = entries[i];
     int row = mainPanel.insertRow(i + 1);
     mainPanel.addCell(row);
     mainPanel.setWidget(row, 0, new Label(entry.getTitle().getText()));
     mainPanel.addCell(row);
     String email = "";
     if (entry.getEmailAddresses().length > 0) {
       email = entry.getEmailAddresses()[0].getAddress();
     }
     mainPanel.setWidget(row, 1, new Label(email));
     mainPanel.addCell(row);
     mainPanel.setWidget(row, 2, new Label(entry.getUpdated().getValue().getDate().toString()));
   }
 }
コード例 #7
0
  public void setModel(ProductInfo[] pi) {
    searchModel = pi;
    while (items.getRowCount() > 0) items.removeRow(0);
    if (searchModel == null || searchModel.length == 0) {
      emptyCartLbl.setVisible(true);
      return;
    }

    RowFormatter fmtr = items.getRowFormatter();
    for (int i = 0; i < searchModel.length; i++) {
      int row = items.insertRow(i);
      for (int j = 0; j < 2; j++) items.insertCell(row, j);
      items.setText(row, 0, searchModel[i].name);
      items.setText(row, 1, searchModel[i].description);
      fmtr.addStyleName(row, "ps-GridRow ps-GridRow-sel");
    }
    emptyCartLbl.setVisible(false);
  }
コード例 #8
0
ファイル: EventEditor.java プロジェクト: jrray/gotefarm
  public void addRole(String role, int min_value, int max_value) {
    if (role.equals(SELECT_A_ROLE)) {
      return;
    }

    final int rows = roleft.getRowCount() - 2;

    // check role doesn't already exist
    for (int row = 0; row < rows; ++row) {
      if (roleft.getText(row + 1, 0).equals(role)) {
        return;
      }
    }

    roleft.insertRow(rows + 1);
    roleft.setText(rows + 1, 0, role);

    final TextBox min = new TextBox();
    final TextBox max = new TextBox();

    min.setText("" + min_value);
    max.setText("" + max_value);

    min.setVisibleLength(2);
    max.setVisibleLength(2);

    ChangeHandler minmax =
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            final Object sender = event.getSource();
            try {
              Integer minv = Integer.parseInt(min.getText());
              Integer maxv = Integer.parseInt(max.getText());

              if (sender == min) {
                if (minv > maxv) {
                  max.setText(min.getText());
                }
              } else if (sender == max) {
                if (maxv < minv) {
                  min.setText(max.getText());
                }
              }
            } catch (NumberFormatException e) {
              if (sender == min) {
                min.setText("0");
              } else if (sender == max) {
                max.setText("0");
              }
            }

            updateRoleTotals();
          }
        };

    min.addChangeHandler(minmax);
    max.addChangeHandler(minmax);

    roleft.setWidget(rows + 1, 1, min);
    roleft.setWidget(rows + 1, 2, max);
    roleft.setWidget(
        rows + 1,
        3,
        new Button(
            "Remove",
            new ClickHandler() {
              public void onClick(ClickEvent event) {
                final Object sender = event.getSource();
                final int rows = roleft.getRowCount() - 2;
                for (int i = 0; i < rows; ++i) {
                  if (roleft.getWidget(i + 1, 3) == sender) {
                    roleft.removeRow(i + 1);
                    updateBadgeRoles();
                    break;
                  }
                }
              }
            }));

    updateRoleTotals();
  }