Skip to content

Commit

Permalink
added check for recently added playlist
Browse files Browse the repository at this point in the history
  • Loading branch information
tayal007 authored Nov 12, 2016
1 parent f934772 commit 5031ce7
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/beatboxer/CreatePlaylistController.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,30 +46,29 @@ public class CreatePlaylistController implements Initializable {
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}
}

@FXML
private void checkName(KeyEvent event) throws Exception{
private void checkName(KeyEvent event) throws Exception {
String newPlaylist = nameField.getText();
newPlaylist = newPlaylist.trim();
if(newPlaylist.equals("")){
if (newPlaylist.equals("")) {
ok.setDisable(true);
errorLabel.setText("");
}
else{
} else {
Show sh = new Show();
ObservableList<BBItem> list = sh.ShowAllPlayLists();
for(BBItem playList : list){
if(playList.getName().equalsIgnoreCase(newPlaylist)){
for (BBItem playList : list) {
if (playList.getName().equalsIgnoreCase(newPlaylist)) {
ok.setDisable(true);
errorLabel.setText("A playlist with that name already exists. Please enter \na different name.");
return;
}
}
if(newPlaylist.equalsIgnoreCase("All Songs") || newPlaylist.equalsIgnoreCase("Favourites")){
if (newPlaylist.equalsIgnoreCase("All Songs") || newPlaylist.equalsIgnoreCase("Favourites") || newPlaylist.equalsIgnoreCase("Recently Added")) {
ok.setDisable(true);
errorLabel.setText("A playlist with that name already exists. Please enter \na different name.");
return;
return;
}
errorLabel.setText("");
ok.setDisable(false);
Expand All @@ -84,14 +83,13 @@ private void cancel(ActionEvent event) {

@FXML
private void okExecute(ActionEvent event) {
try{
try {
PlayList p = new PlayList();
p.create(nameField.getText());
cancel(new ActionEvent());
}
catch(Exception e){
} catch (Exception e) {
;
}
}

}

0 comments on commit 5031ce7

Please sign in to comment.