james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r834622 - in /james/hupa/trunk/client/src/main/java/org/apache/hupa/client: HandlerRegistrationAdapter.java mvp/IMAPMessageListPresenter.java mvp/IMAPMessageListView.java mvp/place/IMAPMessageListPresenterPlace.java
Date Tue, 10 Nov 2009 19:28:50 GMT
Author: norman
Date: Tue Nov 10 19:28:50 2009
New Revision: 834622

URL: http://svn.apache.org/viewvc?rev=834622&view=rev
Log:
Rows per page now work with history.. w0h00

Modified:
    james/hupa/trunk/client/src/main/java/org/apache/hupa/client/HandlerRegistrationAdapter.java
    james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListPresenter.java
    james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListView.java
    james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/place/IMAPMessageListPresenterPlace.java

Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/HandlerRegistrationAdapter.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/HandlerRegistrationAdapter.java?rev=834622&r1=834621&r2=834622&view=diff
==============================================================================
--- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/HandlerRegistrationAdapter.java
(original)
+++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/HandlerRegistrationAdapter.java
Tue Nov 10 19:28:50 2009
@@ -22,7 +22,11 @@
 import com.google.gwt.event.shared.HandlerRegistration;
 
 
-
+/**
+ * Class to act as Adapter between HandlerRegistration in gwt 1.6+ and gwt-incubator
+ *
+ */
+@SuppressWarnings("deprecation")
 public class HandlerRegistrationAdapter implements HandlerRegistration{
     com.google.gwt.gen2.event.shared.HandlerRegistration registration;
 
@@ -31,6 +35,10 @@
     }
 
 
+    /*
+     * (non-Javadoc)
+     * @see com.google.gwt.event.shared.HandlerRegistration#removeHandler()
+     */
     public void removeHandler() {
         registration.removeHandler();
     }

Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListPresenter.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListPresenter.java?rev=834622&r1=834621&r2=834622&view=diff
==============================================================================
--- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListPresenter.java
(original)
+++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListPresenter.java
Tue Nov 10 19:28:50 2009
@@ -50,11 +50,12 @@
 import org.apache.hupa.shared.rpc.SetFlag;
 import org.apache.hupa.widgets.ui.HasEnable;
 
-import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.ChangeEvent;
+import com.google.gwt.event.dom.client.ChangeHandler;
 import com.google.gwt.event.dom.client.ClickEvent;
 import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.event.dom.client.HasChangeHandlers;
 import com.google.gwt.event.dom.client.HasClickHandlers;
-import com.google.gwt.gen2.event.shared.HandlerRegistration;
 import com.google.gwt.gen2.table.event.client.HasPageChangeHandlers;
 import com.google.gwt.gen2.table.event.client.HasPageLoadHandlers;
 import com.google.gwt.gen2.table.event.client.HasRowSelectionHandlers;
@@ -103,9 +104,11 @@
         public HasPageChangeHandlers getDataTablePageChange();
         public void goToPage(int page);
         public int getCurrentPage();
+        public int getRowsPerPageIndex();
+        public void setRowsPerPageIndex(int index);
+        public HasChangeHandlers getRowsPerPageChange();
     }
 
-    private ArrayList<HandlerRegistration> regList = new ArrayList<HandlerRegistration>();
     private User user;
     private IMAPFolder folder;
     private DispatchAsync dispatcher;
@@ -267,7 +270,7 @@
             }
             
         }));
-        regList.add(display.getDataTableSelection().addRowSelectionHandler(new RowSelectionHandler()
{
+        registerHandler(new HandlerRegistrationAdapter(display.getDataTableSelection().addRowSelectionHandler(new
RowSelectionHandler() {
                 public void onRowSelection(RowSelectionEvent event) {
                     if (event.getSelectedRows().size() == 0) {
                         display.getDeleteEnable().setEnabled(false);
@@ -282,7 +285,7 @@
                 
             
             
-        }));
+        })));
         
         registerHandler(display.getRefreshClick().addClickHandler(new ClickHandler() {
 
@@ -299,6 +302,13 @@
             }
             
         })));
+        registerHandler(display.getRowsPerPageChange().addChangeHandler(new ChangeHandler()
{
+
+            public void onChange(ChangeEvent event) {
+                firePresenterRevealedEvent(true);
+            }
+            
+        }));
         display.addTableListener(tableListener);
     }
 
@@ -326,9 +336,6 @@
      */
     protected void onUnbind() {
         display.removeTableListener(tableListener);
-        for (int i = 0; i < regList.size(); i++) {
-            regList.get(i).removeHandler();
-        }
     }
 
     

Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListView.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListView.java?rev=834622&r1=834621&r2=834622&view=diff
==============================================================================
--- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListView.java
(original)
+++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListView.java
Tue Nov 10 19:28:50 2009
@@ -43,6 +43,7 @@
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.event.dom.client.ChangeEvent;
 import com.google.gwt.event.dom.client.ChangeHandler;
+import com.google.gwt.event.dom.client.HasChangeHandlers;
 import com.google.gwt.event.dom.client.HasClickHandlers;
 import com.google.gwt.event.logical.shared.ResizeEvent;
 import com.google.gwt.event.logical.shared.ResizeHandler;
@@ -670,19 +671,63 @@
         return markUnSeenButton;
     }
 
+    /*
+     * (non-Javadoc)
+     * @see org.apache.hupa.client.mvp.IMAPMessageListPresenter.Display#getRefreshClick()
+     */
     public HasClickHandlers getRefreshClick() {
         return refreshLink;
     }
 
+    /*
+     * (non-Javadoc)
+     * @see org.apache.hupa.client.mvp.IMAPMessageListPresenter.Display#goToPage(int)
+     */
     public void goToPage(int page) {
         mailTable.gotoPage(page, false);
     }
     
+    /*
+     * (non-Javadoc)
+     * @see org.apache.hupa.client.mvp.IMAPMessageListPresenter.Display#getCurrentPage()
+     */
     public int getCurrentPage() {
         return mailTable.getCurrentPage();
     }
 
+    /*
+     * (non-Javadoc)
+     * @see org.apache.hupa.client.mvp.IMAPMessageListPresenter.Display#getDataTablePageChange()
+     */
     public HasPageChangeHandlers getDataTablePageChange() {
         return mailTable;
     }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.apache.hupa.client.mvp.IMAPMessageListPresenter.Display#getRowsPerPageIndex()
+     */
+    public int getRowsPerPageIndex() {
+        return pageBox.getSelectedIndex();
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.apache.hupa.client.mvp.IMAPMessageListPresenter.Display#setRowsPerPageIndex(int)
+     */
+    public void setRowsPerPageIndex(int index) {
+        if (pageBox.getItemCount() < index) {
+            index = 0;
+        }             
+        pageBox.setSelectedIndex(index);
+        mailTable.setPageSize(Integer.parseInt(pageBox.getItemText(index)));
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.hupa.client.mvp.IMAPMessageListPresenter.Display#getRowsPerPageChange()
+     */
+    public HasChangeHandlers getRowsPerPageChange() {
+        return pageBox;
+    }
 }

Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/place/IMAPMessageListPresenterPlace.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/place/IMAPMessageListPresenterPlace.java?rev=834622&r1=834621&r2=834622&view=diff
==============================================================================
--- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/place/IMAPMessageListPresenterPlace.java
(original)
+++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/place/IMAPMessageListPresenterPlace.java
Tue Nov 10 19:28:50 2009
@@ -29,6 +29,8 @@
 
 public class IMAPMessageListPresenterPlace extends ProvidedPresenterPlace<IMAPMessageListPresenter>{
 
+    private final static String ROWS_PER_PAGE_INDEX = "rowsPerPageIndex";
+    private final static String PAGE = "page";
     @Inject
     public IMAPMessageListPresenterPlace(Provider<IMAPMessageListPresenter> presenter)
{
         super(presenter);
@@ -43,19 +45,28 @@
     protected void preparePresenter(PlaceRequest request, IMAPMessageListPresenter presenter)
{
         int page = 0;
         try {
-            page = Integer.parseInt(request.getParameter("page", "0"));
+            page = Integer.parseInt(request.getParameter(PAGE, "0"));
         } catch (NumberFormatException e) {
-            e.printStackTrace();
             // ignore
         }
         presenter.getDisplay().goToPage(page);
+        
+        int rowsPerPageIndex = 0;
+        try {
+            rowsPerPageIndex = Integer.parseInt(request.getParameter(ROWS_PER_PAGE_INDEX,
"0"));
+        } catch (NumberFormatException e) {
+            // ignore
+        }
+        presenter.getDisplay().setRowsPerPageIndex(rowsPerPageIndex);
+
         GWT.log("PRES="+request.toString(),null);
 
     }
 
     @Override
     protected PlaceRequest prepareRequest(PlaceRequest request, IMAPMessageListPresenter
presenter) {
-        request = request.with("page", presenter.getDisplay().getCurrentPage() +"");
+        request = request.with(PAGE, presenter.getDisplay().getCurrentPage() +"");
+        request = request.with(ROWS_PER_PAGE_INDEX, presenter.getDisplay().getRowsPerPageIndex()
+ "");
         GWT.log("REQ="+request.toString(),null);
 
         return request;



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message