Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* CDPrintable: A program that prints labels with track listings for your CD cases.
* Copyright (C) 2025 Alexander McLean
*
* This source code is licensed under the GNU General Public License v3.0
* found in the LICENSE file in the root directory of this source tree.
*
* This class represents the final album data that will be used to print the CD label.
*/

package com.CDPrintable.MusicBrainzResources;

public class MusicBrainzFinalizedRelease {
private String title;
private String artist;
private MusicBrainzTrack[] tracks;

public MusicBrainzFinalizedRelease(String title, String artist, MusicBrainzTrack[] tracks) {
this.title = title;
this.artist = artist;
this.tracks = tracks;
}


public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

public String getArtist() {
return artist;
}

public void setArtist(String artist) {
this.artist = artist;
}

public MusicBrainzTrack[] getTracks() {
return tracks;
}

public void setTracks(MusicBrainzTrack[] tracks) {
this.tracks = tracks;
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Title: ").append(title).append("\n");
sb.append("Artist: ").append(artist).append("\n");
sb.append("Tracks: \n");
for (MusicBrainzTrack track : tracks) {
sb.append(track.getTrackNumber()).append(" ").append(track.getTitle()).append("\n");
}
return sb.toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* CDPrintable: A program that prints labels with track listings for your CD cases.
* Copyright (C) 2025 Alexander McLean
*
* This source code is licensed under the GNU General Public License v3.0
* found in the LICENSE file in the root directory of this source tree.
*
* This class renders the final labels for the CD cases.
*/

package com.CDPrintable.MusicBrainzResources;

import java.util.ArrayList;

public class MusicBrainzLabelGenerator {
private ArrayList<MusicBrainzFinalizedRelease> finalizedReleaseList;

public MusicBrainzLabelGenerator() {
finalizedReleaseList = new ArrayList<>();
}

public void addRelease(MusicBrainzFinalizedRelease release) {
finalizedReleaseList.add(release);
}
}
10 changes: 6 additions & 4 deletions src/main/java/com/CDPrintable/ProgramWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class ProgramWindow {
private final JPanel cdSearchPanel = new JPanel();
private final JLabel searchStatusLabel = new JLabel("Status: Nothing's going on.");
private static final ArrayList<String> idList = new ArrayList<>();
private final MusicBrainzLabelGenerator labelGenerator = new MusicBrainzLabelGenerator();

/**
* Creates a new ProgramWindow and sets up the GUI.
Expand Down Expand Up @@ -402,10 +403,11 @@ private void clickSearch(int row, int col, JTable table) {
if (col == 0) {
response = sendRequest(typeOfTable.equals("Disc Name") ? "tracks" : "release", idList.get(row), true);
MusicBrainzJSONReader reader = new MusicBrainzJSONReader(response);
model = reader.getTracksAsTableModel(typeOfTable.equals("Disc Name") ? reader.getTracks() : reader.getReleaseTracks());
MusicBrainzTrack[] tracks = typeOfTable.equals("Disc Name") ? reader.getTracks() : reader.getReleaseTracks();
model = reader.getTracksAsTableModel(tracks);
String date = typeOfTable.equals("Release Name") ? table.getValueAt(row, 3).toString() : null;
createTrackDialog(table.getValueAt(row, 0).toString(), table.getValueAt(row, 1).toString(),
Integer.parseInt(table.getValueAt(row, 2).toString()), date, model);
Integer.parseInt(table.getValueAt(row, 2).toString()), date, model, tracks);
} else if (col == 1) {
response = sendRequest("artist", table.getValueAt(row, 1).toString(), false);
MusicBrainzJSONReader reader = new MusicBrainzJSONReader(response);
Expand All @@ -428,7 +430,7 @@ private void clickSearch(int row, int col, JTable table) {
* @param date The date of the release. CDStubs typically do not have a date.
* @param model The table model to use for the track list.
*/
private void createTrackDialog(String title, String artist, int trackCount, String date, DefaultTableModel model) {
private void createTrackDialog(String title, String artist, int trackCount, String date, DefaultTableModel model, MusicBrainzTrack[] tracks) {
// Set up panels
JPanel mainPanel = new JPanel(new BorderLayout());
JPanel panel = new JPanel();
Expand All @@ -455,7 +457,7 @@ private void createTrackDialog(String title, String artist, int trackCount, Stri
// Show dialog
int result = JOptionPane.showConfirmDialog(null, mainPanel, "Tracks", JOptionPane.YES_NO_OPTION);
if (result == JOptionPane.YES_OPTION) {
System.out.println("ask her out");
labelGenerator.addRelease(new MusicBrainzFinalizedRelease(title, artist, tracks));
} else if (result == JOptionPane.NO_OPTION) {
System.out.println("she rejected you...");
}
Expand Down