use of javax.swing.table.TableRowSorter in project gitblit by gitblit.
the class GitblitAuthority method filterUsers.
private void filterUsers(final String fragment) {
table.clearSelection();
userCertificatePanel.setUserCertificateModel(null);
if (StringUtils.isEmpty(fragment)) {
table.setRowSorter(defaultSorter);
return;
}
RowFilter<UserCertificateTableModel, Object> containsFilter = new RowFilter<UserCertificateTableModel, Object>() {
@Override
public boolean include(Entry<? extends UserCertificateTableModel, ? extends Object> entry) {
for (int i = entry.getValueCount() - 1; i >= 0; i--) {
if (entry.getStringValue(i).toLowerCase().contains(fragment.toLowerCase())) {
return true;
}
}
return false;
}
};
TableRowSorter<UserCertificateTableModel> sorter = new TableRowSorter<UserCertificateTableModel>(tableModel);
sorter.setRowFilter(containsFilter);
table.setRowSorter(sorter);
}
use of javax.swing.table.TableRowSorter in project binnavi by google.
the class ComplexTypePanel method createControls.
private void createControls(final List<BaseType> baseTypes) {
setBorder(new EmptyBorder(5, 5, 5, 5));
final GridBagLayout gridBagLayout = new GridBagLayout();
gridBagLayout.columnWidths = new int[] { 0, 0, 0 };
gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0, 0 };
gridBagLayout.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 1.0, 1.0, Double.MIN_VALUE };
setLayout(gridBagLayout);
final JLabel lblName = new JLabel("Name:");
GridBagConstraints gbcLblName = new GridBagConstraints();
gbcLblName.insets = new Insets(0, 0, 5, 5);
gbcLblName.anchor = GridBagConstraints.WEST;
gbcLblName.gridx = 0;
gbcLblName.gridy = 0;
add(lblName, gbcLblName);
name = new JTextField();
GridBagConstraints gbcName = new GridBagConstraints();
gbcName.insets = new Insets(0, 0, 5, 0);
gbcName.fill = GridBagConstraints.HORIZONTAL;
gbcName.gridx = 1;
gbcName.gridy = 0;
add(name, gbcName);
name.setColumns(10);
final JLabel lblMembers = new JLabel("Members:");
final GridBagConstraints gbcLblMembers = new GridBagConstraints();
gbcLblMembers.anchor = GridBagConstraints.WEST;
gbcLblMembers.insets = new Insets(0, 0, 5, 5);
gbcLblMembers.gridx = 0;
gbcLblMembers.gridy = 2;
add(lblMembers, gbcLblMembers);
final MemberTableModel model = new MemberTableModel();
model.addTableModelListener(new MemberTableModelListener());
members = new MemberTable(model, baseTypes);
final TableRowSorter<MemberTableModel> sorter = new TableRowSorter<MemberTableModel>(model);
// Triggers immediate re-sort when offset is updated.
sorter.setSortsOnUpdates(true);
sorter.setSortable(MemberTableModel.NAME_COLUMN, false);
sorter.setSortable(MemberTableModel.TYPE_COLUMN, false);
// Initial state is ascending sort order.
sorter.toggleSortOrder(MemberTableModel.INDEX_COLUMN);
members.setRowSorter(sorter);
final GridBagConstraints gbcMembers = new GridBagConstraints();
gbcMembers.insets = new Insets(0, 0, 5, 0);
gbcMembers.fill = GridBagConstraints.BOTH;
gbcMembers.gridx = 1;
gbcMembers.gridy = 2;
add(new JScrollPane(members), gbcMembers);
final JLabel lblPreview = new JLabel("Preview:");
final GridBagConstraints gbcLblPreview = new GridBagConstraints();
gbcLblPreview.anchor = GridBagConstraints.WEST;
gbcLblPreview.insets = new Insets(0, 0, 0, 5);
gbcLblPreview.gridx = 0;
gbcLblPreview.gridy = 3;
add(lblPreview, gbcLblPreview);
final JTextArea preview = new JTextArea();
final GridBagConstraints gbcPreview = new GridBagConstraints();
gbcPreview.fill = GridBagConstraints.BOTH;
gbcPreview.gridx = 1;
gbcPreview.gridy = 3;
add(preview, gbcPreview);
}
use of javax.swing.table.TableRowSorter in project jdk8u_jdk by JetBrains.
the class bug7055065 method createAndShowUI.
private static void createAndShowUI() {
JFrame frame = new JFrame("SimpleTableDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel newContentPane = new JPanel();
newContentPane.setOpaque(true);
frame.setContentPane(newContentPane);
final String[] columnNames = { "String", "Number" };
final Object[][] data = { { "aaaa", new Integer(1) }, { "bbbb", new Integer(3) }, { "cccc", new Integer(2) }, { "dddd", new Integer(4) }, { "eeee", new Integer(5) } };
table = new JTable(data, columnNames);
table.setPreferredScrollableViewportSize(new Dimension(500, 400));
table.setFillsViewportHeight(true);
TableModel dataModel = new AbstractTableModel() {
public int getColumnCount() {
return columnNames.length;
}
public int getRowCount() {
return data.length;
}
public Object getValueAt(int row, int col) {
return data[row][col];
}
public String getColumnName(int column) {
return columnNames[column];
}
public Class<?> getColumnClass(int c) {
return getValueAt(0, c).getClass();
}
public boolean isCellEditable(int row, int col) {
return col != 5;
}
public void setValueAt(Object aValue, int row, int column) {
data[row][column] = aValue;
}
};
table.setModel(dataModel);
TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(dataModel);
table.setRowSorter(sorter);
JScrollPane scrollPane = new JScrollPane(table);
newContentPane.add(scrollPane);
frame.pack();
frame.setLocation(0, 0);
frame.setVisible(true);
}
use of javax.swing.table.TableRowSorter in project otapij by FellowTraveler.
the class MarketTradesTableModel method setValue.
public void setValue(Map values, JTable table) {
clearValue();
System.out.println("values.size():" + values.size());
Set set = values.keySet();
Iterator iterator = set.iterator();
int i = 0;
data = new Object[values.size()][];
while (iterator.hasNext()) {
String key = (String) iterator.next();
String[] row = (String[]) values.get(key);
data[i] = row;
i++;
}
if (values.size() > 0) {
RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(this);
table.setRowSorter(sorter);
}
fireTableDataChanged();
}
use of javax.swing.table.TableRowSorter in project otapij by FellowTraveler.
the class BitcoinReceivingAddrTableModel method setValue.
public void setValue(Map values, JTable receiveAddrTable) {
clearValue();
System.out.println("values.size():" + values.size());
Set set = values.keySet();
Iterator iterator = set.iterator();
int i = 0;
data = new Object[values.size()][];
while (iterator.hasNext()) {
String key = (String) iterator.next();
String[] row = (String[]) values.get(key);
data[i] = row;
i++;
}
RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(this);
receiveAddrTable.setRowSorter(sorter);
/*TableColumnModel tcm = receiveAddrTable.getColumnModel();
System.out.println("receivedTable.getColumn()"+tcm.getColumnCount());
if(tcm.getColumnCount()==6){
receiveAddrTable.removeColumn(tcm.getColumn(5));
}*/
fireTableDataChanged();
}
Aggregations