/** * 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()); }
/** * 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); } }
/** * 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 makes no assumptions about the TableModel implementation * that backs the JTable. As such, it requires the TableFormat as an explicit * parameter and expects the TableFormat to be constant (i.e. never changes) * for the life of the TableComparatorChooser. * * @param table the table with headers that can be clicked on * @param tableFormat the TableFormat providing the columns for the table * @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, TableFormat<? super E> tableFormat) { return new TableComparatorChooser<E>(table, sortedList, strategy, tableFormat); }
/** * Creates and installs a TableComparatorChooser. * * @param table the table with headers that can be clicked on * @param sortedList the sorted list to update * @param strategy an implementations of {@link ca.odell.glazedlists.impl.gui.SortingStrategy}, typically one of * <ul> * <li> {@link ca.odell.glazedlists.gui.AbstractTableComparatorChooser#SINGLE_COLUMN} * <li> {@link ca.odell.glazedlists.gui.AbstractTableComparatorChooser#MULTIPLE_COLUMN_MOUSE} * <li> {@link ca.odell.glazedlists.gui.AbstractTableComparatorChooser#MULTIPLE_COLUMN_KEYBOARD} * <li> {@link ca.odell.glazedlists.gui.AbstractTableComparatorChooser#MULTIPLE_COLUMN_MOUSE_WITH_UNDO} * @param tableFormat the TableFormat providing the columns for the table */ protected TableComparatorChooser(JTable table, SortedList<E> sortedList, Object strategy, TableFormat<? super E> tableFormat) { super(sortedList, tableFormat); validateSortingStrategy(strategy); // save the Swing-specific state this.table = table; this.table.addPropertyChangeListener("model", tableModelHandler); this.table.getTableHeader().addPropertyChangeListener("UI", tableHeaderUIHandler); // wrap the default table header with logic that decorates it with a sorting icon wrapDefaultTableHeaderRenderer(); // listen for events on the specified table table.getModel().addTableModelListener(tableModelHandler); // install the sorting strategy to interpret clicks headerClickHandler = new HeaderClickHandler(table, (SortingStrategy)strategy); }
jTable.addMouseListener(listener); TableComparatorChooser<TreeAsset> tableComparatorChooser = TableComparatorChooser.install(jTable, sortedList, TableComparatorChooser.MULTIPLE_COLUMN_MOUSE, tableFormat); tableComparatorChooser.addSortActionListener(new ListenerSorter());
/** * Uninstalls the GlazedLists integration and restores the state of JXTable as it was before * the installation. * * @throws IllegalStateException if this method is called from any Thread * other than the Swing Event Dispatch Thread */ public void uninstall() { checkAccessThread(); tableComparatorChooser.dispose(); tableMemento.restoreStateTo(table); tableModel.dispose(); selectionModel.dispose(); tableComparatorChooser = null; tableModel = null; selectionModel = null; tableFormat = null; table = null; tableMemento = null; }
/** * Creates and installs a TableComparatorChooser. * * @param table the table with headers that can be clicked on * @param sortedList the sorted list to update * @param strategy an implementations of {@link ca.odell.glazedlists.impl.gui.SortingStrategy}, typically one of * <ul> * <li> {@link ca.odell.glazedlists.gui.AbstractTableComparatorChooser#SINGLE_COLUMN} * <li> {@link ca.odell.glazedlists.gui.AbstractTableComparatorChooser#MULTIPLE_COLUMN_MOUSE} * <li> {@link ca.odell.glazedlists.gui.AbstractTableComparatorChooser#MULTIPLE_COLUMN_KEYBOARD} * <li> {@link ca.odell.glazedlists.gui.AbstractTableComparatorChooser#MULTIPLE_COLUMN_MOUSE_WITH_UNDO} * @param tableFormat the TableFormat providing the columns for the table */ protected TableComparatorChooser(JTable table, SortedList<E> sortedList, Object strategy, TableFormat<? super E> tableFormat) { super(sortedList, tableFormat); validateSortingStrategy(strategy); // save the Swing-specific state this.table = table; this.table.addPropertyChangeListener("model", tableModelHandler); this.table.getTableHeader().addPropertyChangeListener("UI", tableHeaderUIHandler); // wrap the default table header with logic that decorates it with a sorting icon wrapDefaultTableHeaderRenderer(); // listen for events on the specified table table.getModel().addTableModelListener(tableModelHandler); // install the sorting strategy to interpret clicks headerClickHandler = new HeaderClickHandler(table, (SortingStrategy)strategy); }
/** * Uninstalls the GlazedLists integration and restores the state of JXTable as it was before * the installation. * * @throws IllegalStateException if this method is called from any Thread * other than the Swing Event Dispatch Thread */ public void uninstall() { checkAccessThread(); tableComparatorChooser.dispose(); tableMemento.restoreStateTo(table); tableModel.dispose(); selectionModel.dispose(); tableComparatorChooser = null; tableModel = null; selectionModel = null; tableFormat = null; table = null; tableMemento = null; }
/** * 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()); }
/** * Creates and installs a TableComparatorChooser. * * @param table the table with headers that can be clicked on * @param sortedList the sorted list to update * @param strategy an implementations of {@link ca.odell.glazedlists.impl.gui.SortingStrategy}, typically one of * <ul> * <li> {@link ca.odell.glazedlists.gui.AbstractTableComparatorChooser#SINGLE_COLUMN} * <li> {@link ca.odell.glazedlists.gui.AbstractTableComparatorChooser#MULTIPLE_COLUMN_MOUSE} * <li> {@link ca.odell.glazedlists.gui.AbstractTableComparatorChooser#MULTIPLE_COLUMN_KEYBOARD} * <li> {@link ca.odell.glazedlists.gui.AbstractTableComparatorChooser#MULTIPLE_COLUMN_MOUSE_WITH_UNDO} * @param tableFormat the TableFormat providing the columns for the table */ protected TableComparatorChooser(JTable table, SortedList<E> sortedList, Object strategy, TableFormat<? super E> tableFormat) { super(sortedList, tableFormat); validateSortingStrategy(strategy); // save the Swing-specific state this.table = table; this.table.addPropertyChangeListener("model", tableModelHandler); this.table.getTableHeader().addPropertyChangeListener("UI", tableHeaderUIHandler); // wrap the default table header with logic that decorates it with a sorting icon wrapDefaultTableHeaderRenderer(); // listen for events on the specified table table.getModel().addTableModelListener(tableModelHandler); // install the sorting strategy to interpret clicks headerClickHandler = new HeaderClickHandler(table, (SortingStrategy)strategy); }
/** * Uninstalls the GlazedLists integration and restores the state of JXTable as it was before * the installation. * * @throws IllegalStateException if this method is called from any Thread * other than the Swing Event Dispatch Thread */ public void uninstall() { checkAccessThread(); tableComparatorChooser.dispose(); tableMemento.restoreStateTo(table); tableModel.dispose(); selectionModel.dispose(); tableComparatorChooser = null; tableModel = null; selectionModel = null; tableFormat = null; table = null; tableMemento = null; }
/** * 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 makes no assumptions about the TableModel implementation * that backs the JTable. As such, it requires the TableFormat as an explicit * parameter and expects the TableFormat to be constant (i.e. never changes) * for the life of the TableComparatorChooser. * * @param table the table with headers that can be clicked on * @param tableFormat the TableFormat providing the columns for the table * @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, TableFormat<? super E> tableFormat) { return new TableComparatorChooser<E>(table, sortedList, strategy, tableFormat); }
return install(table, sortedList, strategy, ((AdvancedTableModel<E>)table.getModel()).getTableFormat());
return new TableComparatorChooser<E>(table, sortedList, strategy, tableFormat);
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); }
movieSelectionModel.setTableComparatorChooser(TableComparatorChooser.install(table, sortedMovies, TableComparatorChooser.SINGLE_COLUMN));
PaddingTableCellRenderer.install(jTable, 3); TableComparatorChooser.install(jTable, sortedListColumn, TableComparatorChooser.MULTIPLE_COLUMN_MOUSE, tableFormat);