1 package com
.Ocio20
.client
;
4 import com
.google
.gwt
.core
.client
.EntryPoint
;
5 import com
.google
.gwt
.core
.client
.GWT
;
6 import com
.google
.gwt
.event
.dom
.client
.ClickEvent
;
7 import com
.google
.gwt
.event
.dom
.client
.ClickHandler
;
8 import com
.google
.gwt
.event
.dom
.client
.KeyCodes
;
9 import com
.google
.gwt
.event
.dom
.client
.KeyUpEvent
;
10 import com
.google
.gwt
.event
.dom
.client
.KeyUpHandler
;
11 import com
.google
.gwt
.user
.client
.rpc
.AsyncCallback
;
12 import com
.google
.gwt
.user
.client
.ui
.Button
;
13 import com
.google
.gwt
.user
.client
.ui
.DialogBox
;
14 import com
.google
.gwt
.user
.client
.ui
.Grid
;
15 import com
.google
.gwt
.user
.client
.ui
.HTML
;
16 import com
.google
.gwt
.user
.client
.ui
.Label
;
17 import com
.google
.gwt
.user
.client
.ui
.ListBox
;
18 import com
.google
.gwt
.user
.client
.ui
.RootPanel
;
19 import com
.google
.gwt
.user
.client
.ui
.StackPanel
;
20 import com
.google
.gwt
.user
.client
.ui
.TextBox
;
21 import com
.google
.gwt
.user
.client
.ui
.VerticalPanel
;
24 * Entry point classes define <code>onModuleLoad()</code>.
26 public class FormSitio
implements EntryPoint
{
28 * The message displayed to the user when the server cannot be reached or
31 private static final String SERVER_ERROR
= "An error occurred while "
32 + "attempting to contact the server. Please check your network "
33 + "connection and try again.";
36 * Create a remote service proxy to talk to the server-side Greeting service.
38 private final GreetingServiceAsync greetingService
= GWT
39 .create(GreetingService
.class);
42 * This is the entry point method.
44 public void onModuleLoad() {
45 final Button sendButton
= new Button("Send");
46 final TextBox nameField
= new TextBox();
47 nameField
.setText("GWT User");
49 // We can add style names to widgets
50 sendButton
.addStyleName("sendButton");
52 // Add the nameField and sendButton to the RootPanel
53 // Use RootPanel.get() to get the entire body element
54 RootPanel
.get("nameFieldContainer").add(nameField
);
55 RootPanel
.get("sendButtonContainer").add(sendButton
);
57 //----------------------------------------------------------------------------------------------------------------
62 tipo de sitio (restaurante, pub, heladeria, bar, cafe, ...) TODO: metemos un textbox con busqueda de los ya definidos ->
63 rellenamos una variable en js que tenga la lista y ahí buscamos.
64 geolocalizacion -> eso en el mapa!
69 final int MAX_LENGTH_NOMBRE
= 35;
70 final int VISIBLE_LENGTH_NOMBRE
= 35;
71 final int MAX_LENGTH_DIRECCION
= 35;
72 final int VISIBLE_LENGTH_DIRECCION
= 35;
73 final int MAX_LENGTH_TIPO
= 35;
74 final int VISIBLE_LENGTH_TIPO
= 35;
77 //final VerticalPanel vpDatosBasicos = new VerticalPanel();
78 final Grid gDatosBasicos
= new Grid(3, 2);
80 final TextBox txtNombre
= new TextBox();
81 final Label lNombre
= new Label("Nombre: ");
82 txtNombre
.setMaxLength(MAX_LENGTH_NOMBRE
);
83 txtNombre
.setVisibleLength(VISIBLE_LENGTH_NOMBRE
);
84 gDatosBasicos
.setWidget(0, 0, lNombre
);
85 gDatosBasicos
.setWidget(0, 1, txtNombre
);
87 final TextBox txtDireccion
= new TextBox();
88 final Label lDireccion
= new Label("Direccion: ");
89 txtDireccion
.setMaxLength(MAX_LENGTH_DIRECCION
);
90 txtDireccion
.setVisibleLength(VISIBLE_LENGTH_DIRECCION
);
91 gDatosBasicos
.setWidget(1, 0, lDireccion
);
92 gDatosBasicos
.setWidget(1, 1, txtDireccion
);
94 final TextBox txtTipo
= new TextBox();
95 final Label lTipo
= new Label("Tipo: ");
96 txtTipo
.setMaxLength(MAX_LENGTH_TIPO
);
97 txtTipo
.setVisibleLength(VISIBLE_LENGTH_TIPO
);
98 gDatosBasicos
.setWidget(2, 0, lTipo
);
99 gDatosBasicos
.setWidget(2, 1, txtTipo
);
104 /* Añadidos -> meterlos como constante
105 Foto, web, contacto, telefono, web, mail, aforo, tranquilidad, musica en vivo, musica, familiar, romantico, no fumadores
106 horario, edades, productoEspecial, precioCaña/refresco/agua/copa/cafe, apropiadoConocerGenteNueva, vistas,
107 terraza, climatizado, zonaDeOcio, nacional/extranjero, futbol/basket/.../canalesDePago, tipoAmbiente (pijo, alternativo, descuidado, gay),
108 gogo, limpieza, actividadesCulturales, bailar, wifi / ordenadores, parkingPrivado, facilidadAparcar, juegosMesa,
109 billar, futbolin, dardos, otrasMaquinas, promocionEspecial (2x1, cada x veces 1 gratis,...), aceptaTarjeta (visa, MasterCard, 4B, ...)
110 diasDeMovimiento, precioEntrada, requisitosEspeciales, localEmblemático, familias, empresas, popularidad
114 final VerticalPanel vpContacto
= new VerticalPanel();
116 final TextBox telefono
= new TextBox();
117 vpContacto
.add(telefono
);
122 // Creamos el StackPanel para meter los formularios
123 final StackPanel stDatosSitio
= new StackPanel();
124 stDatosSitio
.add(gDatosBasicos
, "Datos básicos");
125 stDatosSitio
.add(vpContacto
, "Contacto");
127 // Make a new list box, adding a few items to it.
128 /* ListBox lb = new ListBox();
133 lb.addItem("tintin");
135 // Make enough room for all five items (setting this value to 1 turns it
136 // into a drop-down list).
137 lb.setVisibleItemCount(0);
139 // Add it to the root panel.
140 RootPanel.get().add(lb);
143 RootPanel
.get().add(stDatosSitio
);
144 //----------------------------------------------------------------------------------------------------------------
146 // Focus the cursor on the name field when the app loads
147 nameField
.setFocus(true);
148 nameField
.selectAll();
150 // Create the popup dialog box
151 final DialogBox dialogBox
= new DialogBox();
152 dialogBox
.setText("Remote Procedure Call");
153 dialogBox
.setAnimationEnabled(true);
154 final Button closeButton
= new Button("Close");
155 // We can set the id of a widget by accessing its Element
156 closeButton
.getElement().setId("closeButton");
157 final Label textToServerLabel
= new Label();
158 final HTML serverResponseLabel
= new HTML();
159 VerticalPanel dialogVPanel
= new VerticalPanel();
160 dialogVPanel
.addStyleName("dialogVPanel");
161 dialogVPanel
.add(new HTML("<b>Sending name to the server:</b>"));
162 dialogVPanel
.add(textToServerLabel
);
163 dialogVPanel
.add(new HTML("<br><b>Server replies:</b>"));
164 dialogVPanel
.add(serverResponseLabel
);
165 dialogVPanel
.setHorizontalAlignment(VerticalPanel
.ALIGN_RIGHT
);
166 dialogVPanel
.add(closeButton
);
167 dialogBox
.setWidget(dialogVPanel
);
169 // Add a handler to close the DialogBox
170 closeButton
.addClickHandler(new ClickHandler() {
171 public void onClick(ClickEvent event
) {
173 sendButton
.setEnabled(true);
174 sendButton
.setFocus(true);
178 // Create a handler for the sendButton and nameField
179 class MyHandler
implements ClickHandler
, KeyUpHandler
{
181 * Fired when the user clicks on the sendButton.
183 public void onClick(ClickEvent event
) {
188 * Fired when the user types in the nameField.
190 public void onKeyUp(KeyUpEvent event
) {
191 if (event
.getNativeKeyCode() == KeyCodes
.KEY_ENTER
) {
197 * Send the name from the nameField to the server and wait for a response.
199 private void sendNameToServer() {
200 sendButton
.setEnabled(false);
201 String textToServer
= nameField
.getText();
202 textToServerLabel
.setText(textToServer
);
203 serverResponseLabel
.setText("");
204 greetingService
.greetServer(textToServer
,
205 new AsyncCallback
<String
>() {
206 public void onFailure(Throwable caught
) {
207 // Show the RPC error message to the user
209 .setText("Remote Procedure Call - Failure");
211 .addStyleName("serverResponseLabelError");
212 serverResponseLabel
.setHTML(SERVER_ERROR
);
214 closeButton
.setFocus(true);
217 public void onSuccess(String result
) {
218 dialogBox
.setText("Remote Procedure Call");
220 .removeStyleName("serverResponseLabelError");
221 serverResponseLabel
.setHTML(result
);
223 closeButton
.setFocus(true);
229 // Add a handler to send the name to the server
230 MyHandler handler
= new MyHandler();
231 sendButton
.addClickHandler(handler
);
232 nameField
.addKeyUpHandler(handler
);