Author: norman
Date: Sun Jul 12 17:56:19 2009
New Revision: 793383

URL: http://svn.apache.org/viewvc?rev=793383&view=rev
Log:
Add tooltip widget

Added:
    labs/hupa/src/main/java/org/apache/hupa/client/widgets/ToolTip.java

Added: 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=793383&view=auto
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/widgets/ToolTip.java (added)
+++ labs/hupa/src/main/java/org/apache/hupa/client/widgets/ToolTip.java Sun Jul 
12 17:56:19 2009
@@ -0,0 +1,93 @@
+/****************************************************************
+ * 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.event.logical.shared.CloseEvent;
+import com.google.gwt.event.logical.shared.CloseHandler;
+import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.PopupPanel;
+
+/**
+ * A ToolTip which is shown a configured time before get destroyed
+ *  
+ *
+ */
+public class ToolTip extends PopupPanel implements CloseHandler<ToolTip>{
+
+       private int showTimeMillis;
+       
+       private Timer closeTimer;
+       
+       public ToolTip(String text, int showTimeMillis) {
+               this.showTimeMillis = showTimeMillis;
+               setWidget(new Label(text));
+               closeTimer = new Timer() {
+
+                       @Override
+                       public void run() {
+                               hide(false);
+                       }
+                       
+               };
+               setAnimationEnabled(true);
+               setAutoHideEnabled(true);
+       }
+       
+       public void show() {
+               closeTimer.schedule(showTimeMillis);
+               super.show();
+       }
+       /**
+        * Text to show 
+        * 
+        * @param text
+        */
+       public ToolTip(String text) {
+               this(text,3000);
+       }
+       
+       /**
+        * Set milliseconds to show the Text
+        * @param showTimeMillis
+        */
+       public void setShowTime(int showTimeMillis) {
+               this.showTimeMillis = showTimeMillis;
+       }
+       
+       /**
+        * Return the time in milliseconds 
+        * 
+        * @return showTimeMillis
+        */
+       public int getShowTime() {
+               return showTimeMillis;
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see 
com.google.gwt.event.logical.shared.CloseHandler#onClose(com.google.gwt.event.logical.shared.CloseEvent)
+        */
+       public void onClose(CloseEvent<ToolTip> event) {
+               // Cancel the timer on close
+               closeTimer.cancel();
+       }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to