2011-05-23 31 views
0

目前,我有一個帶有幾個選項卡的TabLayoutPanel,每個選項卡內有一組麪包屑。我希望能夠在標籤旁邊顯示我的麪包屑(在TabBar本身內)。我還沒有看到任何人做過這樣的事情,我開始相信我可能會自己重寫他們的TabLayoutPanel類並在需要的地方實現,但顯然我寧願不走那條路線,除非沒有其他選擇。使用GWT的TabLayoutPanel在選項卡旁邊添加任意文本

任何人有任何指導呢?

回答

1

剛剛遇到同樣的問題。這裏是大多數相關的代碼片段。我在選中標籤時添加了一個Unicode箭頭,並在選項卡被取消選擇時將其刪除。

private final String htmlStr ="\u25bb"; 

     private String getTabTitle(String html){ 
     // Designed to work for this example input. 
     //If you pass a different string you will need to do different matching. 
     if(html.indexOf("\u25bb") < 0) 
      return html; 
     else 
      return html.substring(html.indexOf("\u25bb")+1); 
    } 


    @Override 
public void onBeforeSelection(BeforeSelectionEvent<Integer> event) { 
     if(!getSelectedIndex().equals(event.getItem())) { 
      notifyCurrentTabOfClosing(); 
      selectedIndex = event.getItem(); 
      String tabtitle = getTabTitle(getTabBar().getTabHTML(selectedIndex)); 
      getTabBar().setTabHTML(selectedIndex, htmlStr+tabtitle); 
      } 
     } 
    } 

public void selectTab(Widget widget) { 
     int widgetIndex = getWidgetIndex(widget); 
     selectTab(widgetIndex); 
     String tabtitle = getTabTitle(getTabBar().getTabHTML(widgetIndex)); 
     getTabBar().setTabHTML(widgetIndex, htmlStr+tabtitle); 
    } 
+0

感謝此信息。我最終做了一些非常相似的事情,並且像魅力一樣工作。 – 2011-07-15 15:02:15

相關問題