/** Load table data */
  private void load() {
    // Fill repository IU
    URI location = (URI) locationsCombo.getSelectedItem();
    repoAppsList.clear();
    // Load  Installable units
    repoAppsList.addAll(P2.get().getAllIUnit(location));

    // Fill installed apps
    installedAppsList.clear();
    installedAppsList.addAll(P2.get().getInstalledModel());
  }
  /** Actualiza el combobox de repositorios */
  public void refresh() {
    // Eliminamos los items actuales y la posibilidad de que salte el evento
    locationsCombo.removeActionListener(this);
    locationsCombo.removeAllItems();

    // Añadimos los repositorios actualizados
    for (URI uri : P2.get().getRepositories()) {
      locationsCombo.addItem(uri);
    }

    locationsCombo.addActionListener(this);
  }
  private void install() {
    ArrayList<IUnitModel> iunits = new ArrayList<IUnitModel>();
    for (int i = 0; i < repoAppsList.size(); i++) {
      IUnitModel iunit = repoAppsList.get(i);
      if (iunit.isSelected()) {
        iunits.add(iunit);
      }
    }

    if (P2.get().install(iunits)) {
      ADialog.info(0, this, Msg.getMsg(Env.getAD_Language(ctx), "OK"));
    } else {
      ADialog.error(
          0, this, Msg.getMsg(Env.getAD_Language(ctx), "Updates are not correctly installed "));
    }
  }
  private CPanel generateRepositoriesPanel() {
    CPanel panel = new CPanel();
    panel.setLayout(new BorderLayout());

    CPanel topPanel = new CPanel();
    topPanel.setLayout(new GridBagLayout());
    panel.add(topPanel, BorderLayout.NORTH);

    locationsCombo = new CComboBox(P2.get().getRepositories());
    locationsCombo.addActionListener(this);
    locationLabel.setText(Msg.translate(Env.getCtx(), "Repositories"));
    locationLabel.setLabelFor(locationsCombo);

    topPanel.add(
        locationLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(2, 2, 2, 2),
            0,
            0));
    topPanel.add(
        locationsCombo,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.3,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.BOTH,
            new Insets(2, 2, 2, 20),
            0,
            0));

    repositoryBtn = new CButton(Msg.getMsg(ctx, "Manage Repositories"));
    repositoryBtn.addActionListener(this);

    topPanel.add(
        repositoryBtn,
        new GridBagConstraints(
            1,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(10, 1, 2, 100),
            0,
            0));

    CPanel tablePanel = new CPanel();
    panel.add(tablePanel, BorderLayout.CENTER);

    // Available iu
    repoAppsList = new BasicEventList<IUnitModel>();
    FilterList<IUnitModel> repoFilterList = new FilterList<IUnitModel>(repoAppsList);
    EventTableModel<IUnitModel> tepoTableModel =
        new EventTableModel<IUnitModel>(repoFilterList, new IUnitTableFormat());
    table = new JTable(tepoTableModel);
    tablePanel.add(new JScrollPane(table));

    CPanel btnPanel = new CPanel();
    panel.add(btnPanel, BorderLayout.SOUTH);

    installBtn = new CButton(Msg.getMsg(Env.getAD_Language(ctx), "Install"));
    installBtn.addActionListener(this);
    btnPanel.add(installBtn);

    return panel;
  }