btnSelect.setPreferredSize(new Dimension(81, 0));
btnSelect.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
ListSelectionModel selectionModel = lstReleases.getSelectionModel();
DiscogsReleaseListModel model = (DiscogsReleaseListModel) lstReleases.getModel();
thread = new Thread(new DiscogsCaller(
DiscogsCaller.CallMode.RELEASE, model.getEx(selectionModel.getMinSelectionIndex()).getId(), me), "");
thread.start();
CardLayout cl = (CardLayout) getContentPane().getLayout();
cl.show(getContentPane(), CARD_RELEASE);
}
});
btnSelect.setEnabled(false);
panelArtistControls.add(btnSelect);
Component horizontalStrut = Box.createHorizontalStrut(20);
horizontalStrut.setPreferredSize(new Dimension(10, 0));
horizontalStrut.setMinimumSize(new Dimension(10, 0));
panelArtistControls.add(horizontalStrut);
JButton btnCancelArtist = new JButton("Cancel");
btnCancelArtist.setToolTipText("Abort querying and/or close Discogs dialog.");
btnCancelArtist.setPreferredSize(new Dimension(81, 0));
btnCancelArtist.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
close();
}
});
panelArtistControls.add(btnCancelArtist);
Component horizontalStrut_3 = Box.createHorizontalStrut(20);
panelArtistControls.add(horizontalStrut_3);
splitPaneArtist.setResizeWeight(0.3);
panelArtist.add(splitPaneArtist, BorderLayout.CENTER);
JScrollPane scrollPane = new JScrollPane();
splitPaneArtist.setLeftComponent(scrollPane);
JPanel panel_1 = new JPanel();
panel_1.setPreferredSize(new Dimension(10, 40));
scrollPane.setColumnHeaderView(panel_1);
panel_1.setLayout(new BoxLayout(panel_1, BoxLayout.X_AXIS));
Component horizontalStrut_5 = Box.createHorizontalStrut(20);
panel_1.add(horizontalStrut_5);
JLabel lblArtist = new JLabel("Artist");
panel_1.add(lblArtist);
Component horizontalStrut_6 = Box.createHorizontalStrut(20);
horizontalStrut_6.setPreferredSize(new Dimension(10, 0));
panel_1.add(horizontalStrut_6);
txtArtist = new JTextField();
txtArtist.setToolTipText("Artist query string.");
txtArtist.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (KeyEvent.VK_ENTER == e.getKeyCode()) {
btnQuery.doClick();
}
}
});
txtArtist.setMaximumSize(new Dimension(2147483647, 24));
txtArtist.setText("Artist");
panel_1.add(txtArtist);
txtArtist.setColumns(10);
txtArtist.setText(tracks.get(0).getTrackData().getArtist());
txtArtist.setCaretPosition(0);
JScrollPane scrollPane_1 = new JScrollPane();
splitPaneArtist.setRightComponent(scrollPane_1);
JPanel panel_2 = new JPanel();
panel_2.setPreferredSize(new Dimension(10, 40));
scrollPane_1.setColumnHeaderView(panel_2);
lstReleases.setToolTipText("List of releases belong to selected artist. One is to be selected to continue.");
lstReleases.setModel(new DiscogsReleaseListModel());
lstReleases.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent arg0) {
if (!arg0.getValueIsAdjusting()) {
ListSelectionModel selectionModel = lstReleases.getSelectionModel();
btnSelect.setEnabled(!selectionModel.isSelectionEmpty());
}
}
});
lstReleases.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() > 1) {
ListSelectionModel selectionModel = lstReleases.getSelectionModel();
if (!selectionModel.isSelectionEmpty()) {
DiscogsReleaseListModel releaseModel = (DiscogsReleaseListModel) lstReleases.getModel();
ArtistRelease release = releaseModel.getEx(selectionModel.getMinSelectionIndex());
if(java.awt.Desktop.isDesktopSupported()) {
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if(desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
try {
desktop.browse(new URI("http://www.discogs.com/release/" + release.getId()));
}
catch (Exception exc) {
// ignore any exception since it's absolutely optional feature
}
}
}
}
}
}
});
scrollPane_1.setViewportView(lstReleases);
lstArtists.setToolTipText("List of artists fit query string.");
lstArtists.setModel(new DiscogsArtistListModel());
lstArtists.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent arg0) {
DiscogsArtistListModel artistModel = (DiscogsArtistListModel) lstArtists.getModel();
ListSelectionModel selectionModel = lstArtists.getSelectionModel();
if (!selectionModel.isSelectionEmpty() && !arg0.getValueIsAdjusting()) {
Artist artist = artistModel.getEx(selectionModel.getMinSelectionIndex());
if (artist != null) {
DiscogsReleaseListModel releaseModel = (DiscogsReleaseListModel) lstReleases.getModel();
releaseModel.clear();
for (ArtistRelease release : artist.getReleases()) {
releaseModel.addElement(release);
}
lstReleases.revalidate();
lstReleases.clearSelection();
lstReleases.repaint();
}
}
}
});
scrollPane.setViewportView(lstArtists);
btnQuery.setToolTipText("Query Discogs database.");
btnQuery.setPreferredSize(new Dimension(81, 0));
btnQuery.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
if (!Util.isEmpty(txtArtist.getText())) {
thread = new Thread(new DiscogsCaller(
DiscogsCaller.CallMode.SEARCH_ARTISTS, txtArtist.getText(), me), "");
thread.start();
}
}
});
Component horizontalStrut_7 = Box.createHorizontalStrut(20);
horizontalStrut_7.setPreferredSize(new Dimension(10, 0));
panel_1.add(horizontalStrut_7);
panel_1.add(btnQuery);
Component horizontalStrut_8 = Box.createHorizontalStrut(20);
panel_1.add(horizontalStrut_8);
panel_2.setLayout(new BoxLayout(panel_2, BoxLayout.X_AXIS));
Component horizontalStrut_9 = Box.createHorizontalStrut(20);
panel_2.add(horizontalStrut_9);
JLabel lblFilter = new JLabel("Filter");
panel_2.add(lblFilter);
txtFilter = new JTextField();
txtFilter.setToolTipText("Release filter string.");
txtFilter.setMaximumSize(new Dimension(2147483647, 24));
txtFilter.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent e) {
filterReleases(lstReleases);
}
public void removeUpdate(DocumentEvent e) {
filterReleases(lstReleases);
}
public void insertUpdate(DocumentEvent e) {
filterReleases(lstReleases);
}
});
Component horizontalStrut_10 = Box.createHorizontalStrut(20);
horizontalStrut_10.setPreferredSize(new Dimension(10, 0));
panel_2.add(horizontalStrut_10);
txtFilter.setText("Filter");
panel_2.add(txtFilter);
txtFilter.setColumns(10);
txtFilter.setText(tracks.get(0).getTrackData().getAlbum());
txtFilter.setCaretPosition(0);
DiscogsReleaseListModel model = (DiscogsReleaseListModel) lstReleases.getModel();
model.setFilter(txtFilter.getText());
JButton btnClear = new JButton("Clear");
btnClear.setToolTipText("Clear release filter field.");
btnClear.setPreferredSize(new Dimension(81, 0));
btnClear.addActionListener(new ActionListener() {