reference_modules_gwt - NibiruOS/mobile GitHub Wiki
GWT
Generic cross components
Application
Due to different options (frameworks, deployment environments, etc.), application setup is a little more complicated on GWT.
For example, some frameworks, such as MGWT, are based on GWT activities and places. So, you may choose between using raw GWT activities and places or building you UI using MGWT. The only difference is how the root application widget is created. In order to abstract this, Nibiru Mobile provides the AppWidgetBootstrap.
The GwtPlacesBootstrap class receives an AppWidgetBootstrap and performs GWT places configuration. GwtAppWidgetBootstrap provides an AppWidgetBootstrap implementation that uses standard GWT widgets. On the ar.com.oxen.nibiru.mobile.mgwt
module, MgwtAppWidgetBootstrap class provides a MGWT-based widget for place navigation.
The GwtPlacesBootstrap also receives a DatabaseBootstrap instance which creates the Web SQL database. However, your applicacion may not need/support a local database. Because of this, there is a dummy implementation, explained in the next section.
Data access
The ar.com.oxen.nibiru.mobile.gwt.data
package contains components for accessing Web SQL database. The technologies used for this purpose are GwtMobile-Persistence and persistence.js.
The GwtMobileDatabaseBootstrap class sets up a database using these technologies.
As explained in the previous section, if you aren't going to support Web SQL database (for example if you are targetting browsers that doesn't support this feature), you can use DummyDatabaseBootstrap.
Inversion of control
The ar.com.oxen.nibiru.mobile.gwt.ioc
contains many GIN modules useful for default configurations. Also, it provides a base interface for creating injectors based on GIN (GwtInjector).
On ar.com.oxen.nibiru.mobile.mgwt
module, the ar.com.oxen.nibiru.mobile.mgwt.ioc
package provides GIN modules for configuring dependency injection with MGWT.
Unified API components
Event handling
GWT event handling is implemented using a wrapper for com.google.web.bindery.event.shared.EventBus
. This adapter (GwtEventBus) and simple event/event handler implementations (SimpleEvent and SimpleEventHandler) can be found at the ar.com.oxen.nibiru.mobile.gwt.event
package.
\end_layout
HTTP requests
The com.google.gwt.http.client.RequestBuilder
class is used in order to perform HTTP requests. The adapter to Nibiru Mobile API is located at the ar.com.oxen.nibiru.mobile.gwt.http
package. Its name is RequestBuilderHttpManager.
Object serialization
The package ar.com.oxen.nibiru.mobile.gwt.serializer
contains GWT implementation for JSON serialization: AutoBeanSerializer. It is based in AutoBeans technology, included in GWT.
User interface
The ar.com.oxen.nibiru.mobile.gwt.ui
package contains an alert manager implementation (GwtAlertManager) which uses Window.alert() in order to show messages. Also, a Looper using com.google.gwt.core.client.Scheduler
is provided (SchedulerLooper).
The ar.com.oxen.nibiru.mobile.mgwt.ui
from ar.com.oxen.nibiru.mobile.mgwt
module provides a similar implementation, but using MGWT com.googlecode.mgwt.ui.client.dialog.Dialogs
(MgwtAlertManager).
Place management
The ar.com.oxen.nibiru.mobile.gwt.ui.place
package contains classes that adapt GWT's activities and places to Nibiru Mobile place management API. GwtPlaceManager is a place manager implementation that delegates on com.google.gwt.place.shared.PlaceController
for navigation. It creates SimplePlace instances, which just wraps a GWT place.
\end_layout
DefaultActivityMapper and DefaultPlaceHistoryMapper provide generic implementations for both, ActivityMapper[
and PlaceHistoryMapper
.
The ar.com.oxen.nibiru.mobile.mgwt
module provides the DefaultAnimationMapper class, which just selects a random animation for place transition.
Model-View-Presenter pattern
The ar.com.oxen.nibiru.mobile.gwt.ui.mvp
package contains classes (API implementations and adapteres) for implementing the MVP pattern.
The main class is PresenterActivity, which delegates on the presenter. This activity receives the presenter responsible for executing the logic and the place from DefaultActivityMapper. This class also sets the display widget.
Regarding the view, a base class called BaseGwtView is provided.
On the ar.com.oxen.nibiru.mobile.mgwt
module, you can find MGWT adapters and base classes for MVP pattern inside the ar.com.oxen.nibiru.mobile.mgwt.ui.mvp
package.
User preferences
The ar.com.oxen.nibiru.mobile.gwt.preferences
package contains a cookie-based preferences services (CookiesPreferences). In the future, a Web SQL preferences could be implemented.
Geolocation
Geolocation (as hardware access in general) is implemented using Apache Cordova (aka PhoneGap). Since this API is JavaScript-based, GWT-PhoneGap is used in order to access it from GWT.
Geolocation implementations are found in the ar.com.oxen.nibiru.mobile.gwt.geolocation
package.