Creo en nosotros. Wikipedia.
ShareCode
Permalink: http://www.treeweb.es/u/974/ 01/02/2011

ShareCode

1 package smartResorts.client;2 3 import java.util.ArrayList;4 import java.util.HashMap;5 import java.util.Iterator;6 import java.util.LinkedList;7 import smartResorts.client.ayuda.PanelAyuda;8 import smartResorts.client.ayuda.PanelBienvenida;9 import smartResorts.client.eventos.congresos.PanelCongresos;10 import smartResorts.client.galeria.PanelGalerias;11 import smartResorts.client.materialpromocional.PanelMaterial;12 import smartResorts.client.meetme.PanelMeetMe;13 import smartResorts.client.reservas.Category;14 import smartResorts.client.reservas.MyPopUp;15 import smartResorts.client.reservas.WidgetsHorarios.PanelReservasGenerico;16 import smartResorts.client.services.BotonServicio;17 import smartResorts.client.services.ListadoServicios;18 import smartResorts.client.services.PanelServices;19 import smartResorts.client.services.SubServiceBean;20 import smartResorts.client.services.Subservices;21 import smartResorts.client.services.has_id_service;22 import smartResorts.client.traducciones.PanelTraduccion;23 import smartResorts.client.traducciones.Traducible;24 import smartResorts.client.util.ApiCalls;25 import smartResorts.client.util.StandardRequest;26 import smartResorts.client.weddings.PanelWeddings;27 28 import com.google.gwt.dom.client.Style.Unit;29 import com.google.gwt.event.dom.client.ChangeEvent;30 import com.google.gwt.event.dom.client.ChangeHandler;31 import com.google.gwt.event.dom.client.ClickEvent;32 import com.google.gwt.event.dom.client.ClickHandler;33 import com.google.gwt.json.client.JSONObject;34 import com.google.gwt.json.client.JSONParser;35 import com.google.gwt.user.client.Window;36 import com.google.gwt.user.client.ui.DockLayoutPanel;37 import com.google.gwt.user.client.ui.FlowPanel;38 import com.google.gwt.user.client.ui.HorizontalSplitPanel;39 import com.google.gwt.user.client.ui.ListBox;40 import com.google.gwt.user.client.ui.PopupPanel;41 import com.google.gwt.user.client.ui.ScrollPanel;42 import com.google.gwt.user.client.ui.SimplePanel;43 import com.google.gwt.user.client.ui.Widget;44 import smartResorts.client.social.PanelSocial;45 46 /**47  * Quieres agregar un nuevo modulo-panel-servicio?, es muy sencillo.48  * 49  * 50  * 1.- Solo hay que ir a la BBDD y agregar un id a la tabla sub-services.51  * Si el subservicio va englobado en un servicio hay que poner el identificador52  * como tal, si va en la barra superior está en la categoria "Otros".53  * 54  * 55  * 2.- Hay que agregar el subservicio en el enumerado Subservices de GWT.56  * 57  * 3.- Crear un "PanelDerecho" o FlowPanel o Popup que se lanzará cuando se invoca al58  * servicio.59  * 60  * 4.- Ir al metodo showPanel de esta clase y poner en la lista de enumerados el panel61  * a lanzar en el caso de que se pulse el botón correspondiente.62  * 63  * 64  * 65  * 66  * @author luigi67  *68  */69 70 71 @SuppressWarnings("deprecation")72 public class Estructura extends FlowPanel implements has_id_service{73  74  Subservices subservice;75  76  final FlowPanel header = new FlowPanel();77  SimplePanel logo = new SimplePanel();78  final FlowPanel center = new FlowPanel();79  80  private ListadoServicios left_panel;81  final FlowPanel right_panel = new FlowPanel();82  private PanelDerecho _ultimo_panel_activo = null;83  public static int currentTranslation = 0;84  public static Traducible current_box;85  86  private HashMap<String, Integer> chapuza_complejo = new HashMap<String, Integer>();87  private ListBox _complejos;88  private Button logout = new Button();89  private Button createComplex = new Button();90  private Button adminStrings = new Button();91  92  {93  PopupPanel aux = new PopupPanel();94  aux.setWidget(Log.getInstance());95  aux.show();96  aux.setWidth("200px");97  aux.setHeight("100px");98  }99  100  final Login dialog_login = new Login(new MyCallback<String>() {101 102  @Override103  public void onDone(String result) {104  try{105  Log.log("Va a montar la estructura");106  montarEstructura();107  108  }catch(Exception ex){109  Log.log("Esto revienta");110  }111  }112  @Override113  public void onError(String t) {114  115  }116  });117  118  119  public Estructura() {120  setStyleName("estructura");121  }122  123  private void montarEstructura() {124  125  left_panel = new ListadoServicios(this,false);126  Log.log("Inicializando");127  SmartResorts2_2.centrado_vertical.setVisible(true);128  129  // Cabecera130  header.setStyleName("cabecera");131  add(header);132  133  Log.log("Inicializando");134  135  // Logo136  logo.setStyleName("logo");137  add(logo);138  139  // Big menu140  add(left_panel);141  142  // Center143  right_panel.setStyleName("center");144  add(right_panel);145 146  // Botones de la cabecera147  final ArrayList<BotonServicio> cabeceraBotones = new ArrayList<BotonServicio>();148  try{149  LinkedList<SubServiceBean> auxServices = Global.getSubServices();150  for (int i = 0; i < auxServices.size();i++){151  SubServiceBean sb = auxServices.get(i);152  if (sb == null)153  Log.log("Esto es nulo");154  Log.log("Va a comprobar un boton");155  if (sb.location() == 1){ // Hacer enum para la localizacion.156  Subservices ss = Subservices.values()[sb.getId()];157  Log.log("Va a configurar el id " + sb.getId());158  final BotonServicio auxButton = new BotonServicio(ss);159  auxButton.setText(sb.getName());160  cabeceraBotones.add(auxButton);161  auxButton.setStyleName("gwt-Button boton_cabecera boton_" + i);162  auxButton.setVisible(true);163  header.add(auxButton);164  165  // Inicializamos el clickHandler.166  auxButton.addClickHandler(new ClickHandler() {167  @Override168  public void onClick(ClickEvent event) {169  showPanel(auxButton.getId_service());170  }171  });172  } // Del if.173  }174  Log.log("Inicializa los botones"); 175  176  }catch(Exception ex){177  Log.log("Peta al inicializar la cabecera");178  Log.log(ex);179  } 180  181  // Combo182  if (Global.user_type == "MOBAIL" || Global.user_type == "CORPORATIVO") {183  _complejos = new ListBox();184  header.add(_complejos);185  186  _complejos.addChangeHandler(new ChangeHandler() {187  188  @Override189  public void onChange(ChangeEvent event) {190  191  new StandardRequest(ApiCalls.set_user_complex, new MyCallback<String>() {192  193  @Override194  public void onError(String t) {}195  @Override196  public void onDone(String result) {197  if (_ultimo_panel_activo != null)198  _ultimo_panel_activo.reload();199  Global.id_complex=_complejos.getValue(_complejos.getSelectedIndex());200  201  }202  },"id_complex="+_complejos.getValue(_complejos.getSelectedIndex()));203  204  }205  });206  207  _complejos.clear();208  chapuza_complejo.clear();209  210  211  // Aqui va la peticion.212  new StandardRequest(ApiCalls.get_complex_list, new MyCallback<String>() {213  214  @Override215  public void onError(String t) {}216  @Override217  public void onDone(String result) {218  219  JSONObject complejos = JSONParser.parseStrict(result).isObject();220  Iterator<String> it = complejos.keySet().iterator();221  int i = 0;222  while (it.hasNext()) {223  String key = (String) it.next();224  JSONObject complejo = complejos.get(key).isObject();225  _complejos.addItem(complejo.get("name").isString().stringValue(), ""+complejo.get("id").isNumber().doubleValue());226  chapuza_complejo.put(""+complejo.get("id").isNumber().doubleValue(), i);227  i++;228  }229  230  _complejos.setSelectedIndex(chapuza_complejo.get(Global.id_complex));231  232  }233  },"");234  235  }236  237  //setPanel(new PanelSplash());238  setPanel(new PanelDemo());239  240  // Mostramos ayuda si no se ha marcado que el usuario no quiere volver a verla.241  if (Global.show_wellcome){242  PanelBienvenida pb = new PanelBienvenida();243  pb.center();244  pb.show();245  }246  }247  248  public FlowPanel getHeader() {249  return header;250  }251  252  253  public void setPanel(Widget w) {254  right_panel.clear();255  right_panel.add(w);256  _ultimo_panel_activo = (PanelDerecho) w;257  }258  259  public void setPanelScroll(Widget w) {260  setPanel(w);261  /*262  right_panel.clear();263  right_panel.add(right_panel_scroll);264  right_panel_scroll.clear();265  right_panel_scroll.add(right_panel_scroll_content);266  right_panel_scroll_content.clear();267  right_panel_scroll_content.add(w);268  _ultimo_panel_activo = (PanelDerecho) w;269  */270  }271  272  private void showPanel(Subservices ss){273  274  Widget aux = null;275  Log.log("Te va a mostrar un panel");276  boolean useScrollPanel = false;277  278  279  switch(ss){280  case Info:aux = new PanelInfo();break;281  case Excursiones: aux = new PanelExcursiones();break;282  case Customer_alerts: aux = new PanelAlertasC(1);break;283  case Pre_customer_alerts: aux = new PanelAlertasC(0);break;284  case Post_costumer_alerts: aux = new PanelAlertasC(2);break;285  case Estadisticas: aux = new PanelEstadisticasAlertas();break;286  case Feedback: aux = new PanelFeedbackAlertas();break;287  case Instalaciones: aux = new PanelInstalaciones();break;288  case Actividades: aux = new PanelActividades();break;289  case Mapa: aux = new PanelMapa();break;290  case Habitaciones: aux = new PanelHabitaciones();break;291  case Restaurantes: aux = new PanelReservasGenerico(Category.Restaurantes);break;292  case Spas: aux = new PanelReservasGenerico(Category.Spas);break;293  case Deportes: aux = new PanelReservasGenerico(Category.Deportes);break;294  case Cliente: aux = new ReservasCliente();break;295  case Social: aux = new PanelSocial();break;296  case Empleados: aux = new PanelEmpleados();useScrollPanel = true;break;297  case Clientes: aux = new PanelClientes();break;298  case Post_costumers:aux = new PanelClientes(2);break;299  case Tour_operators:aux = new PanelTourOperators();break;300  case Filtros: aux = new PanelFiltros();break;301  case Configuración:aux = new PanelConfiguration();break;302  case Traducir: aux = (Estructura.currentTranslation == 0)?null:new PanelTraduccion(Estructura.currentTranslation);303  if (aux == null)304  Estructura.showMessage("Debe seleccionar un cuadro de texto para realizar una traducción a otro idioma");305  break;306  307  case Ayuda: aux = new PanelAyuda();break;308  case Services: aux = new PanelServices();break;309  case Publicar: SmartResorts2_2.publish();break;310  311  case MeetMe: aux = new PanelMeetMe();break;312  case Material_promocional: aux = new PanelMaterialPromocional();break;313  case Paneles: aux = new PanelPaneles();break;314  315  case Galerias: aux = new PanelGalerias();break;316  case Congresos: aux = new PanelCongresos();break;317  case Bodas: aux = new PanelWeddings();318  319  320  // Servicios muertos.321  //case Temas: aux = new PanelThemes();break; // Servicio muerto322  // case Pantallas: aux = new PanelScreens();break; // Servicio muerto323  324  325  326  327  }328  329  if (aux == null)330  Log.log("El panel es nulo");331  332  else if (aux instanceof MyPopUp){333  MyPopUp panel = (MyPopUp)aux;334  /*panel.center();*/335  panel.show();336  } else if (aux instanceof PopUp2) {337  PopUp2 panel = (PopUp2)aux;338  panel.show();339  }340  else setPanel(aux);341 342  }343  344  345 346  @Override347  public Subservices get_id_subservice() {348  // TODO Auto-generated method stub349  return subservice;350  }351 352  @Override353  public void set_id_subservice(Subservices subservice) {354  355  // Desde aqui invocamos al subservicio correspondiente.356  this.subservice = subservice;357  showPanel(Subservices.values()[subservice.ordinal()]);358  }359 }360 
Enlace
El enlace para compartir es: