39 |
import javax.swing.Action; |
import javax.swing.Action; |
40 |
import javax.swing.BorderFactory; |
import javax.swing.BorderFactory; |
41 |
import javax.swing.BoxLayout; |
import javax.swing.BoxLayout; |
42 |
|
import javax.swing.Icon; |
43 |
import javax.swing.JCheckBox; |
import javax.swing.JCheckBox; |
44 |
import javax.swing.JComponent; |
import javax.swing.JComponent; |
45 |
import javax.swing.JFrame; |
import javax.swing.JFrame; |
78 |
|
|
79 |
import org.jsampler.task.InstrumentsDb; |
import org.jsampler.task.InstrumentsDb; |
80 |
|
|
|
import org.jsampler.view.DbClipboard; |
|
81 |
import org.jsampler.view.DbDirectoryTreeNode; |
import org.jsampler.view.DbDirectoryTreeNode; |
82 |
import org.jsampler.view.InstrumentsDbTableModel; |
import org.jsampler.view.InstrumentsDbTableModel; |
83 |
|
import org.jsampler.view.InstrumentsDbTableView; |
84 |
|
import org.jsampler.view.std.JSInstrumentsDbTable; |
85 |
|
import org.jsampler.view.std.JSInstrumentsDbTree; |
86 |
|
|
87 |
import org.linuxsampler.lscp.DbDirectoryInfo; |
import org.linuxsampler.lscp.DbDirectoryInfo; |
88 |
import org.linuxsampler.lscp.DbInstrumentInfo; |
import org.linuxsampler.lscp.DbInstrumentInfo; |
89 |
import org.linuxsampler.lscp.DbSearchQuery; |
import org.linuxsampler.lscp.DbSearchQuery; |
90 |
|
|
91 |
import static org.jsampler.view.classic.ClassicI18n.i18n; |
import static org.jsampler.view.classic.ClassicI18n.i18n; |
92 |
|
import static org.jsampler.view.classic.ClassicPrefs.preferences; |
93 |
|
|
94 |
/** |
/** |
95 |
* |
* |
97 |
*/ |
*/ |
98 |
public class InstrumentsDbFrame extends JFrame { |
public class InstrumentsDbFrame extends JFrame { |
99 |
private final JMenuBar menuBar = new JMenuBar(); |
private final JMenuBar menuBar = new JMenuBar(); |
100 |
private final InstrumentsDbTree instrumentsDbTree; |
private final JSInstrumentsDbTree instrumentsDbTree; |
101 |
private final SidePane sidePane; |
private final SidePane sidePane; |
102 |
private final JSplitPane splitPane; |
private final JSplitPane splitPane; |
103 |
private final MainPane mainPane; |
private final MainPane mainPane; |
108 |
|
|
109 |
private final NavigationHistoryModel navigationHistoryModel = new NavigationHistoryModel(); |
private final NavigationHistoryModel navigationHistoryModel = new NavigationHistoryModel(); |
110 |
|
|
|
private static final DbClipboard dbClipboard = new DbClipboard(); |
|
|
|
|
111 |
private JMenu loadInstrumentMenu; |
private JMenu loadInstrumentMenu; |
112 |
private JMenu addToMidiMapMenu; |
private JMenu addToMidiMapMenu; |
113 |
private JMenu addToOrchestraMenu; |
private JMenu addToOrchestraMenu; |
120 |
setTitle(i18n.getLabel("InstrumentsDbFrame.title")); |
setTitle(i18n.getLabel("InstrumentsDbFrame.title")); |
121 |
if(Res.appIcon != null) setIconImage(Res.appIcon.getImage()); |
if(Res.appIcon != null) setIconImage(Res.appIcon.getImage()); |
122 |
|
|
123 |
instrumentsDbTree = new InstrumentsDbTree(CC.getInstrumentsDbTreeModel()); |
instrumentsDbTree = new JSInstrumentsDbTree(CC.getInstrumentsDbTreeModel()); |
124 |
|
|
125 |
sidePane = new SidePane(); |
sidePane = new SidePane(); |
126 |
mainPane = new MainPane(); |
mainPane = new MainPane(); |
191 |
|
|
192 |
m.addSeparator(); |
m.addSeparator(); |
193 |
|
|
194 |
|
mi = new JMenuItem(i18n.getMenuLabel("instrumentsdb.actions.format")); |
195 |
|
m.add(mi); |
196 |
|
mi.addActionListener(new ActionListener() { |
197 |
|
public void |
198 |
|
actionPerformed(ActionEvent e) { |
199 |
|
String s = i18n.getMessage("InstrumentsDbFrame.formatDatabase?"); |
200 |
|
if(!HF.showYesNoDialog(InstrumentsDbFrame.this, s)) return; |
201 |
|
CC.getTaskQueue().add(new InstrumentsDb.Format()); |
202 |
|
} |
203 |
|
}); |
204 |
|
|
205 |
|
m.addSeparator(); |
206 |
|
|
207 |
loadInstrumentMenu = |
loadInstrumentMenu = |
208 |
new JMenu(i18n.getMenuLabel("instrumentsdb.actions.loadInstrument")); |
new JMenu(i18n.getMenuLabel("instrumentsdb.actions.loadInstrument")); |
209 |
m.add(loadInstrumentMenu); |
m.add(loadInstrumentMenu); |
296 |
}); |
}); |
297 |
} |
} |
298 |
|
|
|
public static DbClipboard |
|
|
getDbClipboard() { return dbClipboard; } |
|
|
|
|
299 |
/** Invoked when this window is about to close. */ |
/** Invoked when this window is about to close. */ |
300 |
private void |
private void |
301 |
onWindowClose() { |
onWindowClose() { |
310 |
sb.append(d.width).append(',').append(d.height); |
sb.append(d.width).append(',').append(d.height); |
311 |
ClassicPrefs.setWindowSizeAndLocation("InstrumentsDbFrame", sb.toString()); |
ClassicPrefs.setWindowSizeAndLocation("InstrumentsDbFrame", sb.toString()); |
312 |
int i = splitPane.getDividerLocation(); |
int i = splitPane.getDividerLocation(); |
313 |
ClassicPrefs.setIntProperty("InstrumentsDbFrame.dividerLocation", i); |
preferences().setIntProperty("InstrumentsDbFrame.dividerLocation", i); |
314 |
|
|
315 |
mainPane.getInstrumentsTable().saveColumnsVisibleState(); |
mainPane.getInstrumentsTable().saveColumnsVisibleState(); |
316 |
mainPane.getInstrumentsTable().saveColumnWidths(); |
mainPane.getInstrumentsTable().saveColumnWidths(); |
349 |
|
|
350 |
setBounds(x, y, width, height); |
setBounds(x, y, width, height); |
351 |
|
|
352 |
i = ClassicPrefs.getIntProperty("InstrumentsDbFrame.dividerLocation"); |
i = preferences().getIntProperty("InstrumentsDbFrame.dividerLocation"); |
353 |
if(i != 0) splitPane.setDividerLocation(i); |
if(i != 0) splitPane.setDividerLocation(i); |
354 |
|
|
355 |
} catch(Exception x) { |
} catch(Exception x) { |
367 |
getContentPane().remove(mainPane); |
getContentPane().remove(mainPane); |
368 |
splitPane.setRightComponent(mainPane); |
splitPane.setRightComponent(mainPane); |
369 |
getContentPane().add(splitPane); |
getContentPane().add(splitPane); |
370 |
int i = ClassicPrefs.getIntProperty("InstrumentsDbFrame.dividerLocation"); |
int i = preferences().getIntProperty("InstrumentsDbFrame.dividerLocation"); |
371 |
if(i != 0) splitPane.setDividerLocation(i); |
if(i != 0) splitPane.setDividerLocation(i); |
372 |
} |
} |
373 |
|
|
374 |
private void |
private void |
375 |
removeSidePane() { |
removeSidePane() { |
376 |
int i = splitPane.getDividerLocation(); |
int i = splitPane.getDividerLocation(); |
377 |
ClassicPrefs.setIntProperty("InstrumentsDbFrame.dividerLocation", i); |
preferences().setIntProperty("InstrumentsDbFrame.dividerLocation", i); |
378 |
getContentPane().remove(splitPane); |
getContentPane().remove(splitPane); |
379 |
getContentPane().add(mainPane); |
getContentPane().add(mainPane); |
380 |
} |
} |
595 |
} |
} |
596 |
} |
} |
597 |
|
|
598 |
public InstrumentsDbTree |
public JSInstrumentsDbTree |
599 |
getInstrumentsDbTree() { return instrumentsDbTree; } |
getInstrumentsDbTree() { return instrumentsDbTree; } |
600 |
|
|
601 |
public void |
public void |
635 |
} |
} |
636 |
|
|
637 |
class MainPane extends JPanel { |
class MainPane extends JPanel { |
638 |
private final InstrumentsDbTable instrumentsTable = |
private final JSInstrumentsDbTable instrumentsTable = |
639 |
new InstrumentsDbTable(instrumentsDbTree); |
new JSInstrumentsDbTable(instrumentsDbTree); |
640 |
|
|
641 |
private final DbDirectoryTreeNode searchResultsNode = new DbDirectoryTreeNode(null); |
private final DbDirectoryTreeNode searchResultsNode = new DbDirectoryTreeNode(null); |
642 |
|
|
644 |
setLayout(new BorderLayout()); |
setLayout(new BorderLayout()); |
645 |
JScrollPane sp = new JScrollPane(instrumentsTable); |
JScrollPane sp = new JScrollPane(instrumentsTable); |
646 |
add(sp); |
add(sp); |
647 |
|
instrumentsTable.reloadAction.putValue(Action.SMALL_ICON, Res.iconReload22); |
648 |
|
|
649 |
|
instrumentsTable.createDirectoryAction.putValue ( |
650 |
|
Action.SMALL_ICON, Res.iconNew16 |
651 |
|
); |
652 |
|
|
653 |
instrumentsTable.getParent().setBackground(instrumentsTable.getBackground()); |
instrumentsTable.getParent().setBackground(instrumentsTable.getBackground()); |
654 |
instrumentsTable.getRowSorter().toggleSortOrder(0); |
instrumentsTable.getRowSorter().toggleSortOrder(0); |
655 |
searchResultsNode.setDetached(true); |
searchResultsNode.setDetached(true); |
656 |
} |
} |
657 |
|
|
658 |
public InstrumentsDbTable |
public JSInstrumentsDbTable |
659 |
getInstrumentsTable() { return instrumentsTable; } |
getInstrumentsTable() { return instrumentsTable; } |
660 |
|
|
661 |
public DbDirectoryTreeNode |
public DbDirectoryTreeNode |