Return-Path: Delivered-To: apmail-labs-commits-archive@minotaur.apache.org Received: (qmail 5387 invoked from network); 12 Jul 2009 17:56:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 12 Jul 2009 17:56:34 -0000 Received: (qmail 33734 invoked by uid 500); 12 Jul 2009 17:56:44 -0000 Delivered-To: apmail-labs-commits-archive@labs.apache.org Received: (qmail 33598 invoked by uid 500); 12 Jul 2009 17:56:43 -0000 Mailing-List: contact commits-help@labs.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: labs@labs.apache.org Delivered-To: mailing list commits@labs.apache.org Received: (qmail 33589 invoked by uid 99); 12 Jul 2009 17:56:43 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 12 Jul 2009 17:56:43 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 12 Jul 2009 17:56:40 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 58E982388891; Sun, 12 Jul 2009 17:56:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r793383 - /labs/hupa/src/main/java/org/apache/hupa/client/widgets/ToolTip.java Date: Sun, 12 Jul 2009 17:56:19 -0000 To: commits@labs.apache.org From: norman@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090712175619.58E982388891@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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{ + + 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 event) { + // Cancel the timer on close + closeTimer.cancel(); + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org For additional commands, e-mail: commits-help@labs.apache.org