/** Set a particular column to be visible (or not). @param column The (physical) column to act on @param on True iff the column should be shown */ public void setVisible(int column, boolean on) { if (visible[column] == on) { return; // Already so - nothing to do } visible[column] = on; } /** Recompute the visible columns and update table */ public void recomputeVisibleColumns() { // Recompute visible maps numVisible = 0; for (int i = 0; i < numCols; i++) { if (visible[i]) { visibleColumns[numVisible] = i; numVisible++; } } //System.out.println("updated numVisible to " + numVisible + " - id is " + myid); // firstTableStructureChanged() seems to remove the selection // However, we want to preserve the selection across this // operation int keepSelection = selectedRow; // XXX won't work for multiple selection fireTableStructureChanged(); // Consider using TableModelEvent // instead so I can indicate insertion vs deletion etc. setupCellEditors(); setupCellRenderers(); resizeColumns(); selectedRow = keepSelection; // restore selection // Restore selection if (selectedRow != -1) { ignoreSelection = true; table.changeSelection(selectedRow, 0, false, false); ignoreSelection = false; } } /** @return True iff the given physical column is visible */ public boolean getColumnVisible(int col) { return visible[col]; } /** Edit the visible table columns */ public void selectVisibleColumns(DebuggerTableWindow sourceWindow) { JPanel panel = new javax.swing.JPanel(); panel.setLayout(new GridBagLayout()); ArrayList boxes = new ArrayList(numCols); GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 12); GridBagConstraints firstConstraints = new GridBagConstraints(); firstConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; firstConstraints.anchor = java.awt.GridBagConstraints.WEST; firstConstraints.insets = new java.awt.Insets(12, 12, 0, 12); for (int i = 0; i < numCols; i++) { // XXX Use formatting class (MessageFormat) ! JCheckBox b = new JCheckBox( MessageFormat.format(IpeDebugger.getText( "VisColsDesc"), // NOI18N new String[] { columnNames[i], columnHelp[i] }), visible[i]); if (i == 0) { panel.add(b, firstConstraints); } else { panel.add(b, gridBagConstraints); } boxes.add(b); // This is kinda silly but we've already baked a fully description // into the label so it's not necessary here. b.getAccessibleContext().setAccessibleDescription(columnHelp[i]); } String title = MessageFormat.format( IpeDebugger.getText("TableColumnsHeader"), // NOI18N new String[] { sourceWindow.getName() }); DialogDescriptor dlg = new DialogDescriptor( panel, title, true, DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, DialogDescriptor.DEFAULT_ALIGN, // DialogDescriptor.BOTTOM_ALIGN, null, // get topic! new HelpCtx("Debugging_configure"), // NOI18N null); final Dialog dialog = TopManager.getDefault().createDialog(dlg); dialog.show(); if (dlg.getValue().equals(DialogDescriptor.OK_OPTION)) { // UsageTracking.sendEvent(evt); int num = boxes.size(); int nv = 0; for (int i = 0; i < num; i++) { JCheckBox b = (JCheckBox)boxes.get(i); visible[i] = b.isSelected(); if (visible[i]) { nv++; } } // Don't allow the user to disable ALL columns if (nv == 0) { visible[0] = true; } recomputeVisibleColumns(); if (UsageTracking.enabled) UsageTracking.sendAction("RunConfigDialog: OK", null); // NOI18N } // else Cancel or Esc }