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(); |
283 |
}); |
}); |
284 |
} |
} |
285 |
|
|
|
public static DbClipboard |
|
|
getDbClipboard() { return dbClipboard; } |
|
|
|
|
286 |
/** Invoked when this window is about to close. */ |
/** Invoked when this window is about to close. */ |
287 |
private void |
private void |
288 |
onWindowClose() { |
onWindowClose() { |
297 |
sb.append(d.width).append(',').append(d.height); |
sb.append(d.width).append(',').append(d.height); |
298 |
ClassicPrefs.setWindowSizeAndLocation("InstrumentsDbFrame", sb.toString()); |
ClassicPrefs.setWindowSizeAndLocation("InstrumentsDbFrame", sb.toString()); |
299 |
int i = splitPane.getDividerLocation(); |
int i = splitPane.getDividerLocation(); |
300 |
ClassicPrefs.setIntProperty("InstrumentsDbFrame.dividerLocation", i); |
preferences().setIntProperty("InstrumentsDbFrame.dividerLocation", i); |
301 |
|
|
302 |
mainPane.getInstrumentsTable().saveColumnsVisibleState(); |
mainPane.getInstrumentsTable().saveColumnsVisibleState(); |
303 |
mainPane.getInstrumentsTable().saveColumnWidths(); |
mainPane.getInstrumentsTable().saveColumnWidths(); |
336 |
|
|
337 |
setBounds(x, y, width, height); |
setBounds(x, y, width, height); |
338 |
|
|
339 |
i = ClassicPrefs.getIntProperty("InstrumentsDbFrame.dividerLocation"); |
i = preferences().getIntProperty("InstrumentsDbFrame.dividerLocation"); |
340 |
if(i != 0) splitPane.setDividerLocation(i); |
if(i != 0) splitPane.setDividerLocation(i); |
341 |
|
|
342 |
} catch(Exception x) { |
} catch(Exception x) { |
354 |
getContentPane().remove(mainPane); |
getContentPane().remove(mainPane); |
355 |
splitPane.setRightComponent(mainPane); |
splitPane.setRightComponent(mainPane); |
356 |
getContentPane().add(splitPane); |
getContentPane().add(splitPane); |
357 |
int i = ClassicPrefs.getIntProperty("InstrumentsDbFrame.dividerLocation"); |
int i = preferences().getIntProperty("InstrumentsDbFrame.dividerLocation"); |
358 |
if(i != 0) splitPane.setDividerLocation(i); |
if(i != 0) splitPane.setDividerLocation(i); |
359 |
} |
} |
360 |
|
|
361 |
private void |
private void |
362 |
removeSidePane() { |
removeSidePane() { |
363 |
int i = splitPane.getDividerLocation(); |
int i = splitPane.getDividerLocation(); |
364 |
ClassicPrefs.setIntProperty("InstrumentsDbFrame.dividerLocation", i); |
preferences().setIntProperty("InstrumentsDbFrame.dividerLocation", i); |
365 |
getContentPane().remove(splitPane); |
getContentPane().remove(splitPane); |
366 |
getContentPane().add(mainPane); |
getContentPane().add(mainPane); |
367 |
} |
} |
582 |
} |
} |
583 |
} |
} |
584 |
|
|
585 |
public InstrumentsDbTree |
public JSInstrumentsDbTree |
586 |
getInstrumentsDbTree() { return instrumentsDbTree; } |
getInstrumentsDbTree() { return instrumentsDbTree; } |
587 |
|
|
588 |
public void |
public void |
622 |
} |
} |
623 |
|
|
624 |
class MainPane extends JPanel { |
class MainPane extends JPanel { |
625 |
private final InstrumentsDbTable instrumentsTable = |
private final JSInstrumentsDbTable instrumentsTable = |
626 |
new InstrumentsDbTable(instrumentsDbTree); |
new JSInstrumentsDbTable(instrumentsDbTree); |
627 |
|
|
628 |
private final DbDirectoryTreeNode searchResultsNode = new DbDirectoryTreeNode(null); |
private final DbDirectoryTreeNode searchResultsNode = new DbDirectoryTreeNode(null); |
629 |
|
|
631 |
setLayout(new BorderLayout()); |
setLayout(new BorderLayout()); |
632 |
JScrollPane sp = new JScrollPane(instrumentsTable); |
JScrollPane sp = new JScrollPane(instrumentsTable); |
633 |
add(sp); |
add(sp); |
634 |
|
instrumentsTable.reloadAction.putValue(Action.SMALL_ICON, Res.iconReload22); |
635 |
|
|
636 |
|
instrumentsTable.createDirectoryAction.putValue ( |
637 |
|
Action.SMALL_ICON, Res.iconNew16 |
638 |
|
); |
639 |
|
|
640 |
instrumentsTable.getParent().setBackground(instrumentsTable.getBackground()); |
instrumentsTable.getParent().setBackground(instrumentsTable.getBackground()); |
641 |
instrumentsTable.getRowSorter().toggleSortOrder(0); |
instrumentsTable.getRowSorter().toggleSortOrder(0); |
642 |
searchResultsNode.setDetached(true); |
searchResultsNode.setDetached(true); |
643 |
} |
} |
644 |
|
|
645 |
public InstrumentsDbTable |
public JSInstrumentsDbTable |
646 |
getInstrumentsTable() { return instrumentsTable; } |
getInstrumentsTable() { return instrumentsTable; } |
647 |
|
|
648 |
public DbDirectoryTreeNode |
public DbDirectoryTreeNode |