*
* @return the SettingsPanel
*/
public JPanel createSettingsPanel() {
mChannelListModel = new ChannelListModel();
JPanel panel = new JPanel(new BorderLayout());
JPanel northPn = new JPanel(new GridLayout(1, 2));
JPanel centerPn = new JPanel(new GridLayout(1, 2));
JPanel southPn = new JPanel(new BorderLayout());
southPn.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
panel.add(northPn, BorderLayout.NORTH);
panel.add(centerPn, BorderLayout.CENTER);
panel.add(southPn, BorderLayout.SOUTH);
mAvailableSeparator = DefaultComponentFactory.getInstance()
.createSeparator(
mLocalizer.msg("availableChannels", "Available channels") + ":");
mAvailableSeparator.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 5));
mSubscribedSeparator = DefaultComponentFactory.getInstance()
.createSeparator(
mLocalizer.msg("subscribedChannels", "Subscribed channels") + ":");
mSubscribedSeparator.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 5));
northPn.add(mAvailableSeparator, BorderLayout.NORTH);
northPn.add(mSubscribedSeparator, BorderLayout.NORTH);
// left list box
JPanel listBoxPnLeft = new JPanel(new BorderLayout());
mAllChannels = new ChannelJList(new DefaultListModel());
mAllChannels.setCellRenderer(new ChannelListCellRenderer(true, true, true, true));
listBoxPnLeft.add(new JScrollPane(mAllChannels), BorderLayout.CENTER);
/*
mAllChannels.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if ((mAllChannels.getModel().getSize() == 1)
&& (mAllChannels.getSelectedIndex() >= 0)
&& (mAllChannels.getSelectedValue() instanceof String)) {
mAllChannels.setSelectedIndices(new int[] {});
}
}
});
*/
centerPn.add(listBoxPnLeft);
mRightButton = new JButton(TVBrowserIcons.right(TVBrowserIcons.SIZE_LARGE));
mRightButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
moveChannelsToRight();
}
});
mLeftButton = new JButton(TVBrowserIcons.left(TVBrowserIcons.SIZE_LARGE));
mLeftButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
moveChannelsToLeft();
}
});
JPanel btnPanel = createButtonPn(mRightButton, mLeftButton);
btnPanel.setBorder(BorderFactory.createEmptyBorder(0, Sizes
.dialogUnitXAsPixel(3, btnPanel), 0, Sizes.dialogUnitXAsPixel(3,
btnPanel)));
listBoxPnLeft.add(btnPanel, BorderLayout.EAST);
// right list box
JPanel listBoxPnRight = new JPanel(new BorderLayout());
SortableItemList channelList = new SortableItemList(new ChannelJList());
mSubscribedChannels = channelList.getList();
mFilter = new ChannelFilter();
mSubscribedChannels.setCellRenderer(new FilteredChannelListCellRenderer(mFilter));
// Register DnD on the lists.
mDnDHandler = new ListDragAndDropHandler(mAllChannels, mSubscribedChannels, this);
mDnDHandler.setPaintCueLine(false, true);
// Register the listener for DnD on the lists.
new DragAndDropMouseListener(mAllChannels, mSubscribedChannels, this,
mDnDHandler);
mSubscribedChannelListener = new DragAndDropMouseListener(
mSubscribedChannels, mAllChannels, this, mDnDHandler);
restoreForPopup();
listBoxPnRight.add(new JScrollPane(mSubscribedChannels),
BorderLayout.CENTER);
final JButton configureChannels = new JButton(mLocalizer.msg(
"configSelectedChannels", "Configure selected channels"));
configureChannels.setEnabled(false);
configureChannels.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
configChannels();
}
});
mSubscribedChannels.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if (mSubscribedChannels.getSelectedValues().length > 0) {
configureChannels.setEnabled(true);
} else {
configureChannels.setEnabled(false);
}
}
});
// use INSERT key on left side to move selected channels to active channel
// list
mAllChannels.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_INSERT) {
moveChannelsToRight();
}
}
});
// use DELETE key on right side to remove selected channels
mSubscribedChannels.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_DELETE) {
moveChannelsToLeft();
}
}
});
JPanel btnPanel2 = createButtonPn(channelList.getTopButton(), channelList
.getUpButton(), channelList.getDownButton(), channelList
.getBottomButton());
btnPanel2.setBorder(BorderFactory.createEmptyBorder(0, Sizes
.dialogUnitXAsPixel(3, btnPanel2), 0, 0));
listBoxPnRight.add(btnPanel2, BorderLayout.EAST);
centerPn.add(listBoxPnRight);
final JPanel result = new JPanel(new BorderLayout());
result.addComponentListener(new ComponentAdapter() {
@Override
public void componentHidden(ComponentEvent e) {
if (e.getComponent() == result) {
mRefreshListTimer = null;
}
}
});
result.add(createFilterPanel(), BorderLayout.NORTH);
result.add(panel, BorderLayout.CENTER);
LinkButton urlLabel = new LinkButton(
mLocalizer
.msg(
"addMoreChannels",
"You want to add your own channels? Click here!"),
mLocalizer.msg("addMoreChannelsUrl",
"http://enwiki.tvbrowser.org/index.php/Available_stations"));
JPanel buttonsPanel = new JPanel(new BorderLayout());
// buttonsPanel.add(pn2, BorderLayout.EAST);
buttonsPanel.add(urlLabel, BorderLayout.SOUTH);
result.add(buttonsPanel, BorderLayout.SOUTH);
JButton refreshList = new JButton(mLocalizer.msg("updateChannelList",
"Update channel list"), TVBrowserIcons.refresh(TVBrowserIcons.SIZE_SMALL));