/** * Installs a new TableComparatorChooser that responds to clicks on the * header of the specified table and uses them to sort the specified * <code>sortedList</code> by delegating to the given <code>strategy</code> * If at any time the table should no longer sort, the behaviour can be * removed calling {@link #dispose()} on the object returned by this method. * * <p>This method assumes that the JTable is backed by an AdvancedTableModel * and it is from that AdvancedTableModel that the TableFormat should be * extracted. This is, by far, the typical case and so we provide this * simpler install method for convenience. * * @param table the table with headers that can be clicked on * @param sortedList the sorted list to update * @param strategy an implementations of {@link SortingStrategy}, typically one of * <ul> * <li> {@link AbstractTableComparatorChooser#SINGLE_COLUMN} * <li> {@link AbstractTableComparatorChooser#MULTIPLE_COLUMN_MOUSE} * <li> {@link AbstractTableComparatorChooser#MULTIPLE_COLUMN_KEYBOARD} * <li> {@link AbstractTableComparatorChooser#MULTIPLE_COLUMN_MOUSE_WITH_UNDO} * </ul> * @return TableComparatorChooser object that is responsible for translating * mouse clicks on the table header into sorting actions on the sortedList. */ public static <E> TableComparatorChooser<E> install(JTable table, SortedList<E> sortedList, Object strategy) { return install(table, sortedList, strategy, ((AdvancedTableModel<E>)table.getModel()).getTableFormat()); }
/** * Installs a new TableComparatorChooser that responds to clicks on the * header of the specified table and uses them to sort the specified * <code>sortedList</code> by delegating to the given <code>strategy</code> * If at any time the table should no longer sort, the behaviour can be * removed calling {@link #dispose()} on the object returned by this method. * * <p>This method assumes that the JTable is backed by an AdvancedTableModel * and it is from that AdvancedTableModel that the TableFormat should be * extracted. This is, by far, the typical case and so we provide this * simpler install method for convenience. * * @param table the table with headers that can be clicked on * @param sortedList the sorted list to update * @param strategy an implementations of {@link SortingStrategy}, typically one of * <ul> * <li> {@link AbstractTableComparatorChooser#SINGLE_COLUMN} * <li> {@link AbstractTableComparatorChooser#MULTIPLE_COLUMN_MOUSE} * <li> {@link AbstractTableComparatorChooser#MULTIPLE_COLUMN_KEYBOARD} * <li> {@link AbstractTableComparatorChooser#MULTIPLE_COLUMN_MOUSE_WITH_UNDO} * </ul> * @return TableComparatorChooser object that is responsible for translating * mouse clicks on the table header into sorting actions on the sortedList. */ public static <E> TableComparatorChooser<E> install(JTable table, SortedList<E> sortedList, Object strategy) { return install(table, sortedList, strategy, ((AdvancedTableModel<E>)table.getModel()).getTableFormat()); }
return install(table, sortedList, strategy, ((AdvancedTableModel<E>)table.getModel()).getTableFormat());
/** * Initializes sorting capabilities */ protected void initSorting() { if (getTableHeader() != null) { if (this.tableComparatorChooser != null) { this.tableComparatorChooser.dispose(); } this.tableComparatorChooser = TableComparatorChooser.install(this, this.sortedList, AbstractTableComparatorChooser.MULTIPLE_COLUMN_MOUSE); } }
table.setColumnControlVisible(true); TableComparatorChooser.install(table, sortedIssues, TableComparatorChooser.MULTIPLE_COLUMN_MOUSE_WITH_UNDO);
table.setColumnControlVisible(true); TableComparatorChooser.install(table, sortedIssues, TableComparatorChooser.MULTIPLE_COLUMN_MOUSE_WITH_UNDO);
/** Installs the GlazedLists integration on the given JXTable. */ private JXTableSupport(JXTable table, EventList<E> eventList, TableFormat<? super E> tableFormat, SortedList<E> sortedList, Object sortingStrategy) { this.table = table; this.tableFormat = tableFormat; // remember table state for restore on uninstall tableMemento = JXTableMemento.create(table); tableMemento.storeStateFrom(table); // set state needed to integrate with Glazed Lists tableMemento.configureStateForGlazedLists(table); // prepare and set TableModel und SelectionModel tableModel = GlazedListsSwing.eventTableModelWithThreadProxyList(eventList, tableFormat); table.setModel(tableModel); selectionModel = GlazedListsSwing.eventSelectionModelWithThreadProxyList(eventList); table.setSelectionModel(selectionModel); // finally install TableComparatorChooser tableComparatorChooser = TableComparatorChooser.<E>install(table, sortedList, sortingStrategy, tableFormat); }
/** Installs the GlazedLists integration on the given JXTable. */ private JXTableSupport(JXTable table, EventList<E> eventList, TableFormat<? super E> tableFormat, SortedList<E> sortedList, Object sortingStrategy) { this.table = table; this.tableFormat = tableFormat; // remember table state for restore on uninstall tableMemento = JXTableMemento.create(table); tableMemento.storeStateFrom(table); // set state needed to integrate with Glazed Lists tableMemento.configureStateForGlazedLists(table); // prepare and set TableModel und SelectionModel tableModel = GlazedListsSwing.eventTableModelWithThreadProxyList(eventList, tableFormat); table.setModel(tableModel); selectionModel = GlazedListsSwing.eventSelectionModelWithThreadProxyList(eventList); table.setSelectionModel(selectionModel); // finally install TableComparatorChooser tableComparatorChooser = TableComparatorChooser.<E>install(table, sortedList, sortingStrategy, tableFormat); }
/** * This method initializes projectList. * @return javax.swing.JList */ private JTable getProjectTable() { if (projectTable == null) { projectTableModel = new EventTableModel<>(model.getAllProjectsList(), new ProjectListTableFormat(model)); projectTable = new JHighligthedTable(projectTableModel); TableComparatorChooser.install( projectTable, model.getAllProjectsList(), TableComparatorChooser.MULTIPLE_COLUMN_MOUSE ); projectTable.setToolTipText(textBundle.textFor("ManageProjectsDialog.ProjectList.ToolTipText")); //$NON-NLS-1$ projectTable.getColumn(projectTable.getColumnName(1)).setCellRenderer(new BooleanCellRenderer()); projectTable.getColumn(projectTable.getColumnName(1)).setCellEditor(new JXTable.BooleanEditor()); } return projectTable; }
PaddingTableCellRenderer.install(jTable, 1); TableComparatorChooser.install(jTable, sortedList, TableComparatorChooser.MULTIPLE_COLUMN_MOUSE, tableFormat);
/** * Set up GUI components. */ private void initialize() { // Init search field and a list filtered list for the quick search final JSearchField searchField = new JSearchField(); final MatcherEditor<HoursByProject> textMatcherEditor = new TextComponentMatcherEditor<>(searchField, new HoursByProjectTextFilterator()); final FilterList<HoursByProject> textFilteredIssues = new FilterList<>(this.report.getHoursByProject(), textMatcherEditor); tableModel = new EventTableModel<>(textFilteredIssues, new HoursByProjectTableFormat()); final JTable table = new JHighligthedTable(tableModel); TableComparatorChooser.install( table, this.report.getHoursByProject(), TableComparatorChooser.MULTIPLE_COLUMN_MOUSE ); table.getColumn(table.getColumnName(0)).setCellRenderer(new DefaultTableRenderer(new FormatStringValue(DateFormat.getDateInstance()))); table.getColumn(table.getColumnName(1)).setCellRenderer(new DefaultTableRenderer(new FormatStringValue(new DurationFormat()))); JScrollPane tableScrollPane = new JScrollPane(table); int border = 5; final double[][] size = { { border, TableLayout.FILL, border}, // Columns { border, TableLayout.PREFERRED, border, TableLayout.FILL } }; // Rows this.setLayout(new TableLayout(size)); this.add(searchField, "1, 1"); this.add(tableScrollPane, "1, 3"); }
/** Installs the GlazedLists integration on the given JXTable. */ private JXTableSupport(JXTable table, EventList<E> eventList, TableFormat<? super E> tableFormat, SortedList<E> sortedList, Object sortingStrategy) { this.table = table; this.tableFormat = tableFormat; // remember table state for restore on uninstall tableMemento = JXTableMemento.create(table); tableMemento.storeStateFrom(table); // set state needed to integrate with Glazed Lists tableMemento.configureStateForGlazedLists(table); // prepare and set TableModel und SelectionModel if (table.getFillsViewportHeight()) { // workaround the problem of repainting issues when this property is // set, because of the known mismatch between ListEvents and TableModelEvents // use another event conversion strategy in this case final Factory<E> eventAdapterFactory = GlazedListsSwing.manyToOneEventAdapterFactory(); tableModel = GlazedListsSwing.eventTableModelWithThreadProxyList(eventList, tableFormat, eventAdapterFactory); } else { // use default event conversion strategy tableModel = GlazedListsSwing.eventTableModelWithThreadProxyList(eventList, tableFormat); } table.setModel(tableModel); selectionModel = GlazedListsSwing.eventSelectionModelWithThreadProxyList(eventList); table.setSelectionModel(selectionModel); // finally install TableComparatorChooser tableComparatorChooser = TableComparatorChooser.<E>install(table, sortedList, sortingStrategy, tableFormat); }
jTable.setCellSelectionEnabled(true); TableComparatorChooser.install(jTable, sortedList, TableComparatorChooser.MULTIPLE_COLUMN_MOUSE, tableFormat);
/** * Set up GUI components. */ private void initialize() { // Init search field and a list filtered list for the quick search final JSearchField searchField = new JSearchField(); final MatcherEditor<AccumulatedProjectActivity> textMatcherEditor = new TextComponentMatcherEditor<>(searchField, new AccumulatedProjectActivityTextFilterator()); final FilterList<AccumulatedProjectActivity> textFilteredIssues = new FilterList<>(this.report.getAccumulatedActivitiesByDay(), textMatcherEditor); tableModel = new EventTableModel<>(textFilteredIssues, new AccumulatedActivitiesTableFormat()); final JTable table = new JHighligthedTable(tableModel); TableComparatorChooser.install( table, this.report.getAccumulatedActivitiesByDay(), TableComparatorChooser.MULTIPLE_COLUMN_MOUSE ); table.getColumn(table.getColumnName(0)).setCellRenderer(new DefaultTableRenderer(new FormatStringValue(FormatUtils.DAY_FORMAT))); table.getColumn(table.getColumnName(2)).setCellRenderer(new DefaultTableRenderer(new FormatStringValue(new DurationFormat()))); JScrollPane tableScrollPane = new JScrollPane(table); int border = 5; final double[][] size = { { border, TableLayout.FILL, border}, // Columns { border, TableLayout.PREFERRED, border, TableLayout.FILL } }; // Rows this.setLayout(new TableLayout(size)); this.add(searchField, "1, 1"); this.add(tableScrollPane, "1, 3"); }
PaddingTableCellRenderer.install(jTable, 1); TableComparatorChooser.install(jTable, sortedList, TableComparatorChooser.MULTIPLE_COLUMN_MOUSE, tableFormat);
/** * Set up GUI components. */ private void initialize() { // Init search field and a list filtered list for the quick search final JSearchField searchField = new JSearchField(); final MatcherEditor<HoursByDay> textMatcherEditor = new TextComponentMatcherEditor<>(searchField, new HoursByDayTextFilterator()); final FilterList<HoursByDay> textFilteredIssues = new FilterList<>(this.report.getHoursByDay(), textMatcherEditor); tableModel = new EventTableModel<>(textFilteredIssues, new HoursByDayTableFormat()); final JTable table = new JHighligthedTable(tableModel); TableComparatorChooser.install( table, this.report.getHoursByDay(), TableComparatorChooser.MULTIPLE_COLUMN_MOUSE ); table.getColumn(table.getColumnName(0)).setCellRenderer(new DefaultTableRenderer(new FormatStringValue(DAY_FORMAT))); table.getColumn(table.getColumnName(1)).setCellRenderer(new DefaultTableRenderer(new FormatStringValue(new DurationFormat()))); JScrollPane tableScrollPane = new JScrollPane(table); int border = 5; final double[][] size = { { border, TableLayout.FILL, border}, // Columns { border, TableLayout.PREFERRED, border, TableLayout.FILL } }; // Rows this.setLayout(new TableLayout(size)); this.add(searchField, "1, 1"); this.add(tableScrollPane, "1, 3"); }
/** * Set up GUI components. */ private void initialize() { // Init search field and a list filtered list for the quick search final JSearchField searchField = new JSearchField(); final MatcherEditor<HoursByWeek> textMatcherEditor = new TextComponentMatcherEditor<>(searchField, new HoursByWeekTextFilterator()); final FilterList<HoursByWeek> textFilteredIssues = new FilterList<>(this.report.getHoursByWeek(), textMatcherEditor); tableModel = new EventTableModel<>(textFilteredIssues, new HoursByWeekTableFormat()); final JTable table = new JHighligthedTable(tableModel); TableComparatorChooser.install( table, this.report.getHoursByWeek(), TableComparatorChooser.MULTIPLE_COLUMN_MOUSE ); table.getColumn(table.getColumnName(0)).setCellRenderer(new DefaultTableRenderer(new FormatStringValue(WEEK_FORMAT))); table.getColumn(table.getColumnName(1)).setCellRenderer(new DefaultTableRenderer(new FormatStringValue(YEAR_FORMAT))); table.getColumn(table.getColumnName(2)).setCellRenderer(new DefaultTableRenderer(new FormatStringValue(new DurationFormat()))); JScrollPane tableScrollPane = new JScrollPane(table); int border = 5; final double[][] size = { { border, TableLayout.FILL, border}, // Columns { border, TableLayout.PREFERRED, border, TableLayout.FILL } }; // Rows this.setLayout(new TableLayout(size)); this.add(searchField, "1, 1"); this.add(tableScrollPane, "1, 3"); }
/** * Set up GUI components. */ private void initialize() { // Init search field and a list filtered list for the quick search final JSearchField searchField = new JSearchField(); final MatcherEditor<HoursByMonth> textMatcherEditor = new TextComponentMatcherEditor<>(searchField, new HoursByMonthTextFilterator()); final FilterList<HoursByMonth> textFilteredIssues = new FilterList<>(this.report.getHoursByMonth(), textMatcherEditor); tableModel = new EventTableModel<>(textFilteredIssues, new HoursByMonthTableFormat()); final JTable table = new JHighligthedTable(tableModel); TableComparatorChooser.install( table, this.report.getHoursByMonth(), TableComparatorChooser.MULTIPLE_COLUMN_MOUSE ); table.getColumn(table.getColumnName(0)).setCellRenderer(new DefaultTableRenderer(new FormatStringValue(MONTH_FORMAT))); table.getColumn(table.getColumnName(1)).setCellRenderer(new DefaultTableRenderer(new FormatStringValue(YEAR_FORMAT))); table.getColumn(table.getColumnName(2)).setCellRenderer(new DefaultTableRenderer(new FormatStringValue(new DurationFormat()))); JScrollPane tableScrollPane = new JScrollPane(table); int border = 5; final double[][] size = { { border, TableLayout.FILL, border}, // Columns { border, TableLayout.PREFERRED, border, TableLayout.FILL } }; // Rows this.setLayout(new TableLayout(size)); this.add(searchField, "1, 1"); this.add(tableScrollPane, "1, 3"); }
PaddingTableCellRenderer.install(jTable, 3); TableComparatorChooser.install(jTable, columnSortedList, TableComparatorChooser.MULTIPLE_COLUMN_MOUSE, tableFormat);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.setSelectionModel(new NullSelectionModel()); TableComparatorChooser.install(table, trailerEventList, TableComparatorChooser.SINGLE_COLUMN);