sidebar.addComponent(selections);
sidebar.setExpandRatio(selections, 1.0F);
// Then comes the cover artwork (we'll add the actual image in the
// themeing section)
Embedded cover = new Embedded("Currently Playing");
sidebar.addComponent(cover);
/*
* And lastly, we need the track listing table It should fill the whole
* left side of our bottom layout
*/
Table listing = new Table();
listing.setSizeFull();
listing.setSelectable(true);
bottom.setSecondComponent(listing);
// Add the table headers
listing.addContainerProperty("Name", String.class, "");
listing.addContainerProperty("Time", String.class, "0:00");
listing.addContainerProperty("Artist", String.class, "");
listing.addContainerProperty("Album", String.class, "");
listing.addContainerProperty("Genre", String.class, "");
listing.addContainerProperty("Rating", NativeSelect.class,
new NativeSelect());
// Lets populate the table with random data
String[] tracks = new String[] { "Red Flag", "Millstone",
"Not The Sun", "Breath", "Here We Are", "Deep Heaven",
"Her Voice Resides", "Natural Tan", "End It All", "Kings",
"Daylight Slaving", "Mad Man", "Resolve", "Teargas",
"African Air", "Passing Bird" };
String[] times = new String[] { "4:12", "6:03", "5:43", "4:32", "3:42",
"4:45", "2:56", "9:34", "2:10", "3:44", "5:49", "6:30", "5:18",
"7:42", "3:13", "2:52" };
String[] artists = new String[] { "Billy Talent", "Brand New",
"Breaking Benjamin", "Becoming The Archetype",
"Bullet For My Valentine", "Chasing Victory", "Chimaira",
"Danko Jones", "Deadlock", "Deftones", "From Autumn To Ashes",
"Haste The Day", "Four Year Strong", "In Flames", "Kemopetrol",
"John Legend" };
String[] albums = new String[] { "Once Again", "The Caitiff Choir",
"The Devil And God", "Light Grenades", "Dicthonomy",
"Back In Black", "Dreamer", "Come Clarity", "Year Zero",
"Frames", "Fortress", "Phobia", "The Poison", "Manifesto",
"White Pony", "The Big Dirty" };
String[] genres = new String[] { "Rock", "Metal", "Hardcore", "Indie",
"Pop", "Alternative", "Blues", "Jazz", "Hip Hop",
"Electronica", "Punk", "Hard Rock", "Dance", "R'n'B", "Gospel",
"Country" };
for (int i = 0; i < 1000; i++) {
NativeSelect s = new NativeSelect();
s.addItem("1 star");
s.addItem("2 stars");
s.addItem("3 stars");
s.addItem("4 stars");
s.addItem("5 stars");
s.select(i % 5 + " stars");
final int index = i % 16;
listing.addItem(new Object[] { tracks[index], times[index],
artists[index], albums[index], genres[index], s }, i);
}
// We'll align the track time column to right as well
listing.setColumnAlignment("Time", Table.ALIGN_RIGHT);
// TODO the footer
// Now what's left to do? Themeing of course.
// setTheme("vaadintunes");
/*
* Let's give a namespace to our application window. This way, if
* someone uses the same theme for different applications, we don't get
* unwanted style conflicts.
*/
// root.setStyleName("tTunes");
top.setStyleName("top");
top.setHeight("75px"); // Same as the background image height
playback.setStyleName("playback");
playback.setMargin(new MarginInfo(false, true, false, false)); // Add
// right-side
// margin
play.setStyleName("play");
next.setStyleName("next");
prev.setStyleName("prev");
playback.setComponentAlignment(prev, Alignment.MIDDLE_LEFT);
playback.setComponentAlignment(next, Alignment.MIDDLE_LEFT);
volume.setStyleName("volume");
mute.setStyleName("mute");
max.setStyleName("max");
vol.setWidth("78px");
status.setStyleName("status");
status.setMargin(true);
status.setHeight("46px"); // Height of the background image
toggleVisualization.setStyleName("toggle-vis");
jumpToTrack.setStyleName("jump");
viewAsTable.setStyleName("viewmode-table");
viewAsGrid.setStyleName("viewmode-grid");
coverflow.setStyleName("viewmode-coverflow");
sidebar.setStyleName("sidebar");
music.setStyleName("selected");
cover.setSource(new ThemeResource("images/album-cover.jpg"));
// Because this is an image, it will retain it's aspect ratio
cover.setWidth("100%");
}