/** * Sorts on the specified column. * * @param column the column index. * @param ascending a flag that controls the sort order. * */ public void sortByColumn(final int column, final boolean ascending) { if (isSortable(column)) { super.sortByColumn(column, ascending); Collections.sort(this.properties, new SystemPropertyComparator(ascending)); } }
/** * Sorts on the specified column. * * @param column the column index. * @param ascending a flag that controls the sort order. * */ public void sortByColumn(final int column, final boolean ascending) { if (isSortable(column)) { super.sortByColumn(column, ascending); Collections.sort(this.properties, new SystemPropertyComparator(ascending)); } }
/** * Sorts on the specified column. * * @param column the column index. * @param ascending a flag that controls the sort order. * */ public void sortByColumn(final int column, final boolean ascending) { if (isSortable(column)) { super.sortByColumn(column, ascending); Collections.sort(this.properties, new SystemPropertyComparator(ascending)); } }
/** * Changes the model for the table. Takes care of updating the header listener at the * same time. * * @param model the table model. * */ public void setSortableModel(final SortableTableModel model) { super.setModel(model); this.headerListener.setTableModel(model); final SortButtonRenderer renderer = new SortButtonRenderer(); final TableColumnModel cm = getColumnModel(); for (int i = 0; i < cm.getColumnCount(); i++) { cm.getColumn(i).setHeaderRenderer(renderer); } model.sortByColumn(0, true); }
/** * Changes the model for the table. Takes care of updating the header listener at the * same time. * * @param model the table model. * */ public void setSortableModel(final SortableTableModel model) { super.setModel(model); this.headerListener.setTableModel(model); final SortButtonRenderer renderer = new SortButtonRenderer(); final TableColumnModel cm = getColumnModel(); for (int i = 0; i < cm.getColumnCount(); i++) { cm.getColumn(i).setHeaderRenderer(renderer); } model.sortByColumn(0, true); }
/** * Changes the model for the table. Takes care of updating the header listener at the * same time. * * @param model the table model. * */ public void setSortableModel(final SortableTableModel model) { super.setModel(model); this.headerListener.setTableModel(model); final SortButtonRenderer renderer = new SortButtonRenderer(); final TableColumnModel cm = getColumnModel(); for (int i = 0; i < cm.getColumnCount(); i++) { cm.getColumn(i).setHeaderRenderer(renderer); } model.sortByColumn(0, true); }
/** * When the user releases the mouse button, we attempt to sort the table. * * @param e the mouse event. */ public void mouseReleased(final MouseEvent e) { final JTableHeader header = (JTableHeader) e.getComponent(); if (header.getResizingColumn() == null) { // resizing takes precedence over sorting if (this.sortColumnIndex != -1) { final SortableTableModel model = (SortableTableModel) header.getTable().getModel(); final boolean ascending = !model.isAscending(); model.setAscending(ascending); model.sortByColumn(this.sortColumnIndex, ascending); this.renderer.setPressedColumn(-1); // clear header.repaint(); } } }
/** * When the user releases the mouse button, we attempt to sort the table. * * @param e the mouse event. */ public void mouseReleased(final MouseEvent e) { final JTableHeader header = (JTableHeader) e.getComponent(); if (header.getResizingColumn() == null) { // resizing takes precedence over sorting if (this.sortColumnIndex != -1) { final SortableTableModel model = (SortableTableModel) header.getTable().getModel(); final boolean ascending = !model.isAscending(); model.setAscending(ascending); model.sortByColumn(this.sortColumnIndex, ascending); this.renderer.setPressedColumn(-1); // clear header.repaint(); } } }
/** * When the user releases the mouse button, we attempt to sort the table. * * @param e the mouse event. */ public void mouseReleased(final MouseEvent e) { final JTableHeader header = (JTableHeader) e.getComponent(); if (header.getResizingColumn() == null) { // resizing takes precedence over sorting if (this.sortColumnIndex != -1) { final SortableTableModel model = (SortableTableModel) header.getTable().getModel(); final boolean ascending = !model.isAscending(); model.setAscending(ascending); model.sortByColumn(this.sortColumnIndex, ascending); this.renderer.setPressedColumn(-1); // clear header.repaint(); } } }
/** * Standard constructor - builds a table for the specified model. * * @param model the data. */ public SortableTable(final SortableTableModel model) { super(model); final SortButtonRenderer renderer = new SortButtonRenderer(); final TableColumnModel cm = getColumnModel(); for (int i = 0; i < cm.getColumnCount(); i++) { cm.getColumn(i).setHeaderRenderer(renderer); } final JTableHeader header = getTableHeader(); this.headerListener = new SortableTableHeaderListener(model, renderer); header.addMouseListener(this.headerListener); header.addMouseMotionListener(this.headerListener); model.sortByColumn(0, true); }
/** * Standard constructor - builds a table for the specified model. * * @param model the data. */ public SortableTable(final SortableTableModel model) { super(model); final SortButtonRenderer renderer = new SortButtonRenderer(); final TableColumnModel cm = getColumnModel(); for (int i = 0; i < cm.getColumnCount(); i++) { cm.getColumn(i).setHeaderRenderer(renderer); } final JTableHeader header = getTableHeader(); this.headerListener = new SortableTableHeaderListener(model, renderer); header.addMouseListener(this.headerListener); header.addMouseMotionListener(this.headerListener); model.sortByColumn(0, true); }
/** * Standard constructor - builds a table for the specified model. * * @param model the data. */ public SortableTable(final SortableTableModel model) { super(model); final SortButtonRenderer renderer = new SortButtonRenderer(); final TableColumnModel cm = getColumnModel(); for (int i = 0; i < cm.getColumnCount(); i++) { cm.getColumn(i).setHeaderRenderer(renderer); } final JTableHeader header = getTableHeader(); this.headerListener = new SortableTableHeaderListener(model, renderer); header.addMouseListener(this.headerListener); header.addMouseMotionListener(this.headerListener); model.sortByColumn(0, true); }