public TracksInfoDialog(final PlaylistTable parent, final List<Track> tracks) {
this.parent = parent;
setTitle("Properties");
setModal(false);
final MultiTagFieldModel tagFieldsModel = new MultiTagFieldModel(tracks);
final JComponent tagsTable = createTable(tagFieldsModel);
final JComponent propsTable = createTable(new FileInfoModel(tracks));
JTabbedPane tp = new JTabbedPane();
tp.setFocusable(false);
tp.addTab("Metadata", tagsTable);
tp.addTab("Properties", propsTable);
add(tp, BorderLayout.CENTER);
Box b1 = new Box(BoxLayout.X_AXIS);
b1.add(Box.createHorizontalStrut(10));
final JButton tools = new JButton("Tools");
b1.add(tools);
tools.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final JPopupMenu menu = new JPopupMenu();
JMenuItem menuItemEdit = new JMenuItem("Auto track number");
menu.add(menuItemEdit).addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Tools.autoTrackNumber(tagFieldsModel);
tagFieldsModel.sort();
tagsTable.revalidate();
tagsTable.repaint();
}
});
menu.show(tools, 0, tools.getBounds().height);
}
});
b1.add(Box.createHorizontalGlue());
JButton write = new JButton("Write");
b1.add(write);
write.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
tagFieldsModel.approveModel();
writeTracks(tracks);
}
});
cancel = new JButton("Cancel");
cancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
tagFieldsModel.rejectModel();
setVisible(false);
dispose();
parent.requestFocus();
}
});