-
28 Aug 2012 6:04 AM #1
Feature Request: ToolTip for TabPanel
Feature Request: ToolTip for TabPanel
Back in GXT 2.x it was possible to define a ToolTip for the tab itself (described here). Since there is no header/TabItem anymore, it is only possible to use ToolTips within the widget itself, but not for the tab buttons. Is there any chance you will add this feature it in the future?
-
25 Nov 2012 1:08 PM #2
TabPanel toolTip missing version 3.x
TabPanel toolTip missing version 3.x
Same problem too.
Any suggestions please?Guillermo Martinez
-
25 Nov 2012 11:52 PM #3
In the end I wrote my own TabItemConfig adding a "toolTip" value and an extended TabPanelBaseAppearance rendering a simple html-title (instead of gxt tooltip). It works OK, but I'm still missing the GXT ToolTip allowing advanced tooltips.
ToolTipTabItem.html (render template):
Code:<li title="{config.toolTip}"><a class="{style.tabStripClose}"></a> <a class="{style.tabRight}"> <em class="{style.tabLeft}"> <span class="{style.tabStripInner}"> <span class="{style.tabStripText}">{config.text}</span> </span> </em> </a></li>
ToolTipTabAppearance (if it's our tooltip config - render our tabpanel with tooltip):
Code:... public interface ToolTipItemTemplate extends XTemplates { @XTemplate(source = "ToolTipTabItem.html") SafeHtml render(TabPanelStyle style, ToolTipTabItemConfig config); } ... protected ToolTipItemTemplate toolTipItemTemplate; public ToolTipTabPanelAppearance(TabPanelResources resources, Template template, ItemTemplate itemTemplate, ToolTipItemTemplate toolTipItemTemplate) { super(resources, template, itemTemplate); this.toolTipItemTemplate = toolTipItemTemplate; } @Override public void insert(XElement parent, TabItemConfig config, int index) { if (config instanceof ToolTipTabItemConfig) { XElement item = XDOM.create(toolTipItemTemplate .render(style, (ToolTipTabItemConfig) config).asString()); item.setClassName(CommonStyles.get().disabled(), !config.isEnabled()); if (config.isHTML()) { XElement textEl = item.selectNode("." + style.tabStripText()); textEl.setInnerHTML(config.getHTML()); } getStrip(parent).insertChild(item, index); if (config.getIcon() != null) { setItemIcon(item, config.getIcon()); } if (config.isClosable()) { item.addClassName(style.tabStripClosable()); } } else { super.insert(parent, config, index); } }
And that's how you can use it:
Code:protected TabPanel tabPanel = new TabPanel(new ToolTipTabPanelAppearance()); ToolTipTabItemConfig tic = new ToolTipTabItemConfig(); tic.setToolTip("myToolTip"); tic.setText("myCaption"); tabPanel.add(tabContent, tic);
I hope, this workaround helps you
-
26 Nov 2012 1:57 AM #4
Complete Code
Complete Code
If you don't mind could you please post the complete ToolTipTabAppearance and ToolTipTabItemConfig code?
I'm barely new with Sencha code and any help to the implementation will be appreciate.
Thank you.Guillermo Martinez
-
26 Nov 2012 2:03 AM #5
ToolTipTabItemConfig just adds a toolTip attribute:
ToolTipTabAppearance - I override the insert method and check, which config class is beeing used:Code:public class ToolTipTabItemConfig extends TabItemConfig{ private String toolTip; public ToolTipTabItemConfig() { super(); } public ToolTipTabItemConfig(String text, boolean close) { super(text, close); } public ToolTipTabItemConfig(String text) { super(text); } public String getToolTip() { return toolTip; } public void setToolTip(String toolTip) { this.toolTip = toolTip; } }
Also you need to create "ToolTipTabItem.html" in the same package as ToolTipTabPanelAppearance (see the code in my other post).Code:public class ToolTipTabPanelAppearance extends TabPanelBaseAppearance{ public interface ToolTipItemTemplate extends XTemplates { @XTemplate(source = "ToolTipTabItem.html") SafeHtml render(TabPanelStyle style, ToolTipTabItemConfig config); } protected ToolTipItemTemplate toolTipItemTemplate; public ToolTipTabPanelAppearance() { this(GWT.<TabPanelResources> create(TabPanelResources.class), GWT .<Template> create(Template.class), GWT .<ItemTemplate> create(ItemTemplate.class), GWT .<ToolTipItemTemplate> create(ToolTipItemTemplate.class)); } public ToolTipTabPanelAppearance(TabPanelResources resources, Template template, ItemTemplate itemTemplate, ToolTipItemTemplate toolTipItemTemplate) { super(resources, template, itemTemplate); this.toolTipItemTemplate = toolTipItemTemplate; } @Override public void insert(XElement parent, TabItemConfig config, int index) { if (config instanceof ToolTipTabItemConfig) { XElement item = XDOM.create(toolTipItemTemplate .render(style, (ToolTipTabItemConfig) config).asString()); item.setClassName(CommonStyles.get().disabled(), !config.isEnabled()); if (config.isHTML()) { XElement textEl = item.selectNode("." + style.tabStripText()); textEl.setInnerHTML(config.getHTML()); } getStrip(parent).insertChild(item, index); if (config.getIcon() != null) { setItemIcon(item, config.getIcon()); } if (config.isClosable()) { item.addClassName(style.tabStripClosable()); } } else { super.insert(parent, config, index); } } }
-
26 Nov 2012 2:06 AM #6


Reply With Quote
Thank you so much