PDA

View Full Version : Can't Override Default ToolTip Delay



ccocco_dw
6 Dec 2010, 12:02 PM
I'm trying to lengthen the time interval for displaying a ToolTip over a component. I'd like to do this in one place for the entire application. I extended the ToolTipConfig class, lengthened the delay (setShowDelay(2000)), and substituted the new class for the GXT class via the module file. It doesn't appear to work so I may be missing a step. Do I need to call GWT.create(newClass) for this to work? Since I'm not explicitly using a ToolTipConfig, just setting the ToolTip text for a component, I didn't see a need to create it and set it with the ToolTip text, but perhaps I need to? I was hoping the default one was used implicitly and I would be overriding that. Here's the code sample and module definition.



<?xml version="1.0" encoding="UTF-8"?>
<module>
<inherits name="com.demandware.bm.framework.Framework"/>
<replace-with class="com.demandware.bm.common.client.widget.ToolTipConfig">
<when-type-is class="com.extjs.gxt.ui.client.widget.tips.ToolTipConfig"/>
</replace-with>
<source path="client"/>
<source path="shared"/>
</module>

public class ToolTipConfig extends com.extjs.gxt.ui.client.widget.tips.ToolTipConfig
{
public ToolTipConfig()
{
this(null);
}

public ToolTipConfig(String text)
{
this(null, text);
}

public ToolTipConfig(String title, String text)
{
super(title, text);

this.setShowDelay(2000);
}
}

sven
6 Dec 2010, 12:07 PM
It wont work like this: http://code.google.com/p/google-web-toolkit/wiki/DeferredBindingsForJRE, http://code.google.com/p/google-web-toolkit-doc-1-5/wiki/DevGuideDeferredBindingReplacement

You need to overload the ToolTipConfig class

ccocco_dw
7 Dec 2010, 3:18 AM
If I overload the ToolTipConfig class, I need to explicitly use it for every component I set a ToolTip for rather than just setting the text as I'm now doing. This is fine but what I really wanted to do was override the default ToolTip delay time globally so no one building panels and widgets would have to remember to do this.

sven
7 Dec 2010, 3:23 AM
If I overload the ToolTipConfig class, I need to explicitly use it for every component I set a ToolTip for rather than just setting the text as I'm now doing.
This is not correct


component.setToolTip("mytooltip")
THis creates a ToolTipConfig internaly. If you have overloaded the ToolTipConfig class with your custom one, than your one gets used.

ccocco_dw
7 Dec 2010, 4:21 AM
Thanks Sven, I agree that calling Component.setToolTip(ToolTipConfig myCustomToolTipConfig) will allow me to override the default usage of the GXT ToolTipConfig in Component.setToolTip(String text). What I really wanted to do was override the usage of this default ToolTipConfig entirely in Component.setToolTip(String text) and not have to call Component.setToolTip(ToolTipConfig myCustomToolTipConfig) explicitly, to eliminate having to do so for every widget we create that needs a ToolTip (e.g. we have 400+ web page panels). I was attempting to do this using the replace-with deferred binding in the module XML but it looks like I have to call GWT.create() to force it's usage, which is no different than calling Component.setToolTip(ToolTipConfig myCustomToolTipConfig). Thanks.

sven
7 Dec 2010, 4:23 AM
You are misunderstanding me. If you overload the ToolTipConfig class, than you can use
component.setToolTip("mytooltip")

This is not bound to GXT, but something that works everywhere in java.