/[svn]/jsampler/trunk/src/org/jsampler/view/std/JSDbInstrumentChooser.java
ViewVC logotype

Diff of /jsampler/trunk/src/org/jsampler/view/std/JSDbInstrumentChooser.java

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

revision 1751 by iliev, Thu Sep 13 22:20:38 2007 UTC revision 1752 by iliev, Mon Aug 11 22:51:24 2008 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-2008 Grigor Iliev <grigor@grigoriliev.com>
5   *   *
6   *   This file is part of JSampler.   *   This file is part of JSampler.
7   *   *
# Line 22  Line 22 
22    
23  package org.jsampler.view.std;  package org.jsampler.view.std;
24    
25    import java.awt.BorderLayout;
26  import java.awt.Dialog;  import java.awt.Dialog;
27  import java.awt.Frame;  import java.awt.Frame;
28    
29  import java.awt.event.ActionEvent;  import java.awt.event.ActionEvent;
30    import java.awt.event.ActionListener;
31  import java.awt.event.KeyEvent;  import java.awt.event.KeyEvent;
32  import java.awt.event.MouseAdapter;  import java.awt.event.MouseAdapter;
33  import java.awt.event.MouseEvent;  import java.awt.event.MouseEvent;
34    
35    import javax.swing.Action;
36  import javax.swing.AbstractAction;  import javax.swing.AbstractAction;
37    import javax.swing.JButton;
38  import javax.swing.JComponent;  import javax.swing.JComponent;
39    import javax.swing.JPanel;
40  import javax.swing.JScrollPane;  import javax.swing.JScrollPane;
41  import javax.swing.JSplitPane;  import javax.swing.JSplitPane;
42    import javax.swing.JToolBar;
43  import javax.swing.KeyStroke;  import javax.swing.KeyStroke;
44  import javax.swing.ListSelectionModel;  import javax.swing.ListSelectionModel;
45    
# Line 58  import static org.jsampler.view.std.StdI Line 64  import static org.jsampler.view.std.StdI
64   * @author Grigor Iliev   * @author Grigor Iliev
65   */   */
66  public class JSDbInstrumentChooser extends OkCancelDialog implements ListSelectionListener {  public class JSDbInstrumentChooser extends OkCancelDialog implements ListSelectionListener {
67          protected JSInstrumentsDbTree instrumentsDbTree;          protected JSInstrumentsDbTree instrumentsDbTree =
68          protected JSInstrumentsDbTable instrumentsDbTable;                  createInstrumentsDbTree(CC.getInstrumentsDbTreeModel());
69            
70            protected JSInstrumentsDbTable instrumentsDbTable =
71                    new JSInstrumentsDbTable(instrumentsDbTree, "DbInstrumentChooser.");
72            
73            protected final ToolBar toolBar = new ToolBar();
74            
75                    
76          /**          /**
77           * Creates a new instance of <code>JSDbInstrumentChooser</code>           * Creates a new instance of <code>JSDbInstrumentChooser</code>
# Line 80  public class JSDbInstrumentChooser exten Line 92  public class JSDbInstrumentChooser exten
92          private void          private void
93          initDbInstrumentChooser() {          initDbInstrumentChooser() {
94                  btnOk.setEnabled(false);                  btnOk.setEnabled(false);
                 instrumentsDbTree = new JSInstrumentsDbTree(CC.getInstrumentsDbTreeModel());  
95                  JScrollPane sp = new JScrollPane(instrumentsDbTree);                  JScrollPane sp = new JScrollPane(instrumentsDbTree);
96                                    
                 instrumentsDbTable = new JSInstrumentsDbTable(instrumentsDbTree);  
97                  instrumentsDbTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);                  instrumentsDbTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
98                  instrumentsDbTable.getSelectionModel().addListSelectionListener(this);                  instrumentsDbTable.getSelectionModel().addListSelectionListener(this);
                 instrumentsDbTable.loadColumnWidths();  
99                  JScrollPane sp2 = new JScrollPane(instrumentsDbTable);                  JScrollPane sp2 = new JScrollPane(instrumentsDbTable);
100                                    
101                  JSplitPane splitPane = new JSplitPane (                  JSplitPane splitPane = new JSplitPane (
# Line 99  public class JSDbInstrumentChooser exten Line 108  public class JSDbInstrumentChooser exten
108                  splitPane.setDividerSize(3);                  splitPane.setDividerSize(3);
109                  splitPane.setDividerLocation(200);                  splitPane.setDividerLocation(200);
110                                    
111                  setMainPane(splitPane);                  JPanel p = new JPanel();
112                    p.setLayout(new BorderLayout());
113                    p.add(new ToolBar(), BorderLayout.NORTH);
114                    p.add(splitPane);
115                    
116                    setMainPane(p);
117                                    
118                  instrumentsDbTable.addMouseListener(new MouseAdapter() {                  instrumentsDbTable.addMouseListener(new MouseAdapter() {
119                          public void                          public void
# Line 113  public class JSDbInstrumentChooser exten Line 127  public class JSDbInstrumentChooser exten
127                  });                  });
128                                    
129                  installKeyboardListeners();                  installKeyboardListeners();
130                    
131                    setMinimumSize(getPreferredSize());
132                    setResizable(true);
133          }          }
134                    
135          private void          private void
# Line 122  public class JSDbInstrumentChooser exten Line 139  public class JSDbInstrumentChooser exten
139                          "goUp"                          "goUp"
140                  );                  );
141                                    
142                  getRootPane().getActionMap().put ("goUp", new GoUp());                  getRootPane().getActionMap().put ("goUp", instrumentsDbTree.actionGoUp);
143                                    
144                  instrumentsDbTable.getInputMap().put (                  instrumentsDbTable.getInputMap().put (
145                          KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),                          KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),
# Line 147  public class JSDbInstrumentChooser exten Line 164  public class JSDbInstrumentChooser exten
164                  });                  });
165          }          }
166                    
167            protected JSInstrumentsDbTree
168            createInstrumentsDbTree(InstrumentsDbTreeModel m) { return new JSInstrumentsDbTree(m); }
169            
170          public String          public String
171          getSelectedInstrument() {          getSelectedInstrument() {
172                  DbInstrumentInfo[] infos = instrumentsDbTable.getSelectedInstruments();                  DbInstrumentInfo[] infos = instrumentsDbTable.getSelectedInstruments();
# Line 173  public class JSDbInstrumentChooser exten Line 193  public class JSDbInstrumentChooser exten
193          protected void          protected void
194          onOk() {          onOk() {
195                  if(!btnOk.isEnabled()) return;                  if(!btnOk.isEnabled()) return;
196                    
197                    instrumentsDbTable.saveColumnsVisibleState();
198                    instrumentsDbTable.saveColumnWidths();
199                    
200                  setCancelled(false);                  setCancelled(false);
201                  setVisible(false);                  setVisible(false);
202          }          }
# Line 186  public class JSDbInstrumentChooser exten Line 210  public class JSDbInstrumentChooser exten
210                  btnOk.setEnabled(b);                  btnOk.setEnabled(b);
211          }          }
212                    
213          private class GoUp extends AbstractAction {          protected JButton
214                  GoUp() { }          createToolbarButton(Action a) { return new JButton(a); }
215                            
216                  public void          class ToolBar extends JToolBar {
217                  actionPerformed(ActionEvent e) {                  protected final JButton btnGoUp = createToolbarButton(instrumentsDbTree.actionGoUp);
218                          DbDirectoryTreeNode node = instrumentsDbTree.getSelectedDirectoryNode();                  protected final JButton btnGoBack = createToolbarButton(instrumentsDbTree.actionGoBack);
219                          if(node == null) return;                  protected final JButton btnGoForward = createToolbarButton(instrumentsDbTree.actionGoForward);
220                          if(node.getParent() == null) return;                  protected final JButton btnReload = createToolbarButton(instrumentsDbTable.reloadAction);
221                          instrumentsDbTree.setSelectedDirectoryNode(node.getParent());                  protected final JButton btnPreferences = createToolbarButton(null);
222                    
223                    public ToolBar() {
224                            super("");
225                            setFloatable(false);
226                            
227                            add(btnGoBack);
228                            add(btnGoForward);
229                            add(btnGoUp);
230                            
231                            javax.swing.Icon i = CC.getViewConfig().getBasicIconSet().getReload16Icon();
232                            instrumentsDbTable.reloadAction.putValue(Action.SMALL_ICON, i);
233                            add(btnReload);
234                            
235                            addSeparator();
236                            
237                            i = CC.getViewConfig().getBasicIconSet().getPreferences16Icon();
238                            btnPreferences.setIcon(i);
239                            add(btnPreferences);
240                            
241                            btnPreferences.addActionListener(new ActionListener() {
242                                    public void
243                                    actionPerformed(ActionEvent e) {
244                                            new PreferencesDlg().setVisible(true);
245                                    }
246                            });
247                    }
248            }
249            
250            class PreferencesDlg extends JSInstrumentsDbColumnPreferencesDlg {
251                    PreferencesDlg() {
252                            super(JSDbInstrumentChooser.this, instrumentsDbTable);
253                  }                  }
254          }          }
255  }  }

Legend:
Removed from v.1751  
changed lines
  Added in v.1752

  ViewVC Help
Powered by ViewVC