001    package org.shiftone.jrat.provider.tree.ui.summary.action;
002    
003    import org.jdesktop.swingx.JXTable;
004    import org.jdesktop.swingx.decorator.SortOrder;
005    import org.jdesktop.swingx.table.TableColumnExt;
006    import org.shiftone.jrat.desktop.util.Table;
007    
008    import javax.swing.*;
009    import java.awt.event.ActionEvent;
010    
011    /**
012     * @author (jeff@shiftone.org) Jeff Drost
013     */
014    public class SortAndShowColumnAction extends AbstractAction {
015    
016        private final JXTable table;
017        private final int index;
018    
019    
020        public SortAndShowColumnAction(String string, JXTable table, Table.Column tableColumn) {
021            super(string);
022            this.table = table;
023            this.index = tableColumn.getIndex();
024    
025        }
026    
027    
028        public void actionPerformed(ActionEvent actionEvent) {
029    
030            TableColumnExt tableColumnExt = (TableColumnExt) table.getColumns(true).get(index);
031    
032            // not sure I want to do this
033            tableColumnExt.setVisible(true);
034    
035            table.setSortOrder(tableColumnExt.getIdentifier(), SortOrder.DESCENDING);
036            table.scrollRowToVisible(0);
037        }
038    }