You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by do...@apache.org on 2013/09/12 06:15:00 UTC

svn commit: r1522316 - in /james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui: MessagesCellTable.java res/CssMessagesCellTable.css

Author: dongxu
Date: Thu Sep 12 04:15:00 2013
New Revision: 1522316

URL: http://svn.apache.org/r1522316
Log:
make the unread message row's font bold and the read ones normal, see issue#33

Modified:
    james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/MessagesCellTable.java
    james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/res/CssMessagesCellTable.css

Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/MessagesCellTable.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/MessagesCellTable.java?rev=1522316&r1=1522315&r2=1522316&view=diff
==============================================================================
--- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/MessagesCellTable.java (original)
+++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/MessagesCellTable.java Thu Sep 12 04:15:00 2013
@@ -504,6 +504,7 @@ import java.util.List;
 
 import org.apache.hupa.client.HupaConstants;
 import org.apache.hupa.client.bundles.HupaImageBundle;
+import org.apache.hupa.shared.data.MessageImpl.IMAPFlag;
 import org.apache.hupa.shared.domain.Message;
 
 import com.google.gwt.cell.client.CheckboxCell;
@@ -519,6 +520,7 @@ import com.google.gwt.resources.client.I
 import com.google.gwt.user.cellview.client.Column;
 import com.google.gwt.user.cellview.client.DataGrid;
 import com.google.gwt.user.cellview.client.Header;
+import com.google.gwt.user.cellview.client.RowStyles;
 import com.google.gwt.view.client.DefaultSelectionEventManager;
 import com.google.gwt.view.client.MultiSelectionModel;
 import com.google.gwt.view.client.ProvidesKey;
@@ -538,10 +540,15 @@ public class MessagesCellTable extends D
 
 	public interface Resources extends DataGrid.Resources {
 
-		DataGrid.Resources INSTANCE = GWT.create(Resources.class);
+		Resources INSTANCE = GWT.create(Resources.class);
 
 		@Source("res/CssMessagesCellTable.css")
-		Style dataGridStyle();
+		CustomStyle dataGridStyle();
+	}
+
+	public interface CustomStyle extends Style {
+		String fontBold();
+		String fontNormal();
 	}
 
 	public CheckboxColumn getCheckboxCol() {
@@ -554,12 +561,10 @@ public class MessagesCellTable extends D
 			return item == null ? null : item.getUid();
 		}
 	};
-	private final SelectionModel<? super Message> selectionModel = new MultiSelectionModel<Message>(
-			KEY_PROVIDER);
+	private final SelectionModel<? super Message> selectionModel = new MultiSelectionModel<Message>(KEY_PROVIDER);
 
 	@Inject
-	public MessagesCellTable(final HupaImageBundle imageBundle,
-			final HupaConstants constants) {
+	public MessagesCellTable(final HupaImageBundle imageBundle, final HupaConstants constants) {
 		super(PAGE_SIZE, Resources.INSTANCE);
 
 		this.imageBundle = imageBundle;
@@ -572,8 +577,7 @@ public class MessagesCellTable extends D
 				return false;
 			}
 		};
-		Header<ImageResource> attachedPin = new Header<ImageResource>(
-				headerAttached) {
+		Header<ImageResource> attachedPin = new Header<ImageResource>(headerAttached) {
 			@Override
 			public ImageResource getValue() {
 				return imageBundle.attachmentIcon();
@@ -582,8 +586,7 @@ public class MessagesCellTable extends D
 		header.setUpdater(new ValueUpdater<Boolean>() {
 			@Override
 			public void update(Boolean value) {
-				List<Message> displayedItems = MessagesCellTable.this
-						.getVisibleItems();
+				List<Message> displayedItems = MessagesCellTable.this.getVisibleItems();
 				for (Message msg : displayedItems) {
 					selectionModel.setSelected(msg, value);
 				}
@@ -604,10 +607,27 @@ public class MessagesCellTable extends D
 		addColumn(dateCol, constants.mailTableDate());
 		setColumnWidth(dateCol, 10, Unit.EM);
 		setRowCount(PAGE_SIZE, false);
+		setRowStyles(new RowStyles<Message>() {
+			@Override
+			public String getStyleNames(Message row, int rowIndex) {
+				return haveRead(row) ? markAsRead() : markAsUnread();
+			}
+
+			private String markAsUnread() {
+				return Resources.INSTANCE.dataGridStyle().fontBold();
+			}
+
+			private String markAsRead() {
+				return Resources.INSTANCE.dataGridStyle().fontNormal();
+			}
+
+			private boolean haveRead(Message row) {
+				return row.getFlags().contains(IMAPFlag.SEEN);
+			}
+		});
 		setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
 		setAutoHeaderRefreshDisabled(true);
-		setSelectionModel(selectionModel,
-				DefaultSelectionEventManager.<Message> createCheckboxManager(0));
+		setSelectionModel(selectionModel, DefaultSelectionEventManager.<Message> createCheckboxManager(0));
 	}
 
 	public class CheckboxColumn extends Column<Message, Boolean> {
@@ -662,8 +682,10 @@ public class MessagesCellTable extends D
 	}
 
 	private class DateColumn extends Column<Message, Date> {
+		private static final String DATE_FORMAT = "dd.MMM.yyyy";
+
 		public DateColumn() {
-			super(new DateCell(DateTimeFormat.getFormat("dd.MMM.yyyy")));
+			super(new DateCell(DateTimeFormat.getFormat(DATE_FORMAT)));
 		}
 
 		@Override

Modified: james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/res/CssMessagesCellTable.css
URL: http://svn.apache.org/viewvc/james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/res/CssMessagesCellTable.css?rev=1522316&r1=1522315&r2=1522316&view=diff
==============================================================================
--- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/res/CssMessagesCellTable.css (original)
+++ james/hupa/trunk/client/src/main/java/org/apache/hupa/client/ui/res/CssMessagesCellTable.css Thu Sep 12 04:15:00 2013
@@ -41,7 +41,7 @@
 }
 
 .dataGridCell {
-    cursor: pointer;
+	cursor: pointer;
 	white-space: nowrap;
 	overflow: hidden;
 	text-overflow: ellipsis;
@@ -90,8 +90,8 @@
 }
 
 .dataGridEvenRowCell {
-    border-left: 1px dotted #bbd3da;
-    border-bottom: 0px solid #bbd3da;
+	border-left: 1px dotted #bbd3da;
+	border-bottom: 0px solid #bbd3da;
 }
 
 .dataGridOddRow {
@@ -99,8 +99,8 @@
 }
 
 .dataGridOddRowCell {
-    border-left: 1px dotted #bbd3da;
-    border-bottom: 0px solid #bbd3da;
+	border-left: 1px dotted #bbd3da;
+	border-bottom: 0px solid #bbd3da;
 }
 
 .dataGridHoveredRow {
@@ -108,8 +108,8 @@
 }
 
 .dataGridHoveredRowCell {
-    border-left: 1px dotted #eee;
-    border-bottom: 0px solid #eee;
+	border-left: 1px dotted #eee;
+	border-bottom: 0px solid #eee;
 }
 
 .dataGridKeyboardSelectedRow {
@@ -134,8 +134,8 @@
 }
 
 .dataGridSelectedRowCell {
-    border-left: 1px dotted #628cd5;
-    border-bottom: 0px solid #628cd5;
+	border-left: 1px dotted #628cd5;
+	border-bottom: 0px solid #628cd5;
 }
 
 /**
@@ -143,4 +143,12 @@
  */
 .dataGridKeyboardSelectedCell {
 	border: selectionBorderWidth solid #d7dde8;
+}
+
+.fontBold {
+	font-weight: bold;
+}
+
+.fontNormal {
+	font-weight: normal;
 }
\ No newline at end of file



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