private ObjectListSelectionModel buildTableSelectionModel(ListValueModel preferencesHolder) {
   ObjectListSelectionModel tsm =
       new ObjectListSelectionModel(new ListModelAdapter(preferencesHolder));
   tsm.addListSelectionListener(this.buildTableSelectionListener());
   tsm.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   return tsm;
 }
 private ObjectListSelectionModel buildRowSelectionModel() {
   ObjectListSelectionModel rowSelectionModel =
       new ObjectListSelectionModel(new ListModelAdapter(sortedFieldsAdapter));
   rowSelectionModel.addListSelectionListener(this.buildRowSelectionListener());
   rowSelectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
   return rowSelectionModel;
 }
  /**
   * Sets whether or not this component is enabled. Disabling this pane will
   * also disable its children.
   *
   * @param enabled <code>true<code> if this component and its children should
   * be enabled, <code>false<code> otherwise
   */
  public void setEnabled(boolean enabled) {
    super.setEnabled(enabled);

    addButton.setEnabled(enabled);
    table.setEnabled(enabled);
    table.getTableHeader().setEnabled(enabled);

    if (enabled) {
      editButton.setEnabled(selectionModel.getSelectedValues().length == 1);
      removeButton.setEnabled(!selectionModel.isSelectionEmpty());
    } else {
      table.clearSelection();

      editButton.setEnabled(enabled);
      removeButton.setEnabled(enabled);
    }
  }
 /**
  * Adds a <code>ListSelectionListener</code> to the given selection model in order to keep the
  * enable state of the given remove button in sync with the selection.
  */
 private void buildRemoveButtonEnabler() {
   selectionModel.addListSelectionListener(
       new ListSelectionListener() {
         public void valueChanged(ListSelectionEvent e) {
           if (!e.getValueIsAdjusting()) {
             removeButton.setEnabled(!selectionModel.isSelectionEmpty());
           }
         }
       });
 }
 /**
  * Adds a <code>ListSelectionListener</code> to the given selection model in order to keep the
  * enable state of the given edit button in sync with the selection.
  */
 private void buildEditButtonEnabler() {
   selectionModel.addListSelectionListener(
       new ListSelectionListener() {
         public void valueChanged(ListSelectionEvent e) {
           if (!e.getValueIsAdjusting()) {
             editButton.setEnabled(selectionModel.getSelectedValues().length == 1);
           }
         }
       });
 }
 private ObjectListSelectionModel buildPrimaryKeysSelectionModel() {
   ObjectListSelectionModel selectionModel = new ObjectListSelectionModel(this.primaryKeysModel);
   selectionModel.addListSelectionListener(this.buildSelectionListener());
   return selectionModel;
 }
 private Object[] selectedFields() {
   return rowSelectionModel.getSelectedValues();
 }
 private void rowSelectionChanged() {
   Object[] selection = rowSelectionModel.getSelectedValues();
   boolean fieldSelected = (selection.length > 0);
   removeAction.setEnabled(fieldSelected);
 }
 private ObjectListSelectionModel buildFieldPairSelectionModel(ListValueModel fieldPairsValue) {
   ObjectListSelectionModel selectionModel =
       new ObjectListSelectionModel(new ListModelAdapter(fieldPairsValue));
   selectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
   return selectionModel;
 }
    /**
     * Invoked when the user selects the Remove button.
     *
     * @param listSelectionModel The model containing the selected items
     */
    public void removeSelectedItems(ObjectListSelectionModel listSelectionModel) {
      Collection sessions = CollectionTools.collection(listSelectionModel.getSelectedValues());

      if (canRemoveSessions(sessions)) removeSessions(sessions);
    }
 public boolean enableOptionOnSelectionChange(ObjectListSelectionModel listSelectionModel) {
   return listSelectionModel.getSelectedValuesSize() == 1;
 }
 /**
  * Invoked when the user selects the optional button.
  *
  * @param listSelectionModel The model containing the selected item
  */
 public void optionOnSelection(ObjectListSelectionModel selectionModel) {
   renameSession((SessionAdapter) selectionModel.getSelectedValue());
 }