Exemplo n.º 1
0
 public Position getCellPosition(Widget cell) {
   for (int row = 0; row < table.getRowCount(); row++) {
     for (int col = 0; col < table.getCellCount(row); col++) {
       if (cell == table.getWidget(row, col)) return new Position(row, col);
     }
   }
   return null;
 }
Exemplo n.º 2
0
 private void addColumn(Object columnHeading) {
   Widget widget = createCellWidget(columnHeading);
   int cell = flexTable.getCellCount(HEADER_ROW_INDEX);
   widget.setWidth("100%");
   widget.addStyleName("FlexTable-ColumnLabel");
   flexTable.setWidget(HEADER_ROW_INDEX, cell, widget);
   flexTable.getCellFormatter().addStyleName(HEADER_ROW_INDEX, cell, "FlexTable-ColumnLabelCell");
 }
Exemplo n.º 3
0
  /* tango!ボタンを押したときに、必要に応じて単語をシャッフルする */
  public void shuffle(ArrayList<PickupTango> pickupTangoList) {
    int row = flexTable.getRowCount(); // 行数
    int col = flexTable.getCellCount(row - 1); // 列数
    int listSize = pickupTangoList.size();
    int count = 0;
    panel.remove(flexTable);
    flexTable = new FlexTable();
    panel.add(flexTable);

    /* 行数×列数 > 取ってきた単語数  */
    /* -> 必ず重なる単語があるので、取ってきた単語をもう一度シャッフルして表示する */
    if (row * col > listSize) {
      // Window.alert("row="+row +", col="+col + ", listSize=" + listSize + "\n row * col >
      // listSize");
      for (int i = 0; i < row; i++) {
        for (int j = 0; j < col; j++) {
          randomNumber = (int) (Math.random() * listSize);
          flexTable.setWidget(i, j, TangoPanel.tangoPanel(pickupTangoList.get(randomNumber)));
          // System.out.println("i="+i+", j="+j);
        }
      }

      /* 行数×列数  <= 取ってきた単語数の方 */
      /* 取ってきた単語が既にランダムなので、そのまま表示 */
    } else {
      // Window.alert("row="+row +", col="+col + ", listSize=" + listSize + "\n row * col <=
      // listSize");
      for (int i = 0; i < row; i++) {
        for (int j = 0; j < col; j++) {
          flexTable.setWidget(i, j, TangoPanel.tangoPanel(pickupTangoList.get(count)));
          // System.out.println("i="+i+", j="+j);
          count++;
        }
      }
    }
  }