public EncodeTableModel(String [] headings, List<EncodeFileRecord> records) { this.records = records; List<String> tmp = new ArrayList<String>(); tmp.add(""); // Checkbox heading for(String h : headings) { String heading = h.trim(); if(heading.length() > 0 && !"path".equals(heading)) { tmp.add(heading); } } //tmp.add("path"); columnHeadings = tmp.toArray(new String[tmp.size()]); sorter = new TableRowSorter<EncodeTableModel>(this); sorter.setStringConverter(new TableStringConverter() { @Override public String toString(TableModel model, int row, int column) { final Object value = model.getValueAt(row, column); return value == null ? "" : value.toString(); } }); }
public EncodeTableModel(String[] headings, List<EncodeFileRecord> records) { this.records = records; List<String> tmp = new ArrayList<>(); tmp.add(""); // Checkbox heading for (String h : headings) { String heading = h.trim(); if (heading.length() > 0 && !"path".equals(heading)) { tmp.add(heading); } } //tmp.add("path"); columnHeadings = tmp.toArray(new String[tmp.size()]); sorter = new TableRowSorter<>(this); sorter.setStringConverter(new TableStringConverter() { @Override public String toString(TableModel model, int row, int column) { final Object value = model.getValueAt(row, column); return value == null ? "" : value.toString(); } }); }
@Override public String getStringValueAt(int row, int column) { TableStringConverter converter = getStringConverter(); if (converter != null) { // Use the converter String value = converter.toString( tableModel, row, column); if (value != null) { return value; } return ""; } // No converter, use getValueAt followed by toString Object o = getValueAt(row, column); if (o == null) { return ""; } String string = o.toString(); if (string == null) { return ""; } return string; }
protected TableRowSorter createRowSorter() { ProfilerRowSorter s = new ProfilerRowSorter(getModel()); s.setStringConverter(new TableStringConverter() { public String toString(TableModel model, int row, int column) { return getModelStringValue(row, column); } }); s.setDefaultSortOrder(SortOrder.DESCENDING); s.setSortColumn(0); return s; }
public String getStringValueAt(int row, int column) { TableStringConverter converter = getStringConverter(); if(converter != null) { // Use the converter String value = converter.toString(model, row, column); if(value != null) { return value; } return ""; } // No converter, use getValueAt followed by toString Object o = getValueAt(row, column); if(o == null) { return ""; } String string = o.toString(); if(string == null) { return ""; } return string; }
public String getStringValueAt(int row, int column) { TableStringConverter converter = LogTableRowSorter.this.getStringConverter(); if(converter != null) { String value = converter.toString(LogTableRowSorter.this.tableModel, row, column); return value != null?value:""; } else { Object o = this.getValueAt(row, column); if(o == null) { return ""; } else { String string = o.toString(); return string == null?"":string; } } }
/** * Returns the object responsible for converting values from the model to * strings. * * @return object responsible for converting values to strings. */ public TableStringConverter getStringConverter() { return stringConverter; }
/** * Sets the object responsible for converting values from the model to * strings. If non-<code>null</code> this is used to convert any object * values, that do not have a registered <code>Comparator</code>, to * strings. * * @param stringConverter * the object responsible for converting values from the model to * strings */ public void setStringConverter(TableStringConverter stringConverter) { this.stringConverter = stringConverter; }