labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r791130 - in /labs/hupa/src/main/java/org/apache/hupa: client/ client/model/ client/services/ client/view/ server/
Date Sat, 04 Jul 2009 14:09:46 GMT
Author: norman
Date: Sat Jul  4 14:09:45 2009
New Revision: 791130

URL: http://svn.apache.org/viewvc?rev=791130&view=rev
Log:
First version of supporting search operations

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/model/MessageListModel.java
    labs/hupa/src/main/java/org/apache/hupa/client/model/MessageListModelData.java
    labs/hupa/src/main/java/org/apache/hupa/client/services/IMAPService.java
    labs/hupa/src/main/java/org/apache/hupa/client/services/IMAPServiceAsync.java
    labs/hupa/src/main/java/org/apache/hupa/client/view/MainView.java
    labs/hupa/src/main/java/org/apache/hupa/server/IMAPServiceImpl.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=791130&r1=791129&r2=791130&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 Sat Jul  4 14:09:45
2009
@@ -60,4 +60,6 @@
 	
 	public String loading();
 	public String loginInvalid();
+
+	public String searchButton();
 }

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=791130&r1=791129&r2=791130&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 Sat Jul  4 14:09:45
2009
@@ -18,4 +18,5 @@
 mailTableSubject=Subject
 mailTableDate=Date
 loading=Loading....
-loginInvalid=Unable to login, please check username and password
\ No newline at end of file
+loginInvalid=Unable to login, please check username and password
+searchButton=Search in message
\ No newline at end of file

Modified: labs/hupa/src/main/java/org/apache/hupa/client/model/MessageListModel.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/model/MessageListModel.java?rev=791130&r1=791129&r2=791130&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/model/MessageListModel.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/model/MessageListModel.java Sat Jul  4
14:09:45 2009
@@ -42,7 +42,7 @@
 	public void fetchMessages(final Event<MessageListModelData,HupaAction> event) {
 	    MessageListModelData data = event.getValue();
 	    
-		service.getMessages(data.getUser(),data.getFolder(),data.getStart(),data.getEnd(),
+		service.getMessages(data.getUser(),data.getFolder(),data.getStart(),data.getEnd(),data.getSearchString(),
 				new AsyncCallback<ResultList<IMAPMessage>>() {
 
 					public void onFailure(Throwable caught) {

Modified: labs/hupa/src/main/java/org/apache/hupa/client/model/MessageListModelData.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/model/MessageListModelData.java?rev=791130&r1=791129&r2=791130&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/model/MessageListModelData.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/model/MessageListModelData.java Sat Jul
 4 14:09:45 2009
@@ -28,12 +28,18 @@
     private IMAPFolder folder;
     private int start;
     private int end;
+	private String searchString;
 
     public MessageListModelData(IMAPUser user,IMAPFolder folder, int start, int end) {
+    	this(user,folder,start,end,null);
+    }
+    
+    public MessageListModelData(IMAPUser user,IMAPFolder folder, int start, int end,String
searchString) {
         this.user = user;
         this.folder = folder;
         this.start =start;
         this.end = end;
+        this.searchString = searchString;
     }
     
     public IMAPUser getUser () {
@@ -52,4 +58,7 @@
         return end;
     }
 
+    public String getSearchString() {
+    	return searchString;
+    }
 }

Modified: labs/hupa/src/main/java/org/apache/hupa/client/services/IMAPService.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/services/IMAPService.java?rev=791130&r1=791129&r2=791130&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/services/IMAPService.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/services/IMAPService.java Sat Jul  4 14:09:45
2009
@@ -38,7 +38,7 @@
 	public List<IMAPFolder> getFolders(IMAPUser user)
 			throws IMAPServiceException;
 
-	public ResultList<IMAPMessage> getMessages(IMAPUser user,IMAPFolder folder, int start,
int end) throws IMAPServiceException;
+	public ResultList<IMAPMessage> getMessages(IMAPUser user,IMAPFolder folder, int start,
int end, String searchString) throws IMAPServiceException;
 
 	public IMAPMessage exposeMessage(IMAPUser user,IMAPFolder folder,IMAPMessage message) throws
IMAPServiceException;
 

Modified: labs/hupa/src/main/java/org/apache/hupa/client/services/IMAPServiceAsync.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/services/IMAPServiceAsync.java?rev=791130&r1=791129&r2=791130&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/services/IMAPServiceAsync.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/services/IMAPServiceAsync.java Sat Jul
 4 14:09:45 2009
@@ -37,7 +37,7 @@
 			AsyncCallback<List<IMAPFolder>> callback);
 
 	public void getMessages(IMAPUser user, IMAPFolder folder, int start,
-			int end, AsyncCallback<ResultList<IMAPMessage>> callback);
+			int end,String searchString, AsyncCallback<ResultList<IMAPMessage>> callback);
 
 	public void exposeMessage(IMAPUser user, IMAPFolder folder, IMAPMessage message, AsyncCallback<IMAPMessage>
callback);
 

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=791130&r1=791129&r2=791130&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 Sat Jul  4 14:09:45
2009
@@ -36,13 +36,13 @@
 import org.apache.hupa.client.data.ResultList;
 import org.apache.hupa.client.data.IMAPMessage.IMAPFlag;
 import org.apache.hupa.client.model.FolderModel;
+import org.apache.hupa.client.model.LoginModel;
 import org.apache.hupa.client.model.LogoutModel;
 import org.apache.hupa.client.model.LogoutModelData;
 import org.apache.hupa.client.model.MessageListModel;
 import org.apache.hupa.client.model.MessageListModelData;
 import org.apache.hupa.client.model.MessageModel;
 import org.apache.hupa.client.model.MessageModelData;
-import org.apache.hupa.client.model.LoginModel;
 import org.apache.hupa.client.model.ModelReturnData;
 import org.apache.hupa.client.widgets.IMAPMessageWidget;
 import org.cobogw.gwt.user.client.ui.Button;
@@ -61,6 +61,8 @@
 import com.google.gwt.user.client.ui.FlexTable;
 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.SuggestBox;
 import com.google.gwt.user.client.ui.Tree;
 import com.google.gwt.user.client.ui.TreeItem;
 import com.google.gwt.user.client.ui.VerticalPanel;
@@ -76,7 +78,7 @@
 	private Tree folderTree = new Tree(tImages, true);
 	private HupaConstants constants = GWT.create(HupaConstants.class);
 	private RoundedPanel west;
-	private HorizontalPanel north;
+	private VerticalPanel north;
 	private RoundedPanel center;
 	private DateTimeFormat dFormat = DateTimeFormat.getShortDateTimeFormat();
 	
@@ -89,6 +91,8 @@
 	private IMAPMessageWidget msgWidget = new IMAPMessageWidget();
 	private VerticalPanel centerVP = new VerticalPanel();
 	private Maskable masker = new LoadingMasker();
+	private MultiWordSuggestOracle oracle = new MultiWordSuggestOracle(" ,@");  
+	private SuggestBox searchBox = new SuggestBox(oracle);
 	private Cell cell;
 	private IMAPUser user;
 
@@ -175,18 +179,8 @@
 			public void onClick(ClickEvent event) {
 
 				cell = mailTable.getCellForEvent(event);
-				if (cell.getRowIndex() > 0) {
-				
-					if (cell.getCellIndex() == 0) {
-
-						/*
-						mailTable.getRowFormatter().setStyleName(
-								cell.getRowIndex(),
-								"hupa-Mailtable-row-selected");
-						*/
-					} else {
-						controller.call(new Event<MessageModelData, HupaAction>(HupaAction.EXPOSE_MESSAGE,new
MessageModelData(user,folder,getSelectedMessage()),masker));
-					}
+				if (cell.getRowIndex() > 0 && cell.getCellIndex() != 0) {
+					controller.call(new Event<MessageModelData, HupaAction>(HupaAction.EXPOSE_MESSAGE,new
MessageModelData(user,folder,getSelectedMessage()),masker));
 				}
 
 			}
@@ -199,13 +193,15 @@
 	}
 
 	private void createNorth() {
-		north = new HorizontalPanel();
-		north.setSpacing(5);
-		north.setStyleName("hupa-Northpanel");
-		north.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT);
-
+		north = new VerticalPanel();
 		north.setWidth("100%");
-		north.add(new Label(constants.productName()));
+		HorizontalPanel northTop = new HorizontalPanel();
+		northTop.setSpacing(5);
+		northTop.setStyleName("hupa-Northpanel");
+		northTop.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT);
+
+		northTop.setWidth("100%");
+		northTop.add(new Label(constants.productName()));
 
 		Button logoutButton = new Button(constants.logoutButton());
 		logoutButton.addClickHandler(new ClickHandler() {
@@ -215,9 +211,35 @@
 			}
 			
 		});
-		north.add(logoutButton);
-		north.setCellHorizontalAlignment(logoutButton,
+		northTop.add(logoutButton);
+		northTop.setCellHorizontalAlignment(logoutButton,
 				VerticalPanel.ALIGN_RIGHT);
+		north.add(northTop);
+		
+		HorizontalPanel hPanel = new HorizontalPanel();
+		hPanel.setSpacing(5);
+		hPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
+		
+		searchBox.setWidth("150px");
+		searchBox.setLimit(20);
+		hPanel.add(searchBox);
+		
+		final Button searchButton = new Button(constants.searchButton());
+		searchButton.addClickHandler(new ClickHandler() {
+
+			public void onClick(ClickEvent event) {
+				controller.call(new Event<MessageListModelData, HupaAction>(
+						HupaAction.FETCH_MESSAGES,
+						new MessageListModelData(user, folder,
+								0, 20,searchBox.getValue()), masker));
+				searchBox.setValue("");
+			}
+			
+		});
+		hPanel.add(searchButton);
+		
+		north.add(hPanel);
+		
 	}
 
 	/**
@@ -266,6 +288,7 @@
 
 			});
 			IMAPMessage message = result.get(i);
+			fillOracle(message);
 			mMap.put(rows, message);
 			mailTable.setWidget(rows, 0, mCheckbox);
 			mailTable.setText(rows, 1, truncate(message.getIMAPHeader()
@@ -424,6 +447,11 @@
 		center.clear();
 		center.add(centerVP);
 	}
+	
+	private void fillOracle(IMAPMessage msg) {
+		oracle.add(msg.getIMAPHeader().getFrom());
+		oracle.add(msg.getIMAPHeader().getSubject());
+	}
 
 	public IMAPMessage getSelectedMessage() {
 		return mMap.get(cell.getRowIndex());

Modified: labs/hupa/src/main/java/org/apache/hupa/server/IMAPServiceImpl.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/server/IMAPServiceImpl.java?rev=791130&r1=791129&r2=791130&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/server/IMAPServiceImpl.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/server/IMAPServiceImpl.java Sat Jul  4 14:09:45
2009
@@ -101,7 +101,7 @@
 
 	}
 
-	public ResultList<IMAPMessage> getMessages(IMAPUser user,IMAPFolder folder, int start,
int end) throws IMAPServiceException {
+	public ResultList<IMAPMessage> getMessages(IMAPUser user,IMAPFolder folder, int start,
int end,String searchString) throws IMAPServiceException {
 		ResultList<IMAPMessage> mList = new ResultList<IMAPMessage>();
 
 		IMAPProtocol proto = null;
@@ -119,8 +119,17 @@
 			if (end > exists) {
 				end = 0;
 			}
-
-			SequenceSet sSet = new SequenceSet(exists - end, exists - start);
+			SequenceSet sSet;
+			if (searchString == null) {
+				sSet = new SequenceSet(exists - end, exists - start);
+			} else {
+				Integer[] matchedIds = proto.search(new SearchKey[]{new SearchKey(SearchKey.BODY,searchString),
new SearchKey(SearchKey.SUBJECT,searchString), new SearchKey(SearchKey.FROM,searchString)});
+				if (matchedIds == null || matchedIds.length == 0) {
+					return mList;
+				}
+				sSet = new SequenceSet(matchedIds);
+			}
+			
 			org.columba.ristretto.imap.IMAPHeader[] headers = proto
 					.fetchHeader(sSet);
 			IMAPFlags[] flags = proto.fetchFlags(sSet);



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


Mime
View raw message