TextView document = wavelet.getRootBlip().getDocument();
GadgetView gadgetView = document.getGadgetView();
for (Gadget gadget : gadgetView.getGadgets()) {
if ((gadget != null) && ("true".equals(gadget.getField(GADGET_STATE)))) {
if (twitterService.checkAuthorization(wavelet, loginForm)) {
FetchController controller =
twitterWave.isInSearchMode() ? new SearchController(twitterService, rootBlip,
twitterWave, robotMessageBundle.getEvents()) : new TimelineController(
twitterService, rootBlip, twitterWave, robotMessageBundle.getEvents());
// Fetch and append tweets.
appendTweets(wavelet, controller.fetch());
// Clear the login form and render the search or update form.
controller.renderForm();
}
}
}
}
if (event.getType() == EventType.FORM_BUTTON_CLICKED ||
event.getType() == EventType.BLIP_SUBMITTED) {
// Handle the normal flow after logging in.
FetchController controller =
twitterWave.isInSearchMode() ? new SearchController(twitterService, rootBlip,
twitterWave, robotMessageBundle.getEvents()) : new TimelineController(
twitterService, rootBlip, twitterWave, robotMessageBundle.getEvents());
// Fetch tweets when search or update button is clicked.
if (controller.isButtonClicked()) {
appendTweets(wavelet, controller.execute());
}
// Handle blip submitted events, that are considered as
// @replies.
for (Event blipSubmittedEvent : robotMessageBundle.getBlipSubmittedEvents()) {