labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r792792 - in /labs/hupa: src/main/java/org/apache/hupa/client/mvp/IMAPMessagePresenter.java src/main/java/org/apache/hupa/client/mvp/IMAPMessageView.java src/main/java/org/apache/hupa/client/mvp/MainView.java war/Hupa.css
Date Fri, 10 Jul 2009 03:12:24 GMT
Author: norman
Date: Fri Jul 10 03:12:24 2009
New Revision: 792792

URL: http://svn.apache.org/viewvc?rev=792792&view=rev
Log:
some more work in progress for MVP and better look

Added:
    labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessagePresenter.java
Modified:
    labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageView.java
    labs/hupa/src/main/java/org/apache/hupa/client/mvp/MainView.java
    labs/hupa/war/Hupa.css

Added: labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessagePresenter.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessagePresenter.java?rev=792792&view=auto
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessagePresenter.java (added)
+++ labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessagePresenter.java Fri Jul 10
03:12:24 2009
@@ -0,0 +1,25 @@
+package org.apache.hupa.client.mvp;
+
+import com.google.gwt.gen2.table.event.client.HasRowSelectionHandlers;
+import com.google.gwt.gen2.table.event.client.RowSelectionEvent;
+import com.google.gwt.gen2.table.event.client.RowSelectionHandler;
+
+public class IMAPMessagePresenter {
+	
+	public interface Display {
+		public HasRowSelectionHandlers getDataTableSelection();
+	}
+	
+	
+	public void bind(Display display) {
+		display.getDataTableSelection().addRowSelectionHandler(new RowSelectionHandler() {
+
+			public void onRowSelection(RowSelectionEvent event) {
+				// TODO Auto-generated method stub
+				
+			}
+			
+		});
+	}
+
+}

Modified: labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageView.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageView.java?rev=792792&r1=792791&r2=792792&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageView.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageView.java Fri Jul 10 03:12:24
2009
@@ -30,19 +30,22 @@
 import org.apache.hupa.client.data.IMAPFolder;
 import org.apache.hupa.client.data.IMAPMessage;
 import org.apache.hupa.client.data.IMAPUser;
-import org.apache.hupa.client.data.IMAPMessage.IMAPFlag;
 import org.apache.hupa.client.events.EventBus;
 import org.apache.hupa.client.events.LoadMessagesEvent;
 import org.apache.hupa.client.events.LoadMessagesEventHandler;
+import org.apache.hupa.client.mvp.IMAPMessagePresenter.Display;
 import org.apache.hupa.client.rpc.FetchMessages;
 import org.apache.hupa.client.rpc.FetchMessagesResult;
+import org.cobogw.gwt.user.client.ui.Button;
+import org.cobogw.gwt.user.client.ui.ButtonBar;
 
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.event.dom.client.ClickEvent;
 import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.event.logical.shared.ResizeEvent;
+import com.google.gwt.event.logical.shared.ResizeHandler;
 import com.google.gwt.gen2.table.client.AbstractColumnDefinition;
 import com.google.gwt.gen2.table.client.ColumnDefinition;
-import com.google.gwt.gen2.table.client.DefaultRowRenderer;
 import com.google.gwt.gen2.table.client.DefaultTableDefinition;
 import com.google.gwt.gen2.table.client.FixedWidthFlexTable;
 import com.google.gwt.gen2.table.client.FixedWidthGrid;
@@ -56,18 +59,21 @@
 import com.google.gwt.gen2.table.client.AbstractScrollTable.ScrollPolicy;
 import com.google.gwt.gen2.table.client.PagingOptions.PagingOptionsImages;
 import com.google.gwt.gen2.table.client.SelectionGrid.SelectionPolicy;
-import com.google.gwt.gen2.table.client.TableDefinition.AbstractRowView;
 import com.google.gwt.gen2.table.client.TableModelHelper.Request;
+import com.google.gwt.gen2.table.event.client.HasRowSelectionHandlers;
 import com.google.gwt.gen2.table.event.client.PageLoadEvent;
 import com.google.gwt.gen2.table.event.client.PageLoadHandler;
+import com.google.gwt.user.client.Window;
 import com.google.gwt.user.client.rpc.AsyncCallback;
 import com.google.gwt.user.client.ui.CheckBox;
 import com.google.gwt.user.client.ui.Composite;
 import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.RootPanel;
 import com.google.gwt.user.client.ui.VerticalPanel;
 import com.google.inject.Inject;
 
-public class IMAPMessageView extends Composite{
+public class IMAPMessageView extends Composite implements Display{
 
 	private HupaConstants constants = GWT.create(HupaConstants.class);
 	private DispatchAsync dispatcher;
@@ -75,10 +81,7 @@
 	private IMAPFolder folder;
 	private String searchValue;
 
-	private PagingScrollTable<IMAPMessage> mailTable = new PagingScrollTable<IMAPMessage>(
-			new IMAPMessageTableModel(), createDataTable(),
-			createHeaderTable(),
-			createTableDefinitation());
+	private PagingScrollTable<IMAPMessage> mailTable;
 	
 	@Inject
 	public IMAPMessageView(DispatchAsync dispatcher,EventBus bus) {
@@ -98,87 +101,92 @@
 		
 		VerticalPanel vPanel = new VerticalPanel();
 
+		mailTable = new PagingScrollTable<IMAPMessage>(
+				new IMAPMessageTableModel(), createDataTable(),
+				createHeaderTable(),
+				createTableDefinitation());
 		mailTable.setPageSize(20);
-		mailTable.setEmptyTableWidget(new HTML("There is no data to display"));
+		HTML emptyTable = new HTML("There is no data to display");
+		emptyTable.setHeight("300px");
+		mailTable.setEmptyTableWidget(emptyTable);
 		FixedWidthGridBulkRenderer<IMAPMessage> bulkRenderer = new FixedWidthGridBulkRenderer<IMAPMessage>(mailTable.getDataTable(),mailTable);
 		mailTable.setBulkRenderer(bulkRenderer);
 		
 		mailTable.setCellPadding(0);
 		mailTable.setResizePolicy(ResizePolicy.FILL_WIDTH);
 		mailTable.setScrollPolicy(ScrollPolicy.DISABLED);
-		mailTable.setSize("900px", "600px");
+		mailTable.setSize(Window.getClientWidth() - 200 + "px", "600px");
 		mailTable.addPageLoadHandler(new PageLoadHandler() {
 
 			public void onPageLoad(PageLoadEvent event) {
 				for (int i = 0; i < mailTable.getDataTable().getRowCount(); i++) {
-					if (i % 2 == 0) {
-						mailTable.getDataTable().getRowFormatter().setStyleName(i,
-								"hupa-Mailtable-row1");
-					} else {
-						mailTable.getDataTable().getRowFormatter().setStyleName(i,
-								"hupa-Mailtable-row2");
-					}
-					/*
-					mailTable.getDataTable().getCellFormatter().setWordWrap(i, 0,
-							false);
-					mailTable.getDataTable().getCellFormatter().setWordWrap(i, 1,
-							false);
-					mailTable.getDataTable().getCellFormatter().setWordWrap(i, 2,
-							false);
-					*/
+					mailTable.getDataTable().getRowFormatter().setStyleName(i,"hupa-Mailtable-row");
+					mailTable.getDataTable().getCellFormatter().setWordWrap(i, 0,false);
+					mailTable.getDataTable().getCellFormatter().setWordWrap(i, 1,false);
+					mailTable.getDataTable().getCellFormatter().setWordWrap(i, 2,false);
+					
 					mailTable.getDataTable().getCellFormatter().addStyleName(i,0,"hupa-Mailtable");
 					mailTable.getDataTable().getCellFormatter().addStyleName(i,1,"hupa-Mailtable");
-					mailTable.getDataTable().getCellFormatter().addStyleName(i,2,"hupa-Mailtable-cell-date");
+					mailTable.getDataTable().getCellFormatter().addStyleName(i,2,"hupa-Mailtable");
+					//mailTable.getDataTable().getCellFormatter().addStyleName(i,2,"hupa-Mailtable-cell-date");
 
 				}
 			}
 			
 		});
 		mailTable.getDataTable().setCellSpacing(0);
-		
+		Window.addResizeHandler(new ResizeHandler() {
 
+			public void onResize(ResizeEvent event) {
+				int width = event.getWidth() - 200;
+				mailTable.setWidth(width + "px");
+		
+			}
+		});
+		
+		mailTable.fillWidth();
 		PagingOptions options = new PagingOptions(mailTable, (PagingOptionsImages) GWT.create(MyPagingOptionImages.class));
 		
-		vPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
-		vPanel.add(options);
+		ButtonBar navigatorBar = new ButtonBar();
+		Button newMailButton = new Button(constants.newMailButton());
+		navigatorBar.add(newMailButton);
+		Button deleteMailButton = new Button(constants.deleteMailButton());
+		navigatorBar.add(deleteMailButton);
+
+		HorizontalPanel hPanel = new HorizontalPanel();
+		hPanel.setStyleName("hupa-MailTableControl");
+		hPanel.setSpacing(10);
+		hPanel.add(navigatorBar);
+		hPanel.add(options);
+		hPanel.setWidth("100%");
+		hPanel.setHeight("100%");
+		vPanel.add(hPanel);
 		vPanel.add(mailTable);
-		//vPanel.add(options);
 		initWidget(vPanel);
 	}
 	
-	private String truncate(String rawString) {
-		if (rawString.length() > 50) {
-			return rawString.substring(0, 50);
-		} else {
-			return rawString;
-		}
-	}
-	
 
 	private TableDefinition<IMAPMessage> createTableDefinitation() {
 		DefaultTableDefinition<IMAPMessage> def = new DefaultTableDefinition<IMAPMessage>(createColumnDefinitionList());
-		def.setRowRenderer(new DefaultRowRenderer<IMAPMessage>() {
-
-			@Override
-			public void renderRowValue(IMAPMessage rowValue,
-					AbstractRowView<IMAPMessage> view) {
-				super.renderRowValue(rowValue, view);
-			}
-			
-		});
 		return def;
 	}
 
 	private FixedWidthFlexTable createHeaderTable() {
 		FixedWidthFlexTable headerTable = new FixedWidthFlexTable();
+		return headerTable;
+		/*
 		final CheckBox box = new CheckBox();
 		box.addClickHandler(new ClickHandler() {
 
 			public void onClick(ClickEvent event) {
 				CheckBox headerCheckbox = (CheckBox) event.getSource();
-				for (int i = 1; i < mailTable.getDataTable().getRowCount(); i++) {
-					((CheckBox) mailTable.getDataTable().getWidget(i, 0))
-							.setValue(headerCheckbox.getValue());
+				if (headerCheckbox.getValue()) {
+					mailTable.getDataTable().selectAllRows();
+				} else {
+					mailTable.getDataTable().deselectAllRows();
+				}
+				
+				for (int i = 0; i < mailTable.getDataTable().getRowCount(); i++) {
 					if(headerCheckbox.getValue() == true) {
 						mailTable.getDataTable().getRowFormatter().setStyleName(i, "hupa-Mailtable-row-selected");
 					} else {
@@ -186,13 +194,16 @@
 
 					}
 				
+				
 					IMAPMessage message = mailTable.getRowValue(i);
+					
 					if (message.getIMAPFlags().contains(IMAPFlag.SEEN) == false) {
 						mailTable.getDataTable().getRowFormatter().addStyleName(i,
 								"hupa-Mailtable-row-notseen");
 					} else {
 						mailTable.getDataTable().getRowFormatter().removeStyleName(i, "hupa-Mailtable-row-notseen");
 					}
+					
 				}
 			}
 
@@ -211,6 +222,7 @@
 		headerTable.getFlexCellFormatter().addStyleName(0,2,"hupa-Mailtable-Header");
 		headerTable.getFlexCellFormatter().addStyleName(0,3,"hupa-Mailtable-Header");
 		return headerTable;
+		*/
 	}
 	
 	/**
@@ -227,19 +239,19 @@
 		List<ColumnDefinition<IMAPMessage, ?>> cList = new ArrayList<ColumnDefinition<IMAPMessage,
?>>();
 
 		FromColumnDefination from = new FromColumnDefination();
-		from.setMinimumColumnWidth(200);
+		from.setColumnTruncatable(true);
+		from.setPreferredColumnWidth(250);
 		cList.add(from);
 
 		
 		SubjectColumnDefination subject =new SubjectColumnDefination();
-		subject.setMinimumColumnWidth(500);
-
-		
+		subject.setColumnTruncatable(true);
+		from.setPreferredColumnWidth(800);
 		cList.add(subject);
 		
 		DateColumnDefination date = new DateColumnDefination();
-		date.setMinimumColumnWidth(100);
-		
+		date.setColumnTruncatable(true);
+
 		cList.add(date);
 		
 		return cList;
@@ -251,6 +263,18 @@
 		public void requestRows(
 				final Request request,
 				final com.google.gwt.gen2.table.client.TableModel.Callback<IMAPMessage> callback)
{
+			GWT.log("HERE", null);
+			if (user == null || folder == null) {
+				setRowCount(0);
+				callback.onRowsReady(request, new TableModelHelper.Response<IMAPMessage>() {
+
+					@Override
+					public Iterator<IMAPMessage> getRowValues() {
+						return new ArrayList<IMAPMessage>().iterator();
+					}
+					
+				});
+			}
 			dispatcher.execute(new FetchMessages(user,folder,request.getStartRow(),request.getStartRow()
+ request.getNumRows(),searchValue), new AsyncCallback<FetchMessagesResult>() {
 
 				public void onFailure(Throwable caught) {
@@ -309,7 +333,7 @@
 
 		@Override
 		public String getCellValue(IMAPMessage rowValue) {
-			return rowValue.getIMAPHeader().getReceivedDate().toString();
+			return ""; //rowValue.getIMAPHeader().getReceivedDate().toString();
 		}
 
 		@Override
@@ -319,4 +343,8 @@
 		}
 		
 	}
+
+	public HasRowSelectionHandlers getDataTableSelection() {
+		return mailTable.getDataTable();
+	}
 }

Modified: labs/hupa/src/main/java/org/apache/hupa/client/mvp/MainView.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/mvp/MainView.java?rev=792792&r1=792791&r2=792792&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/mvp/MainView.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/mvp/MainView.java Fri Jul 10 03:12:24 2009
@@ -4,6 +4,7 @@
 
 import org.apache.hupa.client.HupaConstants;
 import org.apache.hupa.client.bundles.IMAPTreeImages;
+import org.apache.hupa.client.data.IMAPFolder;
 import org.apache.hupa.client.data.IMAPMessage;
 import org.apache.hupa.client.widgets.IMAPTreeItem;
 import org.cobogw.gwt.user.client.ui.Button;
@@ -71,7 +72,7 @@
 	private void createWest() {
 			west = new RoundedPanel(RoundedPanel.ALL);
 			west.add(folderTree);
-			west.setWidth("30%");	
+			west.setWidth("150px");	
 			folderTree.setAnimationEnabled(true);
 			
 		
@@ -119,30 +120,10 @@
 	}
 
 	private void createCenter() {
-
-		centerVP.setSpacing(10);
-
-		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);
-		Button deleteMailButton = new Button(constants.deleteMailButton());
-		navigatorBar.add(deleteMailButton);
-
-		navPanel.add(navigatorBar);
-		
-		rowsPerPageBox.setWidth("40px");
-		rowsPerPageBox.setValue("20");
-		
-		navPanel.add(rowsPerPageBox);
-		navPanel.add(new Label(constants.rowsPerPageLabel()));
-		centerVP.add(navPanel);
-		//messageView.setPixelSize(900, 600);
-		centerVP.add(messageView);
-		center = new RoundedPanel();
-		center.add(centerVP);
+		center = new RoundedPanel(RoundedPanel.ALL, 3);
+		center.setBorderColor("#C3D9FF");
+		
+		center.add(messageView);
 		center.setWidth("100%");
 
 	}
@@ -170,8 +151,13 @@
 		folderTree.clear();
 		
 		for (int i = 0; i < treeList.size(); i++) {
-			folderTree.addItem(treeList.get(i));
-		
+			IMAPTreeItem item = treeList.get(i);
+			IMAPFolder folder = (IMAPFolder)item.getUserObject();
+			folderTree.addItem(item);
+
+			if (folder.getFullName().equalsIgnoreCase("INBOX")) {
+				folderTree.setSelectedItem(item);
+			}
 		}
 	}
 }

Modified: labs/hupa/war/Hupa.css
URL: http://svn.apache.org/viewvc/labs/hupa/war/Hupa.css?rev=792792&r1=792791&r2=792792&view=diff
==============================================================================
--- labs/hupa/war/Hupa.css (original)
+++ labs/hupa/war/Hupa.css Fri Jul 10 03:12:24 2009
@@ -1,31 +1,28 @@
-h1 {
-  font-size: 2em;
-  font-weight: bold;
-  color: #777777;
-  margin: 40px 0px 70px;
-  text-align: center;
-}
 
 .cbg-RP { 
-	background-color:	#E6E6FA; 
+	background-color:	#E0ECFF;
 }
 
 .hupa-ErrorLabel {
     color:              #FF0000;
 }
 
+.hupa-MailTableControl {
+	background-color:	#E0ECFF;	
+}
+
 .hupa-LoginWidgetHeader {
 	border-top:			1pt solid grey;
 	border-bottom:		1pt solid grey;
 	text-align:			left;
 	padding-left:		5px;
-	background-color:	#E6E6FA;
+	background-color:	#E0ECFF;
 }
 
 .hupa-IMAPMessageWidget-Header {
 	border:				1pt solid grey;
 	text-align:			left;
-	background-color:	#E6E6FA;
+	background-color:	#E0ECFF;
 }
 
 .hupa-IMAPMessageWidget-ButtonBar {
@@ -37,16 +34,15 @@
 .hupa-Northpanel {
 	border-top:			1pt solid grey;
 	border-bottom:		1pt solid grey;
-	
-	background-color:	#E6E6FA;
+	background-color:	#E0ECFF;
 }
 
 .hupa-Mailtable{
-    border-bottom:      1pt solid silver;
+    border-top:      1pt solid silver;
 }
 
 .hupa-Mailtable-Header {
-	background-color:	#E6E6FA;
+	background-color:	#E0ECFF;
 	text-align: 		center;
 	border-top:         1pt solid grey;
 	border-bottom:      1pt solid grey;
@@ -61,7 +57,7 @@
 	  background-color:	#F0E68C;
 	  text-align: 		left;
 	  vertical-align: 	top;
-  	  margin: 			0px 5px 0px 5px;
+	padding: 			0px 10px 0px 10px;
 	  font-size: 	    80%;
 	  cursor:           hand;
 }
@@ -69,27 +65,10 @@
 .hupa-Mailtable-row {
     text-align: 		left;
 	vertical-align: 	top;
-	margin: 			0px 5px 0px 5px;
+	padding: 			0px 10px 0px 10px;
 	font-size: 			80%;
 	cursor:             hand;
 }
-.hupa-Mailtable-row1 {
-	background-color:	#FFFFFF;
-	text-align: 		left;
-	vertical-align: 	top;
-	margin: 			0px 5px 0px 5px;
-	font-size: 			80%;
-	cursor:             hand; 
-}
-
-.hupa-Mailtable-row2 {
-	background-color:	#F5F5F5;
-	text-align: 		left;
-	vertical-align:		top;
-	margin: 			0px 5px 0px 5px;
-	font-size: 			80%;
-	cursor:             hand; 
-}
 
 .hupa-Mailtable-cell-date {
 	text-align: 		right;
@@ -97,5 +76,5 @@
 }
 
 .hupa-IMAPFolder-selected {
-	background:			#E6E6FA;
+	background:			#E0ECFF;
 }
\ No newline at end of file



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


Mime
View raw message