001 // Copyright 2004, 2005 The Apache Software Foundation
002 //
003 // Licensed under the Apache License, Version 2.0 (the "License");
004 // you may not use this file except in compliance with the License.
005 // You may obtain a copy of the License at
006 //
007 // http://www.apache.org/licenses/LICENSE-2.0
008 //
009 // Unless required by applicable law or agreed to in writing, software
010 // distributed under the License is distributed on an "AS IS" BASIS,
011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012 // See the License for the specific language governing permissions and
013 // limitations under the License.
014
015 package org.apache.tapestry.components;
016
017 /**
018 * Different types of JavaScript events that an {@link ILinkComponent} can provide handlers for.
019 *
020 * @author Howard Lewis Ship
021 * @since 0.2.9
022 */
023
024 public class LinkEventType
025 {
026 private final String _name;
027
028 private final String _attributeName;
029
030 /**
031 * Type for <code>onMouseOver</code>. This may also be called "focus".
032 */
033
034 public static final LinkEventType MOUSE_OVER = new LinkEventType("MOUSE_OVER", "onMouseOver");
035
036 /**
037 * Type for <code>onMouseOut</code>. This may also be called "blur".
038 */
039
040 public static final LinkEventType MOUSE_OUT = new LinkEventType("MOUSE_OUT", "onMouseOut");
041
042 /**
043 * Type for <code>onClick</code>.
044 *
045 * @since 1.0.1
046 */
047
048 public static final LinkEventType CLICK = new LinkEventType("CLICK", "onClick");
049
050 /**
051 * Type for <code>onDblClick</code>.
052 *
053 * @since 1.0.1
054 */
055
056 public static final LinkEventType DOUBLE_CLICK = new LinkEventType("DOUBLE_CLICK", "onDblClick");
057
058 /**
059 * Type for <code>onMouseDown</code>.
060 *
061 * @since 1.0.1.
062 */
063
064 public static final LinkEventType MOUSE_DOWN = new LinkEventType("MOUSE_DOWN", "onMouseDown");
065
066 /**
067 * Type for <code>onMouseUp</code>.
068 *
069 * @since 1.0.1
070 */
071
072 public static final LinkEventType MOUSE_UP = new LinkEventType("MOUSE_UP", "onMouseUp");
073
074 /**
075 * Constructs a new type of event. The name should match the static final variable (i.e.,
076 * MOUSE_OVER) and the attributeName is the name of the HTML attribute to be managed (i.e.,
077 * "onMouseOver").
078 * <p>
079 * This method is protected so that subclasses can be created to provide additional managed
080 * event types.
081 */
082
083 protected LinkEventType(String name, String attributeName)
084 {
085
086 _name = name;
087 _attributeName = attributeName;
088 }
089
090 /**
091 * Returns the name of the HTML attribute corresponding to this type.
092 */
093
094 public String getAttributeName()
095 {
096 return _attributeName;
097 }
098
099 public String toString()
100 {
101 return "LinkEventType[" + _name + "]";
102 }
103 }