From f473070a948a814611b2dc51518292526e569ac2 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Sun, 1 Jan 2012 22:02:23 +0100 Subject: [PATCH] Add comments with my understanding of the ClientFactory --- src/main/java/org/glom/web/client/ClientFactory.java | 11 +++++++++++ src/main/java/org/glom/web/client/OnlineGlom.java | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/src/main/java/org/glom/web/client/ClientFactory.java b/src/main/java/org/glom/web/client/ClientFactory.java index 4458667..99a9f55 100644 --- a/src/main/java/org/glom/web/client/ClientFactory.java +++ b/src/main/java/org/glom/web/client/ClientFactory.java @@ -28,6 +28,17 @@ import org.glom.web.client.ui.TableSelectionView; import com.google.gwt.place.shared.PlaceController; import com.google.web.bindery.event.shared.EventBus; +/** This creates the various views and other objects for OnlineGlom. + * + * GWT.create(ClientFactory.class) actually instantiates + * ClientFactoryImpl (or an alternative) according to the rules in + * our OnlineGlom.gwt.xml. + * See http://code.google.com/webtoolkit/doc/latest/DevGuideMvpActivitiesAndPlaces.html + * + * The *View types returned here are just interfaces, + * allowing alternative ClientFactory implementations to return instances of + * different actual view classes. + */ public interface ClientFactory { EventBus getEventBus(); diff --git a/src/main/java/org/glom/web/client/OnlineGlom.java b/src/main/java/org/glom/web/client/OnlineGlom.java index d87c88e..4c650d3 100644 --- a/src/main/java/org/glom/web/client/OnlineGlom.java +++ b/src/main/java/org/glom/web/client/OnlineGlom.java @@ -111,6 +111,10 @@ public class OnlineGlom implements EntryPoint { layoutPanel.setWidgetVisible(tableSelectionPanel, false); layoutPanel.setWidgetVisible(dataPanel, false); + // We might, in future, use different ClientFactory implementations to create different views + // for different browser types (such as mobile), so we use GWT.create() to have deferred binding. + // See http://code.google.com/webtoolkit/doc/latest/DevGuideMvpActivitiesAndPlaces.html + // which describes how to do this via our OnlineGlom.gwt.xml file. ClientFactory clientFactory = GWT.create(ClientFactory.class); EventBus eventBus = clientFactory.getEventBus(); PlaceController placeController = clientFactory.getPlaceController(); -- 2.1.4