ColumnControlButton extends JButton { protected List<ColumnVisibilityAction> getColumnVisibilityActions() { if (columnVisibilityActions == null) { columnVisibilityActions = new ArrayList<ColumnVisibilityAction>(); } return columnVisibilityActions; } ColumnControlButton(JXTable table);  ColumnControlButton(JXTable table, Icon icon); @Override void updateUI(); void togglePopup(); boolean getAdditionalActionsVisible(); void setAdditionalActionsVisible(boolean additionalActionsVisible); void setActionGrouper(ActionGrouper grouper); @Override void applyComponentOrientation(ComponentOrientation o); static final String COLUMN_CONTROL_MARKER; static final String COLUMN_CONTROL_BUTTON_ICON_KEY; static final String COLUMN_CONTROL_BUTTON_MARGIN_KEY; }
@Test public void testColumnVisibilityActionOnHideableInitial() { JXTable table = new JXTable(10, 3); table.getColumnExt(0).setHideable(false); table.setColumnControlVisible(true); ColumnControlButton columnControl = (ColumnControlButton) table.getColumnControl(); ColumnVisibilityAction action = columnControl.getColumnVisibilityActions().get(0); assertFalse("action must be disabled initially", action.isEnabled()); }
@Test public void testColumnVisibilityActionOnHideable() { JXTable table = new JXTable(10, 3); table.setColumnControlVisible(true); ColumnControlButton columnControl = (ColumnControlButton) table.getColumnControl(); ColumnVisibilityAction action = columnControl.getColumnVisibilityActions().get(0); TableColumnExt columnExt = table.getColumnExt(0); columnExt.setVisible(false); columnExt.setHideable(false); assertTrue("visibility action must be selected if not hideable", action.isSelected()); assertFalse("action must be disabled", action.isEnabled()); columnExt.setHideable(true); assertFalse("visibility action must be unselected if hideable", action.isSelected()); }
@Test public void testColumnVisibilityAction() { JXTable table = new JXTable(10, 3); table.setColumnControlVisible(true); ColumnControlButton columnControl = (ColumnControlButton) table.getColumnControl(); ColumnVisibilityAction action = columnControl.getColumnVisibilityActions().get(0); TableColumnExt columnExt = table.getColumnExt(0); boolean visible = columnExt.isVisible(); assertTrue(visible); assertEquals(columnExt.isVisible(), action.isSelected()); action.setSelected(!visible); assertEquals(!visible, columnExt.isVisible()); }