item = new ToolItem(toolbar,SWT.PUSH); item.setText("||"); item.setEnabled(false);
pause = new ToolItem(toolbar,SWT.PUSH); pause.setText("||"); pause.addSelectionListener(new SelectionAdapter(){ public void widgetSelected(SelectionEvent e){ setPaused(!playThread.isPaused()); } });
  void initGUI(){    shell = new Shell(display);    shell.setText("iRATE radio");    shell.addShellListener(new ShellAdapter()    {      public void shellClosed(ShellEvent e){        quit();      }    });    //probly should use filllayout..but i dont wanna figure it out    //gridlayout is overkill for this    GridLayout layout = new GridLayout(2, false);    layout.horizontalSpacing = 0;    // Set the layout into the composite.    shell.setLayout(layout);    // Create the children of the composite.        Menu menubar = new Menu(shell, SWT.BAR);    shell.setMenuBar(menubar);        MenuItem item1 = new MenuItem(menubar,SWT.CASCADE);    item1.setText("Action");        Menu menu1 = new Menu(item1);    item1.setMenu(menu1);        MenuItem item1_1 = new MenuItem(menu1,SWT.PUSH);    item1_1.setText("Download More");    item1_1.addSelectionListener(new SelectionAdapter(){      public void widgetSelected(SelectionEvent e){        downloadThread.go();      }    });            MenuItem item1_2 = new MenuItem(menu1,SWT.PUSH);    item1_2.setText("Purge");	item1_2.addSelectionListener(new SelectionAdapter(){	  public void widgetSelected(SelectionEvent e){		trackDatabase.purge();		update();	  }	});            //	MenuItem item1_3 = new MenuItem(menu1,SWT.SEPARATOR);        MenuItem item1_4 = new MenuItem(menu1,SWT.PUSH);    item1_4.setText("Quit");    item1_4.addSelectionListener(new SelectionAdapter(){      public void widgetSelected(SelectionEvent e){        quit();      }    });                    MenuItem item2 = new MenuItem(menubar,SWT.CASCADE);    item2.setText("Settings");        Menu menu2 = new Menu(item2);    item2.setMenu(menu2);        //MenuItem item2_1 = new MenuItem(menu2,SWT.PUSH);    //item2_1.setText("Account");        MenuItem mDownload = new MenuItem(menu2, SWT.CASCADE);	mDownload.setText("Auto Download");	menu2 = new Menu(mDownload);	mDownload.setMenu(menu2);		int counts[] = new int[] {0,2, 5, 11, 17, 23, 29};	int autoDownload = trackDatabase.getAutoDownload(); 	for(int i=0;i< counts.length;i++){        MenuItem mTimes = new MenuItem(menu2, SWT.CHECK, i);		final int count = counts[i];		mTimes.setText(i==0?"Disabled":"Every " + count + " times" );		mTimes.setSelection(count == autoDownload);		mTimes.addSelectionListener(new SelectionAdapter(){		public void widgetSelected(SelectionEvent e){			//stupid trick to make self the only selected item			MenuItem self = (MenuItem)e.getSource();			Menu parent = self.getParent();			MenuItem items[] = parent.getItems();			for(int i = 0;i< parent.getItemCount();i++)				parent.getItem(i).setSelection(false);			self.setSelection(true);						trackDatabase.setAutoDownload(count);			downloadThread.checkAutoDownload();		}		});	}                lblTitle = new Label(shell, SWT.NONE);    lblTitle.setText("Current song goes here");    GridData gridData = new GridData();    gridData.horizontalAlignment = GridData.FILL;    gridData.horizontalSpan = 2;    lblTitle.setLayoutData(gridData);        tblSongs = new Table(shell, SWT.NONE);            TableColumn col = new TableColumn(tblSongs,SWT.LEFT);    col.setWidth(100);    col.setText("Artist");    col.addListener(SWT.Selection, new Listener() {      public void handleEvent(Event e) {        SortTableByStringColumn(0, tblSongs);      }    });        col = new TableColumn(tblSongs,SWT.LEFT);    col.setWidth(100);    col.setText("Track");    col.addListener(SWT.Selection, new Listener() {      public void handleEvent(Event e) {        SortTableByStringColumn(1, tblSongs);      }    });    col = new TableColumn(tblSongs,SWT.LEFT);    col.setWidth(100);    col.setText("Rating");    col = new TableColumn(tblSongs,SWT.LEFT);    col.setWidth(100);    col.setText("Plays");    col = new TableColumn(tblSongs,SWT.LEFT);    col.setWidth(100);    col.setText("Last");    //col.setWidth(50);    tblSongs.setHeaderVisible(true);    synchronizePlaylist(playListManager, tblSongs);    tblSongs.addSelectionListener(new SelectionAdapter(){    public void widgetSelected(SelectionEvent e){		playThread.play(getTrackByTableItem(tblSongs.getSelection()[0]));	}   });        for(int i = 0;i< tblSongs.getColumns().length;i++)      tblSongs.getColumns()[i].pack();        gridData = new GridData();    gridData.horizontalAlignment = GridData.FILL;    gridData.grabExcessHorizontalSpace = true;    gridData.verticalAlignment = GridData.FILL;    gridData.grabExcessVerticalSpace = true;    gridData.horizontalSpan = 2;    tblSongs.setLayoutData(gridData);    tblSongs.pack();  	ToolBar toolbar = new ToolBar(shell,SWT.FLAT);    ToolItem item;    item = new ToolItem(toolbar,SWT.PUSH);    item.setText("This sux");    item.addSelectionListener(new SelectionAdapter(){      public void widgetSelected(SelectionEvent e){        setRating(0);        playThread.reject();      }    });        item = new ToolItem(toolbar,SWT.PUSH);    item.setText("Yawn");    item.addSelectionListener(new SelectionAdapter(){      public void widgetSelected(SelectionEvent e){        setRating(2);      }    });    item = new ToolItem(toolbar,SWT.PUSH);    item.setText("Not bad");    item.addSelectionListener(new SelectionAdapter(){      public void widgetSelected(SelectionEvent e){        setRating(5);      }    });    item = new ToolItem(toolbar,SWT.PUSH);    item.setText("Cool");    item.addSelectionListener(new SelectionAdapter(){      public void widgetSelected(SelectionEvent e){        setRating(7);      }    });    item = new ToolItem(toolbar,SWT.PUSH);    item.setText("Love it");    item.addSelectionListener(new SelectionAdapter(){      public void widgetSelected(SelectionEvent e){        setRating(10);      }    });    new ToolItem(toolbar,SWT.SEPARATOR);            item = new ToolItem(toolbar,SWT.PUSH);    item.setText("||");    item.setEnabled(false);        item = new ToolItem(toolbar,SWT.PUSH);    item.setText(">>");    item.addSelectionListener(new SelectionAdapter(){      public void widgetSelected(SelectionEvent e){        playThread.reject();		downloadThread.checkAutoDownload();      }    });    gridData = new GridData();    gridData.horizontalAlignment = GridData.FILL;    gridData.grabExcessHorizontalSpace = true;    gridData.horizontalSpan = 2;    toolbar.setLayoutData(gridData);        lblState = new Label(shell, SWT.NONE);    lblState.setText(strState);        gridData = new GridData();    gridData.horizontalAlignment = GridData.BEGINNING;    gridData.grabExcessHorizontalSpace = true;    lblState.setLayoutData(gridData);    progressBar = new ProgressBar(shell, SWT.HORIZONTAL);    gridData = new GridData();    gridData.horizontalAlignment = GridData.END;    progressBar.setLayoutData(gridData);        shell.pack();    progressBar.setMinimum(0);    progressBar.setMaximum(100);    //progressBar.setSelection(100);            Rectangle rec = shell.getBounds();    rec.height = 300;    shell.setBounds(rec);   // Point p = progressBar.getSize();    //lblState.setSize(rec.width - p.x-5, p.y);        shell.open();  }