@Override public void valueChanged(ListSelectionEvent e) { if (isUpdatePossible() && STable.class.isAssignableFrom(STable.this.getClass())) { deselectedIndices = new ArrayList<>(); selectedIndices = new ArrayList<>(); if (getSelectionMode() == SINGLE_SELECTION) { addIndex(e.getFirstIndex()); addIndex(e.getLastIndex()); } else { for (int index = e.getFirstIndex(); index <= e.getLastIndex(); ++index) { addIndex(index); } } update(((TableCG) getCG()).getSelectionUpdate(STable.this, deselectedIndices, selectedIndices)); } else { reload(); } }
@Override public SComponent getTableCellRendererComponent(STable table, Object value, boolean selected, int row, int col) { if (useIcons) { setText(null); switch (table.getSelectionMode()) { case ListSelectionModel.SINGLE_SELECTION: setIcon(selected ? singleSelectionIcon : singleNonSelectionIcon); break; default: setIcon(selected ? multiSelectionIcon : multiNonSelectionIcon); break; } } else { setIcon(null); setText(String.valueOf(row + 1)); } // style if (selected) { setStyle(selectionStyle); } else { setStyle(nonSelectionStyle); } return this; }
@MacroTag public static void cellEvent(MacroContext context, int row, int col) throws IOException { Device device = context.getDevice(); SComponent _c = context.getComponent(); STable table = (STable) _c; final boolean isEditingCell = table.isEditing() && row == table.getEditingRow() && col == table.getEditingColumn(); final boolean editableCell = table.isCellEditable(row, col); final boolean clickableCell = table instanceof XTable && ((XTable)table).isClickListenerSet(table.convertColumnIndexToModel(col)); final boolean selectableCell = table.getSelectionMode() != SListSelectionModel.NO_SELECTION && !table.isEditable() && table.isSelectable(); final boolean isClickable = _c instanceof SClickable; String parameter = null; if ((table.isEditable() && editableCell) || clickableCell) parameter = STable.getEditParameter(row, col); else if (selectableCell) parameter = STable.getToggleSelectionParameter(row, col) + ";shiftKey='+event.shiftKey+';ctrlKey='+event.ctrlKey+'"; if (parameter != null && (selectableCell || editableCell || clickableCell) && !isClickable) { Utils.printClickability(device, table, parameter, true, table.getShowAsFormComponent()); } }
/** * Renders the row sometimes needed to allow row selection. */ protected void writeSelectionBody(final Device device, final STable table, final SCellRendererPane rendererPane, final int row) throws IOException { if (isSelectionColumnVisible(table)) { final SComponent comp = getRowSelectionRenderer(table, row); final String columnStyle = Utils.joinStyles(comp, "num"); device.print("<td valign=\"top\" align=\"right\""); Utils.optAttribute(device, "width", selectionColumnWidth); String value = STable.getToggleSelectionParameter(row, -1) + ";shiftKey='+event.shiftKey+';ctrlKey='+event.ctrlKey+'"; if (table.getSelectionMode() != SListSelectionModel.NO_SELECTION) { printClickability(device, table, value, table.getShowAsFormComponent()); device.print(" class=\"clickable "); device.print(columnStyle); device.print("\""); } else { device.print(" class=\""); device.print(columnStyle); device.print("\""); } device.print(">"); // Renders the content of the row selection row rendererPane.writeComponent(device, comp, table); device.print("</td>"); } }
if (table.getSelectionMode() != SListSelectionModel.NO_SELECTION) { printClickability(device, table, value, table.getShowAsFormComponent()); device.print(" class=\"clickable ");
&& row == table.getEditingRow() && col == table.getEditingColumn(); final boolean editableCell = table.isCellEditable(row, col); final boolean selectableCell = table.getSelectionMode() != SListSelectionModel.NO_SELECTION && !table.isEditable() && table.isSelectable();
final boolean selectableCell = table.getSelectionMode() != SListSelectionModel.NO_SELECTION && !table.isEditable() && table.isSelectable();