Author: norman
Date: Sun Jul  5 16:20:22 2009
New Revision: 791266

URL: http://svn.apache.org/viewvc?rev=791266&view=rev
Log:
Support changing of Emails/Page value

Added:
    
labs/hupa/src/main/java/org/apache/hupa/client/widgets/NumberOnlyTextBox.java
Modified:
    labs/hupa/src/main/java/org/apache/hupa/client/HupaConstants.java
    labs/hupa/src/main/java/org/apache/hupa/client/HupaConstants.properties
    labs/hupa/src/main/java/org/apache/hupa/client/view/MainView.java

Modified: labs/hupa/src/main/java/org/apache/hupa/client/HupaConstants.java
URL: 
http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/HupaConstants.java?rev=791266&r1=791265&r2=791266&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/HupaConstants.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/HupaConstants.java Sun Jul  
5 16:20:22 2009
@@ -62,4 +62,6 @@
        public String loginInvalid();
 
        public String searchButton();
+
+       public String rowsPerPageLabel();
 }

Modified: 
labs/hupa/src/main/java/org/apache/hupa/client/HupaConstants.properties
URL: 
http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/HupaConstants.properties?rev=791266&r1=791265&r2=791266&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/HupaConstants.properties 
(original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/HupaConstants.properties Sun 
Jul  5 16:20:22 2009
@@ -19,4 +19,5 @@
 mailTableDate=Date
 loading=Loading....
 loginInvalid=Unable to login, please check username and password
-searchButton=Search in message
\ No newline at end of file
+searchButton=Search in message
+rowsPerPageLabel=Emails per Page
\ No newline at end of file

Modified: labs/hupa/src/main/java/org/apache/hupa/client/view/MainView.java
URL: 
http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/view/MainView.java?rev=791266&r1=791265&r2=791266&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/view/MainView.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/view/MainView.java Sun Jul  
5 16:20:22 2009
@@ -46,6 +46,7 @@
 import org.apache.hupa.client.model.ModelReturnData;
 import org.apache.hupa.client.widgets.IMAPMessageWidget;
 import org.apache.hupa.client.widgets.IMAPTreeItem;
+import org.apache.hupa.client.widgets.NumberOnlyTextBox;
 import org.cobogw.gwt.user.client.ui.Button;
 import org.cobogw.gwt.user.client.ui.ButtonBar;
 import org.cobogw.gwt.user.client.ui.RoundedPanel;
@@ -66,7 +67,6 @@
 import com.google.gwt.user.client.ui.HorizontalPanel;
 import com.google.gwt.user.client.ui.Label;
 import com.google.gwt.user.client.ui.MultiWordSuggestOracle;
-import com.google.gwt.user.client.ui.SimplePanel;
 import com.google.gwt.user.client.ui.SuggestBox;
 import com.google.gwt.user.client.ui.Tree;
 import com.google.gwt.user.client.ui.TreeItem;
@@ -99,6 +99,8 @@
        private MultiWordSuggestOracle oracle = new MultiWordSuggestOracle(" 
,@");  
        private SuggestBox searchBox = new SuggestBox(oracle);
        private Button searchButton = new Button(constants.searchButton());
+       private NumberOnlyTextBox rowsPerPageBox = new NumberOnlyTextBox();
+       
        private Cell cell;
        private IMAPUser user;
 
@@ -119,7 +121,7 @@
                                TreeItem item = event.getSelectedItem();
                                
                                folder = (IMAPFolder) item.getUserObject();
-                               controller.call(new Event<MessageListModelData, 
HupaAction>(HupaAction.FETCH_MESSAGES, new 
MessageListModelData(user,folder,0,20), masker));
+                               controller.call(new Event<MessageListModelData, 
HupaAction>(HupaAction.FETCH_MESSAGES, new 
MessageListModelData(user,folder,0,rowsPerPage), masker));
                        }
 
                });
@@ -131,6 +133,7 @@
 
                HorizontalPanel navPanel = new HorizontalPanel();
                navPanel.setSpacing(10);
+               navPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
                ButtonBar navigatorBar = new ButtonBar();
                Button newMailButton = new Button(constants.newMailButton());
                navigatorBar.add(newMailButton);
@@ -138,7 +141,21 @@
                navigatorBar.add(deleteMailButton);
 
                navPanel.add(navigatorBar);
+               
+               rowsPerPageBox.setWidth("40px");
+               rowsPerPageBox.setValue("20");
+               rowsPerPageBox.addKeyUpHandler(new KeyUpHandler() {
 
+                       public void onKeyUp(KeyUpEvent event) {
+                               if (event.getNativeKeyCode() == 
KeyCodes.KEY_ENTER) {
+                                       rowsPerPage = 
Integer.parseInt(rowsPerPageBox.getValue());
+                                       controller.call(new 
Event<MessageListModelData, HupaAction>(HupaAction.FETCH_MESSAGES, new 
MessageListModelData(user,folder,0,rowsPerPage), masker));
+                               }
+                       }
+                       
+               });
+               navPanel.add(rowsPerPageBox);
+               navPanel.add(new Label(constants.rowsPerPageLabel()));
                centerVP.add(navPanel);
                
                final CheckBox headerCheckbox = new CheckBox();
@@ -254,8 +271,8 @@
                                controller.call(new Event<MessageListModelData, 
HupaAction>(
                                                HupaAction.FETCH_MESSAGES,
                                                new MessageListModelData(user, 
folder,
-                                                               0, 
20,searchValue), masker));
-                               searchBox.setValue("");
+                                                               0, 
rowsPerPage,searchValue), masker));
+                               //searchBox.setValue("");
                        }
                        
                });

Added: 
labs/hupa/src/main/java/org/apache/hupa/client/widgets/NumberOnlyTextBox.java
URL: 
http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/widgets/NumberOnlyTextBox.java?rev=791266&view=auto
==============================================================================
--- 
labs/hupa/src/main/java/org/apache/hupa/client/widgets/NumberOnlyTextBox.java 
(added)
+++ 
labs/hupa/src/main/java/org/apache/hupa/client/widgets/NumberOnlyTextBox.java 
Sun Jul  5 16:20:22 2009
@@ -0,0 +1,39 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.hupa.client.widgets;
+
+import com.google.gwt.event.dom.client.KeyPressEvent;
+import com.google.gwt.event.dom.client.KeyPressHandler;
+import com.google.gwt.user.client.ui.TextBox;
+
+public class NumberOnlyTextBox extends TextBox implements KeyPressHandler{
+       
+       public NumberOnlyTextBox() {
+               addKeyPressHandler(this);
+       }
+
+       public void onKeyPress(KeyPressEvent event) {
+               char keyCode = event.getCharCode();
+           if (!Character.isDigit(keyCode)) {
+            cancelKey();
+        } 
+       }
+       
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to