// Path: src/main/java/songo/TableUtil.java
// public class TableUtil {
// 	public static void packColumns(Table table) {
// 		for(TableColumn column : table.getColumns())
// 			column.pack();
// 	}
// }
// 
// Path: src/main/java/songo/vk/Audio.java
// public class Audio {
// 	public final String artist;
// 	public final String title;
// 	public final String url;
// 	public final int duration;
// 
// 	Audio(String artist, String title, String url, int duration) {
// 		this.artist = artist;
// 		this.title = title;
// 		this.url = url;
// 		this.duration = duration;
// 	}
// 
// 	@Override
// 	public int hashCode() {
// 		return Objects.hashCode(artist, title);
// 	}
// 
// 	@Override
// 	public boolean equals(Object obj) {
// 		if(obj == null)
// 			return false;
// 		if(this == obj)
// 			return true;
// 		if(!(obj instanceof Audio))
// 			return false;
// 		Audio a = (Audio) obj;
// 		return artist.equals(a.artist) && title.equals(a.title);
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return Objects.toStringHelper(this)
// 			.add("artist", artist)
// 			.add("title", title)
// 			.add("url", url)
// 			.toString();
// 	}
// }


import com.google.common.collect.ImmutableList;
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import songo.TableUtil;
import songo.annotation.SearchTab;
import songo.annotation.SessionBus;
import songo.vk.Audio;
import java.util.List;
		add.setText("Add");
		add.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				bus.post(new Add());
			}
		});
		MenuItem replace = new MenuItem(menu, SWT.NONE);
		replace.setText("Replace");
		replace.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				bus.post(new Replace());
			}
		});
		table.setMenu(menu);
	}

	public String getSearchQuery() {
		return searchField.getText();
	}

	public void setResults(List<Audio> results) {
		this.results = results;
		table.setRedraw(false);
		table.removeAll();
		for(Audio a : results) {
			TableItem item = new TableItem(table, SWT.NONE);
			item.setText(new String[]{a.artist, a.title});
		}
// Path: src/main/java/songo/TableUtil.java
// public class TableUtil {
// 	public static void packColumns(Table table) {
// 		for(TableColumn column : table.getColumns())
// 			column.pack();
// 	}
// }
// 
// Path: src/main/java/songo/vk/Audio.java
// public class Audio {
// 	public final String artist;
// 	public final String title;
// 	public final String url;
// 	public final int duration;
// 
// 	Audio(String artist, String title, String url, int duration) {
// 		this.artist = artist;
// 		this.title = title;
// 		this.url = url;
// 		this.duration = duration;
// 	}
// 
// 	@Override
// 	public int hashCode() {
// 		return Objects.hashCode(artist, title);
// 	}
// 
// 	@Override
// 	public boolean equals(Object obj) {
// 		if(obj == null)
// 			return false;
// 		if(this == obj)
// 			return true;
// 		if(!(obj instanceof Audio))
// 			return false;
// 		Audio a = (Audio) obj;
// 		return artist.equals(a.artist) && title.equals(a.title);
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return Objects.toStringHelper(this)
// 			.add("artist", artist)
// 			.add("title", title)
// 			.add("url", url)
// 			.toString();
// 	}
// }


// Path: src/main/java/songo/view/SearchView.java
import com.google.common.collect.ImmutableList;
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import songo.TableUtil;
import songo.annotation.SearchTab;
import songo.annotation.SessionBus;
import songo.vk.Audio;
import java.util.List;

		add.setText("Add");
		add.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				bus.post(new Add());
			}
		});
		MenuItem replace = new MenuItem(menu, SWT.NONE);
		replace.setText("Replace");
		replace.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				bus.post(new Replace());
			}
		});
		table.setMenu(menu);
	}

	public String getSearchQuery() {
		return searchField.getText();
	}

	public void setResults(List<Audio> results) {
		this.results = results;
		table.setRedraw(false);
		table.removeAll();
		for(Audio a : results) {
			TableItem item = new TableItem(table, SWT.NONE);
			item.setText(new String[]{a.artist, a.title});
		}
		TableUtil.packColumns(table);