public void selectPlaylist(Playlist playlist) {
    Object selectedValue = _list.getSelectedValue();
    if (selectedValue != null
        && ((LibraryPlaylistsListCell) selectedValue).getPlaylist() != null
        && ((LibraryPlaylistsListCell) selectedValue).getPlaylist().equals(playlist)) {
      // already selected
      try {
        _listSelectionListener.valueChanged(null);
      } catch (Exception e) {
        System.out.println();
      }
      return;
    }

    int size = _model.getSize();

    for (int i = 0; i < size; i++) {
      try {
        LibraryPlaylistsListCell cell = (LibraryPlaylistsListCell) _model.get(i);
        if (cell.getPlaylist() != null && cell.getPlaylist().equals(playlist)) {
          _list.setSelectedValue(cell, true);
          return;
        }
      } catch (Exception e) {
      }
    }
  }
  void selectExhibit() {
    ExhibitInfo e = getCurrentExhibit();

    contentListModel.notifyChange();
    exhibitPhotosModel.notifyChange();
    contentList.setSelectionInterval(0, 0);
    for (ListSelectionListener l : contentList.getListSelectionListeners()) {
      l.valueChanged(new ListSelectionEvent(contentList, 0, 0, false));
    }
    exhibitXCoordField.getModel().setValue(e.getX());
    exhibitXCoordOrig.setText("X coordinate: (was " + e.origXCoord + ")");
    exhibitYCoordField.getModel().setValue(e.getY());
    exhibitYCoordOrig.setText("Y coordinate: (was " + e.origYCoord + ")");

    exhibitNextDropdown.setSelectedItem(e.getNext());
    if (e.getNext() != null) {
      exhibitNextOrig.setText("Next: (was " + e.origNext + ")");
    } else {
      exhibitPreviousOrig.setText("Next:");
    }
    exhibitPreviousDropdown.setSelectedItem(e.getPrevious());
    if (e.getPrevious() != null) {
      exhibitPreviousOrig.setText("Previous: (was " + e.origPrevious + ")");
    } else {
      exhibitPreviousOrig.setText("Previous:");
    }

    exhibitPhotosList.setSelectionInterval(0, 0);
    exhibitAliasesList.setSelectionInterval(0, 0);

    exhibitAliasesModel.notifyChange();

    selectPhoto();
    selectAlias();
  }
 /**
  * Set the selection behavior for a OneToManyIndexMap.
  *
  * @param allSelected This only applies to OneToManyIndexMaps, if true all destination indices
  *     must be selected in order for the source index to be selected, if false then the source
  *     index is selected if any of its associated destination indices are selected.
  */
 public void setAllSelected(boolean allSelected) {
   this.allSelected = allSelected;
   if (map != null && !map.isOneToOne()) {
     selListener.valueChanged(
         new ListSelectionEvent(
             src, src.getMinSelectionIndex(), src.getMaxSelectionIndex(), false));
   }
 }
 /**
  * Link two ListSelectionModels so that selections in either will be reflected in the other. If a
  * map is given, it provides the mapping of indices between the two ListSelectionModels.
  *
  * @param model1 One of the ListSelectionModels to link together.
  * @param model2 The other ListSelectionModels to link together.
  * @param map If not null, this provides the mapping of indices between the two
  *     ListSelectionModels.
  * @param allSelected Sets the selection behavior for a OneToManyIndexMap.
  * @see #setAllSelected
  */
 public IndexMapSelection(
     ListSelectionModel model1, ListSelectionModel model2, IndexMap map, boolean allSelected) {
   this.src = model1;
   this.dst = model2;
   this.map = map;
   this.allSelected = allSelected;
   if (src.getMinSelectionIndex() >= 0) {
     selListener.valueChanged(
         new ListSelectionEvent(
             src, src.getMinSelectionIndex(), src.getMaxSelectionIndex(), false));
   }
   src.addListSelectionListener(selListener);
   dst.addListSelectionListener(selListener);
 }
示例#5
0
 private void fireSelectionChanged(ListSelectionEvent event) {
   for (ListSelectionListener listener : listeners) {
     listener.valueChanged(event);
   }
 }
 public void valueChanged(ListSelectionEvent e) {
   for (ListSelectionListener l : listeners) {
     l.valueChanged(e);
   }
 }
示例#7
0
  private <T extends Enum<T>> void createControls(JPanel panel, ZrtpConfigureTableModel<T> model) {
    ResourceManagementService resources = NeomediaActivator.getResources();

    final JButton upButton = new JButton(resources.getI18NString("impl.media.configform.UP"));
    upButton.setOpaque(false);

    final JButton downButton = new JButton(resources.getI18NString("impl.media.configform.DOWN"));
    downButton.setOpaque(false);

    Container buttonBar = new TransparentPanel(new GridLayout(0, 1));
    buttonBar.add(upButton);
    buttonBar.add(downButton);

    panel.setBorder(BorderFactory.createEmptyBorder(MARGIN, MARGIN, MARGIN, MARGIN));
    panel.setLayout(new GridBagLayout());

    final JTable table = new JTable(model.getRowCount(), 2);
    table.setShowGrid(false);
    table.setTableHeader(null);
    table.setModel(model);
    // table.setFillsViewportHeight(true); // Since 1.6 only - nicer view

    /*
     * The first column contains the check boxes which enable/disable their
     * associated encodings and it doesn't make sense to make it wider than
     * the check boxes.
     */
    TableColumnModel tableColumnModel = table.getColumnModel();
    TableColumn tableColumn = tableColumnModel.getColumn(0);
    tableColumn.setMaxWidth(tableColumn.getMinWidth() + 5);
    table.doLayout();

    GridBagConstraints constraints = new GridBagConstraints();
    constraints.anchor = GridBagConstraints.CENTER;
    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridwidth = 1;
    constraints.gridx = 0;
    constraints.gridy = 1;
    constraints.weightx = 1;
    constraints.weighty = 1;
    panel.add(new JScrollPane(table), constraints);

    constraints.anchor = GridBagConstraints.NORTHEAST;
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridwidth = 1;
    constraints.gridx = 1;
    constraints.gridy = 1;
    constraints.weightx = 0;
    constraints.weighty = 0;
    panel.add(buttonBar, constraints);

    ListSelectionListener tableSelectionListener =
        new ListSelectionListener() {
          @SuppressWarnings("unchecked")
          public void valueChanged(ListSelectionEvent event) {
            if (table.getSelectedRowCount() == 1) {
              int selectedRow = table.getSelectedRow();
              if (selectedRow > -1) {
                ZrtpConfigureTableModel<T> model = (ZrtpConfigureTableModel<T>) table.getModel();
                upButton.setEnabled(selectedRow > 0 && model.checkEnableUp(selectedRow));
                downButton.setEnabled(
                    selectedRow < (table.getRowCount() - 1) && model.checkEnableDown(selectedRow));
                return;
              }
            }
            upButton.setEnabled(false);
            downButton.setEnabled(false);
          }
        };
    table.getSelectionModel().addListSelectionListener(tableSelectionListener);

    TableModelListener tableListener =
        new TableModelListener() {
          @SuppressWarnings("unchecked")
          public void tableChanged(TableModelEvent e) {
            if (table.getSelectedRowCount() == 1) {
              int selectedRow = table.getSelectedRow();
              if (selectedRow > -1) {
                ZrtpConfigureTableModel<T> model = (ZrtpConfigureTableModel<T>) table.getModel();
                upButton.setEnabled(selectedRow > 0 && model.checkEnableUp(selectedRow));
                downButton.setEnabled(
                    selectedRow < (table.getRowCount() - 1) && model.checkEnableDown(selectedRow));
                return;
              }
            }
            upButton.setEnabled(false);
            downButton.setEnabled(false);
          }
        };
    table.getModel().addTableModelListener(tableListener);

    tableSelectionListener.valueChanged(null);

    ActionListener buttonListener =
        new ActionListener() {
          @SuppressWarnings("unchecked")
          public void actionPerformed(ActionEvent event) {
            Object source = event.getSource();
            boolean up;
            if (source == upButton) up = true;
            else if (source == downButton) up = false;
            else return;

            int index =
                ((ZrtpConfigureTableModel<T>) table.getModel())
                    .move(table.getSelectedRow(), up, up);
            table.getSelectionModel().setSelectionInterval(index, index);
          }
        };
    upButton.addActionListener(buttonListener);
    downButton.addActionListener(buttonListener);
  }
示例#8
0
 void notifySelectionChanged(final ListSelectionEvent event) {
   for (ListSelectionListener l : mySelectionListeners) {
     l.valueChanged(event);
   }
 }
 public void reselectPlaylist() {
   _listSelectionListener.valueChanged(null);
 }