public void setData(SearchResult data) {
   if (cellTable != null) {
     cellTable.setRowCount(data.getTotalSize(), true);
     // cellTable.setVisibleRange( data.getStart( ), data.getLength( ) );
     cellTable.setRowData(data.getRange().getStart(), data.getRows());
   }
 }
Esempio n. 2
0
 private void showWorkersCellTable(String json) {
   jsonData = getJSONData(json);
   workers = new ArrayList<MyWorker>();
   Worker worker = null;
   for (int i = 1; i < jsonData.length(); i++) {
     worker = jsonData.get(i);
     String name = worker.getName();
     String username = worker.getUsername();
     String department = worker.getDepartment();
     int id = worker.getId();
     MyWorker w = new MyWorker(name, username, department, id);
     workers.add(w);
   }
   TextColumn<MyWorker> nameCol =
       new TextColumn<MyWorker>() {
         @Override
         public String getValue(MyWorker worker) {
           return worker.name;
         }
       };
   TextColumn<MyWorker> usernameCol =
       new TextColumn<MyWorker>() {
         @Override
         public String getValue(MyWorker worker) {
           return worker.username;
         }
       };
   TextColumn<MyWorker> deptCol =
       new TextColumn<MyWorker>() {
         @Override
         public String getValue(MyWorker worker) {
           return worker.department;
         }
       };
   CellTable<MyWorker> table = new CellTable<MyWorker>();
   final SingleSelectionModel<MyWorker> selectionModel = new SingleSelectionModel<MyWorker>();
   table.setSelectionModel(selectionModel);
   selectionModel.addSelectionChangeHandler(
       new SelectionChangeEvent.Handler() {
         public void onSelectionChange(SelectionChangeEvent e) {
           MyWorker choice = selectionModel.getSelectedObject();
           if (choice != null) {
             selectedWorker = choice;
           }
         }
       });
   table.addColumn(nameCol, "Name");
   table.addColumn(usernameCol, "Username");
   table.addColumn(deptCol, "Department");
   table.setRowCount(workers.size(), true);
   table.setRowData(0, workers);
   HorizontalPanel buttonPanel = new HorizontalPanel();
   buttonPanel.add(addButton);
   buttonPanel.add(editButton);
   buttonPanel.add(deleteButton);
   mainPanel.clear();
   mainPanel.add(buttonPanel);
   mainPanel.add(table);
 }
Esempio n. 3
0
  /**
   * The table that holds the basic friends list.
   *
   * @param result
   */
  private void setTable(GetLogResult result) {
    if (cellTable.getColumnCount() == 4) {
      dataList.clear();
      dataList = dataProvider.getList();
      for (GetLogType friend : result.getResults()) dataList.add(friend);
    } else {
      TextColumn<GetLogType> victimColumn =
          new TextColumn<GetLogType>() {
            @Override
            public String getValue(GetLogType log) {
              if (log.getFbVictimName() != null) return log.getFbVictimName();
              else return "";
            }
          };
      victimColumn.setSortable(true);

      TextColumn<GetLogType> commentPermalink =
          new TextColumn<GetLogType>() {
            @Override
            public String getValue(GetLogType log) {
              if (log.getFbCommentPermalink() != null) return log.getFbCommentPermalink();
              else return "";
            }
          };
      commentPermalink.setSortable(true);

      TextColumn<GetLogType> comment =
          new TextColumn<GetLogType>() {
            @Override
            public String getValue(GetLogType log) {
              if (log.getFbComment() != null) return log.getFbComment();
              else return "";
            }
          };
      comment.setSortable(true);

      TextColumn<GetLogType> date =
          new TextColumn<GetLogType>() {
            @Override
            public String getValue(GetLogType log) {
              if (log.getDate() != null) return log.getDate().toString();
              else return "";
            }
          };
      date.setSortable(true);

      cellTable.addColumn(victimColumn, "Name");
      cellTable.addColumn(commentPermalink, "Comment Link");
      cellTable.addColumn(comment, "Comment Text");
      cellTable.addColumn(date, "Time");

      // Fix column sizes for stupid facebook
      cellTable.setWidth("675px", true);
      cellTable.setColumnWidth(victimColumn, 10.0, Unit.PCT);
      cellTable.setColumnWidth(commentPermalink, 40.0, Unit.PCT);
      cellTable.setColumnWidth(comment, 40.0, Unit.PCT);
      cellTable.setColumnWidth(date, 10.0, Unit.PCT);

      // Attach provider
      dataProvider.addDataDisplay(cellTable);
      dataList = dataProvider.getList();
      for (GetLogType friend : result.getResults()) dataList.add(friend);

      // Set row count
      cellTable.setRowCount(dataList.size());
      cellTable.setPageSize(20);

      ListHandler<GetLogType> columnSortHandler = new ListHandler<GetLogType>(dataList);
      columnSortHandler.setComparator(
          victimColumn,
          new Comparator<GetLogType>() {

            @Override
            public int compare(GetLogType o1, GetLogType o2) {
              if (o1 == o2) {
                return 0;
              }

              // Compare the name columns.
              if (o1 != null) {
                return (o2 != null) ? o1.getFbVictimName().compareTo(o2.getFbVictimName()) : 1;
              }
              return -1;
            }
          });

      columnSortHandler.setComparator(
          commentPermalink,
          new Comparator<GetLogType>() {

            @Override
            public int compare(GetLogType o1, GetLogType o2) {
              if (o1 == o2) {
                return 0;
              }

              // Compare the role columns.
              if (o1 != null) {
                return (o2 != null)
                    ? o1.getFbCommentPermalink().compareTo(o2.getFbCommentPermalink())
                    : 1;
              }
              return -1;
            }
          });

      columnSortHandler.setComparator(
          comment,
          new Comparator<GetLogType>() {
            @Override
            public int compare(GetLogType o1, GetLogType o2) {
              if (o1 == o2) {
                return 0;
              }

              // Compare the role columns.
              if (o1 != null) {
                return (o2 != null) ? o1.getFbComment().compareTo(o2.getFbComment()) : 1;
              }
              return -1;
            }
          });

      columnSortHandler.setComparator(
          date,
          new Comparator<GetLogType>() {

            @Override
            public int compare(GetLogType o1, GetLogType o2) {
              if (o1 == o2) {
                return 0;
              }

              // Compare the role columns.
              if (o1 != null) {
                return (o2 != null) ? o1.getDate().compareTo(o2.getDate()) : 1;
              }
              return -1;
            }
          });

      cellTable.addColumnSortHandler(columnSortHandler);
      cellTable.getColumnSortList().push(date);
      cellTable.setPageSize(5000);
    }
  }
Esempio n. 4
0
 public void updateLawTableData() {
   table.setRowCount(0);
   table.setRowCount(laws.size(), true);
   table.setRowData(laws);
   table.redraw();
 }
Esempio n. 5
0
 public void setPhotoCount(int photoCount) {
   cellTable.setRowCount(photoCount);
   AppContext.getInstance()
       .getEventBus()
       .fireEvent(new ShowPhotoRange(cellTable.getVisibleRange()));
 }