ComponentAdapter { public int getColumnIndex(Object identifier) { if (identifier.equals(getColumnIdentifierAt(0))) { return 0; } return -1; } ComponentAdapter(JComponent component); JComponent getComponent(); String getColumnName(int columnIndex); Object getColumnIdentifierAt(int columnIndex); int getColumnIndex(Object identifier); boolean isTestable(int column); Class<?> getColumnClass(int column); Class<?> getColumnClass(); int getColumnCount(); int getRowCount(); abstract Object getValueAt(int row, int column); abstract boolean isCellEditable(int row, int column); String getString(); String getString(int modelColumnIndex); String getFilteredStringAt(int row, int column); String getStringAt(int row, int column); Object getValue(); Object getValue(int modelColumnIndex); Object getFilteredValueAt(int row, int column); Rectangle getCellBounds(); abstract boolean hasFocus(); abstract boolean isSelected(); abstract boolean isEditable(); boolean isExpanded(); boolean isLeaf(); boolean isHierarchical(); int getDepth(); int convertColumnIndexToView(int columnModelIndex); int convertColumnIndexToModel(int columnViewIndex); int convertRowIndexToView(int rowModelIndex); int convertRowIndexToModel(int rowViewIndex); static final Object DEFAULT_COLUMN_IDENTIFIER; public int row; public int column; }
@Test public void testColumnIdentifierListReverse() { JXListT tree = new JXListT(new String[] {"one" }); ComponentAdapter adapter = tree.getComponentAdapter(0); assertEquals(0, adapter.getColumnIndex(ComponentAdapter.DEFAULT_COLUMN_IDENTIFIER)); }
@Test public void testColumnIdentifierListNotFound() { JXListT tree = new JXListT(new String[] {"one" }); ComponentAdapter adapter = tree.getComponentAdapter(0); assertEquals(-1, adapter.getColumnIndex("unknown")); }
@Test public void testColumnIdentifierTreeReverse() { JXTreeT tree = new JXTreeT(); ComponentAdapter adapter = tree.getComponentAdapter(0); assertEquals(0, adapter.getColumnIndex(ComponentAdapter.DEFAULT_COLUMN_IDENTIFIER)); }
@Test public void testColumnIdentifierTreeNotFound() { JXTreeT tree = new JXTreeT(); ComponentAdapter adapter = tree.getComponentAdapter(0); assertEquals(-1, adapter.getColumnIndex("unknown")); }
@Test public void testColumnIdentifierReverseHidden() { JXTableT table = new JXTableT(new AncientSwingTeam()); ComponentAdapter adapter = table.getComponentAdapter(0, 0); Object id = new Integer(50); table.getColumn(1).setIdentifier(id); table.getColumnExt(1).setVisible(false); assertEquals(1, adapter.getColumnIndex(id)); }
@Test public void testColumnIdentifierReverse() { JXTableT table = new JXTableT(new AncientSwingTeam()); ComponentAdapter adapter = table.getComponentAdapter(0, 0); Object id = new Integer(50); table.getColumn(1).setIdentifier(id); assertEquals(1, adapter.getColumnIndex(id)); }
@Test public void testColumnIdentifierReverseNotFound() { JXTableT table = new JXTableT(new AncientSwingTeam()); ComponentAdapter adapter = table.getComponentAdapter(0, 0); Object id = new Integer(50); table.getColumn(1).setIdentifier(id); assertEquals(-1, adapter.getColumnIndex("unknown")); }
@Test public void testColumnIdentifierReverseNullIdentifier() { JXTableT table = new JXTableT(new AncientSwingTeam()); ComponentAdapter adapter = table.getComponentAdapter(0, 0); try { adapter.getColumnIndex(null); fail("must throw for null identifier"); } catch (NullPointerException e) { } catch (Exception e) { fail("expected ArrayIndexOutOfBounds but was: " + e); } }