/** * Returns the default active index. Note that some tab sets support multiple active tabs, see * {@link #getActiveIndices()}. * <p> * If there are no active tabs, then the first tab will be returned as the default tab. * </p> * * @return the default active tab index. */ public int getActiveIndex() { List<Integer> activeTabs = getActiveIndices(); return activeTabs.isEmpty() ? 0 : activeTabs.get(0); }
/** * @return a String representation of this component, for debugging purposes. */ @Override public String toString() { String details = "active tab=" + getActiveIndices(); return toString(details, 1, 1); }
/** * Returns the active tabs (as seen by the given context/session). * * @return the active tabs (as seen by the given context/session). */ public List<WTab> getActiveTabs() { List<Integer> activeIndices = getActiveIndices(); if (activeIndices.isEmpty()) { return Collections.emptyList(); } List<WTab> activeTabs = new ArrayList<>(activeIndices.size()); List<WTab> tabs = getTabs(); for (int index : activeIndices) { activeTabs.add(tabs.get(index)); } return Collections.unmodifiableList(activeTabs); }
/** * Test getActiveIndices - when tabset is empty. */ @Test public void testGetActiveIndices() { WTabSet tabset = new WTabSet(); List<Integer> activeIndices = tabset.getActiveIndices(); Assert.assertNotNull("should not return null List", activeIndices); Assert.assertTrue("should return empty List", activeIndices.isEmpty()); }
List<Integer> oldIndices = getActiveIndices(); List<Integer> changes = new ArrayList<>(1); int[] indices = new int[indicesStr.length];
List<Integer> activeIndices = tabset.getActiveIndices(); Assert.assertNotNull("should get non null List", activeIndices); Assert.assertEquals("active indices should be those expected", expectedIndices, setActiveContext(createUIContext()); tabset.setTabVisible(0, false); activeIndices = tabset.getActiveIndices(); Assert.assertNotNull("should get non null List", activeIndices); Assert.assertEquals("active indices should be those expected", expectedIndices, activeIndices = tabset.getActiveIndices(); Assert.assertEquals("active indices should be those expected", expectedIndices, activeIndices); tabset.setTabVisible(1, false); tabset.setTabVisible(2, false); activeIndices = tabset.getActiveIndices(); Assert.assertNotNull("should get non null List", activeIndices); Assert.assertEquals("active indices should be those expected", expectedIndices,