Package videoclub.client

Source Code of videoclub.client.VideoClub

package videoclub.client;

import java.util.ArrayList;
import java.util.List;

import videoclub.client.dto.ClasificacionDTO;
import videoclub.client.dto.PeliculaDTO;
import videoclub.client.dto.PersonaDTO;
import videoclub.client.dto.ProductoraDTO;
import videoclub.client.extensiones.ParallelCallback;
import videoclub.client.extensiones.ParentCallback;
import videoclub.client.extensiones.VerificadorDeCampos;

import com.google.gwt.cell.client.ButtonCell;
import com.google.gwt.cell.client.FieldUpdater;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.InlineHTML;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TabPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.cellview.client.CellTable;
import com.google.gwt.user.cellview.client.Column;
import com.google.gwt.user.cellview.client.HasKeyboardSelectionPolicy.KeyboardSelectionPolicy;
import com.google.gwt.user.cellview.client.TextColumn;

public class VideoClub implements EntryPoint {
 
  private CellTable<PeliculaDTO> tablePelicula = new CellTable<PeliculaDTO>()
  private CellTable<PersonaDTO> tablePersona = new CellTable<PersonaDTO>()
  private CellTable<ProductoraDTO> tableProductora = new CellTable<ProductoraDTO>();
  private CellTable<ClasificacionDTO> tableClasificacion = new CellTable<ClasificacionDTO>();


 
  public void onModuleLoad() {
   
      // or we can set an id on a specific element for styling

    RootPanel rootPanel = RootPanel.get();
     
      HTMLPanel panel = new HTMLPanel("");
      panel.addStyleName("centered");
      rootPanel.add(panel);
      TabPanel tabPanel = new TabPanel();
      panel.add(tabPanel);
     
    //TAB PELICULAS
    VerticalPanel verticalPanel = new VerticalPanel();
    tabPanel.add(verticalPanel, "Peliculas", true);
    verticalPanel.setSize("5cm", "3cm");
    Button btnAgregarPelicula = new Button("Agregar Pelicula");
    verticalPanel.add(btnAgregarPelicula);
    tablePelicula.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
    //columnas de la tabla
    TextColumn<PeliculaDTO> pelTituloColumn = new TextColumn<PeliculaDTO>() {
        @Override
        public String getValue(PeliculaDTO object) {
          return object.getTitulo();
      }
    };
    tablePelicula.addColumn(pelTituloColumn, "T\u00edtulo original");
    TextColumn<PeliculaDTO> pelTituloEspanolColumn = new TextColumn<PeliculaDTO>() {
        @Override
        public String getValue(PeliculaDTO object) {
          return object.getTitulo_esp();
      }
    };
    tablePelicula.addColumn(pelTituloEspanolColumn, "T\u00edtulo espa\u00f1ol");
    TextColumn<PeliculaDTO> pelAnioColumn = new TextColumn<PeliculaDTO>() {
        @Override
        public String getValue(PeliculaDTO object) {
          return object.getAnio().toString();
      }
    };
    tablePelicula.addColumn(pelAnioColumn, "A\u00f1o");
    TextColumn<PeliculaDTO> pelClasificacionColumn = new TextColumn<PeliculaDTO>() {
        @Override
        public String getValue(PeliculaDTO object) {
          return object.getDetalle_clasificacion();
      }
    };
    tablePelicula.addColumn(pelClasificacionColumn, "Clasificaci\u00F3n");
    TextColumn<PeliculaDTO> pelDirectorColumn = new TextColumn<PeliculaDTO>() {
        @Override
        public String getValue(PeliculaDTO object) {
          return object.getNombre_director();
      }
    };
    tablePelicula.addColumn(pelDirectorColumn, "Director");
    TextColumn<PeliculaDTO> pelProductoraColumn = new TextColumn<PeliculaDTO>() {
        @Override
        public String getValue(PeliculaDTO object) {
          return object.getNombre_productora();
      }
    };
    tablePelicula.addColumn(pelProductoraColumn, "Productora");
    TextColumn<PeliculaDTO> pelActoresColumn = new TextColumn<PeliculaDTO>() {
        @Override
        public String getValue(PeliculaDTO object) {
          return object.getActoresString();
      }
    };
    tablePelicula.addColumn(pelActoresColumn, "Actores");
    //columna modificar de la tabla
    ButtonCell btnModificarPelicula = new ButtonCell();
    Column<PeliculaDTO,String> modificarPelicula = new Column<PeliculaDTO,String>(btnModificarPelicula) {
      public String getValue(PeliculaDTO object) {
        return "Modificar";
      }
    };
    modificarPelicula.setFieldUpdater(new FieldUpdater<PeliculaDTO, String>() {
        @Override
        public void update(int index, PeliculaDTO object, String value) {
          // The user clicked on the button for the passed auction.
          btnModificarPeliculaHandler(object);
      }
    });
    tablePelicula.addColumn(modificarPelicula);
    //columna borrar de la tabla
    ButtonCell btnBorrarPelicula = new ButtonCell();
    Column<PeliculaDTO,String> borrarPelicula = new Column<PeliculaDTO,String>(btnBorrarPelicula) {
      public String getValue(PeliculaDTO object) {
        return "Borrar";
      }
    };
    borrarPelicula.setFieldUpdater(new FieldUpdater<PeliculaDTO, String>() {
        @Override
        public void update(int index, PeliculaDTO object, String value) {
          // The user clicked on the button for the passed auction.
          btnBorrarPeliculaHandler(object.getTitulo(), object.getAnio());
      }
    });
    tablePelicula.addColumn(borrarPelicula);
    tablePelicula.setSize("1000px", "50px");
    verticalPanel.add(tablePelicula);
    //FIN TAB PELICULAS     
   
    //TAB PERSONAS
    VerticalPanel verticalPanel_1 = new VerticalPanel();
    tabPanel.add(verticalPanel_1, "Actores/Directores", false);
    verticalPanel_1.setSize("5cm", "3cm");
    Button btnAgregarPersona = new Button("Agregar Actor/Director");
    verticalPanel_1.add(btnAgregarPersona);
    tablePersona.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
    //columnas de la tabla
    TextColumn<PersonaDTO> perApellidoColumn = new TextColumn<PersonaDTO>() {
        @Override
        public String getValue(PersonaDTO object) {
          return object.getApellido();
      }
    };
    tablePersona.addColumn(perApellidoColumn, "Apellido");
    TextColumn<PersonaDTO> perNombreColumn = new TextColumn<PersonaDTO>() {
        @Override
        public String getValue(PersonaDTO object) {
          return object.getNombre();
      }
    };
    tablePersona.addColumn(perNombreColumn, "Nombre");
    TextColumn<PersonaDTO> perNacionalidadColumn = new TextColumn<PersonaDTO>() {
        @Override
        public String getValue(PersonaDTO object) {
          return object.getNacionalidad();
      }
    };
    tablePersona.addColumn(perNacionalidadColumn, "Nacionalidad");
    //columna modificar de la tabla
    ButtonCell btnModificarPersona = new ButtonCell();
    Column<PersonaDTO,String> modificarPersona = new Column<PersonaDTO,String>(btnModificarPersona) {
      public String getValue(PersonaDTO object) {
        return "Modificar";
      }
    };
    modificarPersona.setFieldUpdater(new FieldUpdater<PersonaDTO, String>() {
        @Override
        public void update(int index, PersonaDTO object, String value) {
          // The user clicked on the button for the passed auction.
          btnModificarPersonaHandler(object);
      }
    });
    tablePersona.addColumn(modificarPersona);
    //columna borrar de la tabla
    ButtonCell btnBorrarPersona = new ButtonCell();
    Column<PersonaDTO,String> borrarPersona = new Column<PersonaDTO,String>(btnBorrarPersona) {
      public String getValue(PersonaDTO object) {
        return "Borrar";
      }
    };
    borrarPersona.setFieldUpdater(new FieldUpdater<PersonaDTO, String>() {
        @Override
        public void update(int index, PersonaDTO object, String value) {
          // The user clicked on the button for the passed auction.
          btnBorrarPersonaHandler(object.getApellido(),object.getNombre());
      }
    });
    tablePersona.addColumn(borrarPersona);
    tablePersona.setSize("1000px", "50px");
    verticalPanel_1.add(tablePersona);
    //FIN TAB PERSONAS   
   
    //TAB PRODUCTORAS
    VerticalPanel verticalPanel_2 = new VerticalPanel();
    tabPanel.add(verticalPanel_2, "Productoras", false);
    verticalPanel_2.setSize("5cm", "3cm");
    Button btnAgregarProductora = new Button("Agregar Productora");
    verticalPanel_2.add(btnAgregarProductora);
    tableProductora.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
    //columnas de la tabla
    TextColumn<ProductoraDTO> prodNombreColumn = new TextColumn<ProductoraDTO>() {
        @Override
        public String getValue(ProductoraDTO object) {
          return object.getNombre();
      }
    };
    tableProductora.addColumn(prodNombreColumn, "Nombre");
    TextColumn<ProductoraDTO> prodPaisColumn = new TextColumn<ProductoraDTO>() {
        @Override
        public String getValue(ProductoraDTO object) {
          return object.getPais();
      }
    };
    tableProductora.addColumn(prodPaisColumn, "Pa\u00eds");
    TextColumn<ProductoraDTO> prodDireccionColumn = new TextColumn<ProductoraDTO>() {
        @Override
        public String getValue(ProductoraDTO object) {
          return object.getDireccion();
      }
    };
    tableProductora.addColumn(prodDireccionColumn, "Direcci\u00F3n");
    TextColumn<ProductoraDTO> prodTelefonoColumn = new TextColumn<ProductoraDTO>() {
        @Override
        public String getValue(ProductoraDTO object) {
          return object.getTelefono();
      }
    };
    tableProductora.addColumn(prodTelefonoColumn, "Tel\u00e9fono");
    TextColumn<ProductoraDTO> prodDesdeColumn = new TextColumn<ProductoraDTO>() {
        @Override
        public String getValue(ProductoraDTO object) {
          return object.getDesde().toString();
      }
    };
    tableProductora.addColumn(prodDesdeColumn, "Desde");
    //columna modificar de la tabla
    ButtonCell btnModificarProductora = new ButtonCell();
    Column<ProductoraDTO,String> modificarProductora = new Column<ProductoraDTO,String>(btnModificarProductora) {
      public String getValue(ProductoraDTO object) {
        return "Modificar";
      }
    };
    modificarProductora.setFieldUpdater(new FieldUpdater<ProductoraDTO, String>() {
        @Override
        public void update(int index, ProductoraDTO object, String value) {
          // The user clicked on the button for the passed auction.
          btnModificarProductoraHandler(object);
      }
    });
    tableProductora.addColumn(modificarProductora);
    //columna borrar de la tabla
    ButtonCell btnBorrarProductora = new ButtonCell();
    Column<ProductoraDTO,String> borrarProductora = new Column<ProductoraDTO,String>(btnBorrarProductora) {
      public String getValue(ProductoraDTO object) {
        return "Borrar";
      }
    };
    borrarProductora.setFieldUpdater(new FieldUpdater<ProductoraDTO, String>() {
        @Override
        public void update(int index, ProductoraDTO object, String value) {
          // The user clicked on the button for the passed auction.
          btnBorrarProductoraHandler(object.getNombre());
      }
    });
    tableProductora.addColumn(borrarProductora);
    tableProductora.setSize("1000px", "50px");
    verticalPanel_2.add(tableProductora);   
    //FIN TAB PRODUCTORAS 
   
    //TAB CLASIFICACIONES
    VerticalPanel verticalPanel_3 = new VerticalPanel();
    tabPanel.add(verticalPanel_3, "Clasificaciones", false);
    verticalPanel_3.setSize("5cm", "3cm");
    Button btnAgregarClasificacion = new Button("Agregar Clasificaci\u00F3n");
    verticalPanel_3.add(btnAgregarClasificacion);
    tableClasificacion.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
    //columnas de la tabla
    TextColumn<ClasificacionDTO> classDetalleColumn = new TextColumn<ClasificacionDTO>() {
        @Override
        public String getValue(ClasificacionDTO object) {
          return object.getDetalle();
      }
    };
    tableClasificacion.addColumn(classDetalleColumn, "Detalle");
    //columna modificar de la tabla
    ButtonCell btnModificarClasificacion = new ButtonCell();
    Column<ClasificacionDTO,String> modificarClasificacion = new Column<ClasificacionDTO,String>(btnModificarClasificacion) {
      public String getValue(ClasificacionDTO object) {
        return "Modificar";
      }
    };
    modificarClasificacion.setFieldUpdater(new FieldUpdater<ClasificacionDTO, String>() {
        @Override
        public void update(int index, ClasificacionDTO object, String value) {
          // The user clicked on the button for the passed auction.
          btnModificarClasificacionHandler(object.getDetalle());
      }
    });
    tableClasificacion.addColumn(modificarClasificacion);
    //columna borrar de la tabla
    ButtonCell btnBorrarClasificacion = new ButtonCell();
    Column<ClasificacionDTO,String> borrarClasificacion = new Column<ClasificacionDTO,String>(btnBorrarClasificacion) {
      public String getValue(ClasificacionDTO object) {
        return "Borrar";
      }
    };
    borrarClasificacion.setFieldUpdater(new FieldUpdater<ClasificacionDTO, String>() {
        @Override
        public void update(int index, ClasificacionDTO object, String value) {
          // The user clicked on the button for the passed auction.
          btnBorrarClasificacionHandler(object.getDetalle());
      }
    });
    tableClasificacion.addColumn(borrarClasificacion);
    tableClasificacion.setSize("1000px", "50px");
    verticalPanel_3.add(tableClasificacion);
   
    //select peliculas tab
    tabPanel.selectTab(0);
   

   

    //------------- PELICULAS ------------------------------
    btnAgregarPelicula.addClickHandler(new ClickHandler() {
          @Override
          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
                            closeButton.getElement().setId("closeButton");
                            final HTML serverResponseLabel = new HTML();
                            VerticalPanel dialogVPanel = new VerticalPanel();
                            dialogVPanel.add(serverResponseLabel);
                            dialogVPanel.add(closeButton);
                            dialogBox.setWidget(dialogVPanel);
                           
                            if (VerificadorDeCampos.isValidName(detalleClasificacion.getText())){
                           
                                  service.agregarClasificacion(detalleClasificacion.getText(), new AsyncCallback<String>() {
                                public void onFailure(Throwable caught) {
                                  Window.alert(caught.getMessage());
                                }
                     
                                public void onSuccess(String result) {
                                  actualizarListaClasificacion();
                                  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 CLASIFICACION ------------------------------

                 
                 
                  tabPanel.addSelectionHandler(new SelectionHandler<Integer>() {
                    public void onSelection(SelectionEvent<Integer> event) {
                      switch (event.getSelectedItem()){
                      case 0: actualizarListaPeliculas();break;
                      case 1: actualizarListaPersonas();break;
                      case 2: actualizarListaProductoras();break;
                      case 3: actualizarListaClasificacion();break;
                      }
                    }
                  });
    //FIN TAB CLASIFICACIONES
   
      actualizarListaPeliculas();

   
  }
//FIN ON MODULE LOAD
 
 
 
 
  //------------- PELICULAS ------------------------------
  private void actualizarListaPeliculas(){
   
    MyUserServiceAsync service = (MyUserServiceAsync) GWT
              .create(MyUserService.class);
          ServiceDefTarget serviceDef = (ServiceDefTarget) service;
          serviceDef.setServiceEntryPoint(GWT.getModuleBaseURL()
              + "userService");
          service.getPelList(new AsyncCallback<List<PeliculaDTO>>() {
        public void onFailure(Throwable caught) {
          Window.alert(caught.getMessage());
        }

        @Override
        public void onSuccess(List<PeliculaDTO> result) {
          tablePelicula.setRowCount(result.size());
          tablePelicula.setRowData(result);
        }
      });
   
  }
 
  private void btnBorrarPeliculaHandler(final String input,final Integer input2){
   
    final MyUserServiceAsync service = (MyUserServiceAsync) GWT
              .create(MyUserService.class);
          ServiceDefTarget serviceDef = (ServiceDefTarget) service;
          serviceDef.setServiceEntryPoint(GWT.getModuleBaseURL()
              + "userService");
          service.deletePelicula(input, input2, new AsyncCallback<String>() {
        public void onFailure(Throwable caught) {
          Window.alert(caught.getMessage());
        }
        @Override
        public void onSuccess(String result) {
          actualizarListaPeliculas();
         
            final DialogBox dialogBox2 = new DialogBox();
            dialogBox2.setAnimationEnabled(true);
            final Button closeButton2 = new Button("Close");
            closeButton2.getElement().setId("closeButton");
            final HTML serverResponseLabel2 = new HTML();
            serverResponseLabel2.setHTML(result);
            VerticalPanel dialogVPanel2 = new VerticalPanel();
            dialogVPanel2.add(serverResponseLabel2);
            dialogVPanel2.add(closeButton2);
            dialogBox2.setWidget(dialogVPanel2);
            dialogBox2.center();
           
            closeButton2.addClickHandler(new ClickHandler() {
              public void onClick(ClickEvent event) {
                dialogBox2.hide();
              }
            });
        }
      });
  }
 
  private void btnModificarPeliculaHandler(final PeliculaDTO input){
 
    final MyUserServiceAsync service = (MyUserServiceAsync) GWT
              .create(MyUserService.class);
          ServiceDefTarget serviceDef = (ServiceDefTarget) service;
          serviceDef.setServiceEntryPoint(GWT.getModuleBaseURL()
              + "userService");
       
    final DialogBox listPopUp2 = new DialogBox();
     listPopUp2.setAnimationEnabled(true);
      final TextBox tituloPelicula = new TextBox();
      tituloPelicula.setText(input.getTitulo());
      final TextBox tituloEspPelicula = new TextBox();
      tituloEspPelicula.setText(input.getTitulo_esp());
      final TextBox anioPelicula = new TextBox();
      anioPelicula.setText(input.getAnio().toString());
      final ListBox clasificacionPelicula = new ListBox();
      final ListBox productoraPelicula = new ListBox();
      final ListBox directorPelicula = new ListBox();
      final ListBox actorPelicula = new ListBox(true);
      actorPelicula.setVisibleItemCount(10);
     
      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());
            if (result.get(i).getDetalle().equals(input.getDetalle_clasificacion()))
              clasificacionPelicula.setItemSelected(i, true);
           }
        }
        clasificacionPelicula.addItem("");
        if (input.getDetalle_clasificacion().equals("")){
          clasificacionPelicula.setItemSelected(var, true);
        }
      }
    });
     
      service.getProdList(new AsyncCallback<List<ProductoraDTO>>() {
      public void onFailure(Throwable caught) {
        Window.alert(caught.getMessage());
      }

      @Override
      public void onSuccess(List<ProductoraDTO> result) {
        int var = result.size();
        if (var > 0){
          for (Integer i = 0; i < var; i++) {
            productoraPelicula.addItem(result.get(i).getNombre());
            if (result.get(i).getNombre().equals(input.getNombre_productora()))
              productoraPelicula.setItemSelected(i, true);
           }
        }
      }
    });
     
      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());
            if ((result.get(i).getApellido() + ", " + result.get(i).getNombre()).equals(input.getNombre_director())){
              directorPelicula.setItemSelected(i, true);
            }
            actorPelicula.addItem(result.get(i).getApellido() + ", " + result.get(i).getNombre());
            if (input.getActoresString().contains((result.get(i).getApellido() + ", " + result.get(i).getNombre()))){
              actorPelicula.setItemSelected(i, true);
            }
           }
        }
        directorPelicula.addItem("");
        //actorPelicula.addItem("");
        if (input.getNombre_director().equals("")){
          directorPelicula.setItemSelected(var, true);
        }
      }
    });             
     
    final Button changeButton = new Button("Modificar");
     final Button closeChangeButton = new Button("Cerrar");

     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("Modificar 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, changeButton);
    formulario.setWidget(9, 4, closeChangeButton);
   

     dialogChangeVPanel.add(tituloPopUp);
     dialogChangeVPanel.add(formulario);
     listPopUp2.setWidget(dialogChangeVPanel);
     listPopUp2.center();                    
   

     //button modificar dentro del pop-up
     changeButton.addClickHandler(new ClickHandler() {
          public void onClick(ClickEvent event) {
         
          String directorString = "";
          String clasifString = "";
          if (directorPelicula.getItemCount() > 0){
            directorString = directorPelicula.getValue(directorPelicula.getSelectedIndex());
          }
          if (clasificacionPelicula.getItemCount() > 0){
            clasifString = clasificacionPelicula.getValue(clasificacionPelicula.getSelectedIndex());
          }
           
          final DialogBox dialogBox2 = new DialogBox();
          dialogBox2.setAnimationEnabled(true);
          final Button closeButton2 = new Button("Close");
          closeButton2.getElement().setId("closeButton");
          final HTML serverResponseLabel2 = new HTML();
          VerticalPanel dialogVPanel2 = new VerticalPanel();
          dialogVPanel2.add(serverResponseLabel2);
          dialogVPanel2.add(closeButton2);
          dialogBox2.setWidget(dialogVPanel2);


            if ((VerificadorDeCampos.isValidName(tituloPelicula.getText()))&&(VerificadorDeCampos.isValidNumber(anioPelicula.getText()))){
              final PeliculaDTO pelDTO = new PeliculaDTO(tituloPelicula.getText(), tituloEspPelicula.getText(), Integer.valueOf(anioPelicula.getValue()));
            pelDTO.setDetalle_clasificacion(clasifString);
            pelDTO.setNombre_director(directorString);
            pelDTO.setNombre_productora(productoraPelicula.getValue(productoraPelicula.getSelectedIndex()));
            pelDTO.setActores(getSelectedItems(actorPelicula));
            pelDTO.setActores(pelDTO.getActores().toString());
            service.updatePelicula(input.getTitulo(), input.getAnio(),pelDTO, new AsyncCallback<String>() {
              public void onFailure(Throwable caught) {
                Window.alert(caught.getMessage());
              }
              @Override
              public void onSuccess(String result) {
                actualizarListaPeliculas();
               
                listPopUp2.hide();
                  serverResponseLabel2.setHTML(result);
                  dialogBox2.center();
                 
              }
            });
           
            }else{
              serverResponseLabel2.setHTML("Debe verificar los campos.<br />- Asegurese de escribir todos los campos obligatorios.<br />- Asegurese de escribir los a\u00f1os de manera correcta");
              dialogBox2.center();
            closeButton2.setFocus(true);               
            }                   
         
        closeButton2.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
              dialogBox2.hide();
            }
          });
         
         
          }
      });
    
     closeChangeButton.addClickHandler(new ClickHandler() {
    public void onClick(ClickEvent event) {
      listPopUp2.hide();
    }
  });
  }
 
  //------------- FIN PELICULAS ------------------------------

 
 
 
 
  //------------- PERSONAS ------------------------------
  private void actualizarListaPersonas(){
   
    MyUserServiceAsync service = (MyUserServiceAsync) GWT
              .create(MyUserService.class);
          ServiceDefTarget serviceDef = (ServiceDefTarget) service;
          serviceDef.setServiceEntryPoint(GWT.getModuleBaseURL()
              + "userService");
          service.getPersList(new AsyncCallback<List<PersonaDTO>>() {
        public void onFailure(Throwable caught) {
          Window.alert(caught.getMessage());
        }

        @Override
        public void onSuccess(List<PersonaDTO> result) {
          tablePersona.setRowCount(result.size());
          tablePersona.setRowData(result);
        }
      });
   
  }
 
  private void btnBorrarPersonaHandler(final String input,final String input2){
   
    final MyUserServiceAsync service = (MyUserServiceAsync) GWT
              .create(MyUserService.class);
          ServiceDefTarget serviceDef = (ServiceDefTarget) service;
          serviceDef.setServiceEntryPoint(GWT.getModuleBaseURL()
              + "userService");
          service.deletePersona(input, input2, new AsyncCallback<String>() {
        public void onFailure(Throwable caught) {
          Window.alert(caught.getMessage());
        }
        @Override
        public void onSuccess(String result) {
          actualizarListaPersonas();
         
            final DialogBox dialogBox2 = new DialogBox();
            dialogBox2.setAnimationEnabled(true);
            final Button closeButton2 = new Button("Close");
            closeButton2.getElement().setId("closeButton");
            final HTML serverResponseLabel2 = new HTML();
            serverResponseLabel2.setHTML(result);
            VerticalPanel dialogVPanel2 = new VerticalPanel();
            dialogVPanel2.add(serverResponseLabel2);
            dialogVPanel2.add(closeButton2);
            dialogBox2.setWidget(dialogVPanel2);
            dialogBox2.center();
           
            closeButton2.addClickHandler(new ClickHandler() {
              public void onClick(ClickEvent event) {
                dialogBox2.hide();
              }
            });
        }
      });
  }

  private void btnModificarPersonaHandler(final PersonaDTO input){
   
    final DialogBox listPopUp2 = new DialogBox();
     listPopUp2.setAnimationEnabled(true);
      final TextBox apellidoPersona = new TextBox();
      apellidoPersona.setText(input.getApellido());
      final TextBox nombrePersona = new TextBox();
      nombrePersona.setText(input.getNombre());
      final TextBox nacionalidadPersona = new TextBox();
      nacionalidadPersona.setText(input.getNacionalidad());
    final Button changeButton = new Button("Modificar");
     final Button closeChangeButton = new Button("Cerrar");
     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, changeButton);
    formulario.setWidget(5, 4, closeChangeButton);
    
     dialogChangeVPanel.add(tituloPopUp);
     dialogChangeVPanel.add(formulario);
     listPopUp2.setWidget(dialogChangeVPanel);
     listPopUp2.center();
   

     final MyUserServiceAsync service = (MyUserServiceAsync) GWT
              .create(MyUserService.class);
          ServiceDefTarget serviceDef = (ServiceDefTarget) service;
          serviceDef.setServiceEntryPoint(GWT.getModuleBaseURL()
              + "userService");
     changeButton.addClickHandler(new ClickHandler() {
       public void onClick(ClickEvent event) {
         final PersonaDTO persDTO = new PersonaDTO(apellidoPersona.getText(), nombrePersona.getText(), nacionalidadPersona.getText());
        final DialogBox dialogBox2 = new DialogBox();
        dialogBox2.setAnimationEnabled(true);
        final Button closeButton2 = new Button("Close");
        closeButton2.getElement().setId("closeButton");
        final HTML serverResponseLabel2 = new HTML();
        VerticalPanel dialogVPanel2 = new VerticalPanel();
        dialogVPanel2.add(serverResponseLabel2);
        dialogVPanel2.add(closeButton2);
        dialogBox2.setWidget(dialogVPanel2);

        List<String> lista = new ArrayList<String>();
        lista.add(apellidoPersona.getText());
        lista.add(nombrePersona.getText());
               
        if (VerificadorDeCampos.isValidCollectionName(lista)){
       
           service.updatePersona(input.getApellido(), input.getNombre(),persDTO, new AsyncCallback<String>() {
               public void onFailure(Throwable caught) {
                Window.alert(caught.getMessage());
              }
              @Override
              public void onSuccess(String result) {
                actualizarListaPersonas();
               
                listPopUp2.hide();
                  serverResponseLabel2.setHTML(result);
                  dialogBox2.center();
                 
              }
          });
          

         }else{
           serverResponseLabel2.setHTML("Debe verificar los campos.<br />- Asegurese de escribir todos los campos.<br />- Asegurese de escribir los a\u00f1os de manera correcta");
           dialogBox2.center();
          closeButton2.setFocus(true);               
        }                   
           
        closeButton2.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
              dialogBox2.hide();
            }
          });
           
           
          }
        });
    
       closeChangeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
          listPopUp2.hide();
        }
      });
  }
  //------------- FIN PERSONAS ------------------------------
 
 
 
 
 
  //------------- PRODUCTORA ------------------------------
  private void actualizarListaProductoras(){
   
    MyUserServiceAsync service = (MyUserServiceAsync) GWT
              .create(MyUserService.class);
          ServiceDefTarget serviceDef = (ServiceDefTarget) service;
          serviceDef.setServiceEntryPoint(GWT.getModuleBaseURL()
              + "userService");
          service.getProdList(new AsyncCallback<List<ProductoraDTO>>() {
        public void onFailure(Throwable caught) {
          Window.alert(caught.getMessage());
        }

        @Override
        public void onSuccess(List<ProductoraDTO> result) {
          tableProductora.setRowCount(result.size());
          tableProductora.setRowData(result);
        }
      });
   
  }
 
  private void btnBorrarProductoraHandler(final String input){
   
    final MyUserServiceAsync service = (MyUserServiceAsync) GWT
              .create(MyUserService.class);
          ServiceDefTarget serviceDef = (ServiceDefTarget) service;
          serviceDef.setServiceEntryPoint(GWT.getModuleBaseURL()
              + "userService");
          service.deleteProductora(input, new AsyncCallback<String>() {
        public void onFailure(Throwable caught) {
          Window.alert(caught.getMessage());
        }
        @Override
        public void onSuccess(String result) {
          actualizarListaProductoras();
         
          final DialogBox dialogBox2 = new DialogBox();
          dialogBox2.setAnimationEnabled(true);
          final Button closeButton2 = new Button("Close");
          closeButton2.getElement().setId("closeButton");
          final HTML serverResponseLabel2 = new HTML();
          serverResponseLabel2.setHTML(result);
          VerticalPanel dialogVPanel2 = new VerticalPanel();
          dialogVPanel2.add(serverResponseLabel2);
          dialogVPanel2.add(closeButton2);
          dialogBox2.setWidget(dialogVPanel2);
          dialogBox2.center();
       
          closeButton2.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
              dialogBox2.hide();
          }
        });
      }
    });
  }

  private void btnModificarProductoraHandler(final ProductoraDTO input){
   
    final DialogBox listPopUp2 = new DialogBox();
     listPopUp2.setAnimationEnabled(true);
      final TextBox nombreProductora = new TextBox();
      nombreProductora.setText(input.getNombre());
      final TextBox paisProductora = new TextBox();
      paisProductora.setText(input.getPais());
      final TextBox direccionProductora = new TextBox();
      direccionProductora.setText(input.getDireccion());
      final TextBox telProductora = new TextBox();
      telProductora.setText(input.getTelefono());
      final TextBox desdeProductora = new TextBox();
      desdeProductora.setText(input.getDesde().toString());
    final Button changeButton = new Button("Modificar");
     final Button closeChangeButton = new Button("Cerrar");
     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, changeButton);
    formulario.setWidget(7, 4, closeChangeButton);
    
     dialogChangeVPanel.add(tituloPopUp);
     dialogChangeVPanel.add(formulario);
     listPopUp2.setWidget(dialogChangeVPanel);
     listPopUp2.center();
   

     final MyUserServiceAsync service = (MyUserServiceAsync) GWT
              .create(MyUserService.class);
          ServiceDefTarget serviceDef = (ServiceDefTarget) service;
          serviceDef.setServiceEntryPoint(GWT.getModuleBaseURL()
              + "userService");
     changeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
        final DialogBox dialogBox2 = new DialogBox();
        dialogBox2.setAnimationEnabled(true);
        final Button closeButton2 = new Button("Close");
        closeButton2.getElement().setId("closeButton");
        final HTML serverResponseLabel2 = new HTML();
        VerticalPanel dialogVPanel2 = new VerticalPanel();
        dialogVPanel2.add(serverResponseLabel2);
        dialogVPanel2.add(closeButton2);
        dialogBox2.setWidget(dialogVPanel2);

        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.getText()));
          service.updateProductora(input.getNombre(),prodDTO, new AsyncCallback<String>() {
            public void onFailure(Throwable caught) {
              Window.alert(caught.getMessage());
            }
            @Override
            public void onSuccess(String result) {
              actualizarListaProductoras();
             
              listPopUp2.hide();
              serverResponseLabel2.setHTML(result);
              dialogBox2.center();
               
            }
          });
         
        }else{
          serverResponseLabel2.setHTML("Debe verificar los campos.<br />- Asegurese de escribir todos los campos.<br />- Asegurese de escribir los a\u00f1os de manera correcta");
          dialogBox2.center();
          closeButton2.setFocus(true);               
       
           
          closeButton2.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
              dialogBox2.hide();
            }
          });
           
           
          }
        });
    
     closeChangeButton.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        listPopUp2.hide();
      }
    });
  }
  //------------- FIN PRODUCTORA ------------------------------
 
 
 
 
  //------------- CLASIFICACION ------------------------------
  private void actualizarListaClasificacion(){
   
    MyUserServiceAsync service = (MyUserServiceAsync) GWT
              .create(MyUserService.class);
          ServiceDefTarget serviceDef = (ServiceDefTarget) service;
          serviceDef.setServiceEntryPoint(GWT.getModuleBaseURL()
              + "userService");
          service.getClasList(new AsyncCallback<List<ClasificacionDTO>>() {
        public void onFailure(Throwable caught) {
          Window.alert(caught.getMessage());
        }

        @Override
        public void onSuccess(List<ClasificacionDTO> result) {
          tableClasificacion.setRowCount(result.size());
          tableClasificacion.setRowData(result);
        }
      });
   
  }
  private void btnBorrarClasificacionHandler(final String input){
   
    final MyUserServiceAsync service = (MyUserServiceAsync) GWT
              .create(MyUserService.class);
          ServiceDefTarget serviceDef = (ServiceDefTarget) service;
          serviceDef.setServiceEntryPoint(GWT.getModuleBaseURL()
              + "userService");
          service.deleteClasificacion(input, new AsyncCallback<String>() {
        public void onFailure(Throwable caught) {
          Window.alert(caught.getMessage());
        }
        @Override
        public void onSuccess(String result) {
         
          actualizarListaClasificacion();
         
            final DialogBox dialogBox2 = new DialogBox();
            dialogBox2.setAnimationEnabled(true);
            final Button closeButton2 = new Button("Close");
            closeButton2.getElement().setId("closeButton");
            final HTML serverResponseLabel2 = new HTML();
            serverResponseLabel2.setHTML(result);
            VerticalPanel dialogVPanel2 = new VerticalPanel();
            dialogVPanel2.add(serverResponseLabel2);
            dialogVPanel2.add(closeButton2);
            dialogBox2.setWidget(dialogVPanel2);
            dialogBox2.center();
           
            closeButton2.addClickHandler(new ClickHandler() {
              public void onClick(ClickEvent event) {
                dialogBox2.hide();
              }
            });
        }
      });
  }
 
 
private void btnModificarClasificacionHandler(final String input){
   
    final DialogBox listPopUp2 = new DialogBox();
     listPopUp2.setAnimationEnabled(true);
      final TextBox newFirstField = new TextBox();
      newFirstField.setText(input);
    final Button changeButton = new Button("Modificar");
     final Button closeChangeButton = new Button("Cerrar");
    
     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, newFirstField);
    formulario.setWidget(1, 3, requerido1Label);
    formulario.setWidget(3, 2, changeButton);
    formulario.setWidget(3, 4, closeChangeButton)
    
     VerticalPanel dialogVPanel3 = new VerticalPanel();
     dialogVPanel3.add(tituloPopUp);
     dialogVPanel3.add(formulario);
     listPopUp2.setWidget(dialogVPanel3);
     listPopUp2.center();
   

     final MyUserServiceAsync service = (MyUserServiceAsync) GWT
              .create(MyUserService.class);
          ServiceDefTarget serviceDef = (ServiceDefTarget) service;
          serviceDef.setServiceEntryPoint(GWT.getModuleBaseURL()
              + "userService");
     changeButton.addClickHandler(new ClickHandler() {
          public void onClick(ClickEvent event) {
           
          final DialogBox dialogBox2 = new DialogBox();
            dialogBox2.setAnimationEnabled(true);
            final Button closeButton2 = new Button("Close");
            closeButton2.getElement().setId("closeButton");
            final HTML serverResponseLabel2 = new HTML();
            VerticalPanel dialogVPanel2 = new VerticalPanel();
            dialogVPanel2.add(serverResponseLabel2);
            dialogVPanel2.add(closeButton2);
            dialogBox2.setWidget(dialogVPanel2);

            if (VerificadorDeCampos.isValidName(newFirstField.getText())){
           
              service.updateClasificacion(input,newFirstField.getText(), new AsyncCallback<String>() {
              public void onFailure(Throwable caught) {
                Window.alert(caught.getMessage());
              }
              @Override
              public void onSuccess(String result) {
                actualizarListaClasificacion();
               
                listPopUp2.hide();
                  serverResponseLabel2.setHTML(result);
 
                  dialogBox2.center();
             
              });
             
            }else{
              serverResponseLabel2.setHTML("Debe verificar los campos.<br />- Asegurese de escribir todos los campos.<br />- Asegurese de escribir los a\u00f1os de manera correcta");
              dialogBox2.center();
              closeButton2.setFocus(true);               
            }
           
          closeButton2.addClickHandler(new ClickHandler() {
              public void onClick(ClickEvent event) {
                dialogBox2.hide();
              }
            });         
        }
        });
    
     closeChangeButton.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        listPopUp2.hide();
      }
    });
  }
  //------------- FIN CLASIFICACION ------------------------------
 
  public List<String> getSelectedItems(ListBox listBox) {
    List<String> selectedItems = new ArrayList<String>();
      for (int i = 0; i < listBox.getItemCount(); i++) {
          if (listBox.isItemSelected(i)) {
              selectedItems.add(listBox.getValue(i));
          }
      }
      return selectedItems;
  }
}
TOP

Related Classes of videoclub.client.VideoClub

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.