| 4848 | /// |
| 4849 | /// - #getTabIterator(com.codename1.ui.Component) |
| 4850 | public static class TabIterator implements ListIterator<Component> { |
| 4851 | private final java.util.List<Component> components; |
| 4852 | private int currPos; |
| 4853 | private Component current; |
| 4854 | |
| 4855 | private TabIterator(java.util.List<Component> components, Component current) { |
| 4856 | this.components = components; |
| 4857 | setCurrent(current); |
| 4858 | } |
| 4859 | |
| 4860 | /// Gets the current component in this iterator. |
| 4861 | public Component getCurrent() { |
| 4862 | return current; |
| 4863 | } |
| 4864 | |
| 4865 | /// Sets the current component in the iterator. This reposition the iterator |
| 4866 | /// to the given component. |
| 4867 | /// |
| 4868 | /// #### Parameters |
| 4869 | /// |
| 4870 | /// - `cmp`: The component to set as the current component. |
| 4871 | public void setCurrent(Component cmp) { |
| 4872 | current = cmp; |
| 4873 | |
| 4874 | currPos = cmp != null ? components.indexOf(cmp) : -1; |
| 4875 | } |
| 4876 | |
| 4877 | /// Gets the next component in this iterator. If the current component explicitly specifies |
| 4878 | /// a nextFocusRight or nextFocusDown component, then that component will be returned. |
| 4879 | /// Otherwise it will follow the tab index order. |
| 4880 | /// |
| 4881 | /// #### Returns |
| 4882 | /// |
| 4883 | /// The next component to be traversed after `#getCurrent()` |
| 4884 | public Component getNext() { |
| 4885 | Component current = getCurrent(); |
| 4886 | if (current == null && components.isEmpty()) { |
| 4887 | return null; |
| 4888 | } |
| 4889 | |
| 4890 | Component next = current != null ? current.getNextFocusRight() : null; |
| 4891 | if (next != null && next.isFocusable() && next.isVisible() && next.isEnabled()) { |
| 4892 | return next; |
| 4893 | } |
| 4894 | next = current != null ? current.getNextFocusDown() : null; |
| 4895 | if (next != null && next.isFocusable() && next.isVisible() && next.isEnabled()) { |
| 4896 | return next; |
| 4897 | } |
| 4898 | if (currPos < 0 && !components.isEmpty()) { |
| 4899 | return components.get(0); |
| 4900 | } |
| 4901 | if (currPos < components.size() - 1) { |
| 4902 | return components.get(currPos + 1); |
| 4903 | } |
| 4904 | return null; |
| 4905 | } |
| 4906 | |
| 4907 | /// Gets the previous component that should be traversed when going "back" in through the |
nothing calls this directly
no outgoing calls
no test coverage detected