albumsWidget.setEditHandler(new RowOperationHandler<Album>() {
@Override
public void handle(Album a) {
AlbumForm af = new AlbumForm(a, em);
final PopupPanel pp = new PopupPanel(true, true);
af.setSaveHandler(new RowOperationHandler<Album>() {
@Override
public void handle(Album album) {
em.flush();
refreshUI();
pp.hide();
}
});
pp.setWidget(af);
pp.setGlassEnabled(true);
pp.show();
af.grabFocus();
}
});
resetEverythingButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
((ErraiEntityManager) em).removeAll();
preFillDatabaseIfEmpty();
refreshUI();
}
});
newAlbumButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
AlbumForm af = new AlbumForm(new Album(), em);
final PopupPanel pp = new PopupPanel(true, true);
af.setSaveHandler(new RowOperationHandler<Album>() {
@Override
public void handle(Album album) {
em.persist(album);
em.flush();
refreshUI();
pp.hide();
}
});
pp.setWidget(af);
pp.setGlassEnabled(true);
pp.show();
af.grabFocus();
}
});
newArtistButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
ArtistForm af = new ArtistForm(new Artist(), em);
final PopupPanel pp = new PopupPanel(true, true);
af.setSaveHandler(new RowOperationHandler<Artist>() {
@Override
public void handle(Artist artist) {
em.persist(artist);
em.flush();
refreshUI();
pp.hide();
}
});
pp.setWidget(af);
pp.setGlassEnabled(true);
pp.show();
af.grabFocus();
}
});
preFillDatabaseIfEmpty();