* improved HistoryPanel layout

* TVRageClient.EpisodeListFeed will not fail, if XML does not contain an episode list
This commit is contained in:
Reinhard Pointner 2008-10-12 20:14:41 +00:00
parent 197bfd1b42
commit 192da2cb17
2 changed files with 22 additions and 9 deletions

View File

@ -32,14 +32,27 @@ public class HistoryPanel extends JPanel {
}
protected void setupHeader() {
private void setupHeader() {
for (int i = 0; i < 3; i++) {
JLabel columnHeader = new JLabel();
columnHeader.setFont(columnHeader.getFont().deriveFont(Font.BOLD));
columnHeaders.add(columnHeader);
add(columnHeader, (i == 0) ? "align left, gapbefore 20" : "align right, gapafter 20");
add(columnHeader, getHeaderConstraint(i));
}
}
private String getHeaderConstraint(int headerIndex) {
switch (headerIndex) {
case 0:
return "align left, gapbefore 24";
case 1:
return "align center";
default:
return "align right, gapafter 12";
}
}

View File

@ -138,14 +138,14 @@ public class TVRageClient implements EpisodeListClient {
private final int totalSeasons;
private final Node episodeListNode;
private final Document feed;
public EpisodeListFeed(Document dom) {
name = XPathUtil.selectString("Show/name", dom);
totalSeasons = XPathUtil.selectInteger("Show/totalseasons", dom);
public EpisodeListFeed(Document feed) {
name = XPathUtil.selectString("Show/name", feed);
totalSeasons = XPathUtil.selectInteger("Show/totalseasons", feed);
episodeListNode = XPathUtil.selectNode("Show/Episodelist", dom);
this.feed = feed;
}
@ -172,9 +172,9 @@ public class TVRageClient implements EpisodeListClient {
public List<Episode> getEpisodeList(int season) {
if (season > getTotalSeasons() || season < 0)
throw new IllegalArgumentException(String.format("%s only has %d seasons", getName(), getTotalSeasons()));
throw new IllegalArgumentException(String.format("%s only has %d seasons.", getName(), getTotalSeasons()));
List<Node> nodes = XPathUtil.selectNodes("Season[@no='" + season + "']/episode", episodeListNode);
List<Node> nodes = XPathUtil.selectNodes("//Season[@no='" + season + "']/episode", feed);
List<Episode> episodes = new ArrayList<Episode>(nodes.size());
String numberOfSeason = Integer.toString(season);