private void btnReverseSolverSelectionActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnReverseSolverSelectionActionPerformed

    for (int i = 0; i < solTableModel.getRowCount(); i++) {
      solTableModel.setSelected(i, !solTableModel.isSelected(i));
    }
  } // GEN-LAST:event_btnReverseSolverSelectionActionPerformed
  private void btnSolverTabFilterSolversActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnSolverTabFilterSolversActionPerformed

    EDACCApp.getApplication().show(solverFilter);
    solTableModel.fireTableDataChanged();
    updateSolverFilterStatus();
  } // GEN-LAST:event_btnSolverTabFilterSolversActionPerformed
 private void btnDeselectAllSolversActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnDeselectAllSolversActionPerformed
   for (int i = 0; i < solTableModel.getRowCount(); i++) {
     solTableModel.setSelected(i, false);
   }
 } // GEN-LAST:event_btnDeselectAllSolversActionPerformed
  /** Creates new form EDACCExperimentModeImportSolverConfigs */
  public EDACCExperimentModeImportSolverConfigs(
      java.awt.Frame parent, boolean modal, ExperimentController expController) {
    super(parent, modal);

    ArrayList<SolverConfiguration> scs = null;
    ArrayList<Solver> solvers = new ArrayList<Solver>();
    try {
      scs = SolverConfigurationDAO.getAll();
      ParameterInstanceDAO.cacheParameterInstances(scs);
      LinkedList<Solver> tmp = SolverDAO.getAll();
      solvers.addAll(tmp);
    } catch (SQLException ex) {
    }

    cancelled = true;
    selectedSolverConfigs = new ArrayList<SolverConfiguration>();
    experimentTableModel = new ExperimentTableModel(true);
    solverConfigTableModelByExperiments = new SolverConfigurationTableModel();
    solverConfigTableModelBySolvers = new SolverConfigurationTableModel();
    experimentTableModel.setExperiments(expController.getExperiments());

    initComponents();

    tblExperiments.setDefaultRenderer(
        char.class,
        new DefaultTableCellRenderer() {

          @Override
          public Component getTableCellRendererComponent(
              JTable table,
              Object value,
              boolean isSelected,
              boolean hasFocus,
              int row,
              int column) {
            JLabel lbl =
                (JLabel)
                    super.getTableCellRendererComponent(
                        table, value, isSelected, hasFocus, row, column);
            lbl.setHorizontalAlignment(JLabel.CENTER);
            return lbl;
          }
        });

    tblExperiments
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {

              @Override
              public void valueChanged(ListSelectionEvent e) {
                solverConfigurationTableRowFilterByExperiments.clearIncludedExperiments();
                for (int row : tblExperiments.getSelectedRows()) {
                  Experiment exp =
                      experimentTableModel.getExperimentAt(
                          tblExperiments.convertRowIndexToModel(row));
                  solverConfigurationTableRowFilterByExperiments.includeExperiment(exp.getId());
                }
                solverConfigTableModelByExperiments.fireTableDataChanged();
              }
            });

    TableRowSorter tableSolverConfigurationsRowSorterByExperiments =
        new TableRowSorter<SolverConfigurationTableModel>(solverConfigTableModelByExperiments);
    solverConfigurationTableRowFilterByExperiments = new SolverConfigurationTableRowFilter();
    tableSolverConfigurationsRowSorterByExperiments.setRowFilter(
        solverConfigurationTableRowFilterByExperiments);
    tblSolverConfigsByExperiments.setRowSorter(tableSolverConfigurationsRowSorterByExperiments);
    tblSolverConfigsByExperiments.setModel(solverConfigTableModelByExperiments);
    Util.addSpaceSelection(tblSolverConfigsByExperiments, SolverConfigurationTableModel.COL_SEL);
    solverConfigTableModelByExperiments.setSolverConfigurations(scs);

    solTableModel = new SolverTableModel();
    tableSolvers.setModel(solTableModel);
    tableSolvers.removeColumn(
        tableSolvers.getColumnModel().getColumn(SolverTableModel.COL_SELECTED));
    solTableModel.setSolvers(solvers);
    TableRowSorter tableSolverConfigurationsRowSorterBySolvers =
        new TableRowSorter<SolverConfigurationTableModel>(solverConfigTableModelBySolvers);
    solverConfigurationTableRowFilterBySolvers = new SolverConfigurationTableRowFilter();
    tableSolverConfigurationsRowSorterBySolvers.setRowFilter(
        solverConfigurationTableRowFilterBySolvers);
    tblSolverConfigsBySolvers.setRowSorter(tableSolverConfigurationsRowSorterBySolvers);
    tblSolverConfigsBySolvers.setModel(solverConfigTableModelBySolvers);
    Util.addSpaceSelection(tblSolverConfigsBySolvers, SolverConfigurationTableModel.COL_SEL);
    solverConfigTableModelBySolvers.setSolverConfigurations(scs);

    tableSolvers
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {

              @Override
              public void valueChanged(ListSelectionEvent e) {
                solverConfigurationTableRowFilterBySolvers.clearSolverBinaryIds();
                for (int rowView : tableSolvers.getSelectedRows()) {
                  int rowModel = tableSolvers.convertRowIndexToModel(rowView);
                  for (SolverBinaries sb : solTableModel.getSolver(rowModel).getSolverBinaries()) {
                    solverConfigurationTableRowFilterBySolvers.addSolverBinaryId(sb.getId());
                  }
                }
                solverConfigTableModelBySolvers.fireTableDataChanged();
                updateExistingSolverConfigFilterStatus();
              }
            });

    SwingUtilities.invokeLater(
        new Runnable() {

          @Override
          public void run() {
            existingSolverConfigFilter =
                new EDACCFilter(
                    EDACCApp.getApplication().getMainFrame(),
                    true,
                    tblSolverConfigsBySolvers,
                    true);
            solverFilter =
                new EDACCFilter(EDACCApp.getApplication().getMainFrame(), true, tableSolvers, true);
          }
        });
  }