import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.visualization.client.AbstractDataTable;
import com.google.gwt.visualization.client.DataTable;
import com.google.gwt.visualization.client.VisualizationUtils;
import com.google.gwt.visualization.client.AbstractDataTable.ColumnType;
import com.google.gwt.visualization.client.visualizations.corechart.Options;
import com.google.gwt.visualization.client.visualizations.corechart.PieChart;
//import com.smartgwt.client.widgets.calendar.Timeline;
/**
* This is a demo of how to properly handle dynamically created and destroyed
* widgets. Entry point classes define <code>onModuleLoad()</code>.
*/
public class WidgetAddDelete implements EntryPoint {
private final Button addChartButton = new Button("Add PieChart");
private final Button removeChartButton = new Button("Remove PieChart");
// private final Button addTimelineButton = new Button("Add Timeline");
// private final Button removeTimelineButton = new Button("Remove Timeline");
private final VerticalPanel mainPanel = new VerticalPanel();
private Widget contentWidget = null;
// private Widget timelineWidget = null;
/**
* This is the entry point method.
*/
public void onModuleLoad() {
mainPanel.add(addChartButton);
mainPanel.add(removeChartButton);
// mainPanel.add(addTimelineButton);
// mainPanel.add(removeTimelineButton);
RootPanel.get().add(mainPanel);
setUpButtons();
}
/**
* Add click handlers to the buttons.
*/
private void setUpButtons() {
addChartButton.addClickHandler(new ClickHandler() {
public void onClick(final ClickEvent event) {
if (contentWidget == null) {
Runnable onLoadCallback = new Runnable() {
public void run() {
PieChart content = new PieChart(createTable(), createOptions());
mainPanel.add(content);
contentWidget = content;
}
};
VisualizationUtils.loadVisualizationApi(onLoadCallback, PieChart.PACKAGE);
}
}
});
removeChartButton.addClickHandler(new ClickHandler() {
public void onClick(final ClickEvent event) {
if (contentWidget != null) {
mainPanel.remove(contentWidget);
contentWidget = null;
}
}
});
// addTimelineButton.addClickHandler(new ClickHandler() {
// public void onClick(final ClickEvent event) {
// if (timelineWidget == null) {
// Timeline timeline = new Timeline();
// mainPanel.add(timeline);
// timelineWidget = timeline;
// }
// }
// });
// removeTimelineButton.addClickHandler(new ClickHandler() {
// public void onClick(final ClickEvent event) {
// if (timelineWidget != null) {
// timelineWidget.removeFromParent();
// mainPanel.remove(timelineWidget);
// timelineWidget = null;
// }
// }
// });
}
private AbstractDataTable createTable() {
DataTable data = DataTable.create();
data.addColumn(ColumnType.STRING, "Task");
data.addColumn(ColumnType.NUMBER, "Hours per Day");
data.addRows(2);
data.setValue(0, 0, "Work");
data.setValue(0, 1, 14);
data.setValue(1, 0, "Sleep");
data.setValue(1, 1, 10);
return data;
}
private Options createOptions() {
Options options = Options.create();
options.setWidth(400);
options.setHeight(240);
options.setTitle("My Daily Activities");
return options;
}
}
Hi Colin,
Thanks for replying so quickly. I've tried compiling with -Dgwt.style=PRETTY and even DETAILED, but the short variable names remain for DOM objects created by, or at least related to, gwt-viz. Using Chrome's dev tools, I can look inside these objects to verify the connection to gwt-viz.
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment