33 |
import java.awt.event.WindowAdapter; |
import java.awt.event.WindowAdapter; |
34 |
import java.awt.event.WindowEvent; |
import java.awt.event.WindowEvent; |
35 |
|
|
36 |
|
import java.util.List; |
37 |
import java.util.logging.Level; |
import java.util.logging.Level; |
38 |
|
|
39 |
import javax.swing.AbstractAction; |
import javax.swing.AbstractAction; |
54 |
import javax.swing.JToggleButton; |
import javax.swing.JToggleButton; |
55 |
import javax.swing.JToolBar; |
import javax.swing.JToolBar; |
56 |
import javax.swing.KeyStroke; |
import javax.swing.KeyStroke; |
57 |
|
import javax.swing.RowSorter.SortKey; |
58 |
|
import javax.swing.SortOrder; |
59 |
|
|
60 |
import javax.swing.event.ChangeEvent; |
import javax.swing.event.ChangeEvent; |
61 |
import javax.swing.event.ChangeListener; |
import javax.swing.event.ChangeListener; |
62 |
import javax.swing.event.ListSelectionEvent; |
import javax.swing.event.ListSelectionEvent; |
63 |
import javax.swing.event.ListSelectionListener; |
import javax.swing.event.ListSelectionListener; |
64 |
|
import javax.swing.event.RowSorterEvent; |
65 |
|
import javax.swing.event.RowSorterListener; |
66 |
import javax.swing.event.TreeSelectionEvent; |
import javax.swing.event.TreeSelectionEvent; |
67 |
import javax.swing.event.TreeSelectionListener; |
import javax.swing.event.TreeSelectionListener; |
68 |
|
|
94 |
import org.linuxsampler.lscp.DbInstrumentInfo; |
import org.linuxsampler.lscp.DbInstrumentInfo; |
95 |
import org.linuxsampler.lscp.DbSearchQuery; |
import org.linuxsampler.lscp.DbSearchQuery; |
96 |
|
|
97 |
|
import static javax.swing.event.RowSorterEvent.Type.SORT_ORDER_CHANGED; |
98 |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
99 |
import static org.jsampler.view.fantasia.FantasiaPrefs.preferences; |
import static org.jsampler.view.fantasia.FantasiaPrefs.preferences; |
100 |
|
import static org.jsampler.view.fantasia.FantasiaPrefs.INSTRUMENTS_DB_FRAME_SORT_ORDER; |
101 |
|
|
102 |
/** |
/** |
103 |
* |
* |
670 |
); |
); |
671 |
|
|
672 |
instrumentsTable.getParent().setBackground(instrumentsTable.getBackground()); |
instrumentsTable.getParent().setBackground(instrumentsTable.getBackground()); |
673 |
instrumentsTable.getRowSorter().toggleSortOrder(0); |
|
674 |
|
int i = preferences().getIntProperty(INSTRUMENTS_DB_FRAME_SORT_ORDER); |
675 |
|
boolean descending = i < 0; |
676 |
|
if(i < 0) i *= -1; |
677 |
|
|
678 |
|
instrumentsTable.getRowSorter().toggleSortOrder(--i); |
679 |
|
if(descending) instrumentsTable.getRowSorter().toggleSortOrder(i); |
680 |
searchResultsNode.setDetached(true); |
searchResultsNode.setDetached(true); |
681 |
|
|
682 |
|
RowSorterListener l = new RowSorterListener() { |
683 |
|
public void |
684 |
|
sorterChanged(RowSorterEvent e) { |
685 |
|
if(e.getType() != SORT_ORDER_CHANGED) return; |
686 |
|
rowSorterChanged(); |
687 |
|
} |
688 |
|
}; |
689 |
|
|
690 |
|
instrumentsTable.getRowSorter().addRowSorterListener(l); |
691 |
|
} |
692 |
|
|
693 |
|
private void |
694 |
|
rowSorterChanged() { |
695 |
|
List<? extends SortKey> list = instrumentsTable.getRowSorter().getSortKeys(); |
696 |
|
if(list.isEmpty()) return; |
697 |
|
SortKey k = list.get(0); |
698 |
|
int i = k.getColumn() + 1; |
699 |
|
if(k.getSortOrder() == SortOrder.UNSORTED) return; |
700 |
|
if(k.getSortOrder() == SortOrder.DESCENDING) i *= -1; |
701 |
|
preferences().setIntProperty(INSTRUMENTS_DB_FRAME_SORT_ORDER, i); |
702 |
} |
} |
703 |
|
|
704 |
public JSInstrumentsDbTable |
public JSInstrumentsDbTable |