labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r794643 - in /labs/hupa: ./ src/main/java/org/apache/hupa/ src/main/java/org/apache/hupa/client/ src/main/java/org/apache/hupa/client/gin/ src/main/java/org/apache/hupa/client/mvp/ src/main/java/org/apache/hupa/client/rpc/
Date Thu, 16 Jul 2009 11:59:15 GMT
Author: norman
Date: Thu Jul 16 11:59:15 2009
New Revision: 794643

URL: http://svn.apache.org/viewvc?rev=794643&view=rev
Log:
Make use of gwt-presenter which is a slim framework which simplify the usage of MVP

Added:
    labs/hupa/src/main/java/org/apache/hupa/client/gin/HupaClientModule.java
      - copied, changed from r794142, labs/hupa/src/main/java/org/apache/hupa/client/gin/MyClientModule.java
    labs/hupa/src/main/java/org/apache/hupa/client/gin/HupaGinjector.java
      - copied, changed from r794142, labs/hupa/src/main/java/org/apache/hupa/client/gin/MyGinjector.java
Removed:
    labs/hupa/src/main/java/org/apache/hupa/client/gin/MyClientModule.java
    labs/hupa/src/main/java/org/apache/hupa/client/gin/MyGinjector.java
    labs/hupa/src/main/java/org/apache/hupa/client/rpc/EventBus.java
Modified:
    labs/hupa/pom.xml
    labs/hupa/src/main/java/org/apache/hupa/Hupa.gwt.xml
    labs/hupa/src/main/java/org/apache/hupa/client/Hupa.java
    labs/hupa/src/main/java/org/apache/hupa/client/mvp/AppPresenter.java
    labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListPresenter.java
    labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListView.java
    labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessagePresenter.java
    labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageView.java
    labs/hupa/src/main/java/org/apache/hupa/client/mvp/LoginPresenter.java
    labs/hupa/src/main/java/org/apache/hupa/client/mvp/LoginView.java
    labs/hupa/src/main/java/org/apache/hupa/client/mvp/MainPresenter.java
    labs/hupa/src/main/java/org/apache/hupa/client/mvp/MainView.java

Modified: labs/hupa/pom.xml
URL: http://svn.apache.org/viewvc/labs/hupa/pom.xml?rev=794643&r1=794642&r2=794643&view=diff
==============================================================================
--- labs/hupa/pom.xml (original)
+++ labs/hupa/pom.xml Thu Jul 16 11:59:15 2009
@@ -53,6 +53,11 @@
 			<url>http://gwt-dispatch.googlecode.com/svn/maven2</url>
 		</repository>
 		<repository>
+			<id>gwt-presenter</id>
+			<name>GWT Presenter repository at googlecode</name>
+			<url>http://gwt-presenter.googlecode.com/svn/maven2</url>
+		</repository>
+		<repository>
 			<id>cobogw</id>
 			<name>Cobogw repository at googlecode</name>
 			<url>http://cobogw.googlecode.com/svn/maven2</url>
@@ -265,6 +270,11 @@
 			<version>1.0.0-SNAPSHOT</version>
 		</dependency>
 		<dependency>
+			<groupId>net.customware.gwt.presenter</groupId>
+			<artifactId>gwt-presenter</artifactId>
+			<version>1.0.0-SNAPSHOT</version>
+		</dependency>
+		<dependency>
 			<groupId>com.google.gwt</groupId>
 			<artifactId>gwt-incubator</artifactId>
 			<version>march-02-2009</version>

Modified: labs/hupa/src/main/java/org/apache/hupa/Hupa.gwt.xml
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/Hupa.gwt.xml?rev=794643&r1=794642&r2=794643&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/Hupa.gwt.xml (original)
+++ labs/hupa/src/main/java/org/apache/hupa/Hupa.gwt.xml Thu Jul 16 11:59:15 2009
@@ -18,6 +18,8 @@
   <inherits name='com.google.gwt.gen2.table.override.Override'/>
   <inherits name='com.google.gwt.gen2.table.ScrollTable'/>
   <inherits name='net.customware.gwt.dispatch.Dispatch' />
+  <inherits name='net.customware.gwt.presenter.Presenter' />
+  
   <inherits name="com.google.gwt.inject.Inject"/>
   
   <source path="shared"/>

Modified: labs/hupa/src/main/java/org/apache/hupa/client/Hupa.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/Hupa.java?rev=794643&r1=794642&r2=794643&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/Hupa.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/Hupa.java Thu Jul 16 11:59:15 2009
@@ -19,7 +19,7 @@
 
 package org.apache.hupa.client;
 
-import org.apache.hupa.client.gin.MyGinjector;
+import org.apache.hupa.client.gin.HupaGinjector;
 import org.apache.hupa.client.mvp.AppPresenter;
 
 import com.google.gwt.core.client.EntryPoint;
@@ -27,7 +27,7 @@
 import com.google.gwt.user.client.ui.RootPanel;
 
 public class Hupa implements EntryPoint{
-	private final MyGinjector injector = GWT.create(MyGinjector.class);
+	private final HupaGinjector injector = GWT.create(HupaGinjector.class);
 	
 	public void onModuleLoad() {
 		

Copied: labs/hupa/src/main/java/org/apache/hupa/client/gin/HupaClientModule.java (from r794142,
labs/hupa/src/main/java/org/apache/hupa/client/gin/MyClientModule.java)
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/gin/HupaClientModule.java?p2=labs/hupa/src/main/java/org/apache/hupa/client/gin/HupaClientModule.java&p1=labs/hupa/src/main/java/org/apache/hupa/client/gin/MyClientModule.java&r1=794142&r2=794643&rev=794643&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/gin/MyClientModule.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/gin/HupaClientModule.java Thu Jul 16 11:59:15
2009
@@ -19,6 +19,11 @@
 
 package org.apache.hupa.client.gin;
 
+import net.customware.gwt.presenter.client.DefaultEventBus;
+import net.customware.gwt.presenter.client.EventBus;
+import net.customware.gwt.presenter.client.gin.AbstractPresenterModule;
+import net.customware.gwt.presenter.client.place.PlaceManager;
+
 import org.apache.hupa.client.mvp.AppPresenter;
 import org.apache.hupa.client.mvp.IMAPMessageListPresenter;
 import org.apache.hupa.client.mvp.IMAPMessageListView;
@@ -28,30 +33,22 @@
 import org.apache.hupa.client.mvp.LoginView;
 import org.apache.hupa.client.mvp.MainPresenter;
 import org.apache.hupa.client.mvp.MainView;
-import org.apache.hupa.client.rpc.EventBus;
 
-import com.google.gwt.inject.client.AbstractGinModule;
 import com.google.inject.Singleton;
 
-public class MyClientModule extends AbstractGinModule{
+public class HupaClientModule extends AbstractPresenterModule {
 
 	@Override
-	protected void configure() {
-		bind(EventBus.class).in(Singleton.class);
-		
-		bind(LoginPresenter.Display.class).to(LoginView.class).in(Singleton.class);
-		bind(LoginPresenter.class).in(Singleton.class);
+	protected void configure() {		
+		bind(EventBus.class).to(DefaultEventBus.class).in(Singleton.class);
+		bind(PlaceManager.class).in(Singleton.class);
+		bindPresenter(LoginPresenter.class,LoginPresenter.Display.class, LoginView.class);
+		bindPresenter(IMAPMessageListPresenter.class,IMAPMessageListPresenter.Display.class,IMAPMessageListView.class);
+		bindPresenter(IMAPMessagePresenter.class,IMAPMessagePresenter.Display.class,IMAPMessageView.class);
+		bindPresenter(MainPresenter.class,MainPresenter.Display.class,MainView.class);
 		
 		bind(AppPresenter.class).in(Singleton.class);
-		
-		bind(MainPresenter.Display.class).to(MainView.class).in(Singleton.class);
-		bind(MainPresenter.class).in(Singleton.class);
-		
-		bind(IMAPMessageListPresenter.Display.class).to(IMAPMessageListView.class).in(Singleton.class);
-		bind(IMAPMessageListPresenter.class).in(Singleton.class);
-		
-		bind(IMAPMessagePresenter.Display.class).to(IMAPMessageView.class).in(Singleton.class);
-		bind(IMAPMessagePresenter.class).in(Singleton.class);
+
 	}
 
 }

Copied: labs/hupa/src/main/java/org/apache/hupa/client/gin/HupaGinjector.java (from r794142,
labs/hupa/src/main/java/org/apache/hupa/client/gin/MyGinjector.java)
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/gin/HupaGinjector.java?p2=labs/hupa/src/main/java/org/apache/hupa/client/gin/HupaGinjector.java&p1=labs/hupa/src/main/java/org/apache/hupa/client/gin/MyGinjector.java&r1=794142&r2=794643&rev=794643&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/gin/MyGinjector.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/gin/HupaGinjector.java Thu Jul 16 11:59:15
2009
@@ -25,7 +25,7 @@
 import com.google.gwt.inject.client.GinModules;
 import com.google.gwt.inject.client.Ginjector;
 
-@GinModules({ClientDispatchModule.class,MyClientModule.class})
-public interface MyGinjector extends Ginjector {
+@GinModules({ClientDispatchModule.class,HupaClientModule.class})
+public interface HupaGinjector extends Ginjector {
 	public AppPresenter getAppPresenter();
 }

Modified: labs/hupa/src/main/java/org/apache/hupa/client/mvp/AppPresenter.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/mvp/AppPresenter.java?rev=794643&r1=794642&r2=794643&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/mvp/AppPresenter.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/mvp/AppPresenter.java Thu Jul 16 11:59:15
2009
@@ -21,8 +21,8 @@
 package org.apache.hupa.client.mvp;
 
 import net.customware.gwt.dispatch.client.DispatchAsync;
+import net.customware.gwt.presenter.client.EventBus;
 
-import org.apache.hupa.client.rpc.EventBus;
 import org.apache.hupa.shared.data.IMAPUser;
 import org.apache.hupa.shared.events.LoginEvent;
 import org.apache.hupa.shared.events.LoginEventHandler;
@@ -81,16 +81,13 @@
 					
 				};
 				noopTimer.scheduleRepeating(30000);
-				container.clear();
-				mainPresenter.go(container);
+				showMain();
 			}
-			
 		});
 		bus.addHandler(LogoutEvent.TYPE, new LogoutEventHandler() {
 
 			public void onLogout(LogoutEvent event) {
-				container.clear();
-				loginPresenter.go(container);
+				showLogin();
 				if (noopTimer != null) {
 					noopTimer.cancel();
 				}
@@ -99,8 +96,20 @@
 		});
 	}
 	
+
+	private void showMain() {
+		container.clear();
+		container.add(mainPresenter.getDisplay().asWidget());
+	}
+	
+	
+	private void showLogin() {
+		container.clear();
+		container.add(loginPresenter.getDisplay().asWidget());
+	}
+	
 	public void go(HasWidgets container) {
 		this.container = container;
-		loginPresenter.go(container);
+		showLogin();
 	}
 }

Modified: labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListPresenter.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListPresenter.java?rev=794643&r1=794642&r2=794643&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListPresenter.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListPresenter.java Thu Jul
16 11:59:15 2009
@@ -19,10 +19,15 @@
 
 package org.apache.hupa.client.mvp;
 
+import net.customware.gwt.presenter.client.EventBus;
+import net.customware.gwt.presenter.client.place.Place;
+import net.customware.gwt.presenter.client.place.PlaceRequest;
+import net.customware.gwt.presenter.client.widget.WidgetDisplay;
+import net.customware.gwt.presenter.client.widget.WidgetPresenter;
+
 import org.apache.hupa.client.events.ClickEvent;
 import org.apache.hupa.client.events.ClickHandler;
 import org.apache.hupa.client.events.HasClickHandlers;
-import org.apache.hupa.client.rpc.EventBus;
 import org.apache.hupa.shared.data.IMAPFolder;
 import org.apache.hupa.shared.data.IMAPMessage;
 import org.apache.hupa.shared.data.IMAPUser;
@@ -34,36 +39,36 @@
 
 import com.google.gwt.gen2.table.event.client.HasPageLoadHandlers;
 import com.google.gwt.gen2.table.event.client.HasRowSelectionHandlers;
-import com.google.gwt.user.client.ui.HasWidgets;
-import com.google.gwt.user.client.ui.Widget;
 import com.google.inject.Inject;
 
-public class IMAPMessageListPresenter {
+public class IMAPMessageListPresenter extends WidgetPresenter<IMAPMessageListPresenter.Display>{
 	
-	public interface Display {
+	public interface Display extends WidgetDisplay{
 		public HasRowSelectionHandlers getDataTableSelection();
 		public HasPageLoadHandlers getDataTableLoad();
 		public HasClickHandlers getDataTableClick();
 		public void reloadData(IMAPUser user, IMAPFolder folder,String searchValue);
 	}
 
-	
-	private Display display;	
-	private EventBus bus;
 	protected IMAPUser user;
 	protected IMAPFolder folder;
 	protected String searchValue;
 	
 	@Inject
-	public IMAPMessageListPresenter(EventBus bus,IMAPMessageListPresenter.Display display) {
-		this.bus = bus;
-		this.display = display;
-		bindHandlers();
-		bind(display);
+	public IMAPMessageListPresenter(IMAPMessageListPresenter.Display display,EventBus bus) {
+		super(display,bus);
+		bind();
 	}
 	
-	private void bindHandlers() {
-		bus.addHandler(LoadMessagesEvent.TYPE, new LoadMessagesEventHandler() {
+	@Override
+	public Place getPlace() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	protected void onBind() {
+		eventBus.addHandler(LoadMessagesEvent.TYPE, new LoadMessagesEventHandler() {
 
 			public void onLoadMessagesEvent(LoadMessagesEvent loadMessagesEvent) {
 				user = loadMessagesEvent.getUser();
@@ -73,7 +78,7 @@
 			}
 			
 		});
-		bus.addHandler(LoginEvent.TYPE, new LoginEventHandler() {
+		eventBus.addHandler(LoginEvent.TYPE, new LoginEventHandler() {
 
 			public void onLogin(LoginEvent event) {
 				user = event.getUser();
@@ -83,25 +88,37 @@
 
 			
 		});
-	}
-	
-	public void bind(final Display display) {
-		this.display = display;
 		
 		display.getDataTableClick().addClickHandler(new ClickHandler<IMAPMessage>() {
 
 			public void onClick(ClickEvent<IMAPMessage> event) {
 				if (event.getCell() >=1) {
-					bus.fireEvent(new ExpandMessageEvent(user,folder,event.getRowValue()));
+					eventBus.fireEvent(new ExpandMessageEvent(user,folder,event.getRowValue()));
 				}
 			}
 			
 		});
 	}
-	
-	
-	public void go(HasWidgets w) {
-		w.add((Widget)display);
+
+	@Override
+	protected void onPlaceRequest(PlaceRequest request) {
+		// TODO Auto-generated method stub
+		
+	}
+
+	@Override
+	protected void onUnbind() {
+		
+	}
+
+	public void refreshDisplay() {
+		// TODO Auto-generated method stub
+		
+	}
+
+	public void revealDisplay() {
+		// TODO Auto-generated method stub
+		
 	}
 	
 

Modified: labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListView.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListView.java?rev=794643&r1=794642&r2=794643&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListView.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListView.java Thu Jul 16
11:59:15 2009
@@ -25,11 +25,11 @@
 import java.util.List;
 
 import net.customware.gwt.dispatch.client.DispatchAsync;
+import net.customware.gwt.presenter.client.EventBus;
 
 import org.apache.hupa.client.HupaConstants;
 import org.apache.hupa.client.bundles.MyPagingOptionImages;
 import org.apache.hupa.client.mvp.IMAPMessageListPresenter.Display;
-import org.apache.hupa.client.rpc.EventBus;
 import org.apache.hupa.client.widgets.MyFixedWithGrid;
 import org.apache.hupa.client.widgets.PagingScrollToolTipTable;
 import org.apache.hupa.client.widgets.ToolTipProvider;
@@ -428,5 +428,19 @@
 	public org.apache.hupa.client.events.HasClickHandlers getDataTableClick() {
 		return dataTable;
 	}
+
+	public Widget asWidget() {
+		return this;
+	}
+
+	public void startProcessing() {
+		// TODO Auto-generated method stub
+		
+	}
+
+	public void stopProcessing() {
+		// TODO Auto-generated method stub
+		
+	}
 	
 }

Modified: labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessagePresenter.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessagePresenter.java?rev=794643&r1=794642&r2=794643&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessagePresenter.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessagePresenter.java Thu Jul 16
11:59:15 2009
@@ -20,19 +20,21 @@
 package org.apache.hupa.client.mvp;
 
 import net.customware.gwt.dispatch.client.DispatchAsync;
+import net.customware.gwt.presenter.client.EventBus;
+import net.customware.gwt.presenter.client.place.Place;
+import net.customware.gwt.presenter.client.place.PlaceRequest;
+import net.customware.gwt.presenter.client.widget.WidgetDisplay;
+import net.customware.gwt.presenter.client.widget.WidgetPresenter;
 
-import org.apache.hupa.client.rpc.EventBus;
 import org.apache.hupa.shared.data.IMAPMessage;
 
 import com.google.gwt.user.client.ui.HasHTML;
 import com.google.gwt.user.client.ui.HasText;
-import com.google.gwt.user.client.ui.HasWidgets;
-import com.google.gwt.user.client.ui.Widget;
 import com.google.inject.Inject;
 
-public class IMAPMessagePresenter {
+public class IMAPMessagePresenter extends WidgetPresenter<IMAPMessagePresenter.Display>{
 
-	public interface Display {
+	public interface Display extends WidgetDisplay{
 		public HasText getFrom();
 
 		public HasText getTo();
@@ -44,23 +46,17 @@
 		public HasHTML getContent();
 	}
 
-
+	public static final Place PLACE = new Place("IMAPMessage");
 	private IMAPMessage message;
-	private EventBus bus;
 	private DispatchAsync dispatcher;
 
 	@Inject
-	private IMAPMessagePresenter(DispatchAsync dispatcher, EventBus bus,IMAPMessagePresenter.Display
display) {
+	private IMAPMessagePresenter(IMAPMessagePresenter.Display display,EventBus bus, DispatchAsync
dispatcher) {
+		super(display,bus);
 		this.dispatcher = dispatcher;
-		this.bus = bus;
-		bind(display);
+		bind();
 	}
 
-	private Display display;
-
-	public void bind(Display display) {
-		this.display = display;
-	}
 	
 	public void bind(IMAPMessage message) {
 		this.message = message;
@@ -74,7 +70,32 @@
 		display.getContent().setHTML(message.getIMAPMessageContent().getText());
 	}
 
-	public void go(HasWidgets w) {
-		w.add((Widget) display);
+	@Override
+	public Place getPlace() {
+		return PLACE;
+	}
+
+	@Override
+	protected void onBind() {
+	}
+
+	@Override
+	protected void onPlaceRequest(PlaceRequest request) {
+		// TODO Auto-generated method stub
+		
+	}
+
+	@Override
+	protected void onUnbind() {
+		
+	}
+
+	public void refreshDisplay() {
+		updateDisplay();
+	}
+
+	public void revealDisplay() {
+		// TODO Auto-generated method stub
+		
 	}
 }

Modified: labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageView.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageView.java?rev=794643&r1=794642&r2=794643&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageView.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageView.java Thu Jul 16 11:59:15
2009
@@ -33,6 +33,7 @@
 import com.google.gwt.user.client.ui.Label;
 import com.google.gwt.user.client.ui.ScrollPanel;
 import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.Widget;
 
 public class IMAPMessageView extends Composite implements Display{
 	private Grid detailGrid = new Grid(4, 2);
@@ -123,4 +124,16 @@
 		return to;
 	}
 
+	public Widget asWidget() {
+		return this;
+	}
+
+	public void startProcessing() {
+		
+	}
+
+	public void stopProcessing() {
+		
+	}
+
 }

Modified: labs/hupa/src/main/java/org/apache/hupa/client/mvp/LoginPresenter.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/mvp/LoginPresenter.java?rev=794643&r1=794642&r2=794643&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/mvp/LoginPresenter.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/mvp/LoginPresenter.java Thu Jul 16 11:59:15
2009
@@ -20,9 +20,13 @@
 package org.apache.hupa.client.mvp;
 
 import net.customware.gwt.dispatch.client.DispatchAsync;
+import net.customware.gwt.presenter.client.EventBus;
+import net.customware.gwt.presenter.client.place.Place;
+import net.customware.gwt.presenter.client.place.PlaceRequest;
+import net.customware.gwt.presenter.client.widget.WidgetDisplay;
+import net.customware.gwt.presenter.client.widget.WidgetPresenter;
 
 import org.apache.hupa.client.HupaConstants;
-import org.apache.hupa.client.rpc.EventBus;
 import org.apache.hupa.shared.events.LoginEvent;
 import org.apache.hupa.shared.rpc.LoginUser;
 import org.apache.hupa.shared.rpc.LoginUserResult;
@@ -35,14 +39,12 @@
 import com.google.gwt.user.client.ui.Focusable;
 import com.google.gwt.user.client.ui.HasText;
 import com.google.gwt.user.client.ui.HasValue;
-import com.google.gwt.user.client.ui.HasWidgets;
-import com.google.gwt.user.client.ui.Widget;
 import com.google.inject.Inject;
 
-public class LoginPresenter {
+public class LoginPresenter extends WidgetPresenter<LoginPresenter.Display>{
     private HupaConstants constants = GWT.create(HupaConstants.class);
 
-	public interface Display {
+	public interface Display extends WidgetDisplay{
 		public HasClickHandlers getLoginClick();
 		public HasClickHandlers getResetClick();
 		public HasValue<String> getUserNameValue();
@@ -52,40 +54,15 @@
 	}
 	
 	private DispatchAsync dispatcher;
-	private LoginPresenter.Display display;
-	private EventBus bus;
-	
+	public static final Place PLACE = new Place("Login");
+
 	@Inject
-	public LoginPresenter(DispatchAsync dispatcher,EventBus bus,LoginPresenter.Display display)
{
+	public LoginPresenter(LoginPresenter.Display display,EventBus bus,DispatchAsync dispatcher)
{
+		super(display,bus);
 		this.dispatcher = dispatcher;
-		this.bus = bus;
-		this.display = display;
-		
-		bind(display);
+		bind();
 	}
-	
-	/**
-	 * Bind Display to this Presenter
-	 * 
-	 * @param display
-	 */
-	public void bind(Display display) {
-		this.display = display;
-		display.getLoginClick().addClickHandler(new ClickHandler() {
-
-			public void onClick(ClickEvent event) {
-				doLogin();
-			}
-			
-		});
-		display.getResetClick().addClickHandler(new ClickHandler() {
 
-			public void onClick(ClickEvent event) {
-				doReset();
-			}
-			
-		});
-	}
 	
 	/**
 	 * Try to login the user
@@ -99,7 +76,7 @@
 			}
 
 			public void onSuccess(LoginUserResult result) {
-				bus.fireEvent(new LoginEvent(result.getUser()));
+				eventBus.fireEvent(new LoginEvent(result.getUser()));
 				doReset();
 			}
 			
@@ -114,10 +91,53 @@
 		display.getPasswordValue().setValue("");
 		display.getErrorText().setText("");
 		display.getUserNameFocus().setFocus(true);
+	}
+
+	@Override
+	public Place getPlace() {
+		return PLACE;
+	}
+
+	@Override
+	protected void onBind() {
+		display.getLoginClick().addClickHandler(new ClickHandler() {
+
+			public void onClick(ClickEvent event) {
+				GWT.log("HERE", null);
+				doLogin();
+			}
+			
+		});
+		display.getResetClick().addClickHandler(new ClickHandler() {
+
+			public void onClick(ClickEvent event) {
+				GWT.log("RESET", null);
+
+				doReset();
+			}
+			
+		});
+	}
+
+	@Override
+	protected void onPlaceRequest(PlaceRequest request) {
+		// TODO Auto-generated method stub
+		
+	}
+
+	@Override
+	protected void onUnbind() {
+		// TODO Auto-generated method stub
+		
+	}
+
+	public void refreshDisplay() {
+		// TODO Auto-generated method stub
 		
 	}
 
-	public void go(HasWidgets container) {
-		container.add((Widget)display);
+	public void revealDisplay() {
+		// TODO Auto-generated method stub
+		
 	}
 }

Modified: labs/hupa/src/main/java/org/apache/hupa/client/mvp/LoginView.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/mvp/LoginView.java?rev=794643&r1=794642&r2=794643&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/mvp/LoginView.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/mvp/LoginView.java Thu Jul 16 11:59:15
2009
@@ -39,6 +39,7 @@
 import com.google.gwt.user.client.ui.PasswordTextBox;
 import com.google.gwt.user.client.ui.TextBox;
 import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.Widget;
 
 public class LoginView extends Composite implements KeyUpHandler,LoginPresenter.Display{
     
@@ -194,4 +195,25 @@
 	public Focusable getUserNameFocus() {
 		return usernameTextBox;
 	}
+
+
+	/*
+	 * (non-Javadoc)
+	 * @see net.customware.gwt.presenter.client.widget.WidgetDisplay#asWidget()
+	 */
+	public Widget asWidget() {
+		return this;
+	}
+
+
+	public void startProcessing() {
+		// TODO Auto-generated method stub
+		
+	}
+
+
+	public void stopProcessing() {
+		// TODO Auto-generated method stub
+		
+	}
 }

Modified: labs/hupa/src/main/java/org/apache/hupa/client/mvp/MainPresenter.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/mvp/MainPresenter.java?rev=794643&r1=794642&r2=794643&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/mvp/MainPresenter.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/mvp/MainPresenter.java Thu Jul 16 11:59:15
2009
@@ -25,8 +25,12 @@
 import java.util.List;
 
 import net.customware.gwt.dispatch.client.DispatchAsync;
+import net.customware.gwt.presenter.client.EventBus;
+import net.customware.gwt.presenter.client.place.Place;
+import net.customware.gwt.presenter.client.place.PlaceRequest;
+import net.customware.gwt.presenter.client.widget.WidgetDisplay;
+import net.customware.gwt.presenter.client.widget.WidgetPresenter;
 
-import org.apache.hupa.client.rpc.EventBus;
 import org.apache.hupa.client.widgets.IMAPTreeItem;
 import org.apache.hupa.shared.data.IMAPFolder;
 import org.apache.hupa.shared.data.IMAPMessage;
@@ -59,29 +63,26 @@
 import com.google.gwt.user.client.Window.ClosingHandler;
 import com.google.gwt.user.client.rpc.AsyncCallback;
 import com.google.gwt.user.client.ui.HasValue;
-import com.google.gwt.user.client.ui.HasWidgets;
 import com.google.gwt.user.client.ui.TreeItem;
 import com.google.gwt.user.client.ui.Widget;
 import com.google.gwt.user.client.ui.HTMLTable.Cell;
 import com.google.inject.Inject;
 
-public class MainPresenter {
+public class MainPresenter extends WidgetPresenter<MainPresenter.Display>{
 
 	
-	public interface Display {
+	public interface Display extends WidgetDisplay{
 		public HasClickHandlers getLogoutClick();
 		public HasSelectionHandlers<TreeItem> getTree();
 		//public HasRowSelectionHandlers getTableClick();
 		public void bindTreeItems(List<IMAPTreeItem> treeList);
 		public HasClickHandlers getSearchClick();
 		public HasValue<String> getSearchValue();
-		public HasWidgets getCenterContainer();
 		public void fillOracle(ArrayList<IMAPMessage> messages);
+		public void setCenter(Widget widget);
 	}
 	
 	private DispatchAsync dispatcher;
-	private EventBus bus;
-	private Display display;
 	private IMAPUser user;
 	private IMAPFolder folder;
 	
@@ -91,69 +92,15 @@
 	
 	
 	@Inject
-	public MainPresenter(DispatchAsync dispatcher, EventBus bus,MainPresenter.Display display,IMAPMessageListPresenter
messageListPresenter, IMAPMessagePresenter messagePresenter) {
-		this.bus = bus;
+	public MainPresenter(MainPresenter.Display display, EventBus bus, DispatchAsync dispatcher,IMAPMessageListPresenter
messageListPresenter, IMAPMessagePresenter messagePresenter) {
+		super(display,bus);
 		this.dispatcher = dispatcher;
 		this.messageListPresenter = messageListPresenter;
 		this.messagePresenter = messagePresenter;
-		this.display = display;
-		
-		bindHandler();
-		bind(display);
+		showMessageTable();
+		bind();
 	}
 	
-	private void bindHandler() {
-		bus.addHandler(LoginEvent.TYPE, new LoginEventHandler() {
-
-			public void onLogin(LoginEvent event) {
-				user = event.getUser();
-				loadTreeItems();
-			}
-			
-		});
-		bus.addHandler(LogoutEvent.TYPE, new LogoutEventHandler() {
-
-			public void onLogout(LogoutEvent logoutEvent) {
-				reset();
-			}
-			
-		});
-		
-		bus.addHandler(MessagesReceivedEvent.TYPE, new MessagesReceivedEventHandler() {
-
-			public void onMessagesReceived(MessagesReceivedEvent event) {
-				display.fillOracle(event.getMessages());
-			}
-			
-		});
-		
-		bus.addHandler(ExpandMessageEvent.TYPE, new ExpandMessageEventHandler() {
-
-			public void onExpandMessage(ExpandMessageEvent event) {
-				dispatcher.execute(new ExposeMessage(event.getUser(),event.getFolder(),event.getMessage()),
new AsyncCallback<ExposeMessageResult>() {
-
-					public void onFailure(Throwable caught) {
-						GWT.log("ERROR=", caught);
-					}
-
-					public void onSuccess(ExposeMessageResult result) {
-						showMessage(result.getMessage());
-					}
-					
-				});
-			}
-			
-		});
-		
-		Window.addWindowClosingHandler(new ClosingHandler() {
-
-			public void onWindowClosing(ClosingEvent event) {
-				doLogout();
-			}
-			
-		});
-		
-	}
 	
 	protected void loadTreeItems() {
 		dispatcher.execute(new FetchFolders(user), new AsyncCallback<FetchFoldersResult>()
{
@@ -206,8 +153,97 @@
 		});
 		return tList;
 	}
-	public void bind(final Display display) {
-		this.display = display;
+
+	private void doLogout() {
+		if (user != null) {
+			dispatcher.execute(new LogoutUser(user), new AsyncCallback<LogoutUserResult>() {
+
+				public void onFailure(Throwable caught) {
+					GWT.log("ERROR",caught);
+				}
+
+				public void onSuccess(LogoutUserResult result) {
+					eventBus.fireEvent(new LogoutEvent(result.getUser()));
+				}
+			
+			});
+		}
+	}
+
+	private void showMessageTable() {
+		display.setCenter(messageListPresenter.getDisplay().asWidget());
+	}
+	
+	private void showMessage(IMAPMessage message) {
+		messagePresenter.bind(message);
+		display.setCenter(messagePresenter.getDisplay().asWidget());
+	}
+	
+	
+	private void reset() {
+		display.getSearchValue().setValue("");
+		display.bindTreeItems(new ArrayList<IMAPTreeItem>());
+	}
+	
+
+	@Override
+	public Place getPlace() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	protected void onBind() {
+		eventBus.addHandler(LoginEvent.TYPE, new LoginEventHandler() {
+
+			public void onLogin(LoginEvent event) {
+				user = event.getUser();
+				loadTreeItems();
+			}
+			
+		});
+		eventBus.addHandler(LogoutEvent.TYPE, new LogoutEventHandler() {
+
+			public void onLogout(LogoutEvent logoutEvent) {
+				reset();
+			}
+			
+		});
+		
+		eventBus.addHandler(MessagesReceivedEvent.TYPE, new MessagesReceivedEventHandler() {
+
+			public void onMessagesReceived(MessagesReceivedEvent event) {
+				display.fillOracle(event.getMessages());
+			}
+			
+		});
+		
+		eventBus.addHandler(ExpandMessageEvent.TYPE, new ExpandMessageEventHandler() {
+
+			public void onExpandMessage(ExpandMessageEvent event) {
+				dispatcher.execute(new ExposeMessage(event.getUser(),event.getFolder(),event.getMessage()),
new AsyncCallback<ExposeMessageResult>() {
+
+					public void onFailure(Throwable caught) {
+						GWT.log("ERROR=", caught);
+					}
+
+					public void onSuccess(ExposeMessageResult result) {
+						showMessage(result.getMessage());
+					}
+					
+				});
+			}
+			
+		});
+		
+		Window.addWindowClosingHandler(new ClosingHandler() {
+
+			public void onWindowClosing(ClosingEvent event) {
+				doLogout();
+			}
+			
+		});
+		
 		reset();
 		display.getLogoutClick().addClickHandler(new ClickHandler() {
 
@@ -223,7 +259,7 @@
 				TreeItem item = event.getSelectedItem();
 				folder = (IMAPFolder) item.getUserObject();
 				showMessageTable();
-				bus.fireEvent(new LoadMessagesEvent(user,folder));
+				eventBus.fireEvent(new LoadMessagesEvent(user,folder));
 			}
 			
 		});
@@ -235,48 +271,31 @@
 				if (display.getSearchValue().getValue().trim().length() >0) {
 					searchValue = display.getSearchValue().getValue().trim();
 				}
-				bus.fireEvent(new LoadMessagesEvent(user,folder,searchValue));
+				eventBus.fireEvent(new LoadMessagesEvent(user,folder,searchValue));
 			}
 			
 		});
-			
 	}
 
-	private void doLogout() {
-		if (user != null) {
-			dispatcher.execute(new LogoutUser(user), new AsyncCallback<LogoutUserResult>() {
-
-				public void onFailure(Throwable caught) {
-					GWT.log("ERROR",caught);
-				}
-
-				public void onSuccess(LogoutUserResult result) {
-					bus.fireEvent(new LogoutEvent(result.getUser()));
-				}
-			
-			});
-		}
+	@Override
+	protected void onPlaceRequest(PlaceRequest request) {
+		// TODO Auto-generated method stub
+		
 	}
 
-	private void showMessageTable() {
-		display.getCenterContainer().clear();
-		messageListPresenter.go(display.getCenterContainer());
-	}
-	
-	private void showMessage(IMAPMessage message) {
-		display.getCenterContainer().clear();
-		messagePresenter.bind(message);
-		messagePresenter.go(display.getCenterContainer());
+	@Override
+	protected void onUnbind() {
+		// TODO Auto-generated method stub
+		
 	}
-	
-	
-	private void reset() {
-		display.getSearchValue().setValue("");
-		display.bindTreeItems(new ArrayList<IMAPTreeItem>());
+
+	public void refreshDisplay() {
+		// TODO Auto-generated method stub
+		
 	}
-	
-	public void go(HasWidgets w) {
-		w.add((Widget)display);
-		showMessageTable();
+
+	public void revealDisplay() {
+		// TODO Auto-generated method stub
+		
 	}
 }

Modified: labs/hupa/src/main/java/org/apache/hupa/client/mvp/MainView.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/mvp/MainView.java?rev=794643&r1=794642&r2=794643&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/mvp/MainView.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/mvp/MainView.java Thu Jul 16 11:59:15 2009
@@ -39,7 +39,6 @@
 import com.google.gwt.user.client.ui.Composite;
 import com.google.gwt.user.client.ui.DockPanel;
 import com.google.gwt.user.client.ui.HasValue;
-import com.google.gwt.user.client.ui.HasWidgets;
 import com.google.gwt.user.client.ui.HorizontalPanel;
 import com.google.gwt.user.client.ui.Label;
 import com.google.gwt.user.client.ui.MultiWordSuggestOracle;
@@ -47,6 +46,7 @@
 import com.google.gwt.user.client.ui.Tree;
 import com.google.gwt.user.client.ui.TreeItem;
 import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.Widget;
 import com.google.inject.Inject;
 
 public class MainView extends Composite implements MainPresenter.Display{
@@ -183,7 +183,22 @@
 		searchBox.setText("");
 	}
 
-	public HasWidgets getCenterContainer() {
-		return center;
+	public void setCenter(Widget widget) {
+		center.clear();
+		center.setWidget(widget);
+	}
+
+	public Widget asWidget() {
+		return this;
+	}
+
+	public void startProcessing() {
+		// TODO Auto-generated method stub
+		
+	}
+
+	public void stopProcessing() {
+		// TODO Auto-generated method stub
+		
 	}
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org


Mime
View raw message