/[svn]/jsampler/trunk/src/org/jsampler/view/fantasia/InstrumentsDbFrame.java
ViewVC logotype

Annotation of /jsampler/trunk/src/org/jsampler/view/fantasia/InstrumentsDbFrame.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1286 - (hide annotations) (download)
Fri Aug 10 20:24:23 2007 UTC (16 years, 10 months ago) by iliev
File size: 24785 byte(s)
- Updated to version 0.6a. The Fantasia distribution is now
  capable of controlling all features available in LinuxSampler

1 iliev 1286 /*
2     * JSampler - a java front-end for LinuxSampler
3     *
4     * Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com>
5     *
6     * This file is part of JSampler.
7     *
8     * JSampler is free software; you can redistribute it and/or modify
9     * it under the terms of the GNU General Public License version 2
10     * as published by the Free Software Foundation.
11     *
12     * JSampler is distributed in the hope that it will be useful,
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     * GNU General Public License for more details.
16     *
17     * You should have received a copy of the GNU General Public License
18     * along with JSampler; if not, write to the Free Software
19     * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20     * MA 02111-1307 USA
21     */
22    
23     package org.jsampler.view.fantasia;
24    
25     import java.awt.BorderLayout;
26     import java.awt.Dimension;
27    
28     import java.awt.event.ActionEvent;
29     import java.awt.event.ActionListener;
30     import java.awt.event.ItemEvent;
31     import java.awt.event.ItemListener;
32     import java.awt.event.KeyEvent;
33     import java.awt.event.WindowAdapter;
34     import java.awt.event.WindowEvent;
35    
36     import java.util.logging.Level;
37    
38     import javax.swing.AbstractAction;
39     import javax.swing.Action;
40     import javax.swing.BorderFactory;
41     import javax.swing.BoxLayout;
42     import javax.swing.Icon;
43     import javax.swing.JCheckBox;
44     import javax.swing.JComponent;
45     import javax.swing.JFrame;
46     import javax.swing.JMenu;
47     import javax.swing.JMenuBar;
48     import javax.swing.JMenuItem;
49     import javax.swing.JPanel;
50     import javax.swing.JScrollPane;
51     import javax.swing.JSplitPane;
52     import javax.swing.JTextField;
53     import javax.swing.JToggleButton;
54     import javax.swing.JToolBar;
55     import javax.swing.KeyStroke;
56    
57     import javax.swing.event.ListSelectionEvent;
58     import javax.swing.event.ListSelectionListener;
59     import javax.swing.event.TreeSelectionEvent;
60     import javax.swing.event.TreeSelectionListener;
61    
62     import javax.swing.plaf.ToolBarUI;
63    
64     import net.sf.juife.InformationDialog;
65     import net.sf.juife.NavigationPage;
66     import net.sf.juife.NavigationPane;
67    
68     import net.sf.juife.DefaultNavigationHistoryModel;
69     import net.sf.juife.Task;
70    
71     import net.sf.juife.event.TaskEvent;
72     import net.sf.juife.event.TaskListener;
73    
74     import org.jsampler.CC;
75     import org.jsampler.HF;
76     import org.jsampler.Instrument;
77     import org.jsampler.JSI18n;
78    
79     import org.jsampler.task.InstrumentsDb;
80    
81     import org.jsampler.view.DbDirectoryTreeNode;
82     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;
88     import org.linuxsampler.lscp.DbInstrumentInfo;
89     import org.linuxsampler.lscp.DbSearchQuery;
90    
91     import static org.jsampler.view.fantasia.FantasiaI18n.i18n;
92     import static org.jsampler.view.fantasia.FantasiaPrefs.preferences;
93    
94     /**
95     *
96     * @author Grigor Iliev
97     */
98     public class InstrumentsDbFrame extends JFrame {
99     private final JMenuBar menuBar = new JMenuBar();
100     private final JSInstrumentsDbTree instrumentsDbTree;
101     private final SidePane sidePane;
102     private final JSplitPane splitPane;
103     private final MainPane mainPane;
104    
105     private final GoUp goUp = new GoUp();
106     private final GoBack goBack = new GoBack();
107     private final GoForward goForward = new GoForward();
108    
109     private final NavigationHistoryModel navigationHistoryModel = new NavigationHistoryModel();
110    
111     private JMenu loadInstrumentMenu;
112     private JMenu addToMidiMapMenu;
113     private JMenu addToOrchestraMenu;
114    
115     /**
116     * Creates a new instance of <code>InstrumentsDbFrame</code>
117     */
118     public
119     InstrumentsDbFrame() {
120     setTitle(i18n.getLabel("InstrumentsDbFrame.title"));
121     if(Res.iconAppIcon != null) setIconImage(Res.iconAppIcon.getImage());
122    
123     instrumentsDbTree = new JSInstrumentsDbTree(CC.getInstrumentsDbTreeModel());
124    
125     sidePane = new SidePane();
126     mainPane = new MainPane();
127    
128     instrumentsDbTree.setSelectedDirectory("/");
129    
130     getContentPane().add(new ToolbarBar(), BorderLayout.NORTH);
131    
132     splitPane = new JSplitPane (
133     JSplitPane.HORIZONTAL_SPLIT,
134     true, // continuousLayout
135     sidePane,
136     mainPane
137     );
138    
139     splitPane.setDividerSize(3);
140     splitPane.setDividerLocation(200);
141    
142     addMenu();
143    
144     pack();
145     setSavedSize();
146    
147     getContentPane().add(splitPane);
148     mainPane.getInstrumentsTable().loadColumnWidths();
149    
150     addWindowListener(new WindowAdapter() {
151     public void
152     windowClosing(WindowEvent we) { onWindowClose(); }
153     });
154    
155     instrumentsDbTree.addTreeSelectionListener(goUp);
156     instrumentsDbTree.addTreeSelectionListener(navigationHistoryModel);
157     installKeyboardListeners();
158     }
159    
160     private void
161     addMenu() {
162     JMenu m;
163     JMenuItem mi;
164    
165     setJMenuBar(menuBar);
166    
167     // Actions
168     m = new JMenu(i18n.getMenuLabel("instrumentsdb.actions"));
169     menuBar.add(m);
170    
171     mi = new JMenuItem(mainPane.getInstrumentsTable().createDirectoryAction);
172     mi.setIcon(null);
173     m.add(mi);
174    
175     mi = new JMenuItem(mainPane.getInstrumentsTable().deleteAction);
176     mi.setIcon(null);
177     mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));
178     m.add(mi);
179    
180     JMenu addInstrumentsMenu =
181     new JMenu(i18n.getMenuLabel("instrumentsdb.actions.addInstruments"));
182     m.add(addInstrumentsMenu);
183    
184     mi = new JMenuItem(mainPane.getInstrumentsTable().addInstrumentsFromFileAction);
185     mi.setIcon(null);
186     addInstrumentsMenu.add(mi);
187    
188     mi = new JMenuItem(mainPane.getInstrumentsTable().addInstrumentsFromDirAction);
189     mi.setIcon(null);
190     addInstrumentsMenu.add(mi);
191    
192     m.addSeparator();
193    
194     loadInstrumentMenu =
195     new JMenu(i18n.getMenuLabel("instrumentsdb.actions.loadInstrument"));
196     m.add(loadInstrumentMenu);
197     mainPane.getInstrumentsTable().registerLoadInstrumentMenus(loadInstrumentMenu);
198    
199     addToMidiMapMenu =
200     new JMenu(i18n.getMenuLabel("instrumentsdb.actions.addToMidiMap"));
201     m.add(addToMidiMapMenu);
202     mainPane.getInstrumentsTable().registerAddToMidiMapMenu(addToMidiMapMenu);
203    
204     addToOrchestraMenu =
205     new JMenu(i18n.getMenuLabel("instrumentsdb.actions.addToOrchestra"));
206     m.add(addToOrchestraMenu);
207     mainPane.getInstrumentsTable().registerAddToOrchestraMenu(addToOrchestraMenu);
208    
209     m.addSeparator();
210    
211     mi = new JMenuItem(mainPane.getInstrumentsTable().reloadAction);
212     mi.setIcon(null);
213     mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0));
214     m.add(mi);
215    
216     m.addSeparator();
217    
218     mi = new JMenuItem(mainPane.getInstrumentsTable().propertiesAction);
219     mi.setIcon(null);
220     mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.ALT_MASK));
221     m.add(mi);
222    
223     m = new JMenu(i18n.getMenuLabel("instrumentsdb.edit"));
224     menuBar.add(m);
225    
226     mi = new JMenuItem(mainPane.getInstrumentsTable().cutAction);
227     mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.CTRL_MASK));
228     mi.setIcon(null);
229     m.add(mi);
230    
231     mi = new JMenuItem(mainPane.getInstrumentsTable().copyAction);
232     mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_MASK));
233     mi.setIcon(null);
234     m.add(mi);
235    
236     mi = new JMenuItem(mainPane.getInstrumentsTable().pasteAction);
237     mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.CTRL_MASK));
238     mi.setIcon(null);
239     m.add(mi);
240    
241     m.addSeparator();
242    
243     mi = new JMenuItem(mainPane.getInstrumentsTable().renameAction);
244     mi.setIcon(null);
245     m.add(mi);
246    
247     mi = new JMenuItem(mainPane.getInstrumentsTable().changeDescriptionAction);
248     mi.setIcon(null);
249     m.add(mi);
250    
251     m = new JMenu(i18n.getMenuLabel("instrumentsdb.go"));
252     menuBar.add(m);
253    
254     mi = new JMenuItem(goUp);
255     mi.setIcon(null);
256     mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.ALT_MASK));
257     m.add(mi);
258    
259     mi = new JMenuItem(goBack);
260     mi.setIcon(null);
261     mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.ALT_MASK));
262     m.add(mi);
263    
264     mi = new JMenuItem(goForward);
265     mi.setIcon(null);
266     mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.ALT_MASK));
267     m.add(mi);
268     }
269    
270     private void
271     installKeyboardListeners() {
272     getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put (
273     KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0),
274     "goUp"
275     );
276    
277     getRootPane().getActionMap().put ("goUp", new AbstractAction() {
278     public void
279     actionPerformed(ActionEvent e) {
280     if(!goUp.isEnabled()) return;
281     goUp.actionPerformed(null);
282     }
283     });
284     }
285    
286     /** Invoked when this window is about to close. */
287     private void
288     onWindowClose() {
289     boolean b = (getExtendedState() & MAXIMIZED_BOTH) == MAXIMIZED_BOTH;
290     preferences().setBoolProperty("InstrumentsDbFrame.windowMaximized", b);
291     if(b) return;
292    
293     java.awt.Point p = getLocation();
294     Dimension d = getSize();
295     StringBuffer sb = new StringBuffer();
296     sb.append(p.x).append(',').append(p.y).append(',');
297     sb.append(d.width).append(',').append(d.height);
298     String s = "InstrumentsDbFrame.windowSizeAndLocation";
299     preferences().setStringProperty(s, sb.toString());
300     int i = splitPane.getDividerLocation();
301     preferences().setIntProperty("InstrumentsDbFrame.dividerLocation", i);
302    
303     mainPane.getInstrumentsTable().saveColumnsVisibleState();
304     mainPane.getInstrumentsTable().saveColumnWidths();
305     }
306    
307     private void
308     setDefaultSize() {
309     Dimension dimension = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
310     double width = dimension.getWidth();
311     double height = dimension.getHeight();
312     setBounds(100, 100, (int) width - 200, (int) height - 200);
313     }
314    
315     private void
316     setSavedSize() {
317     String sp = "InstrumentsDbFrame.windowSizeAndLocation";
318     String s = preferences().getStringProperty(sp, null);
319     if(s == null) {
320     setDefaultSize();
321     return;
322     }
323    
324     try {
325     int i = s.indexOf(',');
326     int x = Integer.parseInt(s.substring(0, i));
327    
328     s = s.substring(i + 1);
329     i = s.indexOf(',');
330     int y = Integer.parseInt(s.substring(0, i));
331    
332     s = s.substring(i + 1);
333     i = s.indexOf(',');
334     int width = Integer.parseInt(s.substring(0, i));
335    
336     s = s.substring(i + 1);
337     int height = Integer.parseInt(s);
338    
339     setBounds(x, y, width, height);
340    
341     i = preferences().getIntProperty("InstrumentsDbFrame.dividerLocation");
342     if(i != 0) splitPane.setDividerLocation(i);
343    
344     } catch(Exception x) {
345     String msg = "Parsing of window size and location string failed";
346     CC.getLogger().log(Level.INFO, msg, x);
347     setDefaultSize();
348     }
349    
350     if(preferences().getBoolProperty("InstrumentsDbFrame.windowMaximized")) {
351     setExtendedState(getExtendedState() | MAXIMIZED_BOTH);
352     }
353     }
354    
355     private void
356     addSidePane() {
357     getContentPane().remove(mainPane);
358     splitPane.setRightComponent(mainPane);
359     getContentPane().add(splitPane);
360     int i = preferences().getIntProperty("InstrumentsDbFrame.dividerLocation");
361     if(i != 0) splitPane.setDividerLocation(i);
362     }
363    
364     private void
365     removeSidePane() {
366     int i = splitPane.getDividerLocation();
367     preferences().setIntProperty("InstrumentsDbFrame.dividerLocation", i);
368     getContentPane().remove(splitPane);
369     getContentPane().add(mainPane);
370     }
371    
372     private class GoUp extends AbstractAction implements TreeSelectionListener {
373     GoUp() {
374     super(i18n.getMenuLabel("instrumentsdb.go.up"));
375    
376     String s = i18n.getMenuLabel("instrumentsdb.go.up.tt");
377     putValue(SHORT_DESCRIPTION, s);
378     putValue(Action.SMALL_ICON, Res.iconGoUp22);
379     setEnabled(false);
380     }
381    
382     public void
383     actionPerformed(ActionEvent e) {
384     DbDirectoryTreeNode node = instrumentsDbTree.getSelectedDirectoryNode();
385     if(node == null) return;
386     instrumentsDbTree.setSelectedDirectoryNode(node.getParent());
387     }
388    
389     public void
390     valueChanged(TreeSelectionEvent e) {
391     DbDirectoryTreeNode n = instrumentsDbTree.getSelectedDirectoryNode();
392     if(n == null) {
393     setEnabled(false);
394     return;
395     }
396    
397     setEnabled(n.getParent() != null);
398     }
399     }
400    
401     private class GoBack extends AbstractAction {
402     GoBack() {
403     super(i18n.getMenuLabel("instrumentsdb.go.back"));
404    
405     String s = i18n.getMenuLabel("instrumentsdb.go.back.tt");
406     putValue(SHORT_DESCRIPTION, s);
407     putValue(Action.SMALL_ICON, Res.iconGoBack22);
408     setEnabled(false);
409     }
410    
411     public void
412     actionPerformed(ActionEvent e) {
413     navigationHistoryModel.goBack();
414     }
415     }
416    
417     private class GoForward extends AbstractAction {
418     GoForward() {
419     super(i18n.getMenuLabel("instrumentsdb.go.forward"));
420    
421     String s = i18n.getMenuLabel("instrumentsdb.go.forward.tt");
422     putValue(SHORT_DESCRIPTION, s);
423     putValue(Action.SMALL_ICON, Res.iconGoForward22);
424     setEnabled(false);
425     }
426    
427     public void
428     actionPerformed(ActionEvent e) {
429     navigationHistoryModel.goForward();
430     }
431     }
432    
433     class ToolbarBar extends JToolBar {
434     private final ToggleButton btnFolders = new ToggleButton();
435     private final ToggleButton btnFind = new ToggleButton();
436    
437     private final ToolbarButton btnGoUp = new ToolbarButton(goUp);
438     private final ToolbarButton btnGoBack = new ToolbarButton(goBack);
439     private final ToolbarButton btnGoForward = new ToolbarButton(goForward);
440     private final ToolbarButton btnReload =
441     new ToolbarButton(mainPane.getInstrumentsTable().reloadAction);
442    
443     private final ToolbarButton btnPreferences = new ToolbarButton();
444    
445     public ToolbarBar() {
446     super(i18n.getLabel("InstrumentsDbFrame.ToolbarBar.name"));
447     setFloatable(false);
448    
449     btnFolders.setIcon(Res.iconFolderOpen22);
450     btnFolders.doClick(0);
451     btnFind.setIcon(Res.iconFind22);
452     btnPreferences.setIcon(Res.iconPreferences22);
453    
454     add(btnFolders);
455     add(btnFind);
456     addSeparator();
457     add(btnGoBack);
458     add(btnGoForward);
459     add(btnGoUp);
460     add(btnReload);
461     addSeparator();
462     add(btnPreferences);
463    
464    
465     btnFolders.addActionListener(new ActionListener() {
466     public void
467     actionPerformed(ActionEvent e) {
468     if(!btnFolders.isSelected() && !btnFind.isSelected()) {
469     removeSidePane();
470     }
471    
472     if(!btnFolders.isSelected()) return;
473    
474     if(btnFind.isSelected()) btnFind.doClick(0);
475     else addSidePane();
476    
477     sidePane.showFoldersPage();
478     }
479     });
480    
481     btnFind.addActionListener(new ActionListener() {
482     public void
483     actionPerformed(ActionEvent e) {
484     if(!btnFolders.isSelected() && !btnFind.isSelected()) {
485     removeSidePane();
486     }
487    
488     if(!btnFind.isSelected()) return;
489    
490     if(btnFolders.isSelected()) btnFolders.doClick(0);
491     else addSidePane();
492    
493     sidePane.showSearchPage();
494     }
495     });
496    
497     btnPreferences.addActionListener(new ActionListener() {
498     public void
499     actionPerformed(ActionEvent e) {
500     new PreferencesDlg().setVisible(true);
501     }
502     });
503     }
504     }
505    
506     class ToggleButton extends JToggleButton {
507     ToggleButton() {
508     setFocusPainted(false);
509     }
510     }
511    
512     private class NavigationHistoryModel
513     extends DefaultNavigationHistoryModel<DbDirectoryTreeNode>
514     implements TreeSelectionListener, ActionListener {
515    
516     private boolean lock = false;
517    
518     NavigationHistoryModel() {
519     addActionListener(this);
520     }
521    
522     public DbDirectoryTreeNode
523     goBack() {
524     lock = true;
525     DbDirectoryTreeNode node = selectDirectory(super.goBack());
526     lock = false;
527     return node;
528     }
529    
530     public DbDirectoryTreeNode
531     goForward() {
532     lock = true;
533     DbDirectoryTreeNode node = selectDirectory(super.goForward());
534     lock = false;
535     return node;
536     }
537    
538     private DbDirectoryTreeNode
539     selectDirectory(DbDirectoryTreeNode node) {
540     if(node == null) return null;
541    
542     if(node == mainPane.getSearchResultsNode()) {
543     mainPane.showSearchResultsNode();
544     return node;
545     }
546    
547     String path = node.getInfo().getDirectoryPath();
548     if(CC.getInstrumentsDbTreeModel().getNodeByPath(path) != null) {
549     getInstrumentsDbTree().setSelectedDirectory(path);
550     return node;
551     }
552    
553     removePage();
554     fireActionPerformed();
555     String s = i18n.getMessage("InstrumentsDbFrame.unknownDirectory!", path);
556     HF.showErrorMessage(s, InstrumentsDbFrame.this);
557     return node;
558     }
559    
560     public void
561     addPage(DbDirectoryTreeNode node) {
562     if(lock) return;
563     if(node == null) return;
564     super.addPage(node);
565     }
566    
567     public void
568     valueChanged(TreeSelectionEvent e) {
569     addPage(instrumentsDbTree.getSelectedDirectoryNode());
570     }
571    
572     public void
573     actionPerformed(ActionEvent e) {
574     goBack.setEnabled(hasBack());
575     goForward.setEnabled(hasForward());
576     }
577     }
578    
579     public JSInstrumentsDbTree
580     getInstrumentsDbTree() { return instrumentsDbTree; }
581    
582     public void
583     setSearchResults(DbDirectoryInfo[] directories) {
584     setSearchResults(directories, null);
585     }
586    
587     public void
588     setSearchResults(DbInstrumentInfo[] instruments) {
589     setSearchResults(null, instruments);
590     }
591    
592     public void
593     setSearchResults(DbDirectoryInfo[] directories, DbInstrumentInfo[] instruments) {
594     DbDirectoryTreeNode node = mainPane.getSearchResultsNode();
595     node.removeAllDirectories();
596     node.removeAllInstruments();
597    
598     if(instruments != null) {
599     for(DbInstrumentInfo i : instruments) i.setShowAbsolutePath(true);
600     node.addInstruments(instruments);
601     }
602    
603     if(directories != null) {
604     DbDirectoryTreeNode[] nodeS = new DbDirectoryTreeNode[directories.length];
605     for(int i = 0; i < directories.length; i++) {
606     DbDirectoryInfo d = directories[i];
607     d.setShowAbsolutePath(true);
608     nodeS[i] = new DbDirectoryTreeNode(d);
609    
610    
611     }
612     node.addDirectories(nodeS);
613     }
614    
615     mainPane.showSearchResultsNode();
616     }
617    
618     class MainPane extends JPanel {
619     private final JSInstrumentsDbTable instrumentsTable =
620     new JSInstrumentsDbTable(instrumentsDbTree);
621    
622     private final DbDirectoryTreeNode searchResultsNode = new DbDirectoryTreeNode(null);
623    
624     MainPane() {
625     setLayout(new BorderLayout());
626     JScrollPane sp = new JScrollPane(instrumentsTable);
627     add(sp);
628    
629     //instrumentsTable.setBackground(new java.awt.Color(0x626262));
630     instrumentsTable.getModel().setShowDummyColumn(false);
631     instrumentsTable.reloadAction.putValue(Action.SMALL_ICON, Res.iconReload22);
632    
633     instrumentsTable.createDirectoryAction.putValue (
634     Action.SMALL_ICON, Res.iconNew16
635     );
636    
637     instrumentsTable.getParent().setBackground(instrumentsTable.getBackground());
638     instrumentsTable.getRowSorter().toggleSortOrder(0);
639     searchResultsNode.setDetached(true);
640     }
641    
642     public JSInstrumentsDbTable
643     getInstrumentsTable() { return instrumentsTable; }
644    
645     public DbDirectoryTreeNode
646     getSearchResultsNode() { return searchResultsNode; }
647    
648     public void
649     showSearchResultsNode() {
650     instrumentsDbTree.clearSelection();
651     instrumentsTable.setParentDirectoryNode(searchResultsNode);
652     navigationHistoryModel.addPage(searchResultsNode);
653     }
654     }
655    
656    
657     class SidePane extends NavigationPane {
658     private final NavigationPage foldersPage = new NavigationPage();
659     private final DbSearchPage searchPage = new DbSearchPage(InstrumentsDbFrame.this);
660    
661     SidePane() {
662     setTitlebarVisiblie(false);
663    
664     foldersPage.setTitle(i18n.getLabel("InstrumentsDbFrame.folders"));
665     foldersPage.setLayout(new BorderLayout());
666     foldersPage.add(new JScrollPane(instrumentsDbTree));
667    
668     NavigationPage[] pages = { foldersPage, searchPage };
669     setPages(pages);
670     showFoldersPage();
671     }
672    
673     /** Shows the folders page in the left pane. */
674     public void
675     showFoldersPage() { getModel().addPage(foldersPage); }
676    
677     /** Shows the search page in the left pane. */
678     public void
679     showSearchPage() { getModel().addPage(searchPage); }
680     }
681    
682     private final EventHandler eventHandler = new EventHandler();
683    
684     private EventHandler
685     getHandler() { return eventHandler; }
686    
687     private class EventHandler implements ListSelectionListener {
688     public void
689     valueChanged(ListSelectionEvent e) {
690    
691     }
692     }
693    
694     class PreferencesDlg extends InformationDialog implements ItemListener {
695     private final JCheckBox checkShowSizeColumn =
696     new JCheckBox(JSI18n.i18n.getLabel("InstrumentsDbTableModel.SIZE"));
697    
698     private final JCheckBox checkShowFormatFamilyColumn =
699     new JCheckBox(JSI18n.i18n.getLabel("InstrumentsDbTableModel.FORMAT_FAMILY"));
700    
701     private final JCheckBox checkShowFormatVersionColumn =
702     new JCheckBox(JSI18n.i18n.getLabel("InstrumentsDbTableModel.FORMAT_VERSION"));
703    
704     private final JCheckBox checkShowIsDrumColumn =
705     new JCheckBox(JSI18n.i18n.getLabel("InstrumentsDbTableModel.IS_DRUM"));
706    
707     private final JCheckBox checkShowCreatedColumn =
708     new JCheckBox(JSI18n.i18n.getLabel("InstrumentsDbTableModel.CREATED"));
709    
710     private final JCheckBox checkShowModifiedColumn =
711     new JCheckBox(JSI18n.i18n.getLabel("InstrumentsDbTableModel.MODIFIED"));
712    
713     private final JCheckBox checkShowProductColumn =
714     new JCheckBox(JSI18n.i18n.getLabel("InstrumentsDbTableModel.PRODUCT"));
715    
716     private final JCheckBox checkShowArtistsColumn =
717     new JCheckBox(JSI18n.i18n.getLabel("InstrumentsDbTableModel.ARTISTS"));
718    
719     private final JCheckBox checkShowInstrumentFileColumn
720     = new JCheckBox(JSI18n.i18n.getLabel("InstrumentsDbTableModel.INSTRUMENT_FILE"));
721    
722     private final JCheckBox checkShowInstrumentNrColumn =
723     new JCheckBox(JSI18n.i18n.getLabel("InstrumentsDbTableModel.INSTRUMENT_NR"));
724    
725     private final JCheckBox checkShowKeywordsColumn =
726     new JCheckBox(JSI18n.i18n.getLabel("InstrumentsDbTableModel.KEYWORDS"));
727    
728     PreferencesDlg() {
729     super(InstrumentsDbFrame.this);
730     InstrumentsDbTableModel m = mainPane.instrumentsTable.getModel();
731    
732     checkShowSizeColumn.setSelected(m.getShowSizeColumn());
733     checkShowFormatFamilyColumn.setSelected(m.getShowFormatFamilyColumn());
734     checkShowFormatVersionColumn.setSelected(m.getShowFormatVersionColumn());
735     checkShowIsDrumColumn.setSelected(m.getShowIsDrumColumn());
736     checkShowCreatedColumn.setSelected(m.getShowCreatedColumn());
737     checkShowModifiedColumn.setSelected(m.getShowModifiedColumn());
738     checkShowProductColumn.setSelected(m.getShowProductColumn());
739     checkShowArtistsColumn.setSelected(m.getShowArtistsColumn());
740     checkShowInstrumentFileColumn.setSelected(m.getShowInstrumentFileColumn());
741     checkShowInstrumentNrColumn.setSelected(m.getShowInstrumentNrColumn());
742     checkShowKeywordsColumn.setSelected(m.getShowKeywordsColumn());
743    
744     checkShowSizeColumn.addItemListener(this);
745     checkShowFormatFamilyColumn.addItemListener(this);
746     checkShowFormatVersionColumn.addItemListener(this);
747     checkShowIsDrumColumn.addItemListener(this);
748     checkShowCreatedColumn.addItemListener(this);
749     checkShowModifiedColumn.addItemListener(this);
750     checkShowProductColumn.addItemListener(this);
751     checkShowArtistsColumn.addItemListener(this);
752     checkShowInstrumentFileColumn.addItemListener(this);
753     checkShowInstrumentNrColumn.addItemListener(this);
754     checkShowKeywordsColumn.addItemListener(this);
755    
756     JPanel p = new JPanel();
757     p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
758     p.add(checkShowSizeColumn);
759     p.add(checkShowFormatFamilyColumn);
760     p.add(checkShowFormatVersionColumn);
761     p.add(checkShowIsDrumColumn);
762     p.add(checkShowCreatedColumn);
763     p.add(checkShowModifiedColumn);
764     p.add(checkShowProductColumn);
765     p.add(checkShowArtistsColumn);
766     p.add(checkShowInstrumentFileColumn);
767     p.add(checkShowInstrumentNrColumn);
768     p.add(checkShowKeywordsColumn);
769     String s = i18n.getLabel("InstrumentsDbFrame.columns");
770     p.setBorder(BorderFactory.createTitledBorder(s));
771    
772     setMainPane(p);
773     }
774    
775     public void
776     itemStateChanged(ItemEvent e) {
777     mainPane.getInstrumentsTable().saveColumnWidths();
778    
779     InstrumentsDbTableModel m = mainPane.instrumentsTable.getModel();
780    
781     Object source = e.getItemSelectable();
782     if(source == checkShowSizeColumn) {
783     m.setShowSizeColumn(checkShowSizeColumn.isSelected());
784     } else if(source == checkShowFormatFamilyColumn) {
785     boolean b = checkShowFormatFamilyColumn.isSelected();
786     m.setShowFormatFamilyColumn(b);
787     } else if(source == checkShowFormatVersionColumn) {
788     boolean b = checkShowFormatVersionColumn.isSelected();
789     m.setShowFormatVersionColumn(b);
790     } else if(source == checkShowIsDrumColumn) {
791     m.setShowIsDrumColumn(checkShowIsDrumColumn.isSelected());
792     } else if(source == checkShowCreatedColumn) {
793     m.setShowCreatedColumn(checkShowCreatedColumn.isSelected());
794     } else if(source == checkShowModifiedColumn) {
795     m.setShowModifiedColumn(checkShowModifiedColumn.isSelected());
796     } else if(source == checkShowProductColumn) {
797     m.setShowProductColumn(checkShowProductColumn.isSelected());
798     } else if(source == checkShowArtistsColumn) {
799     m.setShowArtistsColumn(checkShowArtistsColumn.isSelected());
800     } else if(source == checkShowInstrumentFileColumn) {
801     boolean b = checkShowInstrumentFileColumn.isSelected();
802     m.setShowInstrumentFileColumn(b);
803     } else if(source == checkShowInstrumentNrColumn) {
804     boolean b = checkShowInstrumentNrColumn.isSelected();
805     m.setShowInstrumentNrColumn(b);
806     } else if(source == checkShowKeywordsColumn) {
807     m.setShowKeywordsColumn(checkShowKeywordsColumn.isSelected());
808     }
809    
810     mainPane.getInstrumentsTable().loadColumnWidths();
811     mainPane.getInstrumentsTable().getRowSorter().toggleSortOrder(0);
812     }
813     }
814     }

  ViewVC Help
Powered by ViewVC