labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r794819 - in /labs/hupa/src/main/java/org/apache/hupa/client/mvp: IMAPMessageListPresenter.java IMAPMessageListView.java
Date Thu, 16 Jul 2009 20:03:52 GMT
Author: norman
Date: Thu Jul 16 20:03:51 2009
New Revision: 794819

URL: http://svn.apache.org/viewvc?rev=794819&view=rev
Log:
Start to implements deletion of messages

Modified:
    labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListPresenter.java
    labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListView.java

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=794819&r1=794818&r2=794819&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 20:03:51 2009
@@ -19,6 +19,9 @@
 
 package org.apache.hupa.client.mvp;
 
+import java.util.ArrayList;
+
+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;
@@ -36,9 +39,12 @@
 import org.apache.hupa.shared.events.LoadMessagesEventHandler;
 import org.apache.hupa.shared.events.LoginEvent;
 import org.apache.hupa.shared.events.LoginEventHandler;
+import org.apache.hupa.shared.rpc.DeleteMessage;
+import org.apache.hupa.shared.rpc.DeleteMessageResult;
 
 import com.google.gwt.gen2.table.event.client.HasPageLoadHandlers;
 import com.google.gwt.gen2.table.event.client.HasRowSelectionHandlers;
+import com.google.gwt.user.client.rpc.AsyncCallback;
 import com.google.inject.Inject;
 
 public class IMAPMessageListPresenter extends WidgetPresenter<IMAPMessageListPresenter.Display>{
@@ -47,16 +53,20 @@
 		public HasRowSelectionHandlers getDataTableSelection();
 		public HasPageLoadHandlers getDataTableLoad();
 		public HasClickHandlers getDataTableClick();
+		public ArrayList<Integer> getSelectedMessagesUids();
+		public com.google.gwt.event.dom.client.HasClickHandlers getDeleteClick();
 		public void reloadData(IMAPUser user, IMAPFolder folder,String searchValue);
 	}
 
 	protected IMAPUser user;
 	protected IMAPFolder folder;
 	protected String searchValue;
+	private DispatchAsync dispatcher;
 	
 	@Inject
-	public IMAPMessageListPresenter(IMAPMessageListPresenter.Display display,EventBus bus) {
+	public IMAPMessageListPresenter(IMAPMessageListPresenter.Display display,EventBus bus,DispatchAsync
dispatcher) {
 		super(display,bus);
+		this.dispatcher = dispatcher;
 		bind();
 	}
 	
@@ -98,6 +108,25 @@
 			}
 			
 		});
+		display.getDeleteClick().addClickHandler(new com.google.gwt.event.dom.client.ClickHandler()
{
+
+			public void onClick(com.google.gwt.event.dom.client.ClickEvent event) {
+				dispatcher.execute(new DeleteMessage(user,folder,display.getSelectedMessagesUids()),
new AsyncCallback<DeleteMessageResult>() {
+
+					public void onFailure(Throwable caught) {
+						// TODO Auto-generated method stub
+						
+					}
+
+					public void onSuccess(DeleteMessageResult result) {
+						// TODO Auto-generated method stub
+						
+					}
+					
+				});
+			}
+			
+		});
 	}
 
 	@Override

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=794819&r1=794818&r2=794819&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
20:03:51 2009
@@ -45,6 +45,7 @@
 import org.cobogw.gwt.user.client.ui.Rating;
 
 import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.HasClickHandlers;
 import com.google.gwt.event.logical.shared.ResizeEvent;
 import com.google.gwt.event.logical.shared.ResizeHandler;
 import com.google.gwt.gen2.table.client.AbstractColumnDefinition;
@@ -70,6 +71,7 @@
 import com.google.gwt.gen2.table.event.client.PageLoadHandler;
 import com.google.gwt.gen2.table.event.client.RowSelectionEvent;
 import com.google.gwt.gen2.table.event.client.RowSelectionHandler;
+import com.google.gwt.gen2.table.event.client.TableEvent.Row;
 import com.google.gwt.i18n.client.DateTimeFormat;
 import com.google.gwt.user.client.Window;
 import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -92,6 +94,9 @@
 	private PagingScrollToolTipTable<IMAPMessage> mailTable;
 	private EventBus bus;
 	private MyFixedWidthGrid<IMAPMessage> dataTable = createDataTable();
+	private ArrayList<Integer> selectedUids = new ArrayList<Integer>();
+	private Button deleteMailButton = new Button(constants.deleteMailButton());
+
 	
 	@Inject
 	public IMAPMessageListView(DispatchAsync dispatcher,EventBus bus) {
@@ -183,7 +188,6 @@
 		ButtonBar navigatorBar = new ButtonBar();
 		Button newMailButton = new Button(constants.newMailButton());
 		navigatorBar.add(newMailButton);
-		final Button deleteMailButton = new Button(constants.deleteMailButton());
 		deleteMailButton.setEnabled(false);
 		navigatorBar.add(deleteMailButton);
 		
@@ -196,6 +200,13 @@
 				} else {
 					deleteMailButton.setEnabled(true);
 				}
+				selectedUids.clear();
+				Iterator<Row> rowIt = event.getSelectedRows().iterator();
+				while(rowIt.hasNext()) {
+					int uid = mailTable.getRowValue(rowIt.next().getRowIndex()).getUid();
+					selectedUids.add(uid);
+				}
+				
 			}
 			
 		});
@@ -442,5 +453,13 @@
 		// TODO Auto-generated method stub
 		
 	}
+
+	public ArrayList<Integer> getSelectedMessagesUids() {
+		return selectedUids;
+	}
+
+	public HasClickHandlers getDeleteClick() {
+		return deleteMailButton;
+	}
 	
 }



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


Mime
View raw message