Pivot
  1. Pivot
  2. PIVOT-816

Add "setSelectedTab(Component)" method to TabPane to facilitate selecting tabs programmatically

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: 2.0.1
    • Fix Version/s: 2.0.1
    • Component/s: wtk
    • Labels:
    • Environment:
      Windows XP SP3, JDK 1.6.0_16

      Description

      There is already a "setSelectedIndex", "getSelectedIndex" and "getSelectedTab" methods. It would be nice and orthogonal to have a "setSelectedTab" method also.

      My use case is this: I have TabPane components identified by bxml:id in my main layout file, and references to these components in the .java code. So, rather than relying on indexes to programmatically select a tab (which might change if I reorder the tabs), if I could just use the tab component itself (since I have a reference to it) to make the selection, then it would be more reliable.

      1. tab.patch
        0.8 kB
        Roger Whitcomb

        Activity

        Hide
        Roger Whitcomb added a comment -

        Sending wtk\src\org\apache\pivot\wtk\TabPane.java
        Transmitting file data .
        Committed revision 1197807.

        Show
        Roger Whitcomb added a comment - Sending wtk\src\org\apache\pivot\wtk\TabPane.java Transmitting file data . Committed revision 1197807.
        Hide
        Sandro Martini added a comment -

        Hi Roger,
        to me the patch seems Ok, go with the commit ... a minimal test application could be useful but I think that in this case we can live even without it .

        Show
        Sandro Martini added a comment - Hi Roger, to me the patch seems Ok, go with the commit ... a minimal test application could be useful but I think that in this case we can live even without it .
        Hide
        Roger Whitcomb added a comment -

        The "tab.patch" implements this functionality.

        I have tested it with our application and it works just as I had hoped.

        If the "component" is null, the selected index goes back to -1, and if the component isn't a child of the TabPane an exception is thrown. This is consistent with "getSelectedTab".

        Show
        Roger Whitcomb added a comment - The "tab.patch" implements this functionality. I have tested it with our application and it works just as I had hoped. If the "component" is null, the selected index goes back to -1, and if the component isn't a child of the TabPane an exception is thrown. This is consistent with "getSelectedTab".

          People

          • Assignee:
            Roger Whitcomb
            Reporter:
            Roger Whitcomb
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Due:
              Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 10m
              10m
              Remaining:
              Remaining Estimate - 10m
              10m
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development