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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1705 by iliev, Tue Feb 19 16:32:36 2008 UTC revision 1864 by iliev, Sat Mar 14 20:44:58 2009 UTC
# Line 1  Line 1 
1  /*  /*
2   *   JSampler - a java front-end for LinuxSampler   *   JSampler - a java front-end for LinuxSampler
3   *   *
4   *   Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com>   *   Copyright (C) 2005-2009 Grigor Iliev <grigor@grigoriliev.com>
5   *   *
6   *   This file is part of JSampler.   *   This file is part of JSampler.
7   *   *
# Line 24  package org.jsampler.view.fantasia; Line 24  package org.jsampler.view.fantasia;
24    
25  import java.awt.BorderLayout;  import java.awt.BorderLayout;
26  import java.awt.Dimension;  import java.awt.Dimension;
27    import java.awt.Rectangle;
28    
29  import java.awt.event.ActionEvent;  import java.awt.event.ActionEvent;
30  import java.awt.event.ActionListener;  import java.awt.event.ActionListener;
 import java.awt.event.ItemEvent;  
 import java.awt.event.ItemListener;  
31  import java.awt.event.KeyEvent;  import java.awt.event.KeyEvent;
32  import java.awt.event.WindowAdapter;  import java.awt.event.WindowAdapter;
33  import java.awt.event.WindowEvent;  import java.awt.event.WindowEvent;
34    
 import java.util.List;  
35  import java.util.logging.Level;  import java.util.logging.Level;
36    
37  import javax.swing.AbstractAction;  import javax.swing.AbstractAction;
38  import javax.swing.Action;  import javax.swing.Action;
 import javax.swing.BorderFactory;  
 import javax.swing.BoxLayout;  
 import javax.swing.Icon;  
 import javax.swing.JCheckBox;  
39  import javax.swing.JComponent;  import javax.swing.JComponent;
40  import javax.swing.JFrame;  import javax.swing.JFrame;
41  import javax.swing.JMenu;  import javax.swing.JMenu;
# Line 50  import javax.swing.JMenuItem; Line 44  import javax.swing.JMenuItem;
44  import javax.swing.JPanel;  import javax.swing.JPanel;
45  import javax.swing.JScrollPane;  import javax.swing.JScrollPane;
46  import javax.swing.JSplitPane;  import javax.swing.JSplitPane;
 import javax.swing.JTextField;  
47  import javax.swing.JToggleButton;  import javax.swing.JToggleButton;
48  import javax.swing.JToolBar;  import javax.swing.JToolBar;
49  import javax.swing.KeyStroke;  import javax.swing.KeyStroke;
 import javax.swing.RowSorter.SortKey;  
 import javax.swing.SortOrder;  
50    
 import javax.swing.event.ChangeEvent;  
 import javax.swing.event.ChangeListener;  
51  import javax.swing.event.ListSelectionEvent;  import javax.swing.event.ListSelectionEvent;
52  import javax.swing.event.ListSelectionListener;  import javax.swing.event.ListSelectionListener;
 import javax.swing.event.RowSorterEvent;  
 import javax.swing.event.RowSorterListener;  
 import javax.swing.event.TreeSelectionEvent;  
 import javax.swing.event.TreeSelectionListener;  
53    
 import javax.swing.plaf.ToolBarUI;  
   
 import net.sf.juife.InformationDialog;  
54  import net.sf.juife.NavigationPage;  import net.sf.juife.NavigationPage;
55  import net.sf.juife.NavigationPane;  import net.sf.juife.NavigationPane;
56    
 import net.sf.juife.DefaultNavigationHistoryModel;  
 import net.sf.juife.Task;  
   
 import net.sf.juife.event.TaskEvent;  
 import net.sf.juife.event.TaskListener;  
   
57  import org.jsampler.CC;  import org.jsampler.CC;
58  import org.jsampler.HF;  import org.jsampler.HF;
 import org.jsampler.JSI18n;  
59    
60  import org.jsampler.task.InstrumentsDb;  import org.jsampler.task.InstrumentsDb;
61    
62  import org.jsampler.view.DbDirectoryTreeNode;  import org.jsampler.view.DbDirectoryTreeNode;
63  import org.jsampler.view.InstrumentsDbTableModel;  
64  import org.jsampler.view.InstrumentsDbTableView;  import org.jsampler.view.std.JSInstrumentsDbColumnPreferencesDlg;
65  import org.jsampler.view.std.JSInstrumentsDbTable;  import org.jsampler.view.std.JSInstrumentsDbTable;
66  import org.jsampler.view.std.JSInstrumentsDbTree;  import org.jsampler.view.std.JSLostFilesDlg;
67    
68    import org.jsampler.view.std.StdUtils;
69    
70  import org.linuxsampler.lscp.DbDirectoryInfo;  import org.linuxsampler.lscp.DbDirectoryInfo;
71  import org.linuxsampler.lscp.DbInstrumentInfo;  import org.linuxsampler.lscp.DbInstrumentInfo;
 import org.linuxsampler.lscp.DbSearchQuery;  
72    
 import static javax.swing.event.RowSorterEvent.Type.SORT_ORDER_CHANGED;  
73  import static org.jsampler.view.fantasia.FantasiaI18n.i18n;  import static org.jsampler.view.fantasia.FantasiaI18n.i18n;
74  import static org.jsampler.view.fantasia.FantasiaPrefs.preferences;  import static org.jsampler.view.fantasia.FantasiaPrefs.preferences;
 import static org.jsampler.view.fantasia.FantasiaPrefs.INSTRUMENTS_DB_FRAME_SORT_ORDER;  
75    
76  /**  /**
77   *   *
78   * @author Grigor Iliev   * @author Grigor Iliev
79   */   */
80  public class InstrumentsDbFrame extends JFrame {  public class InstrumentsDbFrame extends JFrame {
81            private final ToolBar toolbar;
82          private final JMenuBar menuBar = new JMenuBar();          private final JMenuBar menuBar = new JMenuBar();
83          private final JSInstrumentsDbTree instrumentsDbTree;          private final FantasiaInstrumentsDbTree instrumentsDbTree;
84          private final SidePane sidePane;          private final SidePane sidePane;
85          private final JSplitPane splitPane;          private final JSplitPane splitPane;
86          private final MainPane mainPane;          private final MainPane mainPane;
87                    
         private final GoUp goUp = new GoUp();  
         private final GoBack goBack = new GoBack();  
         private final GoForward goForward = new GoForward();  
           
         private final NavigationHistoryModel navigationHistoryModel = new NavigationHistoryModel();  
           
88          private JMenu loadInstrumentMenu;          private JMenu loadInstrumentMenu;
89          private JMenu addToMidiMapMenu;          private JMenu addToMidiMapMenu;
90          private JMenu addToOrchestraMenu;          private JMenu addToOrchestraMenu;
# Line 128  public class InstrumentsDbFrame extends Line 97  public class InstrumentsDbFrame extends
97                  setTitle(i18n.getLabel("InstrumentsDbFrame.title"));                  setTitle(i18n.getLabel("InstrumentsDbFrame.title"));
98                  if(Res.iconAppIcon != null) setIconImage(Res.iconAppIcon.getImage());                  if(Res.iconAppIcon != null) setIconImage(Res.iconAppIcon.getImage());
99                                    
100                  instrumentsDbTree = new JSInstrumentsDbTree(CC.getInstrumentsDbTreeModel());                  instrumentsDbTree = new FantasiaInstrumentsDbTree(CC.getInstrumentsDbTreeModel());
                 CC.addInstrumentsDbChangeListener(new ChangeListener() {  
                         public void  
                         stateChanged(ChangeEvent e) {  
                                 instrumentsDbTree.setModel(CC.getInstrumentsDbTreeModel());  
                                   
                                 CC.scheduleInTaskQueue(new Runnable() {  
                                         public void  
                                         run() {  
                                                 instrumentsDbTree.setSelectedDirectory("/");  
                                                 navigationHistoryModel.clearHistory();  
                                         }  
                                 });  
                         }  
                 });  
101                                    
102                  sidePane = new SidePane();                  sidePane = new SidePane();
103                  mainPane = new MainPane();                  mainPane = new MainPane();
104                                    
105                  instrumentsDbTree.setSelectedDirectory("/");                  instrumentsDbTree.setSelectedDirectory("/");
106                                    
107                  getContentPane().add(new ToolbarBar(), BorderLayout.NORTH);                  toolbar = new ToolBar();
108                    getContentPane().add(toolbar, BorderLayout.NORTH);
109                                    
110                  splitPane = new JSplitPane (                  splitPane = new JSplitPane (
111                          JSplitPane.HORIZONTAL_SPLIT,                          JSplitPane.HORIZONTAL_SPLIT,
# Line 174  public class InstrumentsDbFrame extends Line 130  public class InstrumentsDbFrame extends
130                          windowClosing(WindowEvent we) { onWindowClose(); }                          windowClosing(WindowEvent we) { onWindowClose(); }
131                  });                  });
132                                    
                 instrumentsDbTree.addTreeSelectionListener(goUp);  
                 instrumentsDbTree.addTreeSelectionListener(navigationHistoryModel);  
133                  installKeyboardListeners();                  installKeyboardListeners();
134          }          }
135                    
# Line 224  public class InstrumentsDbFrame extends Line 178  public class InstrumentsDbFrame extends
178                          }                          }
179                  });                  });
180                                    
181                    mi = new JMenuItem(i18n.getMenuLabel("instrumentsdb.actions.checkForLostFiles"));
182                    m.add(mi);
183                    mi.addActionListener(new ActionListener() {
184                            public void
185                            actionPerformed(ActionEvent e) {
186                                    new JSLostFilesDlg(InstrumentsDbFrame.this).setVisible(true);
187                            }
188                    });
189                    
190                  m.addSeparator();                  m.addSeparator();
191                                    
192                  loadInstrumentMenu =                  loadInstrumentMenu =
# Line 257  public class InstrumentsDbFrame extends Line 220  public class InstrumentsDbFrame extends
220                                    
221                  m = new JMenu(i18n.getMenuLabel("instrumentsdb.edit"));                  m = new JMenu(i18n.getMenuLabel("instrumentsdb.edit"));
222                  menuBar.add(m);                  menuBar.add(m);
223                    
224                    int modKey = CC.getViewConfig().getDefaultModKey();
225    
226                  mi = new JMenuItem(mainPane.getInstrumentsTable().cutAction);                  mi = new JMenuItem(mainPane.getInstrumentsTable().cutAction);
227                  mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.CTRL_MASK));                  mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, modKey));
228                  mi.setIcon(null);                  mi.setIcon(null);
229                  m.add(mi);                  m.add(mi);
230                                    
231                  mi = new JMenuItem(mainPane.getInstrumentsTable().copyAction);                  mi = new JMenuItem(mainPane.getInstrumentsTable().copyAction);
232                  mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_MASK));                  mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, modKey));
233                  mi.setIcon(null);                  mi.setIcon(null);
234                  m.add(mi);                  m.add(mi);
235                                    
236                  mi = new JMenuItem(mainPane.getInstrumentsTable().pasteAction);                  mi = new JMenuItem(mainPane.getInstrumentsTable().pasteAction);
237                  mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.CTRL_MASK));                  mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, modKey));
238                  mi.setIcon(null);                  mi.setIcon(null);
239                  m.add(mi);                  m.add(mi);
240                                    
241                  m.addSeparator();                  m.addSeparator();
242                                    
243                    mi = new JMenuItem(i18n.getMenuLabel("instrumentsdb.edit.find"));
244                    mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, modKey));
245                    m.add(mi);
246                    mi.addActionListener(new ActionListener() {
247                            public void
248                            actionPerformed(ActionEvent e) {
249                                    if(toolbar.btnFind.isSelected()) return;
250                                    
251                                    String path = instrumentsDbTree.getSelectedDirectoryPath();
252                                    if(path != null) sidePane.searchPage.setSearchPath(path);
253                                    toolbar.btnFind.doClick(0);
254                            }
255                    });
256                    
257                    m.addSeparator();
258                    
259                  mi = new JMenuItem(mainPane.getInstrumentsTable().renameAction);                  mi = new JMenuItem(mainPane.getInstrumentsTable().renameAction);
260                  mi.setIcon(null);                  mi.setIcon(null);
261                  m.add(mi);                  m.add(mi);
# Line 286  public class InstrumentsDbFrame extends Line 267  public class InstrumentsDbFrame extends
267                  m = new JMenu(i18n.getMenuLabel("instrumentsdb.go"));                  m = new JMenu(i18n.getMenuLabel("instrumentsdb.go"));
268                  menuBar.add(m);                  menuBar.add(m);
269                                    
270                  mi = new JMenuItem(goUp);                  instrumentsDbTree.actionGoUp.putValue(Action.SMALL_ICON, Res.iconGoUp22);
271                    mi = new JMenuItem(instrumentsDbTree.actionGoUp);
272                  mi.setIcon(null);                  mi.setIcon(null);
273                  mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.ALT_MASK));                  mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.ALT_MASK));
274                  m.add(mi);                  m.add(mi);
275                                    
276                  mi = new JMenuItem(goBack);                  instrumentsDbTree.actionGoBack.putValue(Action.SMALL_ICON, Res.iconGoBack22);
277                    mi = new JMenuItem(instrumentsDbTree.actionGoBack);
278                  mi.setIcon(null);                  mi.setIcon(null);
279                  mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.ALT_MASK));                  mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.ALT_MASK));
280                  m.add(mi);                  m.add(mi);
281                                    
282                  mi = new JMenuItem(goForward);                  instrumentsDbTree.actionGoForward.putValue(Action.SMALL_ICON, Res.iconGoForward22);
283                    mi = new JMenuItem(instrumentsDbTree.actionGoForward);
284                  mi.setIcon(null);                  mi.setIcon(null);
285                  mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.ALT_MASK));                  mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.ALT_MASK));
286                  m.add(mi);                  m.add(mi);
# Line 312  public class InstrumentsDbFrame extends Line 296  public class InstrumentsDbFrame extends
296                  getRootPane().getActionMap().put ("goUp", new AbstractAction() {                  getRootPane().getActionMap().put ("goUp", new AbstractAction() {
297                          public void                          public void
298                          actionPerformed(ActionEvent e) {                          actionPerformed(ActionEvent e) {
299                                  if(!goUp.isEnabled()) return;                                  if(!instrumentsDbTree.actionGoUp.isEnabled()) return;
300                                  goUp.actionPerformed(null);                                  instrumentsDbTree.actionGoUp.actionPerformed(null);
301                          }                          }
302                  });                  });
303          }          }
# Line 325  public class InstrumentsDbFrame extends Line 309  public class InstrumentsDbFrame extends
309                  preferences().setBoolProperty("InstrumentsDbFrame.windowMaximized", b);                  preferences().setBoolProperty("InstrumentsDbFrame.windowMaximized", b);
310                  if(b) return;                  if(b) return;
311                                    
312                  java.awt.Point p = getLocation();                  StdUtils.saveWindowBounds("InstrumentsDbFrame", getBounds());
                 Dimension d = getSize();  
                 StringBuffer sb = new StringBuffer();  
                 sb.append(p.x).append(',').append(p.y).append(',');  
                 sb.append(d.width).append(',').append(d.height);  
                 String s = "InstrumentsDbFrame.windowSizeAndLocation";  
                 preferences().setStringProperty(s, sb.toString());  
                 int i = splitPane.getDividerLocation();  
                 preferences().setIntProperty("InstrumentsDbFrame.dividerLocation", i);  
313                                    
314                  mainPane.getInstrumentsTable().saveColumnsVisibleState();                  mainPane.getInstrumentsTable().saveColumnsVisibleState();
315                  mainPane.getInstrumentsTable().saveColumnWidths();                  mainPane.getInstrumentsTable().saveColumnWidths();
316          }          }
317                    
318            @Override
319            public void
320            setVisible(boolean b) {
321                    if(b == isVisible()) return;
322                    
323                    super.setVisible(b);
324                    
325                    if(b && preferences().getBoolProperty("InstrumentsDbFrame.windowMaximized")) {
326                            setExtendedState(getExtendedState() | MAXIMIZED_BOTH);
327                    }
328            }
329            
330          private void          private void
331          setDefaultSize() {          setDefaultSize() {
332                  Dimension dimension = java.awt.Toolkit.getDefaultToolkit().getScreenSize();                  Dimension dimension = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
# Line 349  public class InstrumentsDbFrame extends Line 337  public class InstrumentsDbFrame extends
337                    
338          private void          private void
339          setSavedSize() {          setSavedSize() {
340                  String sp = "InstrumentsDbFrame.windowSizeAndLocation";                  Rectangle r = StdUtils.getWindowBounds("InstrumentsDbFrame");
341                  String s = preferences().getStringProperty(sp, null);                  if(r == null) {
                 if(s == null) {  
342                          setDefaultSize();                          setDefaultSize();
343                          return;                          return;
344                  }                  }
345                                    
346                  try {                  setBounds(r);
                         int i = s.indexOf(',');  
                         int x = Integer.parseInt(s.substring(0, i));  
                           
                         s = s.substring(i + 1);  
                         i = s.indexOf(',');  
                         int y = Integer.parseInt(s.substring(0, i));  
                           
                         s = s.substring(i + 1);  
                         i = s.indexOf(',');  
                         int width = Integer.parseInt(s.substring(0, i));  
                           
                         s = s.substring(i + 1);  
                         int height = Integer.parseInt(s);  
                           
                         setBounds(x, y, width, height);  
                           
                         i = preferences().getIntProperty("InstrumentsDbFrame.dividerLocation");  
                         if(i != 0) splitPane.setDividerLocation(i);  
                           
                 } catch(Exception x) {  
                         String msg = "Parsing of window size and location string failed";  
                         CC.getLogger().log(Level.INFO, msg, x);  
                         setDefaultSize();  
                 }  
                   
                 if(preferences().getBoolProperty("InstrumentsDbFrame.windowMaximized")) {  
                         setExtendedState(getExtendedState() | MAXIMIZED_BOTH);  
                 }  
347          }          }
348                    
349          private void          private void
# Line 404  public class InstrumentsDbFrame extends Line 363  public class InstrumentsDbFrame extends
363                  getContentPane().add(mainPane);                  getContentPane().add(mainPane);
364          }          }
365                    
366          private class GoUp extends AbstractAction implements TreeSelectionListener {          class ToolBar extends JToolBar {
                 GoUp() {  
                         super(i18n.getMenuLabel("instrumentsdb.go.up"));  
                           
                         String s = i18n.getMenuLabel("instrumentsdb.go.up.tt");  
                         putValue(SHORT_DESCRIPTION, s);  
                         putValue(Action.SMALL_ICON, Res.iconGoUp22);  
                         setEnabled(false);  
                 }  
                   
                 public void  
                 actionPerformed(ActionEvent e) {  
                         DbDirectoryTreeNode node = instrumentsDbTree.getSelectedDirectoryNode();  
                         if(node == null) return;  
                         instrumentsDbTree.setSelectedDirectoryNode(node.getParent());  
                 }  
                   
                 public void  
                 valueChanged(TreeSelectionEvent e) {  
                         DbDirectoryTreeNode n = instrumentsDbTree.getSelectedDirectoryNode();  
                         if(n == null) {  
                                 setEnabled(false);  
                                 return;  
                         }  
                           
                         setEnabled(n.getParent() != null);  
                 }  
         }  
           
         private class GoBack extends AbstractAction {  
                 GoBack() {  
                         super(i18n.getMenuLabel("instrumentsdb.go.back"));  
                           
                         String s = i18n.getMenuLabel("instrumentsdb.go.back.tt");  
                         putValue(SHORT_DESCRIPTION, s);  
                         putValue(Action.SMALL_ICON, Res.iconGoBack22);  
                         setEnabled(false);  
                 }  
                   
                 public void  
                 actionPerformed(ActionEvent e) {  
                         navigationHistoryModel.goBack();  
                 }  
         }  
           
         private class GoForward extends AbstractAction {  
                 GoForward() {  
                         super(i18n.getMenuLabel("instrumentsdb.go.forward"));  
                           
                         String s = i18n.getMenuLabel("instrumentsdb.go.forward.tt");  
                         putValue(SHORT_DESCRIPTION, s);  
                         putValue(Action.SMALL_ICON, Res.iconGoForward22);  
                         setEnabled(false);  
                 }  
                   
                 public void  
                 actionPerformed(ActionEvent e) {  
                         navigationHistoryModel.goForward();  
                 }  
         }  
           
         class ToolbarBar extends JToolBar {  
367                  private final ToggleButton btnFolders = new ToggleButton();                  private final ToggleButton btnFolders = new ToggleButton();
368                  private final ToggleButton btnFind = new ToggleButton();                  private final ToggleButton btnFind = new ToggleButton();
369                                    
370                  private final ToolbarButton btnGoUp = new ToolbarButton(goUp);                  private final ToolbarButton btnGoUp = new ToolbarButton(instrumentsDbTree.actionGoUp);
371                  private final ToolbarButton btnGoBack = new ToolbarButton(goBack);                  private final ToolbarButton btnGoBack = new ToolbarButton(instrumentsDbTree.actionGoBack);
372                  private final ToolbarButton btnGoForward = new ToolbarButton(goForward);                  private final ToolbarButton btnGoForward = new ToolbarButton(instrumentsDbTree.actionGoForward);
373                  private final ToolbarButton btnReload =                  private final ToolbarButton btnReload = new ToolbarButton(mainPane.getInstrumentsTable().reloadAction);
                         new ToolbarButton(mainPane.getInstrumentsTable().reloadAction);  
374                                    
375                  private final ToolbarButton btnPreferences = new ToolbarButton();                  private final ToolbarButton btnPreferences = new ToolbarButton();
376                                    
377                  public ToolbarBar() {                  public ToolBar() {
378                          super(i18n.getLabel("InstrumentsDbFrame.ToolbarBar.name"));                          super(i18n.getLabel("InstrumentsDbFrame.ToolbarBar.name"));
379                          setFloatable(false);                          setFloatable(false);
380                                                    
# Line 544  public class InstrumentsDbFrame extends Line 441  public class InstrumentsDbFrame extends
441                  }                  }
442          }          }
443                    
444          private class NavigationHistoryModel          public FantasiaInstrumentsDbTree
                 extends DefaultNavigationHistoryModel<DbDirectoryTreeNode>  
                 implements TreeSelectionListener, ActionListener {  
                   
                 private boolean lock = false;  
                   
                 NavigationHistoryModel() {  
                         addActionListener(this);  
                 }  
                   
                 public DbDirectoryTreeNode  
                 goBack() {  
                         lock = true;  
                         DbDirectoryTreeNode node = selectDirectory(super.goBack());  
                         lock = false;  
                         return node;  
                 }  
                   
                 public DbDirectoryTreeNode  
                 goForward() {  
                         lock = true;  
                         DbDirectoryTreeNode node = selectDirectory(super.goForward());  
                         lock = false;  
                         return node;  
                 }  
                   
                 private DbDirectoryTreeNode  
                 selectDirectory(DbDirectoryTreeNode node) {  
                         if(node == null) return null;  
                           
                         if(node == mainPane.getSearchResultsNode()) {  
                                 mainPane.showSearchResultsNode();  
                                 return node;  
                         }  
                           
                         String path = node.getInfo().getDirectoryPath();  
                         if(CC.getInstrumentsDbTreeModel().getNodeByPath(path) != null) {  
                                 getInstrumentsDbTree().setSelectedDirectory(path);  
                                 return node;  
                         }  
                           
                         removePage();  
                         fireActionPerformed();  
                         String s = i18n.getMessage("InstrumentsDbFrame.unknownDirectory!", path);  
                         HF.showErrorMessage(s, InstrumentsDbFrame.this);  
                         return node;  
                 }  
                   
                 public void  
                 addPage(DbDirectoryTreeNode node) {  
                         if(lock) return;  
                         if(node == null) return;  
                         super.addPage(node);  
                 }  
                   
                 public void  
                 valueChanged(TreeSelectionEvent e) {  
                         addPage(instrumentsDbTree.getSelectedDirectoryNode());  
                 }  
                   
                 public void  
                 actionPerformed(ActionEvent e) {  
                         goBack.setEnabled(hasBack());  
                         goForward.setEnabled(hasForward());  
                 }  
         }  
           
         public JSInstrumentsDbTree  
445          getInstrumentsDbTree() { return instrumentsDbTree; }          getInstrumentsDbTree() { return instrumentsDbTree; }
446                    
447          public void          public void
# Line 652  public class InstrumentsDbFrame extends Line 482  public class InstrumentsDbFrame extends
482                    
483          class MainPane extends JPanel {          class MainPane extends JPanel {
484                  private final JSInstrumentsDbTable instrumentsTable =                  private final JSInstrumentsDbTable instrumentsTable =
485                          new JSInstrumentsDbTable(instrumentsDbTree);                          new JSInstrumentsDbTable(instrumentsDbTree, "InstrumentsDbFrame.");
486                                    
487                  private final DbDirectoryTreeNode searchResultsNode = new DbDirectoryTreeNode(null);                  private final DbDirectoryTreeNode searchResultsNode = new DbDirectoryTreeNode(null);
488                                    
489                  MainPane() {                  MainPane() {
490                          setLayout(new BorderLayout());                          setLayout(new BorderLayout());
491                          JScrollPane sp = new JScrollPane(instrumentsTable);                          JScrollPane sp = new JScrollPane(instrumentsTable);
492                            sp.setOpaque(false);
493                            sp.getViewport().setOpaque(false);
494                          add(sp);                          add(sp);
495                                                    
496                          //instrumentsTable.setBackground(new java.awt.Color(0x626262));                          //instrumentsTable.setBackground(new java.awt.Color(0x626262));
# Line 671  public class InstrumentsDbFrame extends Line 503  public class InstrumentsDbFrame extends
503                                                    
504                          instrumentsTable.getParent().setBackground(instrumentsTable.getBackground());                          instrumentsTable.getParent().setBackground(instrumentsTable.getBackground());
505                                                    
                         int i = preferences().getIntProperty(INSTRUMENTS_DB_FRAME_SORT_ORDER);  
                         boolean descending = i < 0;  
                         if(i < 0) i *= -1;  
                           
                         instrumentsTable.getRowSorter().toggleSortOrder(--i);  
                         if(descending) instrumentsTable.getRowSorter().toggleSortOrder(i);  
506                          searchResultsNode.setDetached(true);                          searchResultsNode.setDetached(true);
                           
                         RowSorterListener l = new RowSorterListener() {  
                                 public void  
                                 sorterChanged(RowSorterEvent e) {  
                                         if(e.getType() != SORT_ORDER_CHANGED) return;  
                                         rowSorterChanged();  
                                 }  
                         };  
                           
                         instrumentsTable.getRowSorter().addRowSorterListener(l);  
                 }  
                   
                 private void  
                 rowSorterChanged() {  
                         List<? extends SortKey> list = instrumentsTable.getRowSorter().getSortKeys();  
                         if(list.isEmpty()) return;  
                         SortKey k = list.get(0);  
                         int i = k.getColumn() + 1;  
                         if(k.getSortOrder() == SortOrder.UNSORTED) return;  
                         if(k.getSortOrder() == SortOrder.DESCENDING) i *= -1;  
                         preferences().setIntProperty(INSTRUMENTS_DB_FRAME_SORT_ORDER, i);  
507                  }                  }
508                                    
509                  public JSInstrumentsDbTable                  public JSInstrumentsDbTable
# Line 711  public class InstrumentsDbFrame extends Line 516  public class InstrumentsDbFrame extends
516                  showSearchResultsNode() {                  showSearchResultsNode() {
517                          instrumentsDbTree.clearSelection();                          instrumentsDbTree.clearSelection();
518                          instrumentsTable.setParentDirectoryNode(searchResultsNode);                          instrumentsTable.setParentDirectoryNode(searchResultsNode);
                         navigationHistoryModel.addPage(searchResultsNode);  
519                  }                  }
520          }          }
521                    
# Line 747  public class InstrumentsDbFrame extends Line 551  public class InstrumentsDbFrame extends
551          getHandler() { return eventHandler; }          getHandler() { return eventHandler; }
552                    
553          private class EventHandler implements ListSelectionListener {          private class EventHandler implements ListSelectionListener {
554                    @Override
555                  public void                  public void
556                  valueChanged(ListSelectionEvent e) {                  valueChanged(ListSelectionEvent e) {
557                                                    
558                  }                  }
559          }          }
560                    
561          class PreferencesDlg extends InformationDialog implements ItemListener {          class PreferencesDlg extends JSInstrumentsDbColumnPreferencesDlg {
                 private final JCheckBox checkShowSizeColumn =  
                         new JCheckBox(JSI18n.i18n.getLabel("InstrumentsDbTableModel.SIZE"));  
                   
                 private final JCheckBox checkShowFormatFamilyColumn =  
                         new JCheckBox(JSI18n.i18n.getLabel("InstrumentsDbTableModel.FORMAT_FAMILY"));  
                   
                 private final JCheckBox checkShowFormatVersionColumn =  
                         new JCheckBox(JSI18n.i18n.getLabel("InstrumentsDbTableModel.FORMAT_VERSION"));  
                   
                 private final JCheckBox checkShowIsDrumColumn =  
                         new JCheckBox(JSI18n.i18n.getLabel("InstrumentsDbTableModel.IS_DRUM"));  
                   
                 private final JCheckBox checkShowCreatedColumn =  
                         new JCheckBox(JSI18n.i18n.getLabel("InstrumentsDbTableModel.CREATED"));  
                   
                 private final JCheckBox checkShowModifiedColumn =  
                         new JCheckBox(JSI18n.i18n.getLabel("InstrumentsDbTableModel.MODIFIED"));  
                   
                 private final JCheckBox checkShowProductColumn =  
                         new JCheckBox(JSI18n.i18n.getLabel("InstrumentsDbTableModel.PRODUCT"));  
                   
                 private final JCheckBox checkShowArtistsColumn =  
                         new JCheckBox(JSI18n.i18n.getLabel("InstrumentsDbTableModel.ARTISTS"));  
                   
                 private final JCheckBox checkShowInstrumentFileColumn  
                         = new JCheckBox(JSI18n.i18n.getLabel("InstrumentsDbTableModel.INSTRUMENT_FILE"));  
                   
                 private final JCheckBox checkShowInstrumentNrColumn =  
                         new JCheckBox(JSI18n.i18n.getLabel("InstrumentsDbTableModel.INSTRUMENT_NR"));  
                   
                 private final JCheckBox checkShowKeywordsColumn =  
                         new JCheckBox(JSI18n.i18n.getLabel("InstrumentsDbTableModel.KEYWORDS"));  
                   
562                  PreferencesDlg() {                  PreferencesDlg() {
563                          super(InstrumentsDbFrame.this);                          super(InstrumentsDbFrame.this, mainPane.instrumentsTable);
                         InstrumentsDbTableModel m = mainPane.instrumentsTable.getModel();  
                           
                         checkShowSizeColumn.setSelected(m.getShowSizeColumn());  
                         checkShowFormatFamilyColumn.setSelected(m.getShowFormatFamilyColumn());  
                         checkShowFormatVersionColumn.setSelected(m.getShowFormatVersionColumn());  
                         checkShowIsDrumColumn.setSelected(m.getShowIsDrumColumn());  
                         checkShowCreatedColumn.setSelected(m.getShowCreatedColumn());  
                         checkShowModifiedColumn.setSelected(m.getShowModifiedColumn());  
                         checkShowProductColumn.setSelected(m.getShowProductColumn());  
                         checkShowArtistsColumn.setSelected(m.getShowArtistsColumn());  
                         checkShowInstrumentFileColumn.setSelected(m.getShowInstrumentFileColumn());  
                         checkShowInstrumentNrColumn.setSelected(m.getShowInstrumentNrColumn());  
                         checkShowKeywordsColumn.setSelected(m.getShowKeywordsColumn());  
                           
                         checkShowSizeColumn.addItemListener(this);  
                         checkShowFormatFamilyColumn.addItemListener(this);  
                         checkShowFormatVersionColumn.addItemListener(this);  
                         checkShowIsDrumColumn.addItemListener(this);  
                         checkShowCreatedColumn.addItemListener(this);  
                         checkShowModifiedColumn.addItemListener(this);  
                         checkShowProductColumn.addItemListener(this);  
                         checkShowArtistsColumn.addItemListener(this);  
                         checkShowInstrumentFileColumn.addItemListener(this);  
                         checkShowInstrumentNrColumn.addItemListener(this);  
                         checkShowKeywordsColumn.addItemListener(this);  
                           
                         JPanel p = new JPanel();  
                         p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));  
                         p.add(checkShowSizeColumn);  
                         p.add(checkShowFormatFamilyColumn);  
                         p.add(checkShowFormatVersionColumn);  
                         p.add(checkShowIsDrumColumn);  
                         p.add(checkShowCreatedColumn);  
                         p.add(checkShowModifiedColumn);  
                         p.add(checkShowProductColumn);  
                         p.add(checkShowArtistsColumn);  
                         p.add(checkShowInstrumentFileColumn);  
                         p.add(checkShowInstrumentNrColumn);  
                         p.add(checkShowKeywordsColumn);  
                         String s = i18n.getLabel("InstrumentsDbFrame.columns");  
                         p.setBorder(BorderFactory.createTitledBorder(s));  
                   
                         setMainPane(p);  
                 }  
                   
                 public void  
                 itemStateChanged(ItemEvent e) {  
                         mainPane.getInstrumentsTable().saveColumnWidths();  
                           
                         InstrumentsDbTableModel m = mainPane.instrumentsTable.getModel();  
                           
                         Object source = e.getItemSelectable();  
                         if(source == checkShowSizeColumn) {  
                                 m.setShowSizeColumn(checkShowSizeColumn.isSelected());  
                         } else if(source == checkShowFormatFamilyColumn) {  
                                 boolean b = checkShowFormatFamilyColumn.isSelected();  
                                 m.setShowFormatFamilyColumn(b);  
                         } else if(source == checkShowFormatVersionColumn) {  
                                 boolean b = checkShowFormatVersionColumn.isSelected();  
                                 m.setShowFormatVersionColumn(b);  
                         } else if(source == checkShowIsDrumColumn) {  
                                 m.setShowIsDrumColumn(checkShowIsDrumColumn.isSelected());  
                         } else if(source == checkShowCreatedColumn) {  
                                 m.setShowCreatedColumn(checkShowCreatedColumn.isSelected());  
                         } else if(source == checkShowModifiedColumn) {  
                                 m.setShowModifiedColumn(checkShowModifiedColumn.isSelected());  
                         } else if(source == checkShowProductColumn) {  
                                 m.setShowProductColumn(checkShowProductColumn.isSelected());  
                         } else if(source == checkShowArtistsColumn) {  
                                 m.setShowArtistsColumn(checkShowArtistsColumn.isSelected());  
                         } else if(source == checkShowInstrumentFileColumn) {  
                                 boolean b = checkShowInstrumentFileColumn.isSelected();  
                                 m.setShowInstrumentFileColumn(b);  
                         } else if(source == checkShowInstrumentNrColumn) {  
                                 boolean b = checkShowInstrumentNrColumn.isSelected();  
                                 m.setShowInstrumentNrColumn(b);  
                         } else if(source == checkShowKeywordsColumn) {  
                                 m.setShowKeywordsColumn(checkShowKeywordsColumn.isSelected());  
                         }  
                           
                         mainPane.getInstrumentsTable().loadColumnWidths();  
                         mainPane.getInstrumentsTable().getRowSorter().toggleSortOrder(0);  
564                  }                  }
565          }          }
566  }  }

Legend:
Removed from v.1705  
changed lines
  Added in v.1864

  ViewVC Help
Powered by ViewVC