import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
-import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Widget;
/* Extended title handling */
- /**
- * Data showed in tooltips are stored centrilized as it may be needed in
- * varios place: caption, layouts, and in owner components themselves.
- *
- * Updating TooltipInfo is done in updateComponent method.
- *
- */
- public TooltipInfo getTooltipTitleInfo(ComponentConnector titleOwner,
- Object key) {
- if (null == titleOwner) {
- return null;
- }
- return connectorMap.getTooltipInfo(titleOwner, key);
- }
-
private final VTooltip tooltip = new VTooltip(this);
- /**
- * Component may want to delegate Tooltip handling to client. Layouts add
- * Tooltip (description, errors) to caption, but some components may want
- * them to appear one other elements too.
- *
- * Events wanted by this handler are same as in Tooltip.TOOLTIP_EVENTS
- *
- * @param event
- * @param owner
- */
- public void handleTooltipEvent(Event event, ComponentConnector owner) {
- tooltip.handleTooltipEvent(event, owner, null);
-
- }
-
- /**
- * Component may want to delegate Tooltip handling to client. Layouts add
- * Tooltip (description, errors) to caption, but some components may want
- * them to appear one other elements too.
- *
- * Events wanted by this handler are same as in Tooltip.TOOLTIP_EVENTS
- *
- * @param event
- * @param owner
- * @param key
- * the key for tooltip if this is "additional" tooltip, null for
- * components "main tooltip"
- */
- public void handleTooltipEvent(Event event, ComponentConnector owner,
- Object key) {
- tooltip.handleTooltipEvent(event, owner, key);
-
- }
-
private ConnectorMap connectorMap = GWT.create(ConnectorMap.class);
protected String getUidlSecurityKey() {
return rootConnector;
}
- /**
- * If component has several tooltips in addition to the one provided by
- * {@link com.vaadin.ui.AbstractComponent}, component can register them with
- * this method.
- * <p>
- * Component must also pipe events to
- * {@link #handleTooltipEvent(Event, ComponentConnector, Object)} method.
- * <p>
- * This method can also be used to deregister tooltips by using null as
- * tooltip
- *
- * @param paintable
- * Paintable "owning" this tooltip
- * @param key
- * key assosiated with given tooltip. Can be any object. For
- * example a related dom element. Same key must be given for
- * {@link #handleTooltipEvent(Event, ComponentConnector, Object)}
- * method.
- *
- * @param tooltip
- * the TooltipInfo object containing details shown in tooltip,
- * null if deregistering tooltip
- */
- public void registerTooltip(ComponentConnector paintable, Object key,
- TooltipInfo tooltip) {
- connectorMap.registerTooltip(paintable, key, tooltip);
- }
-
/**
* Gets the {@link ApplicationConfiguration} for the current application.
*
// connectorMap.unregisterConnector(p);
}
+ /**
+ * Get VTooltip instance related to application connection
+ *
+ * @return VTooltip instance
+ */
public VTooltip getVTooltip() {
return tooltip;
}
- @Deprecated
- public void handleTooltipEvent(Event event, Widget owner, Object key) {
- handleTooltipEvent(event, getConnectorMap().getConnector(owner), key);
- }
-
/**
* Method provided for backwards compatibility. Duties previously done by
* this method is now handled by the state change event handler in
return false;
}
- @Deprecated
- public void handleTooltipEvent(Event event, Widget owner) {
- handleTooltipEvent(event, getConnectorMap().getConnector(owner));
-
- }
-
- @Deprecated
- public void registerTooltip(Widget owner, Object key, TooltipInfo info) {
- registerTooltip(getConnectorMap().getConnector(owner), key, info);
- }
-
@Deprecated
public boolean hasEventListeners(Widget widget, String eventIdentifier) {
return hasEventListeners(getConnectorMap().getConnector(widget),
package com.vaadin.terminal.gwt.client;
+import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.ui.Widget;
/**
*/
public void setWidgetEnabled(boolean widgetEnabled);
+ /**
+ * Gets the tooltip info for the given element.
+ *
+ * @param element
+ * The element to lookup a tooltip for
+ * @return The tooltip for the element or null if no tooltip is defined for
+ * this element.
+ */
+ public TooltipInfo getTooltipInfo(Element element);
+
}
return idToConnector.size();
}
- /**
- * FIXME: Should be moved to VAbstractPaintableWidget
- *
- * @param paintable
- * @return
- */
- @Deprecated
- public TooltipInfo getTooltipInfo(ComponentConnector paintable, Object key) {
- ComponentDetail componentDetail = getComponentDetail(paintable);
- if (componentDetail == null) {
- return null;
- }
- return componentDetail.getTooltipInfo(key);
- }
-
- @Deprecated
- public TooltipInfo getWidgetTooltipInfo(Widget widget, Object key) {
- ComponentConnector connector = getConnector(widget);
- if (connector == null) {
- return null;
- }
- return getTooltipInfo(connector, key);
- }
-
public Collection<? extends ServerConnector> getConnectors() {
return Collections.unmodifiableCollection(idToConnector.values());
}
- /**
- * FIXME: Should not be here
- *
- * @param componentConnector
- * @return
- */
- @Deprecated
- public void registerTooltip(ComponentConnector componentConnector,
- Object key, TooltipInfo tooltip) {
- getComponentDetail(componentConnector).putAdditionalTooltip(key,
- tooltip);
-
- }
-
/**
* Tests if the widget is the root widget of a {@link ComponentConnector}.
*
setTitle(tooltip);
}
+ public TooltipInfo(String tooltip, String errorMessage) {
+ setTitle(tooltip);
+ setErrorMessage(errorMessage);
+ }
+
public String getTitle() {
return title;
}
errorMessageHtml = errorMessage;
}
+ /**
+ * Checks is a message has been defined for the tooltip.
+ *
+ * @return true if title or error message is present, false if both are
+ * empty
+ */
+ public boolean hasMessage() {
+ return (title != null && !title.isEmpty())
+ || (errorMessageHtml != null && errorMessageHtml.isEmpty());
+ }
+
+ public boolean equals(TooltipInfo other) {
+ return (other != null && other.title == title && other.errorMessageHtml == errorMessageHtml);
+ }
}
ICON, CAPTION, REQUIRED, ERROR
}
+ private TooltipInfo tooltipInfo = null;
+
/**
* Creates a caption that is not linked to a {@link ComponentConnector}.
*
}
setStyleName(CLASSNAME);
- sinkEvents(VTooltip.TOOLTIP_EVENTS);
-
}
/**
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
final Element target = DOM.eventGetTarget(event);
- if (client != null && owner != null && target != getElement()) {
- client.handleTooltipEvent(event, owner);
- }
if (DOM.eventGetType(event) == Event.ONLOAD
&& icon.getElement() == target) {
}
}
+ /**
+ * Sets the tooltip that should be shown for the caption
+ *
+ * @param tooltipInfo
+ * The tooltip that should be shown or null if no tooltip should
+ * be shown
+ */
+ public void setTooltipInfo(TooltipInfo tooltipInfo) {
+ this.tooltipInfo = tooltipInfo;
+ }
+
+ /**
+ * Returns the tooltip that should be shown for the caption
+ *
+ * @return The tooltip to show or null if no tooltip should be shown
+ */
+ public TooltipInfo getTooltipInfo() {
+ return tooltipInfo;
+ }
+
protected Element getTextElement() {
return captionText;
}
*/
package com.vaadin.terminal.gwt.client;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.event.dom.client.KeyDownEvent;
+import com.google.gwt.event.dom.client.KeyDownHandler;
+import com.google.gwt.event.dom.client.MouseMoveEvent;
+import com.google.gwt.event.dom.client.MouseMoveHandler;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.FlowPanel;
+import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ui.VOverlay;
/**
private static final int QUICK_OPEN_DELAY = 100;
VErrorMessage em = new VErrorMessage();
Element description = DOM.createDiv();
- private ComponentConnector tooltipOwner;
private boolean closing = false;
private boolean opening = false;
private ApplicationConnection ac;
// Open next tooltip faster. Disabled after 2 sec of showTooltip-silence.
private boolean justClosed = false;
- // If this is "additional" tooltip, this field contains the key for it
- private Object tooltipKey;
public VTooltip(ApplicationConnection client) {
super(false, false, true);
}
}
- public void showTooltip(ComponentConnector owner, Event event, Object key) {
- if (closing && tooltipOwner == owner && tooltipKey == key) {
- // return to same tooltip, cancel closing
- closeTimer.cancel();
- closing = false;
- justClosedTimer.cancel();
- justClosed = false;
- return;
- }
+ private void showTooltip() {
- if (closing) {
+ // Close current tooltip
+ if (isShowing()) {
closeNow();
}
- updatePosition(event);
-
- if (opening) {
- showTimer.cancel();
- }
- tooltipOwner = owner;
- tooltipKey = key;
-
// Schedule timer for showing the tooltip according to if it was
// recently closed or not.
- if (justClosed) {
- showTimer.schedule(QUICK_OPEN_DELAY);
- } else {
- showTimer.schedule(OPEN_DELAY);
- }
+ int timeout = justClosed ? QUICK_OPEN_DELAY : OPEN_DELAY;
+ showTimer.schedule(timeout);
opening = true;
}
private void closeNow() {
- if (closing) {
- hide();
- tooltipOwner = null;
- setWidth("");
- closing = false;
- }
+ hide();
+ setWidth("");
+ closing = false;
}
private Timer showTimer = new Timer() {
@Override
public void run() {
- TooltipInfo info = ac.getTooltipTitleInfo(tooltipOwner, tooltipKey);
+ TooltipInfo info = tooltipEventHandler.getTooltipInfo();
if (null != info) {
show(info);
}
if (opening) {
showTimer.cancel();
opening = false;
- tooltipOwner = null;
}
if (!isAttached()) {
return;
public void updatePosition(Event event) {
tooltipEventMouseX = DOM.eventGetClientX(event);
tooltipEventMouseY = DOM.eventGetClientY(event);
-
- }
-
- public void handleTooltipEvent(Event event, ComponentConnector owner,
- Object key) {
- final int type = DOM.eventGetType(event);
- if ((VTooltip.TOOLTIP_EVENTS & type) == type) {
- if (type == Event.ONMOUSEOVER) {
- showTooltip(owner, event, key);
- } else if (type == Event.ONMOUSEMOVE) {
- updatePosition(event);
- } else {
- hideTooltip();
- }
- } else {
- // non-tooltip event, hide tooltip
- hideTooltip();
- }
}
@Override
// cancel closing event if tooltip is mouseovered; the user might want
// to scroll of cut&paste
- switch (type) {
- case Event.ONMOUSEOVER:
+ if (type == Event.ONMOUSEOVER) {
+ // Cancel closing so tooltip stays open and user can copy paste the
+ // tooltip
closeTimer.cancel();
closing = false;
- break;
- case Event.ONMOUSEOUT:
+ }
+ }
+
+ /**
+ * Replace current open tooltip with new content
+ */
+ public void replaceCurrentTooltip() {
+ if (closing) {
+ closeTimer.cancel();
+ closeNow();
+ }
+
+ TooltipInfo info = tooltipEventHandler.getTooltipInfo();
+ if (null != info) {
+ show(info);
+ }
+ opening = false;
+ }
+
+ private class TooltipEventHandler implements MouseMoveHandler,
+ ClickHandler, KeyDownHandler {
+
+ /**
+ * Current element hovered
+ */
+ private com.google.gwt.dom.client.Element currentElement = null;
+
+ /**
+ * Current tooltip active
+ */
+ private TooltipInfo currentTooltipInfo = null;
+
+ /**
+ * Get current active tooltip information
+ *
+ * @return Current active tooltip information or null
+ */
+ public TooltipInfo getTooltipInfo() {
+ return currentTooltipInfo;
+ }
+
+ /**
+ * Locate connector and it's tooltip for given element
+ *
+ * @param element
+ * Element used in search
+ * @return true if connector and tooltip found
+ */
+ private boolean resolveConnector(Element element) {
+
+ ComponentConnector connector = Util.getConnectorForElement(ac, ac
+ .getRootConnector().getWidget(), element);
+
+ // Try to find first connector with proper tooltip info
+ TooltipInfo info = null;
+ while (connector != null) {
+
+ info = connector.getTooltipInfo(element);
+
+ if (info != null && info.hasMessage()) {
+ break;
+ }
+
+ if (!(connector.getParent() instanceof ComponentConnector)) {
+ connector = null;
+ info = null;
+ break;
+ }
+ connector = (ComponentConnector) connector.getParent();
+ }
+
+ if (connector != null && info != null) {
+ currentTooltipInfo = info;
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Handle hide event
+ *
+ * @param event
+ * Event causing hide
+ */
+ private void handleHideEvent() {
hideTooltip();
- break;
- default:
- // NOP
+ currentTooltipInfo = null;
+ }
+
+ public void onMouseMove(MouseMoveEvent mme) {
+ Event event = Event.as(mme.getNativeEvent());
+ com.google.gwt.dom.client.Element element = Element.as(event
+ .getEventTarget());
+
+ // We can ignore move event if it's handled by move or over already
+ if (currentElement == element) {
+ return;
+ }
+ currentElement = element;
+
+ boolean connectorAndTooltipFound = resolveConnector((com.google.gwt.user.client.Element) element);
+ if (!connectorAndTooltipFound) {
+ if (isShowing()) {
+ handleHideEvent();
+ } else {
+ currentTooltipInfo = null;
+ }
+ } else {
+ updatePosition(event);
+ if (isShowing()) {
+ replaceCurrentTooltip();
+ } else {
+ showTooltip();
+ }
+ }
+ }
+
+ public void onClick(ClickEvent event) {
+ handleHideEvent();
+ }
+
+ public void onKeyDown(KeyDownEvent event) {
+ handleHideEvent();
}
}
+ private final TooltipEventHandler tooltipEventHandler = new TooltipEventHandler();
+
+ /**
+ * Connects DOM handlers to widget that are needed for tooltip presentation.
+ *
+ * @param widget
+ * Widget which DOM handlers are connected
+ */
+ public void connectHandlersToWidget(Widget widget) {
+ widget.addDomHandler(tooltipEventHandler, MouseMoveEvent.getType());
+ widget.addDomHandler(tooltipEventHandler, ClickEvent.getType());
+ widget.addDomHandler(tooltipEventHandler, KeyDownEvent.getType());
+ }
}
import java.util.Set;
+import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.ui.Focusable;
import com.google.gwt.user.client.ui.HasEnabled;
import com.google.gwt.user.client.ui.Widget;
public AbstractComponentConnector() {
}
+ @Override
+ protected void init() {
+ super.init();
+ getConnection().getVTooltip().connectHandlersToWidget(getWidget());
+ }
+
/**
* Creates and returns the widget for this VPaintableWidget. This method
* should only be called once when initializing the paintable.
String styleName = getStyleNames(getWidget().getStylePrimaryName());
getWidget().setStyleName(styleName);
- // Update tooltip
- TooltipInfo tooltipInfo = paintableMap.getTooltipInfo(this, null);
- if (getState().hasDescription()) {
- tooltipInfo.setTitle(getState().getDescription());
- } else {
- tooltipInfo.setTitle(null);
- }
- // add error info to tooltip if present
- tooltipInfo.setErrorMessage(getState().getErrorMessage());
-
// Set captions
if (delegateCaptionHandling()) {
ServerConnector parent = getParent();
+ ") has been unregistered. Widget was removed.");
}
}
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.vaadin.terminal.gwt.client.ComponentConnector#getTooltipInfo(com.
+ * google.gwt.dom.client.Element)
+ */
+ public TooltipInfo getTooltipInfo(Element element) {
+ return new TooltipInfo(getState().getDescription(), getState()
+ .getErrorMessage());
+ }
}
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
import com.vaadin.terminal.gwt.client.Util;
-import com.vaadin.terminal.gwt.client.VTooltip;
import com.vaadin.terminal.gwt.client.ui.Icon;
public class VButton extends FocusWidget implements ClickHandler {
setTabIndex(0);
sinkEvents(Event.ONCLICK | Event.MOUSEEVENTS | Event.FOCUSEVENTS
| Event.KEYEVENTS);
- sinkEvents(VTooltip.TOOLTIP_EVENTS);
setStyleName(CLASSNAME);
* -onload event handler added (for icon handling)
*/
public void onBrowserEvent(Event event) {
- if (client != null) {
- client.handleTooltipEvent(event, this);
- }
if (DOM.eventGetType(event) == Event.ONLOAD) {
Util.notifyParentOfSizeChange(this, true);
}
public VCheckBox() {
setStyleName(CLASSNAME);
- sinkEvents(VTooltip.TOOLTIP_EVENTS);
Element el = DOM.getFirstChild(getElement());
while (el != null) {
DOM.sinkEvents(el,
if (event.getTypeInt() == Event.ONLOAD) {
Util.notifyParentOfSizeChange(this, true);
}
- if (client != null) {
- client.handleTooltipEvent(event, this);
- }
}
}
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.VConsole;
-import com.vaadin.terminal.gwt.client.VTooltip;
import com.vaadin.terminal.gwt.client.ui.Field;
import com.vaadin.terminal.gwt.client.ui.SubPartAware;
import com.vaadin.terminal.gwt.client.ui.VLazyExecutor;
* The text box where the filter is written
*/
protected final TextBox tb = new TextBox() {
- /*
- * (non-Javadoc)
- *
- * @see
- * com.google.gwt.user.client.ui.TextBoxBase#onBrowserEvent(com.google
- * .gwt.user.client.Event)
- */
-
- @Override
- public void onBrowserEvent(Event event) {
- super.onBrowserEvent(event);
- if (client != null) {
- client.handleTooltipEvent(event, VFilterSelect.this);
- }
- }
// Overridden to avoid selecting text when text input is disabled
@Override
@Override
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
- if (client != null) {
- client.handleTooltipEvent(event, VFilterSelect.this);
- }
/*
* Prevent the keyboard focus from leaving the textfield by
}
});
- tb.sinkEvents(VTooltip.TOOLTIP_EVENTS);
- popupOpener.sinkEvents(VTooltip.TOOLTIP_EVENTS | Event.ONMOUSEDOWN);
+ popupOpener.sinkEvents(Event.ONMOUSEDOWN);
panel.add(tb);
panel.add(popupOpener);
initWidget(panel);
import java.util.Date;
-import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.FlowPanel;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.DateTimeService;
-import com.vaadin.terminal.gwt.client.VTooltip;
import com.vaadin.terminal.gwt.client.ui.Field;
public class VDateField extends FlowPanel implements Field {
public VDateField() {
setStyleName(CLASSNAME);
dts = new DateTimeService();
- sinkEvents(VTooltip.TOOLTIP_EVENTS);
- }
-
- @Override
- public void onBrowserEvent(Event event) {
- super.onBrowserEvent(event);
- if (client != null) {
- client.handleTooltipEvent(event, this);
- }
}
/*
import com.vaadin.terminal.gwt.client.MouseEventDetailsBuilder;
import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.VConsole;
-import com.vaadin.terminal.gwt.client.VTooltip;
import com.vaadin.terminal.gwt.client.ValueMap;
import com.vaadin.terminal.gwt.client.ui.customcomponent.VCustomComponent;
import com.vaadin.terminal.gwt.client.ui.dd.DDUtil;
public VDragAndDropWrapper() {
super();
- sinkEvents(VTooltip.TOOLTIP_EVENTS);
hookHtml5Events(getElement());
setStyleName(CLASSNAME);
sinkEvents(Event.TOUCHEVENTS);
}
- @Override
- public void onBrowserEvent(Event event) {
- super.onBrowserEvent(event);
-
- if (hasTooltip && client != null) {
- // Override child tooltips if the wrapper has a tooltip defined
- client.handleTooltipEvent(event, this);
- }
- }
-
/**
* Starts a drag and drop operation from mousedown or touchstart event if
* required conditions are met.
VConsole.log("Embeddable onload");
Util.notifyParentOfSizeChange(this, true);
}
-
- client.handleTooltipEvent(event, this);
}
}
*/
package com.vaadin.terminal.gwt.client.ui.formlayout;
+import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ComponentConnector;
import com.vaadin.terminal.gwt.client.ConnectorHierarchyChangeEvent;
+import com.vaadin.terminal.gwt.client.TooltipInfo;
+import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.communication.StateChangeEvent;
import com.vaadin.terminal.gwt.client.ui.AbstractFieldConnector;
import com.vaadin.terminal.gwt.client.ui.AbstractLayoutConnector;
return (VFormLayout) super.getWidget();
}
+ @Override
+ public TooltipInfo getTooltipInfo(Element element) {
+ TooltipInfo info = null;
+
+ if (element != getWidget().getElement()) {
+ Object node = Util.findWidget(
+ (com.google.gwt.user.client.Element) element,
+ VFormLayout.Caption.class);
+
+ if (node != null) {
+ VFormLayout.Caption caption = (VFormLayout.Caption) node;
+ info = caption.getOwner().getTooltipInfo(element);
+ } else {
+
+ node = Util.findWidget(
+ (com.google.gwt.user.client.Element) element,
+ VFormLayout.ErrorFlag.class);
+
+ if (node != null) {
+ VFormLayout.ErrorFlag flag = (VFormLayout.ErrorFlag) node;
+ info = flag.getOwner().getTooltipInfo(element);
+ }
+ }
+ }
+
+ if (info == null) {
+ info = super.getTooltipInfo(element);
+ }
+
+ return info;
+ }
+
}
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
-import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.SimplePanel;
public Caption(ComponentConnector component) {
super();
owner = component;
-
- sinkEvents(VTooltip.TOOLTIP_EVENTS);
}
private void setStyles(String[] styles) {
public ComponentConnector getOwner() {
return owner;
}
-
- @Override
- public void onBrowserEvent(Event event) {
- super.onBrowserEvent(event);
- owner.getConnection().handleTooltipEvent(event, owner);
- }
}
class ErrorFlag extends HTML {
this.owner = owner;
}
+ public ComponentConnector getOwner() {
+ return owner;
+ }
+
public void updateError(String errorMessage, boolean hideErrors) {
boolean showError = null != errorMessage;
if (hideErrors) {
}
}
- @Override
- public void onBrowserEvent(Event event) {
- super.onBrowserEvent(event);
- if (owner != null) {
- owner.getConnection().handleTooltipEvent(event, owner);
- }
- }
-
}
}
public VLabel(String text) {
super(text);
setStyleName(CLASSNAME);
- sinkEvents(VTooltip.TOOLTIP_EVENTS);
}
@Override
event.stopPropagation();
return;
}
- if (connection != null) {
- connection.handleTooltipEvent(event, this);
- }
}
@Override
import com.google.gwt.user.client.ui.HTML;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.Util;
-import com.vaadin.terminal.gwt.client.VTooltip;
import com.vaadin.terminal.gwt.client.ui.Icon;
public class VLink extends HTML implements ClickHandler {
getElement().appendChild(anchor);
anchor.appendChild(captionElement);
addClickHandler(this);
- sinkEvents(VTooltip.TOOLTIP_EVENTS);
setStyleName(CLASSNAME);
}
if (event.getTypeInt() == Event.ONLOAD) {
Util.notifyParentOfSizeChange(this, true);
}
- if (client != null) {
- client.handleTooltipEvent(event, this);
- }
if (target == captionElement || target == anchor
|| (icon != null && target == icon.getElement())) {
super.onBrowserEvent(event);
+++ /dev/null
-/*
-@VaadinApache2LicenseForJavaFiles@
- */
-package com.vaadin.terminal.gwt.client.ui.listselect;
-
-import com.google.gwt.user.client.Event;
-import com.google.gwt.user.client.ui.ListBox;
-import com.google.gwt.user.client.ui.Widget;
-import com.vaadin.terminal.gwt.client.ApplicationConnection;
-import com.vaadin.terminal.gwt.client.VTooltip;
-
-/**
- * Extended ListBox to listen tooltip events and forward them to generic
- * handler.
- */
-public class TooltipListBox extends ListBox {
- private ApplicationConnection client;
- private Widget widget;
-
- public TooltipListBox(boolean isMultiselect) {
- super(isMultiselect);
- sinkEvents(VTooltip.TOOLTIP_EVENTS);
- }
-
- public void setClient(ApplicationConnection client) {
- this.client = client;
- }
-
- public void setSelect(Widget widget) {
- this.widget = widget;
- }
-
- @Override
- public void onBrowserEvent(Event event) {
- super.onBrowserEvent(event);
- if (client != null) {
- client.handleTooltipEvent(event, widget);
- }
- }
-
-}
\ No newline at end of file
import java.util.Iterator;
import com.google.gwt.event.dom.client.ChangeEvent;
+import com.google.gwt.user.client.ui.ListBox;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.ui.optiongroup.VOptionGroupBase;
private static final int VISIBLE_COUNT = 10;
- protected TooltipListBox select;
+ protected ListBox select;
private int lastSelectedIndex = -1;
public VListSelect() {
- super(new TooltipListBox(true), CLASSNAME);
- select = (TooltipListBox) optionsContainer;
- select.setSelect(this);
+ super(new ListBox(true), CLASSNAME);
+ select = getOptionsContainer();
select.addChangeHandler(this);
select.addClickHandler(this);
select.setStyleName(CLASSNAME + "-select");
select.setVisibleItemCount(VISIBLE_COUNT);
}
+ protected ListBox getOptionsContainer() {
+ return (ListBox) optionsContainer;
+ }
+
@Override
protected void buildOptions(UIDL uidl) {
- select.setClient(client);
select.setMultipleSelect(isMultiselect());
select.setEnabled(!isDisabled() && !isReadonly());
select.clear();
@Override
protected void setTabIndex(int tabIndex) {
- ((TooltipListBox) optionsContainer).setTabIndex(tabIndex);
+ getOptionsContainer().setTabIndex(tabIndex);
}
public void focus() {
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
import com.vaadin.terminal.gwt.client.LayoutManager;
-import com.vaadin.terminal.gwt.client.TooltipInfo;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.Util;
-import com.vaadin.terminal.gwt.client.VTooltip;
import com.vaadin.terminal.gwt.client.ui.Icon;
import com.vaadin.terminal.gwt.client.ui.SimpleFocusablePanel;
import com.vaadin.terminal.gwt.client.ui.SubPartAware;
sinkEvents(Event.ONCLICK | Event.ONMOUSEOVER | Event.ONMOUSEOUT
| Event.ONLOAD);
-
- sinkEvents(VTooltip.TOOLTIP_EVENTS);
}
@Override
}
}
- // Handle tooltips
- if (targetItem == null && client != null) {
- // Handle root menubar tooltips
- client.handleTooltipEvent(e, this);
- } else if (targetItem != null) {
- // Handle item tooltips
- targetItem.onBrowserEvent(e);
- }
-
if (targetItem != null) {
switch (DOM.eventGetType(e)) {
setSelected(false);
setStyleName(CLASSNAME + "-menuitem");
- sinkEvents(VTooltip.TOOLTIP_EVENTS);
}
public void setSelected(boolean selected) {
addStyleDependentName(itemStyle);
}
- if (uidl.hasAttribute(ATTRIBUTE_ITEM_DESCRIPTION)) {
- String description = uidl
- .getStringAttribute(ATTRIBUTE_ITEM_DESCRIPTION);
- TooltipInfo info = new TooltipInfo(description);
-
- VMenuBar root = findRootMenu();
- client.registerTooltip(root, this, info);
- }
- }
-
- @Override
- public void onBrowserEvent(Event event) {
- super.onBrowserEvent(event);
- if (client != null) {
- client.handleTooltipEvent(event, findRootMenu(), this);
- }
}
private VMenuBar findRootMenu() {
import com.vaadin.terminal.gwt.client.MouseEventDetails;
import com.vaadin.terminal.gwt.client.MouseEventDetailsBuilder;
import com.vaadin.terminal.gwt.client.Util;
-import com.vaadin.terminal.gwt.client.VTooltip;
import com.vaadin.terminal.gwt.client.ui.Icon;
import com.vaadin.terminal.gwt.client.ui.button.ButtonServerRpc;
addClickHandler(this);
- sinkEvents(VTooltip.TOOLTIP_EVENTS);
sinkEvents(Event.ONMOUSEDOWN);
sinkEvents(Event.ONMOUSEUP);
}
}
clickPending = false;
}
-
- if (client != null) {
- client.handleTooltipEvent(event, this);
- }
}
@Override
import java.util.Iterator;
import com.google.gwt.event.dom.client.ChangeEvent;
+import com.google.gwt.user.client.ui.ListBox;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.ui.Field;
-import com.vaadin.terminal.gwt.client.ui.listselect.TooltipListBox;
import com.vaadin.terminal.gwt.client.ui.optiongroup.VOptionGroupBase;
public class VNativeSelect extends VOptionGroupBase implements Field {
public static final String CLASSNAME = "v-select";
- protected TooltipListBox select;
+ protected ListBox select;
private boolean firstValueIsTemporaryNullItem = false;
public VNativeSelect() {
- super(new TooltipListBox(false), CLASSNAME);
- select = (TooltipListBox) optionsContainer;
- select.setSelect(this);
+ super(new ListBox(false), CLASSNAME);
+ select = getOptionsContainer();
select.setVisibleItemCount(1);
select.addChangeHandler(this);
select.setStyleName(CLASSNAME + "-select");
}
+ protected ListBox getOptionsContainer() {
+ return (ListBox) optionsContainer;
+ }
+
@Override
protected void buildOptions(UIDL uidl) {
- select.setClient(client);
select.setEnabled(!isDisabled() && !isReadonly());
select.clear();
firstValueIsTemporaryNullItem = false;
@Override
protected void setTabIndex(int tabIndex) {
- ((TooltipListBox) optionsContainer).setTabIndex(tabIndex);
+ getOptionsContainer().setTabIndex(tabIndex);
}
public void focus() {
@Override
public void init() {
+ super.init();
rpc = RpcProxy.create(AbstractOrderedLayoutServerRpc.class, this);
getLayoutManager().registerDependency(this,
getWidget().spacingMeasureElement);
@Override
public void init() {
+ super.init();
rpc = RpcProxy.create(PanelServerRpc.class, this);
VPanel panel = getWidget();
LayoutManager layoutManager = getLayoutManager();
client.updateVariable(id, "scrollTop", scrollTop, false);
client.updateVariable(id, "scrollLeft", scrollLeft, false);
}
- } else if (captionNode.isOrHasChild(target)) {
- if (client != null) {
- client.handleTooltipEvent(event, this);
- }
}
}
import com.vaadin.terminal.gwt.client.ComponentConnector;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.VCaptionWrapper;
-import com.vaadin.terminal.gwt.client.VTooltip;
import com.vaadin.terminal.gwt.client.ui.VOverlay;
import com.vaadin.terminal.gwt.client.ui.richtextarea.VRichTextArea;
});
popup.setAnimationEnabled(true);
- sinkEvents(VTooltip.TOOLTIP_EVENTS);
}
/**
}// class CustomPopup
- @Override
- public void onBrowserEvent(Event event) {
- super.onBrowserEvent(event);
- if (client != null) {
- client.handleTooltipEvent(event, this);
- }
- }
-
}// class VPopupView
import com.vaadin.terminal.gwt.client.ContainerResizedListener;
import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.VConsole;
-import com.vaadin.terminal.gwt.client.VTooltip;
import com.vaadin.terminal.gwt.client.ui.Field;
import com.vaadin.terminal.gwt.client.ui.SimpleFocusablePanel;
import com.vaadin.terminal.gwt.client.ui.VLazyExecutor;
feedbackPopup.addStyleName(CLASSNAME + "-feedback");
feedbackPopup.setWidget(feedback);
-
- sinkEvents(VTooltip.TOOLTIP_EVENTS);
}
void setFeedbackValue(double value) {
event.preventDefault(); // avoid simulated events
event.stopPropagation();
}
- if (client != null) {
- client.handleTooltipEvent(event, this);
- }
}
private void processMouseWheelEvent(final Event event) {
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
+import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style.Position;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.DirectionalManagedLayout;
import com.vaadin.terminal.gwt.client.Paintable;
import com.vaadin.terminal.gwt.client.ServerConnector;
+import com.vaadin.terminal.gwt.client.TooltipInfo;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.ui.AbstractComponentContainerConnector;
}
}
+ @Override
+ public TooltipInfo getTooltipInfo(Element element) {
+
+ TooltipInfo info = null;
+
+ if (element != getWidget().getElement()) {
+ Object node = Util.findWidget(
+ (com.google.gwt.user.client.Element) element,
+ VScrollTableRow.class);
+
+ if (node != null) {
+ VScrollTableRow row = (VScrollTableRow) node;
+ info = row.getTooltip(element);
+ }
+ }
+
+ if (info == null) {
+ info = super.getTooltipInfo(element);
+ }
+
+ return info;
+ }
+
}
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import com.google.gwt.core.client.JavaScriptObject;
private void unlinkRowAtActualIndex(int index) {
final VScrollTableRow toBeRemoved = (VScrollTableRow) renderedRows
.get(index);
- // Unregister row tooltip
- client.registerTooltip(VScrollTable.this, toBeRemoved.getElement(),
- null);
- for (int i = 0; i < toBeRemoved.getElement().getChildCount(); i++) {
- // Unregister cell tooltips
- Element td = toBeRemoved.getElement().getChild(i).cast();
- client.registerTooltip(VScrollTable.this, td, null);
- }
tBodyElement.removeChild(toBeRemoved.getElement());
orphan(toBeRemoved);
renderedRows.remove(index);
private Timer dragTouchTimeout;
private int touchStartY;
private int touchStartX;
+ private TooltipInfo tooltipInfo = null;
+ private Map<TableCellElement, TooltipInfo> cellToolTips = new HashMap<TableCellElement, TooltipInfo>();
private boolean isDragging = false;
private VScrollTableRow(int rowKey) {
String rowDescription = uidl.getStringAttribute("rowdescr");
if (rowDescription != null && !rowDescription.equals("")) {
- TooltipInfo info = new TooltipInfo(rowDescription);
- client.registerTooltip(VScrollTable.this, rowElement, info);
+ tooltipInfo = new TooltipInfo(rowDescription);
} else {
- // Remove possibly previously set tooltip
- client.registerTooltip(VScrollTable.this, rowElement, null);
+ tooltipInfo = null;
}
tHead.getColumnAlignments();
}
}
+ public TooltipInfo getTooltipInfo() {
+ return tooltipInfo;
+ }
+
/**
* Add a dummy row, used for measurements if Table is empty.
*/
if (description != null && !description.equals("")) {
TooltipInfo info = new TooltipInfo(description);
- client.registerTooltip(VScrollTable.this, td, info);
+ cellToolTips.put(td, info);
} else {
- // Remove possibly previously set tooltip
- client.registerTooltip(VScrollTable.this, td, null);
+ cellToolTips.remove(td);
}
td.appendChild(container);
return true;
}
- private void handleTooltips(final Event event, Element target) {
+ public TooltipInfo getTooltip(
+ com.google.gwt.dom.client.Element target) {
+
+ TooltipInfo info = null;
+
if (target.hasTagName("TD")) {
- // Table cell (td)
- Element container = target.getFirstChildElement().cast();
- Element widget = container.getFirstChildElement().cast();
-
- boolean containsWidget = false;
- for (Widget w : childWidgets) {
- if (widget == w.getElement()) {
- containsWidget = true;
- break;
- }
- }
- if (!containsWidget) {
- // Only text nodes has tooltips
- if (ConnectorMap.get(client).getWidgetTooltipInfo(
- VScrollTable.this, target) != null) {
- // Cell has description, use it
- client.handleTooltipEvent(event, VScrollTable.this,
- target);
- } else {
- // Cell might have row description, use row
- // description
- client.handleTooltipEvent(event, VScrollTable.this,
- target.getParentElement());
- }
- }
+ TableCellElement td = (TableCellElement) target.cast();
+ info = cellToolTips.get(td);
+ }
- } else {
- // Table row (tr)
- client.handleTooltipEvent(event, VScrollTable.this, target);
+ if (info == null) {
+ info = tooltipInfo;
}
+
+ return info;
}
/**
}
boolean targetCellOrRowFound = targetTdOrTr != null;
- if (targetCellOrRowFound) {
- handleTooltips(event, targetTdOrTr);
- }
switch (type) {
case Event.ONDBLCLICK:
*/
package com.vaadin.terminal.gwt.client.ui.tabsheet;
-import com.google.gwt.core.client.GWT;
+import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.ComponentConnector;
+import com.vaadin.terminal.gwt.client.TooltipInfo;
import com.vaadin.terminal.gwt.client.UIDL;
+import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.ui.Connect;
import com.vaadin.terminal.gwt.client.ui.SimpleManagedLayout;
import com.vaadin.terminal.gwt.client.ui.layout.MayScrollChildren;
}
+ @Override
+ public TooltipInfo getTooltipInfo(Element element) {
+
+ TooltipInfo info = null;
+
+ // Find a tooltip for the tab, if the element is a tab
+ if (element != getWidget().getElement()) {
+ Object node = Util.findWidget(
+ (com.google.gwt.user.client.Element) element,
+ VTabsheet.TabCaption.class);
+
+ if (node != null) {
+ VTabsheet.TabCaption caption = (VTabsheet.TabCaption) node;
+ info = caption.getTooltipInfo();
+ }
+ }
+
+ // If not tab tooltip was found, use the default
+ if (info == null) {
+ info = super.getTooltipInfo(element);
+ }
+
+ return info;
+ }
+
}
}
}
- private static class TabCaption extends VCaption {
+ public static class TabCaption extends VCaption {
private boolean closable = false;
private Element closeButton;
public boolean updateCaption(UIDL uidl) {
if (uidl.hasAttribute(TabsheetBaseConnector.ATTRIBUTE_TAB_DESCRIPTION)) {
- TooltipInfo tooltipInfo = new TooltipInfo();
- tooltipInfo
- .setTitle(uidl
- .getStringAttribute(TabsheetBaseConnector.ATTRIBUTE_TAB_DESCRIPTION));
- tooltipInfo
- .setErrorMessage(uidl
- .getStringAttribute(TabsheetBaseConnector.ATTRIBUTE_TAB_ERROR_MESSAGE));
- client.registerTooltip(getTabsheet(), getElement(), tooltipInfo);
+ setTooltipInfo(new TooltipInfo(
+ uidl.getStringAttribute(TabsheetBaseConnector.ATTRIBUTE_TAB_DESCRIPTION),
+ uidl.getStringAttribute(TabsheetBaseConnector.ATTRIBUTE_TAB_ERROR_MESSAGE)));
} else {
- client.registerTooltip(getTabsheet(), getElement(), null);
+ setTooltipInfo(null);
}
// TODO need to call this instead of super because the caption does
if (event.getTypeInt() == Event.ONLOAD) {
getTabsheet().tabSizeMightHaveChanged(getTab());
}
- client.handleTooltipEvent(event, getTabsheet(), getElement());
}
public Tab getTab() {
import com.vaadin.terminal.gwt.client.BrowserInfo;
import com.vaadin.terminal.gwt.client.EventId;
import com.vaadin.terminal.gwt.client.Util;
-import com.vaadin.terminal.gwt.client.VTooltip;
import com.vaadin.terminal.gwt.client.ui.Field;
/**
}
addFocusHandler(this);
addBlurHandler(this);
- sinkEvents(VTooltip.TOOLTIP_EVENTS);
}
/*
@Override
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
- if (client != null) {
- client.handleTooltipEvent(event, this);
- }
if (listenTextChangeEvents
&& (event.getTypeInt() & TEXTCHANGE_EVENTS) == event
*/
package com.vaadin.terminal.gwt.client.ui.tree;
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
+import com.google.gwt.dom.client.Element;
import com.vaadin.terminal.gwt.client.AbstractFieldState;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
import com.vaadin.terminal.gwt.client.Paintable;
import com.vaadin.terminal.gwt.client.TooltipInfo;
import com.vaadin.terminal.gwt.client.UIDL;
+import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector;
import com.vaadin.terminal.gwt.client.ui.Connect;
import com.vaadin.terminal.gwt.client.ui.tree.VTree.TreeNode;
public static final String ATTRIBUTE_ACTION_CAPTION = "caption";
public static final String ATTRIBUTE_ACTION_ICON = ATTRIBUTE_NODE_ICON;
+ protected final Map<TreeNode, TooltipInfo> tooltipMap = new HashMap<TreeNode, TooltipInfo>();
+
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
if (!isRealUpdate(uidl)) {
return;
getWidget().body.clear();
// clear out any references to nodes that no longer are attached
getWidget().clearNodeToKeyMap();
+ tooltipMap.clear();
+
TreeNode childTree = null;
UIDL childUidl = null;
for (final Iterator<?> i = uidl.getChildIterator(); i.hasNext();) {
continue;
}
childTree = getWidget().new TreeNode();
+ getConnection().getVTooltip().connectHandlersToWidget(childTree);
updateNodeFromUIDL(childTree, childUidl);
getWidget().body.add(childTree);
childTree.addStyleDependentName("root");
}
String description = uidl.getStringAttribute("descr");
- if (description != null && getConnection() != null) {
- // Set tooltip
- TooltipInfo info = new TooltipInfo(description);
- getConnection().registerTooltip(this, nodeKey, info);
- } else {
- // Remove possible previous tooltip
- getConnection().registerTooltip(this, nodeKey, null);
+ if (description != null) {
+ tooltipMap.put(treeNode, new TooltipInfo(description));
}
if (uidl.getBooleanAttribute("expanded") && !treeNode.getState()) {
continue;
}
final TreeNode childTree = getWidget().new TreeNode();
+ getConnection().getVTooltip().connectHandlersToWidget(childTree);
updateNodeFromUIDL(childTree, childUidl);
containerNode.childNodeContainer.add(childTree);
if (!i.hasNext()) {
return (AbstractFieldState) super.getState();
}
+ @Override
+ public TooltipInfo getTooltipInfo(Element element) {
+
+ TooltipInfo info = null;
+
+ // Try to find a tooltip for a node
+ if (element != getWidget().getElement()) {
+ Object node = Util.findWidget(
+ (com.google.gwt.user.client.Element) element,
+ TreeNode.class);
+
+ if (node != null) {
+ TreeNode tnode = (TreeNode) node;
+ if (tnode.isCaptionElement(element)) {
+ info = tooltipMap.get(tnode);
+ }
+ }
+ }
+
+ // If no tooltip found for the node or if the target was not a node, use
+ // the default tooltip
+ if (info == null) {
+ info = super.getTooltipInfo(element);
+ }
+
+ return info;
+ }
+
}
import com.vaadin.terminal.gwt.client.MouseEventDetailsBuilder;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.Util;
-import com.vaadin.terminal.gwt.client.VTooltip;
import com.vaadin.terminal.gwt.client.ui.Action;
import com.vaadin.terminal.gwt.client.ui.ActionOwner;
import com.vaadin.terminal.gwt.client.ui.FocusElementPanel;
return;
}
- if (target == nodeCaptionSpan) {
- client.handleTooltipEvent(event, VTree.this, key);
- }
-
- final boolean inCaption = target == nodeCaptionSpan
- || (icon != null && target == icon.getElement());
+ final boolean inCaption = isCaptionElement(target);
if (inCaption
&& client
.hasEventListeners(VTree.this, ITEM_CLICK_EVENT_ID)
}
}
+ /**
+ * Checks if the given element is the caption or the icon.
+ *
+ * @param target
+ * The element to check
+ * @return true if the element is the caption or the icon
+ */
+ public boolean isCaptionElement(com.google.gwt.dom.client.Element target) {
+ return (target == nodeCaptionSpan || (icon != null && target == icon
+ .getElement()));
+ }
+
private void fireClick(final Event evt) {
/*
* Ensure we have focus in tree before sending variables. Otherwise
+ "-caption");
Element wrapper = DOM.createDiv();
nodeCaptionSpan = DOM.createSpan();
- DOM.sinkEvents(nodeCaptionSpan, VTooltip.TOOLTIP_EVENTS);
DOM.appendChild(getElement(), nodeCaptionDiv);
DOM.appendChild(nodeCaptionDiv, wrapper);
DOM.appendChild(wrapper, nodeCaptionSpan);
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
import com.vaadin.terminal.gwt.client.VConsole;
-import com.vaadin.terminal.gwt.client.VTooltip;
import com.vaadin.terminal.gwt.client.ui.button.VButton;
/**
panel.add(submitButton);
setStyleName(CLASSNAME);
-
- sinkEvents(VTooltip.TOOLTIP_EVENTS);
- }
-
- @Override
- public void onBrowserEvent(Event event) {
- if ((event.getTypeInt() & VTooltip.TOOLTIP_EVENTS) > 0) {
- client.handleTooltipEvent(event, this);
- }
- super.onBrowserEvent(event);
}
private static native void setEncoding(Element form, String encoding)
final Element target = DOM.eventGetTarget(event);
- if (client != null && header.isOrHasChild(target)) {
- // Handle window caption tooltips
- client.handleTooltipEvent(event, this);
- }
-
if (resizing || resizeBox == target) {
onResizeEvent(event);
bubble = false;
--- /dev/null
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+package com.vaadin.tests.components.abstractcomponent;
+
+import com.vaadin.terminal.WrappedRequest;
+import com.vaadin.tests.VaadinClasses;
+import com.vaadin.tests.components.AbstractTestRoot;
+import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.GridLayout;
+
+public class AllComponentTooltipTest extends AbstractTestRoot {
+
+ @Override
+ protected void setup(WrappedRequest request) {
+ setContent(new GridLayout(5, 5));
+ for (Class<? extends Component> cls : VaadinClasses.getComponents()) {
+ try {
+ AbstractComponent c = (AbstractComponent) cls.newInstance();
+ if (c instanceof LegacyWindow) {
+ continue;
+ }
+
+ c.setDebugId(cls.getName());
+ c.setCaption(cls.getName());
+ c.setDescription(cls.getName());
+ c.setWidth("100px");
+ c.setHeight("100px");
+ getContent().addComponent(c);
+ System.out.println("Added " + cls.getName());
+ } catch (Exception e) {
+ System.err.println("Could not instatiate " + cls.getName());
+ }
+ }
+ }
+
+ @Override
+ protected String getTestDescription() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="http://localhost:8888/" />
+<title>TooltipTests</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">TooltipTests</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.abstractcomponent.TooltipTests?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>showTooltip</td>
+ <td>//div[@id='label']</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>no_tooltip</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsabstractcomponentTooltipTests::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[0]/VCheckBox[0]/domChild[0]</td>
+ <td>10,7</td>
+</tr>
+<tr>
+ <td>showTooltip</td>
+ <td>//div[@id='label']</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>panel_tooltip</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsabstractcomponentTooltipTests::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[0]/VCheckBox[1]/domChild[0]</td>
+ <td>8,6</td>
+</tr>
+<tr>
+ <td>showTooltip</td>
+ <td>//div[@id='label']</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>layout_tooltip</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsabstractcomponentTooltipTests::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[0]/VCheckBox[2]/domChild[0]</td>
+ <td>5,5</td>
+</tr>
+<tr>
+ <td>showTooltip</td>
+ <td>//div[@id='label']</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>label_tooltip</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
--- /dev/null
+package com.vaadin.tests.components.abstractcomponent;
+
+import com.vaadin.data.Property;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
+
+public class TooltipTests extends TestBase {
+
+ private Panel panel;
+ private VerticalLayout layout;
+ private Label label;
+
+ @Override
+ protected String getDescription() {
+ return "Generic tooltip handling tests";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 8425;
+ }
+
+ @Override
+ protected void setup() {
+ HorizontalLayout topLayout = new HorizontalLayout();
+ addComponent(topLayout);
+ CheckBox panelCbox = new CheckBox("Panel");
+ panelCbox.addListener(panelListener);
+ topLayout.addComponent(panelCbox);
+ CheckBox layoutCbox = new CheckBox("Layout");
+ layoutCbox.addListener(layoutListener);
+ topLayout.addComponent(layoutCbox);
+ CheckBox labelCbox = new CheckBox("Label");
+ topLayout.addComponent(labelCbox);
+ labelCbox.addListener(labelListener);
+
+ panel = new Panel();
+ panel.setCaption("Panel caption");
+ panel.setDebugId("panel");
+ addComponent(panel);
+
+ layout = new VerticalLayout();
+ layout.setDebugId("layout");
+ layout.setMargin(true);
+ layout.setSpacing(true);
+ panel.setContent(layout);
+
+ label = new Label("Hover me!");
+ label.setDebugId("label");
+ layout.addComponent(label);
+ }
+
+ private final Property.ValueChangeListener panelListener = new Property.ValueChangeListener() {
+
+ public void valueChange(ValueChangeEvent event) {
+ boolean value = (Boolean) (event.getProperty().getValue());
+ if (value) {
+ panel.setDescription("I'm panel!");
+ } else {
+ panel.setDescription("");
+ }
+ }
+
+ };
+
+ private final Property.ValueChangeListener layoutListener = new Property.ValueChangeListener() {
+
+ public void valueChange(ValueChangeEvent event) {
+ boolean value = (Boolean) (event.getProperty().getValue());
+ if (value) {
+ layout.setDescription("I'm layout!");
+ } else {
+ layout.setDescription("");
+ }
+ }
+
+ };
+
+ private final Property.ValueChangeListener labelListener = new Property.ValueChangeListener() {
+
+ public void valueChange(ValueChangeEvent event) {
+ boolean value = (Boolean) (event.getProperty().getValue());
+ if (value) {
+ label.setDescription("I'm label!");
+ } else {
+ label.setDescription("");
+ }
+ }
+
+ };
+
+}