labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r795003 - in /labs/hupa: src/main/java/org/apache/hupa/client/mvp/MainPresenter.java src/main/java/org/apache/hupa/client/widgets/IMAPTreeItem.java war/Hupa.css
Date Fri, 17 Jul 2009 08:25:29 GMT
Author: norman
Date: Fri Jul 17 08:25:29 2009
New Revision: 795003

URL: http://svn.apache.org/viewvc?rev=795003&view=rev
Log:
decrease unseen message count 

Modified:
    labs/hupa/src/main/java/org/apache/hupa/client/mvp/MainPresenter.java
    labs/hupa/src/main/java/org/apache/hupa/client/widgets/IMAPTreeItem.java
    labs/hupa/war/Hupa.css

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=795003&r1=795002&r2=795003&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 Fri Jul 17 08:25:29
2009
@@ -35,6 +35,7 @@
 import org.apache.hupa.shared.data.IMAPFolder;
 import org.apache.hupa.shared.data.IMAPMessage;
 import org.apache.hupa.shared.data.IMAPUser;
+import org.apache.hupa.shared.data.IMAPMessage.IMAPFlag;
 import org.apache.hupa.shared.events.ExpandMessageEvent;
 import org.apache.hupa.shared.events.ExpandMessageEventHandler;
 import org.apache.hupa.shared.events.LoadMessagesEvent;
@@ -74,7 +75,6 @@
 	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();
@@ -87,6 +87,7 @@
 	private IMAPFolder folder;
 	
 	protected Cell cell;
+	private IMAPTreeItem tItem;
 	private IMAPMessageListPresenter messageListPresenter;
 	private IMAPMessagePresenter messagePresenter;
 	
@@ -127,8 +128,8 @@
 
 		for (int i = 0; i < list.size(); i++) {
 			IMAPFolder iFolder = list.get(i);
-			IMAPTreeItem record = new IMAPTreeItem(iFolder.getName() + " ("
-					+ iFolder.getUnseeMessageCount() + ")");
+			
+			IMAPTreeItem record = new IMAPTreeItem(iFolder);
 			
 			record.setUserObject(iFolder);
 
@@ -140,6 +141,12 @@
 				}
 			}
 
+			// Store the INBOX as starting point after first loading
+			if (iFolder.getFullName().equals(IMAPFolder.DEFAULT_INBOX)) {
+				folder = iFolder;
+				tItem = record;
+			}
+			
 			tList.add(record);
 		}
 
@@ -221,6 +228,13 @@
 		eventBus.addHandler(ExpandMessageEvent.TYPE, new ExpandMessageEventHandler() {
 
 			public void onExpandMessage(ExpandMessageEvent event) {
+				final boolean decreaseUnseen;
+				// check if the message was already seen in the past
+				if (event.getMessage().getIMAPFlags().contains(IMAPFlag.SEEN) == false) {
+					decreaseUnseen = true;
+				} else {
+					decreaseUnseen = false;
+				}
 				dispatcher.execute(new ExposeMessage(event.getUser(),event.getFolder(),event.getMessage()),
new AsyncCallback<ExposeMessageResult>() {
 
 					public void onFailure(Throwable caught) {
@@ -228,6 +242,11 @@
 					}
 
 					public void onSuccess(ExposeMessageResult result) {
+						// decrease the unseen count if we were able to expose the message
+						if (decreaseUnseen) {
+							tItem.decreaseUnseenMessageCount();
+						}
+						
 						showMessage(result.getMessage());
 					}
 					
@@ -256,8 +275,8 @@
 		display.getTree().addSelectionHandler(new SelectionHandler<TreeItem>() {
 
 			public void onSelection(SelectionEvent<TreeItem> event) {
-				TreeItem item = event.getSelectedItem();
-				folder = (IMAPFolder) item.getUserObject();
+				tItem = (IMAPTreeItem)event.getSelectedItem();
+				folder = (IMAPFolder) tItem.getUserObject();
 				showMessageTable();
 				eventBus.fireEvent(new LoadMessagesEvent(user,folder));
 			}

Modified: labs/hupa/src/main/java/org/apache/hupa/client/widgets/IMAPTreeItem.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/widgets/IMAPTreeItem.java?rev=795003&r1=795002&r2=795003&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/widgets/IMAPTreeItem.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/widgets/IMAPTreeItem.java Fri Jul 17 08:25:29
2009
@@ -19,30 +19,98 @@
 
 package org.apache.hupa.client.widgets;
 
+import org.apache.hupa.shared.data.IMAPFolder;
+
 import com.google.gwt.user.client.ui.Label;
 import com.google.gwt.user.client.ui.SimplePanel;
 import com.google.gwt.user.client.ui.TreeItem;
 
 public class IMAPTreeItem extends TreeItem{
+	private Label tLabel = new Label();
 	
-	public IMAPTreeItem(String text) {
+	public IMAPTreeItem(IMAPFolder folder) {
 		super();
 		SimplePanel panel = new SimplePanel();
-		Label tLabel = new Label(text);
 		panel.add(tLabel);
-		setWidget(panel);
-		getWidget().setStyleName("hupa-IMAPFolder");
 
+		setWidget(panel);
+		setUserObject(folder);
+		setFolderText(folder);
 	}
-	
+
+	/*
+	 * (non-Javadoc)
+	 * @see com.google.gwt.user.client.ui.TreeItem#setSelected(boolean)
+	 */
 	public void setSelected(boolean selected) {
 		super.setSelected(selected);
 		if (isSelected()) {
-			getWidget().setStyleName("hupa-IMAPFolder-selected");
+			getWidget().addStyleName("hupa-IMAPFolder-selected");
 		} else {
-			getWidget().setStyleName("hupa-IMAPFolder");
+			getWidget().removeStyleName("hupa-IMAPFolder-selected");
 		}
 	}
 	
+	/**
+	 * Decrease the unseen messagecount of this folder
+	 */
+	public void decreaseUnseenMessageCount() {
+		descreaseUnseenMessageCount(1);
+	}
+	
+	
+	/**
+	 * Decrease the unseen messagecount of this folder
+	 * 
+	 * @param decreaseCount
+	 */
+	public void descreaseUnseenMessageCount(int decreaseCount) {
+		IMAPFolder folder = (IMAPFolder) getUserObject();
+		int count = folder.getUnseeMessageCount();
+		if (count >0) { 
+			count =- decreaseCount;
+			if (count < 0) {
+				count = 0;
+			}
+			folder.setUnseenMessageCount(count);
+			setFolderText(folder);
+		} 
+	}
+	/**
+	 * Increase the unseen messagecount of this folder
+	 * 
+	 * @param increaseCount
+	 */
+	public void increaseUnseenMessageCount() {
+		increaseUnseenMessageCount(1);
+	}
+	
+	/**
+	 * Increase the unseen messagecount of this folder
+	 * 
+	 */
+	public void increaseUnseenMessageCount( int increaseCount) {
+		IMAPFolder folder = (IMAPFolder) getUserObject();
+		int count = folder.getUnseeMessageCount(); 
+		count =+ increaseCount;
+		folder.setUnseenMessageCount(count);
+		setFolderText(folder);
+	}
+	
+	
+	private void setFolderText(IMAPFolder folder) {
+		tLabel.setText(folder.getName() + " ("+folder.getUnseeMessageCount()+")");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see com.google.gwt.user.client.ui.TreeItem#setUserObject(java.lang.Object)
+	 */
+	public void setUserObject(Object obj) {
+		if ((obj instanceof IMAPFolder) == false) {
+			throw new IllegalArgumentException("UserObject needs to be an instance of IMAPFolder");
+		}
+		super.setUserObject(obj);
+	}
 	
 }

Modified: labs/hupa/war/Hupa.css
URL: http://svn.apache.org/viewvc/labs/hupa/war/Hupa.css?rev=795003&r1=795002&r2=795003&view=diff
==============================================================================
--- labs/hupa/war/Hupa.css (original)
+++ labs/hupa/war/Hupa.css Fri Jul 17 08:25:29 2009
@@ -7,7 +7,7 @@
     border-color:	#E0ECFF;
 }
 
-.cbg-Button, .gwt-HTML, .gwt-Tree .gwt-TreeItem, .gwt-SuggestBoxPopup .item, hupa-LoginForm,
.hupa-IMAPMessageWidget-Header-Content, .hupa-ToolTip{ 
+.cbg-Button, .gwt-HTML, .gwt-Tree .gwt-TreeItem, .gwt-SuggestBoxPopup .item, hupa-LoginForm,
.hupa-IMAPMessageWidget-Header-Content, .hupa-ToolTip, .hupa-IMAPFolder {
     font-size:			12px;
 	font-family: 		Arial, Helvetica, sans-serif;
 }



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


Mime
View raw message