public void EVENT_moveBottom(ActionEvent e) {
    int selection[] = table.getSelectedRows();

    int offset = 0;
    if (selection != null && selection.length > 0) {
      for (int i : selection) {
        DownloadWrapper dw = rows.get(i - offset);
        final Download d = dw.download;
        ui.getCore()
            .invokeLater(
                new Runnable() {

                  @Override
                  public void run() {
                    ui.getCore().getNetworkManager().getDownloadManager().moveBottom(d);
                  }
                });
        moveBottom(i - offset, dw);
        offset++;
      }
      model.fireTableStructureChanged();
      // for(int i : selection) if (i<rows.size()-1)
      // table.getSelectionModel().addSelectionInterval(i+1,i+1);
      ListSelectionModel sm = table.getSelectionModel();
      sm.addSelectionInterval(rows.size() - selection.length, rows.size() - 1);
    }
  }
  public void EVENT_moveUp(ActionEvent e) {
    int selection[] = table.getSelectedRows();
    if (selection != null && selection.length > 0) {
      for (int i : selection) {
        DownloadWrapper dw = rows.get(i);
        final Download d = dw.download;
        ui.getCore()
            .invokeLater(
                new Runnable() {

                  @Override
                  public void run() {
                    ui.getCore().getNetworkManager().getDownloadManager().moveUp(d);
                  }
                });
        moveUp(i, dw);
      }
      model.fireTableStructureChanged();
      for (int i : selection) {
        if (i > 0) {
          table.getSelectionModel().addSelectionInterval(i - 1, i - 1);
        }
      }
    }
  }
  public void EVENT_moveTop(ActionEvent e) {
    int selection[] = table.getSelectedRows();
    int offset = 0;
    if (selection != null && selection.length > 0) {
      for (int j = selection.length - 1; j >= 0; j--) {
        int i = selection[j];
        DownloadWrapper dw = rows.get(i + offset);
        final Download d = dw.download;
        ui.getCore()
            .invokeLater(
                new Runnable() {

                  @Override
                  public void run() {
                    ui.getCore().getNetworkManager().getDownloadManager().moveTop(d);
                  }
                });
        moveTop(i + offset, dw);
        offset++;
      }
      model.fireTableStructureChanged();
      // for(int i : selection) if (i>0) table.getSelectionModel().addSelectionInterval(i-1,i-1);
      table.getSelectionModel().addSelectionInterval(0, selection.length - 1);
    }
  }
  public void update() {
    boolean structureChanged = false;

    ArrayList<Download> al =
        new ArrayList<Download>(ui.getCore().getNetworkManager().getDownloadManager().downloads());
    for (Download d : al) {
      DownloadWrapper dw = getWrapperFor(d);
      if (dw == null) {
        structureChanged = true;
        dw = new DownloadWrapper(d);
        rows.add(dw);
      }
      dw.update();
    }

    for (Iterator i = rows.iterator(); i.hasNext(); ) {
      DownloadWrapper w = (DownloadWrapper) i.next();
      if (!ui.getCore().getNetworkManager().getDownloadManager().contains(w.download)) {
        structureChanged = true;
        i.remove();
      }
    }

    if (structureChanged) {
      model.fireTableStructureChanged();
    } else {
      model.fireTableRowsUpdated(0, rows.size());
    }

    showTotalBytesReceived();

    selectDownloadToShowOnDownloadGrid();

    updateDownloadingFromAndUploadingToText();

    downloadGrid.repaint();
  }