25 |
import java.awt.BorderLayout; |
import java.awt.BorderLayout; |
26 |
import java.awt.Dimension; |
import java.awt.Dimension; |
27 |
|
|
28 |
|
import java.awt.event.ActionEvent; |
29 |
|
import java.awt.event.ActionListener; |
30 |
|
|
31 |
import java.util.List; |
import java.util.List; |
32 |
|
|
33 |
|
import javax.swing.Action; |
34 |
|
import javax.swing.JButton; |
35 |
import javax.swing.JComponent; |
import javax.swing.JComponent; |
36 |
import javax.swing.JPanel; |
import javax.swing.JPanel; |
37 |
import javax.swing.JScrollPane; |
import javax.swing.JScrollPane; |
38 |
import javax.swing.JSplitPane; |
import javax.swing.JSplitPane; |
39 |
import javax.swing.RowSorter.SortKey; |
import javax.swing.JToolBar; |
|
import javax.swing.SortOrder; |
|
|
|
|
|
import javax.swing.event.ChangeEvent; |
|
|
import javax.swing.event.ChangeListener; |
|
40 |
|
|
41 |
import org.jsampler.CC; |
import org.jsampler.CC; |
42 |
|
|
43 |
import org.jsampler.view.InstrumentsDbTreeModel; |
import org.jsampler.view.InstrumentsDbTreeModel; |
44 |
|
|
45 |
|
import org.jsampler.view.std.JSInstrumentsDbColumnPreferencesDlg; |
46 |
import org.jsampler.view.std.JSInstrumentsDbTable; |
import org.jsampler.view.std.JSInstrumentsDbTable; |
47 |
|
|
48 |
import org.jvnet.substance.SubstanceLookAndFeel; |
import org.jvnet.substance.SubstanceLookAndFeel; |
69 |
instrumentsDbTree = new FantasiaInstrumentsDbTree(new InstrumentsDbTreeModel(true)); |
instrumentsDbTree = new FantasiaInstrumentsDbTree(new InstrumentsDbTreeModel(true)); |
70 |
} |
} |
71 |
|
|
72 |
instrumentsTable = new JSInstrumentsDbTable(instrumentsDbTree); |
instrumentsTable = new JSInstrumentsDbTable(instrumentsDbTree, "InstrumentsDbPane."); |
|
instrumentsTable.getModel().showNameColumnOnly(); |
|
73 |
instrumentsTable.getModel().setShowDummyColumn(true); |
instrumentsTable.getModel().setShowDummyColumn(true); |
74 |
instrumentsTable.loadColumnWidths("InstrumentsDbPane."); |
instrumentsTable.loadColumnsVisibleState(); |
75 |
instrumentsTable.getRowSorter().toggleSortOrder(0); |
instrumentsTable.loadColumnWidths(); |
76 |
boolean b = preferences().getBoolProperty("InstrumentsDbPane.reverseSortOrder"); |
instrumentsTable.loadSortOrder(); |
|
if(b) instrumentsTable.getRowSorter().toggleSortOrder(0); |
|
|
|
|
|
CC.addInstrumentsDbChangeListener(new ChangeListener() { |
|
|
public void |
|
|
stateChanged(ChangeEvent e) { |
|
|
instrumentsDbTree.setModel(CC.getInstrumentsDbTreeModel()); |
|
|
|
|
|
CC.scheduleInTaskQueue(new Runnable() { |
|
|
public void |
|
|
run() { instrumentsDbTree.setSelectedDirectory("/"); } |
|
|
}); |
|
|
} |
|
|
}); |
|
77 |
|
|
78 |
instrumentsDbTree.setSelectedDirectory("/"); |
instrumentsDbTree.setSelectedDirectory("/"); |
79 |
|
|
92 |
); |
); |
93 |
|
|
94 |
add(splitPane); |
add(splitPane); |
95 |
|
add(new ToolBar(), BorderLayout.NORTH); |
96 |
} |
} |
97 |
|
|
98 |
protected void |
protected void |
99 |
savePreferences() { |
savePreferences() { |
100 |
instrumentsTable.saveColumnWidths("InstrumentsDbPane."); |
instrumentsTable.saveColumnsVisibleState(); |
101 |
|
instrumentsTable.saveColumnWidths(); |
102 |
List<? extends SortKey> list = instrumentsTable.getRowSorter().getSortKeys(); |
} |
103 |
if(list.isEmpty()) return; |
|
104 |
SortKey k = list.get(0); |
class ToolBar extends JToolBar { |
105 |
if(k.getColumn() != 0) return; |
protected final JButton btnGoUp = new ToolbarButton(instrumentsDbTree.actionGoUp); |
106 |
boolean b = k.getSortOrder() == SortOrder.DESCENDING; |
protected final JButton btnGoBack = new ToolbarButton(instrumentsDbTree.actionGoBack); |
107 |
preferences().setBoolProperty("InstrumentsDbPane.reverseSortOrder", b); |
protected final JButton btnGoForward = new ToolbarButton(instrumentsDbTree.actionGoForward); |
108 |
|
protected final JButton btnReload = new ToolbarButton(instrumentsTable.reloadAction); |
109 |
|
protected final JButton btnPreferences = new ToolbarButton(null); |
110 |
|
|
111 |
|
public ToolBar() { |
112 |
|
super(""); |
113 |
|
setFloatable(false); |
114 |
|
|
115 |
|
add(btnGoBack); |
116 |
|
add(btnGoForward); |
117 |
|
add(btnGoUp); |
118 |
|
|
119 |
|
instrumentsTable.reloadAction.putValue(Action.SMALL_ICON, Res.iconReload16); |
120 |
|
add(btnReload); |
121 |
|
|
122 |
|
addSeparator(); |
123 |
|
|
124 |
|
btnPreferences.setIcon(Res.iconPreferences16); |
125 |
|
add(btnPreferences); |
126 |
|
|
127 |
|
btnPreferences.addActionListener(new ActionListener() { |
128 |
|
public void |
129 |
|
actionPerformed(ActionEvent e) { |
130 |
|
new PreferencesDlg().setVisible(true); |
131 |
|
} |
132 |
|
}); |
133 |
|
} |
134 |
|
} |
135 |
|
|
136 |
|
class PreferencesDlg extends JSInstrumentsDbColumnPreferencesDlg { |
137 |
|
PreferencesDlg() { |
138 |
|
super(CC.getMainFrame(), instrumentsTable); |
139 |
|
} |
140 |
} |
} |
141 |
} |
} |