public void onClick(ClickEvent event) {
final ListBox productoraPelicula = new ListBox();
MyUserServiceAsync service = (MyUserServiceAsync) GWT
.create(MyUserService.class);
ServiceDefTarget serviceDef = (ServiceDefTarget) service;
serviceDef.setServiceEntryPoint(GWT.getModuleBaseURL()
+ "userService");
ParallelCallback productoraCallback = new ParallelCallback();
ParentCallback parent = new ParentCallback(productoraCallback) {
public void handleSuccess() {
List<ProductoraDTO> produ = new ArrayList<ProductoraDTO>();
produ = (List<ProductoraDTO>) getCallbackData(0);
int var = produ.size();
if (var > 0){
for (Integer i = 0; i < var; i++) {
productoraPelicula.addItem(produ.get(i).getNombre());
}
}
if (productoraPelicula.getItemCount() > 0){
MyUserServiceAsync service = (MyUserServiceAsync) GWT
.create(MyUserService.class);
ServiceDefTarget serviceDef = (ServiceDefTarget) service;
serviceDef.setServiceEntryPoint(GWT.getModuleBaseURL()
+ "userService");
// Create the popup dialog box
final DialogBox listPopUp = new DialogBox();
listPopUp.setAnimationEnabled(true);
final TextBox tituloPelicula = new TextBox();
//tituloPelicula.setText("T\u00edtulo");
final TextBox tituloEspPelicula = new TextBox();
//tituloEspPelicula.setText("T\u00edtulo espa\u00f1ol");
final TextBox anioPelicula = new TextBox();
anioPelicula.setText("2000");
final ListBox directorPelicula = new ListBox();
final ListBox clasificacionPelicula = new ListBox();
final ListBox actorPelicula = new ListBox(true);
actorPelicula.setVisibleItemCount(10);
///// Cargar ListBoxes -------------
service.getPersList(new AsyncCallback<List<PersonaDTO>>() {
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage());
}
@Override
public void onSuccess(List<PersonaDTO> result) {
int var = result.size();
if (var > 0){
for (Integer i = 0; i < var; i++) {
directorPelicula.addItem(result.get(i).getApellido() + ", " + result.get(i).getNombre());
actorPelicula.addItem(result.get(i).getApellido() + ", " + result.get(i).getNombre());
}
}
directorPelicula.addItem("");
//actorPelicula.addItem("");
}
});
service.getClasList(new AsyncCallback<List<ClasificacionDTO>>() {
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage());
}
@Override
public void onSuccess(List<ClasificacionDTO> result) {
int var = result.size();
if (var > 0){
for (Integer i = 0; i < var; i++) {
clasificacionPelicula.addItem(result.get(i).getDetalle());
}
}
clasificacionPelicula.addItem("");
}
});
///// Cargar ListBoxes--------------
final Button addButton = new Button("Agregar");
final Button closeAddButton = new Button("Cancelar");
// We can set the id of a widget by accessing its Element
closeAddButton.getElement().setId("closeButton0");
VerticalPanel dialogChangeVPanel = new VerticalPanel();
dialogChangeVPanel.addStyleName("dialogVPanel");
InlineHTML tituloLabel = new InlineHTML("T\u00edtulo original:");
InlineHTML tituloEspLabel = new InlineHTML("T\u00edtulo espa\u00f1ol:");
InlineHTML anioLabel = new InlineHTML("A\u00f1o:");
InlineHTML clasificacionLabel = new InlineHTML("Clasificaci\u00F3n:");
InlineHTML directorLabel = new InlineHTML("Director:");
InlineHTML productoraLabel = new InlineHTML("Productora:");
InlineHTML actoresLabel = new InlineHTML("Actores:");
InlineHTML requerido1Label = new InlineHTML("*");
InlineHTML requerido2Label = new InlineHTML("*");
InlineHTML requerido3Label = new InlineHTML("*");
Grid formulario = new Grid(11, 7);
InlineHTML tituloPopUp = new InlineHTML("Agregar Pel\u00edcula:");
formulario.setWidget(1, 2, tituloLabel);
formulario.setWidget(1, 4, tituloPelicula);
formulario.setWidget(1, 3, requerido1Label);
formulario.setWidget(2, 2, tituloEspLabel);
formulario.setWidget(2, 4, tituloEspPelicula);
formulario.setWidget(3, 2, anioLabel);
formulario.setWidget(3, 4, anioPelicula);
formulario.setWidget(3, 3, requerido2Label);
formulario.setWidget(4, 2, clasificacionLabel);
formulario.setWidget(4, 4, clasificacionPelicula);
formulario.setWidget(5, 2, directorLabel);
formulario.setWidget(5, 4, directorPelicula);
formulario.setWidget(6, 2, productoraLabel);
formulario.setWidget(6, 4, productoraPelicula);
formulario.setWidget(6, 3, requerido3Label);
formulario.setWidget(7, 2, actoresLabel);
formulario.setWidget(7, 4, actorPelicula);
formulario.setWidget(9, 2, addButton);
formulario.setWidget(9, 4, closeAddButton);
dialogChangeVPanel.add(tituloPopUp);
dialogChangeVPanel.add(formulario);
listPopUp.setWidget(dialogChangeVPanel);
listPopUp.center();
// Add a handler
addButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
MyUserServiceAsync service = (MyUserServiceAsync) GWT
.create(MyUserService.class);
ServiceDefTarget serviceDef = (ServiceDefTarget) service;
serviceDef.setServiceEntryPoint(GWT.getModuleBaseURL()
+ "userService");
final DialogBox dialogBox = new DialogBox();
dialogBox.setAnimationEnabled(true);
final Button closeButton = new Button("Close");
// We can set the id of a widget by accessing its Element
closeButton.getElement().setId("closeButton");
final HTML serverResponseLabel = new HTML();
String directorString = "";
String clasifString = "";
if (directorPelicula.getItemCount() > 0){
directorString = directorPelicula.getValue(directorPelicula.getSelectedIndex());
}
if (clasificacionPelicula.getItemCount() > 0){
clasifString = clasificacionPelicula.getValue(clasificacionPelicula.getSelectedIndex());
}
VerticalPanel dialogVPanel = new VerticalPanel();
dialogVPanel.add(serverResponseLabel);
dialogVPanel.add(closeButton);
dialogBox.setWidget(dialogVPanel);
if ((VerificadorDeCampos.isValidName(tituloPelicula.getText()))&&(VerificadorDeCampos.isValidNumber(anioPelicula.getText()))){
final PeliculaDTO pelDTO = new PeliculaDTO(tituloPelicula.getText(),tituloEspPelicula.getText(), Integer.valueOf(anioPelicula.getValue()),clasifString,directorString,productoraPelicula.getValue(productoraPelicula.getSelectedIndex()),getSelectedItems(actorPelicula));
service.agregarPelicula(pelDTO, new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage());
}
public void onSuccess(String result) {
actualizarListaPeliculas();
listPopUp.hide();
serverResponseLabel.setHTML(result);
dialogBox.center();
closeButton.setFocus(true);
}
});
}else{
serverResponseLabel.setHTML("Debe verificar los campos.<br />- Asegurese de escribir todos los campos obligatorios.<br />- Asegurese de escribir los a\u00f1os de manera correcta");
dialogBox.center();
closeButton.setFocus(true);
}
// Add a handler to close the DialogBox
closeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
dialogBox.hide();
}
});
}
});
// Add a handler to close the DialogBox
closeAddButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
listPopUp.hide();
}
});
}else{
final DialogBox listPopUpError = new DialogBox();
listPopUpError.setAnimationEnabled(true);
final HTML errormsg = new HTML();
errormsg.setHTML("Debe tener al menos una Productora registrada");
final Button closeError = new Button("Ok");
VerticalPanel dialogChangeVPanel2 = new VerticalPanel();
dialogChangeVPanel2.addStyleName("dialogVPanel");
dialogChangeVPanel2.add(errormsg);
dialogChangeVPanel2.add(closeError);
listPopUpError.setWidget(dialogChangeVPanel2);
listPopUpError.center();
closeError.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
listPopUpError.hide();
}
});
}
}
};
service.getProdList(productoraCallback);
}
});
//------------- FIN PELICULAS ------------------------------
//------------- PERSONAS ------------------------------
btnAgregarPersona.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// Create the popup dialog box
final DialogBox listPopUp = new DialogBox();
listPopUp.setAnimationEnabled(true);
final TextBox apellidoPersona = new TextBox();
//apellidoPersona.setText("Apellido");
final TextBox nombrePersona = new TextBox();
//nombrePersona.setText("Nombre");
final TextBox nacionalidadPersona = new TextBox();
//nacionalidadPersona.setText("Nacionalidad");
final Button addButton = new Button("Agregar");
final Button closeAddButton = new Button("Cancelar");
// We can set the id of a widget by accessing its Element
closeAddButton.getElement().setId("closeButton0");
VerticalPanel dialogChangeVPanel = new VerticalPanel();
dialogChangeVPanel.addStyleName("dialogVPanel");
InlineHTML apellidoLabel = new InlineHTML("Apellido:");
InlineHTML nombreLabel = new InlineHTML("Nombre:");
InlineHTML nacionalidadLabel = new InlineHTML("Nacionalidad:");
InlineHTML requerido1Label = new InlineHTML("*");
InlineHTML requerido2Label = new InlineHTML("*");
Grid formulario = new Grid(7, 7);
InlineHTML tituloPopUp = new InlineHTML("Agregar Persona:");
formulario.setWidget(1, 2, apellidoLabel);
formulario.setWidget(1, 4, apellidoPersona);
formulario.setWidget(1, 3, requerido1Label);
formulario.setWidget(2, 2, nombreLabel);
formulario.setWidget(2, 4, nombrePersona);
formulario.setWidget(2, 3, requerido2Label);
formulario.setWidget(3, 2, nacionalidadLabel);
formulario.setWidget(3, 4, nacionalidadPersona);
formulario.setWidget(5, 2, addButton);
formulario.setWidget(5, 4, closeAddButton);
dialogChangeVPanel.add(tituloPopUp);
dialogChangeVPanel.add(formulario);
listPopUp.setWidget(dialogChangeVPanel);
listPopUp.center();
// Add a handler
addButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
MyUserServiceAsync service = (MyUserServiceAsync) GWT
.create(MyUserService.class);
ServiceDefTarget serviceDef = (ServiceDefTarget) service;
serviceDef.setServiceEntryPoint(GWT.getModuleBaseURL()
+ "userService");
final DialogBox dialogBox = new DialogBox();
dialogBox.setAnimationEnabled(true);
final Button closeButton = new Button("Close");
// We can set the id of a widget by accessing its Element
closeButton.getElement().setId("closeButton");
final HTML serverResponseLabel = new HTML();
final PersonaDTO persDTO = new PersonaDTO(apellidoPersona.getText(),nombrePersona.getText(), nacionalidadPersona.getText());
VerticalPanel dialogVPanel = new VerticalPanel();
dialogVPanel.add(serverResponseLabel);
dialogVPanel.add(closeButton);
dialogBox.setWidget(dialogVPanel);
List<String> lista = new ArrayList<String>();
lista.add(apellidoPersona.getText());
lista.add(nombrePersona.getText());
if (VerificadorDeCampos.isValidCollectionName(lista)){
service.agregarPersona(persDTO, new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage());
}
public void onSuccess(String result) {
actualizarListaPersonas();
listPopUp.hide();
serverResponseLabel.setHTML(result);
dialogBox.center();
closeButton.setFocus(true);
}
});
}else{
serverResponseLabel.setHTML("Debe verificar los campos.<br />- Asegurese de escribir todos los campos.<br />- Asegurese de escribir los a\u00f1os de manera correcta");
dialogBox.center();
closeButton.setFocus(true);
}
// Add a handler to close the DialogBox
closeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
dialogBox.hide();
}
});
}
});
// Add a handler to close the DialogBox
closeAddButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
listPopUp.hide();
}
});
}
});
//------------- FIN PERSONAS ------------------------------
//------------- PRODUCTORA ------------------------------
btnAgregarProductora.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// Create the popup dialog box
final DialogBox listPopUp = new DialogBox();
listPopUp.setAnimationEnabled(true);
final TextBox nombreProductora = new TextBox();
//nombreProductora.setText("Nombre Productora");
final TextBox paisProductora = new TextBox();
//paisProductora.setText("Pais");
final TextBox direccionProductora = new TextBox();
//direccionProductora.setText("Direccion");
final TextBox telProductora = new TextBox();
//telProductora.setText("Telefono");
final TextBox desdeProductora = new TextBox();
desdeProductora.setText("1900");
final Button addButton = new Button("Agregar");
final Button closeAddButton = new Button("Cancelar");
// We can set the id of a widget by accessing its Element
closeAddButton.getElement().setId("closeButton0");
VerticalPanel dialogChangeVPanel = new VerticalPanel();
dialogChangeVPanel.addStyleName("dialogVPanel");
InlineHTML nombreLabel = new InlineHTML("Nombre:");
InlineHTML paisLabel = new InlineHTML("Pa\u00eds:");
InlineHTML direccionLabel = new InlineHTML("Direcci\u00F3n:");
InlineHTML telefonoLabel = new InlineHTML("Tel\u00e9fono:");
InlineHTML desdeLabel = new InlineHTML("Desde:");
InlineHTML requerido1Label = new InlineHTML("*");
InlineHTML requerido2Label = new InlineHTML("*");
InlineHTML requerido3Label = new InlineHTML("*");
Grid formulario = new Grid(9, 7);
InlineHTML tituloPopUp = new InlineHTML("Agregar Productora:");
formulario.setWidget(1, 2, nombreLabel);
formulario.setWidget(1, 4, nombreProductora);
formulario.setWidget(1, 3, requerido1Label);
formulario.setWidget(2, 2, paisLabel);
formulario.setWidget(2, 4, paisProductora);
formulario.setWidget(2, 3, requerido2Label);
formulario.setWidget(3, 2, direccionLabel);
formulario.setWidget(3, 4, direccionProductora);
formulario.setWidget(4, 2, telefonoLabel);
formulario.setWidget(4, 4, telProductora);
formulario.setWidget(5, 2, desdeLabel);
formulario.setWidget(5, 4, desdeProductora);
formulario.setWidget(5, 3, requerido3Label);
formulario.setWidget(7, 2, addButton);
formulario.setWidget(7, 4, closeAddButton);
dialogChangeVPanel.add(tituloPopUp);
dialogChangeVPanel.add(formulario);
listPopUp.setWidget(dialogChangeVPanel);
listPopUp.center();
// Add a handler
addButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
MyUserServiceAsync service = (MyUserServiceAsync) GWT
.create(MyUserService.class);
ServiceDefTarget serviceDef = (ServiceDefTarget) service;
serviceDef.setServiceEntryPoint(GWT.getModuleBaseURL()
+ "userService");
final DialogBox dialogBox = new DialogBox();
dialogBox.setAnimationEnabled(true);
final Button closeButton = new Button("Close");
// We can set the id of a widget by accessing its Element
closeButton.getElement().setId("closeButton");
final HTML serverResponseLabel = new HTML();
VerticalPanel dialogVPanel = new VerticalPanel();
dialogVPanel.add(serverResponseLabel);
dialogVPanel.add(closeButton);
dialogBox.setWidget(dialogVPanel);
List<String> lista = new ArrayList<String>();
lista.add(nombreProductora.getText());
lista.add(paisProductora.getText());
if ((VerificadorDeCampos.isValidCollectionName(lista))&&(VerificadorDeCampos.isValidNumber(desdeProductora.getText()))){
final ProductoraDTO prodDTO = new ProductoraDTO(nombreProductora.getText(),paisProductora.getText(), direccionProductora.getText(), telProductora.getText(), Integer.valueOf(desdeProductora.getValue()));
service.agregarProductora(prodDTO, new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage());
}
public void onSuccess(String result) {
actualizarListaProductoras();
listPopUp.hide();
serverResponseLabel.setHTML(result);
dialogBox.center();
closeButton.setFocus(true);
}
});
}else{
serverResponseLabel.setHTML("Debe verificar los campos.<br />- Asegurese de escribir todos los campos.<br />- Asegurese de escribir los a\u00f1os de manera correcta");
dialogBox.center();
closeButton.setFocus(true);
}
// Add a handler to close the DialogBox
closeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
dialogBox.hide();
}
});
}
});
// Add a handler to close the DialogBox
closeAddButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
listPopUp.hide();
}
});
}
});
//------------- FIN PRODUCTORA ------------------------------
//------------- CLASIFICACION ------------------------------
btnAgregarClasificacion.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// Create the popup dialog box
final DialogBox listPopUp = new DialogBox();
listPopUp.setAnimationEnabled(true);
final TextBox detalleClasificacion = new TextBox();
//detalleClasificacion.setText("Detalle Clasificaci\u00F3n");
final Button addButton = new Button("Agregar");
final Button closeAddButton = new Button("Cancelar");
// We can set the id of a widget by accessing its Element
closeAddButton.getElement().setId("closeButton0");
InlineHTML detalleLabel = new InlineHTML("Detalle:");
InlineHTML requerido1Label = new InlineHTML("*");
Grid formulario = new Grid(5, 7);
InlineHTML tituloPopUp = new InlineHTML("Modificar Clasificaci\u00F3n:");
formulario.setWidget(1, 2, detalleLabel);
formulario.setWidget(1, 4, detalleClasificacion);
formulario.setWidget(1, 3, requerido1Label);
formulario.setWidget(3, 2, addButton);
formulario.setWidget(3, 4, closeAddButton);
VerticalPanel dialogChangeVPanel = new VerticalPanel();
dialogChangeVPanel.add(tituloPopUp);
dialogChangeVPanel.add(formulario);
listPopUp.setWidget(dialogChangeVPanel);
listPopUp.center();
// Add a handler
addButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
MyUserServiceAsync service = (MyUserServiceAsync) GWT
.create(MyUserService.class);
ServiceDefTarget serviceDef = (ServiceDefTarget) service;
serviceDef.setServiceEntryPoint(GWT.getModuleBaseURL()
+ "userService");
final DialogBox dialogBox = new DialogBox();
dialogBox.setAnimationEnabled(true);
final Button closeButton = new Button("Close");
// We can set the id of a widget by accessing its Element