// Handle some of the common steps between creating the content // and object tables. public AbstractViperTable(TablePanel tp) { super(); this.outerTablePanel = tp; setLayout(new BorderLayout()); EnhancedTable table = new EnhancedTable() { public void changeSelection( int rowIndex, int columnIndex, boolean toggle, boolean extend) { ViperTableModel currModel = AbstractViperTable.this.getCurrentModel(); columnIndex = convertColumnIndexToModel(columnIndex); AttrConfig ac = currModel.getAttributeForColumn(columnIndex); Descriptor d = currModel.getDescriptorAtRow(rowIndex); Node n = null; if (ac != null) { Attribute a = d.getAttribute(ac); n = a; } else if (currModel.getInternalColumn(columnIndex) == ViperTableModel.BY_ID) { n = d; } if (n != null) { if (extend) { mediator.getSelection().addNode(n); } else { mediator.getSelection().setTo(n); } } } public boolean isCellSelected(int row, int column) { ViperTableModel currModel = AbstractViperTable.this.getCurrentModel(); column = convertColumnIndexToModel(column); AttrConfig ac = currModel.getAttributeForColumn(column); Descriptor d = currModel.getDescriptorAtRow(row); if (ac != null) { Attribute a = d.getAttribute(ac); return mediator.getSelection().isSelected(a); } else if (currModel.getInternalColumn(column) == ViperTableModel.BY_ID) { return mediator.getSelection().isSelected(d); } return false; } }; table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.resizeAllColumnsToNaturalWidth(); table.setCellSelectionBackground( table.getSelectionBackground().brighter().brighter().brighter()); table.setCellSelectionForeground(table.getForeground().darker()); initAttributeTable(table); JScrollPane scrollPane = new JScrollPane(table); this.add(scrollPane); popup = new DescPropPopup(); popup.setInvoker(getTable()); getTable() .addMouseListener( new MouseAdapter() { public void mousePressed(MouseEvent e) { maybeShowPopup(e); } public void mouseReleased(MouseEvent e) { maybeShowPopup(e); } }); }