labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r793467 - in /labs/hupa/src/main/java/org/apache/hupa/client: mvp/IMAPMessageListView.java widgets/MyPagingScrollTable.java widgets/ToolTip.java widgets/ToolTipProvider.java
Date Mon, 13 Jul 2009 06:03:13 GMT
Author: norman
Date: Mon Jul 13 06:03:12 2009
New Revision: 793467

URL: http://svn.apache.org/viewvc?rev=793467&view=rev
Log:
Better handling of ToolTips

Added:
    labs/hupa/src/main/java/org/apache/hupa/client/widgets/MyPagingScrollTable.java
    labs/hupa/src/main/java/org/apache/hupa/client/widgets/ToolTipProvider.java
Modified:
    labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListView.java
    labs/hupa/src/main/java/org/apache/hupa/client/widgets/ToolTip.java

Modified: labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListView.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListView.java?rev=793467&r1=793466&r2=793467&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListView.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListView.java Mon Jul 13
06:03:12 2009
@@ -31,7 +31,8 @@
 import org.apache.hupa.client.mvp.IMAPMessageListPresenter.Display;
 import org.apache.hupa.client.rpc.EventBus;
 import org.apache.hupa.client.widgets.MyFixedWithGrid;
-import org.apache.hupa.client.widgets.ToolTip;
+import org.apache.hupa.client.widgets.MyPagingScrollTable;
+import org.apache.hupa.client.widgets.ToolTipProvider;
 import org.apache.hupa.shared.data.IMAPFolder;
 import org.apache.hupa.shared.data.IMAPMessage;
 import org.apache.hupa.shared.data.IMAPUser;
@@ -53,7 +54,6 @@
 import com.google.gwt.gen2.table.client.FixedWidthFlexTable;
 import com.google.gwt.gen2.table.client.FixedWidthGridBulkRenderer;
 import com.google.gwt.gen2.table.client.PagingOptions;
-import com.google.gwt.gen2.table.client.PagingScrollTable;
 import com.google.gwt.gen2.table.client.TableDefinition;
 import com.google.gwt.gen2.table.client.TableModel;
 import com.google.gwt.gen2.table.client.TableModelHelper;
@@ -64,8 +64,6 @@
 import com.google.gwt.gen2.table.client.SelectionGrid.SelectionPolicy;
 import com.google.gwt.gen2.table.client.TableDefinition.AbstractCellView;
 import com.google.gwt.gen2.table.client.TableModelHelper.Request;
-import com.google.gwt.gen2.table.event.client.CellHighlightEvent;
-import com.google.gwt.gen2.table.event.client.CellHighlightHandler;
 import com.google.gwt.gen2.table.event.client.HasPageLoadHandlers;
 import com.google.gwt.gen2.table.event.client.HasRowSelectionHandlers;
 import com.google.gwt.gen2.table.event.client.PageLoadEvent;
@@ -78,6 +76,7 @@
 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.Label;
 import com.google.gwt.user.client.ui.VerticalPanel;
 import com.google.gwt.user.client.ui.Widget;
 import com.google.inject.Inject;
@@ -89,9 +88,8 @@
 	private IMAPUser user;
 	private IMAPFolder folder;
 	private String searchValue;
-	private ToolTip tip;
 	
-	private PagingScrollTable<IMAPMessage> mailTable;
+	private MyPagingScrollTable<IMAPMessage> mailTable;
 	private EventBus bus;
 	private MyFixedWithGrid<IMAPMessage> dataTable = createDataTable();
 	
@@ -103,10 +101,10 @@
 		VerticalPanel vPanel = new VerticalPanel();
 
 		
-		mailTable = new PagingScrollTable<IMAPMessage>(
+		mailTable = new MyPagingScrollTable<IMAPMessage>(
 				new IMAPMessageTableModel(), dataTable,
 				createHeaderTable(),
-				createTableDefinitation());
+				createTableDefinitation(), new IMAPMessageToolTipProvider());
 		mailTable.setPageSize(20);
 		
 		
@@ -160,27 +158,6 @@
 			}
 		});
 		
-		dataTable.addCellHighlightHandler(new CellHighlightHandler() {
-
-			public void onCellHighlight(CellHighlightEvent event) {
-
-		
-				if (event.getValue().getCellIndex() == 3) {
-					if (tip != null) {
-						tip.hide(true);
-					}
-					tip = new ToolTip(mailTable.getRowValue(event.getValue().getRowIndex()).getIMAPHeader().getSubject());
-					tip.show();
-				} else if (event.getValue().getCellIndex() == 2) {
-					if (tip != null) {
-						tip.hide(true);
-					}
-					tip = new ToolTip(mailTable.getRowValue(event.getValue().getRowIndex()).getIMAPHeader().getFrom());
-					tip.show();
-				} 
-			}
-			
-		});
 		mailTable.getDataTable().setCellSpacing(0);
 
 	
@@ -232,6 +209,21 @@
 		initWidget(vPanel);
 	}
 
+	private class IMAPMessageToolTipProvider implements ToolTipProvider<IMAPMessage> {
+
+		public Widget getToolTipContent(IMAPMessage rowValue, int cell, int row) {
+			switch (cell) {
+			case 2:
+				return new Label(rowValue.getIMAPHeader().getFrom());
+			case 3:
+				return new Label(rowValue.getIMAPHeader().getSubject());
+			default:
+				break;
+			}
+			return null;
+		}
+		
+	}
 	private TableDefinition<IMAPMessage> createTableDefinitation() {
 		DefaultTableDefinition<IMAPMessage> def = new DefaultTableDefinition<IMAPMessage>(createColumnDefinitionList());
 		

Added: labs/hupa/src/main/java/org/apache/hupa/client/widgets/MyPagingScrollTable.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/widgets/MyPagingScrollTable.java?rev=793467&view=auto
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/widgets/MyPagingScrollTable.java (added)
+++ labs/hupa/src/main/java/org/apache/hupa/client/widgets/MyPagingScrollTable.java Mon Jul
13 06:03:12 2009
@@ -0,0 +1,89 @@
+/****************************************************************
+ * 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.gen2.table.client.FixedWidthFlexTable;
+import com.google.gwt.gen2.table.client.FixedWidthGrid;
+import com.google.gwt.gen2.table.client.PagingScrollTable;
+import com.google.gwt.gen2.table.client.TableDefinition;
+import com.google.gwt.gen2.table.client.TableModel;
+import com.google.gwt.gen2.table.event.client.CellHighlightEvent;
+import com.google.gwt.gen2.table.event.client.CellHighlightHandler;
+import com.google.gwt.gen2.table.event.client.CellUnhighlightEvent;
+import com.google.gwt.gen2.table.event.client.CellUnhighlightHandler;
+import com.google.gwt.gen2.table.event.client.TableEvent.Cell;
+import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.ui.Widget;
+
+public class MyPagingScrollTable<E> extends PagingScrollTable<E>{
+
+	private ToolTipProvider<E> toolTipProvider = null;
+	private Timer toolTipTimer;
+	private ToolTip tTip;
+	public MyPagingScrollTable(TableModel<E> tableModel,
+			FixedWidthGrid dataTable, FixedWidthFlexTable headerTable,
+			TableDefinition<E> tableDefinition,ToolTipProvider<E> tooltipProvider) {
+		super(tableModel, dataTable, headerTable, tableDefinition);
+		this.toolTipProvider = tooltipProvider;
+		
+		
+		dataTable.addCellHighlightHandler(new CellHighlightHandler() {
+
+			public void onCellHighlight(final CellHighlightEvent event) {
+				 toolTipTimer= new Timer() {
+
+						@Override
+						public void run() {
+							Cell c = event.getValue();
+							Widget w = toolTipProvider.getToolTipContent(getRowValue(c.getRowIndex()), c.getCellIndex(),
c.getRowIndex());
+							if (w != null) {
+								tTip = new ToolTip(w,3000);
+								tTip.show();
+							}
+						}
+						
+					};
+					toolTipTimer.schedule(2000);
+			}
+			
+		});
+		
+		dataTable.addCellUnhighlightHandler(new CellUnhighlightHandler() {
+
+			public void onCellUnhighlight(CellUnhighlightEvent event) {
+				if (tTip != null) {
+					tTip.hide(true);
+				}
+				if (toolTipTimer != null) {
+					toolTipTimer.cancel();
+				}
+			}
+			
+		});
+	}
+
+	public MyPagingScrollTable(TableModel<E> tableModel,
+			FixedWidthGrid dataTable, FixedWidthFlexTable headerTable,
+			TableDefinition<E> tableDefinition) {
+		this(tableModel, dataTable, headerTable, tableDefinition,null);
+	}
+
+	
+}

Modified: labs/hupa/src/main/java/org/apache/hupa/client/widgets/ToolTip.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/widgets/ToolTip.java?rev=793467&r1=793466&r2=793467&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/widgets/ToolTip.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/widgets/ToolTip.java Mon Jul 13 06:03:12
2009
@@ -25,6 +25,7 @@
 import com.google.gwt.user.client.Timer;
 import com.google.gwt.user.client.ui.Label;
 import com.google.gwt.user.client.ui.PopupPanel;
+import com.google.gwt.user.client.ui.Widget;
 
 /**
  * A ToolTip which is shown a configured time before get destroyed
@@ -37,9 +38,9 @@
 	
 	private Timer closeTimer;
 	
-	public ToolTip(String text, int showTimeMillis) {
+	public ToolTip(Widget content, int showTimeMillis) {
 		this.showTimeMillis = showTimeMillis;
-		setWidget(new Label(text));
+		setWidget(content);
 		closeTimer = new Timer() {
 
 			@Override
@@ -61,8 +62,8 @@
 	 * 
 	 * @param text
 	 */
-	public ToolTip(String text) {
-		this(text,3000);
+	public ToolTip(Widget w) {
+		this(w,3000);
 	}
 	
 	/**

Added: labs/hupa/src/main/java/org/apache/hupa/client/widgets/ToolTipProvider.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/widgets/ToolTipProvider.java?rev=793467&view=auto
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/widgets/ToolTipProvider.java (added)
+++ labs/hupa/src/main/java/org/apache/hupa/client/widgets/ToolTipProvider.java Mon Jul 13
06:03:12 2009
@@ -0,0 +1,9 @@
+package org.apache.hupa.client.widgets;
+
+import com.google.gwt.user.client.ui.Widget;
+
+public interface ToolTipProvider<E> {
+	
+	public Widget getToolTipContent(E rowValue,int cell,int row);
+
+}



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


Mime
View raw message