Tipo questo

package com.tesi.client;
import com.google.gwt.user.client.HTTPRequest;
import com.google.gwt.user.client.ResponseTextHandler;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.MouseListener;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.xml.client.Document;
import com.google.gwt.xml.client.Element;
import com.google.gwt.xml.client.NodeList;
import com.google.gwt.xml.client.XMLParser;
public class EventDistinctItem implements ClickListener {
private class PopupBox extends DialogBox implements ClickListener, MouseListener{
private String eventName;
private DockPanel contents = new DockPanel();
private PopupDetails popupDetailsPanel;
private PopupParticipant popupParticipantsPanel;
private Button close;
private Label details;
private Label participants;
public PopupBox (DockPanel innerPanel, VerticalPanel detailsPanel, String event) {
eventName = event;
setText("Drag to move popup panel.");
// DialogBox is a SimplePanel, so you have to set its widget property to
// whatever you want its contents to be.
contents.add(innerPanel, DockPanel.NORTH);
close = new Button("Close");
close.addClickListener(this);
contents.add(close, DockPanel.CENTER);
details = new Label("Details");
details.addMouseListener(this);
contents.add(details, DockPanel.WEST);
participants = new Label("Participants");
participants.addMouseListener(this);
contents.add(participants, DockPanel.EAST);
setWidget(contents);
}
public void onClick(Widget sender) {
if (sender == close) {
PopupBox.this.hide();
}
}
public void onMouseDown(Widget sender, int x, int y) {}
public void onMouseEnter(Widget sender) {
if (sender == details) {
popupDetailsPanel = new PopupDetails(detailsPanel);
popupDetailsPanel.center();
}
if (sender == participants) {
popupParticipantsPanel = new PopupParticipant(eventName);
popupParticipantsPanel.center();
}
}
public void onMouseLeave(Widget sender) {
if (sender == details) {
popupDetailsPanel.hide();
}
if (sender == participants) {
popupParticipantsPanel.hide();
}
}
public void onMouseMove(Widget sender, int x, int y) {}
public void onMouseUp(Widget sender, int x, int y) {}
}
private class PopupDetails extends PopupPanel {
public PopupDetails(VerticalPanel details) {
// PopupPanel's constructor takes 'auto-hide' as its boolean parameter.
// If this is set, the panel closes itself automatically when the user
// clicks outside of it.
super(true);
// PopupPanel is a SimplePanel, so you have to set it's widget property to
// whatever you want its contents to be.
setWidget(details);
}
}
private class PopupParticipant extends PopupPanel {
private static final String urlString = "http://localhost:8080/event_participant.php?";
private String eventName;
private VerticalPanel participantsPanel = new VerticalPanel();
public PopupParticipant(String event) {
super(true);
eventName = event;
Entries queryData = new Entries("event", eventName);
Entry[] queryString;
queryString = new Entry[1];
queryString[0] = queryData;
String completeUrl = urlString + QueryData.buildQueryString(queryString);
HTTPRequest.asyncGet(completeUrl, new ResponseTextHandler() {
public void onCompletion(String response) {
renderXml(response);
setWidget(participantsPanel);
}
});
}
private void renderXml(String xmlData) {
Label title = new Label("Participants:");
participantsPanel.add(title);
Document eventParticipantDom = XMLParser.parse(xmlData);
Element eventParticipantElement = eventParticipantDom.getDocumentElement();
XMLParser.removeWhitespace(eventParticipantElement);
NodeList participants = eventParticipantElement.getElementsByTagName("participant");
for (int i = 0; i < participants.getLength(); i++) {
Element participant = (Element)participants.item(i);
String participantText = participant.getFirstChild().getNodeValue();
Label participantLabel = new Label(participantText);
participantsPanel.add(participantLabel);
}
participantsPanel.addStyleName("PopupDetails");
}
}
private boolean EventFlag;
private Element distinctItem;
private String shortname;
private String fullname;
private String location;
private String description;
private String link;
private String beginningDate;
private String endingDate;
private VerticalPanel abstractPanel = new VerticalPanel();
private DockPanel detailPanel = new DockPanel();
private VerticalPanel detailsPanel = new VerticalPanel();
private HTML spacer = new HTML("<br />");
private Label title;
public EventDistinctItem (Element item) {
distinctItem = item;
renderXmlItem();
if (EventFlag)
{ setDistinctItemAbstractTrue();
setDistinctItemDetailed();
setDetails();
}
else {
setDistinctItemAbstractFalse();
}
}
private void renderXmlItem() {
shortname = distinctItem.getAttribute("shortname");
if (shortname.equals("None"))
{
EventFlag = false;
}
else
{
EventFlag = true;
fullname = getFullname();
location = getLocation();
description = getDescription();
link = getLink();
beginningDate = getBeginningDate();
endingDate = getEndingDate();
}
}
private void setDistinctItemAbstractTrue() {
title = new Label(shortname);
title.setStyleName("ActivityItem-TitleArea");
title.addClickListener(this);
abstractPanel.add(title);
HTML longTitle = new HTML(fullname);
longTitle.setStyleName("ActivityItem-Text");
abstractPanel.add(longTitle);
abstractPanel.add(spacer);
}
private void setDistinctItemAbstractFalse() {
Label noData = new Label("No Data Available");
abstractPanel.add(noData);
}
private void setDistinctItemDetailed() {
VerticalPanel headerPanel = new VerticalPanel();
Label title = new Label(shortname);
title.setStyleName("DialogBox-TitleArea");
headerPanel.add(title);
HTML longTitle = new HTML(fullname);
longTitle.setStyleName("DialogBox-Text");
headerPanel.add(longTitle);
detailPanel.add(headerPanel, DockPanel.NORTH);
HTML event_description = new HTML(description);
event_description.setStyleName("DialogBox-Text");