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

Diff of /jsampler/trunk/src/org/jsampler/view/JSMainFrame.java

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

revision 911 by iliev, Mon Aug 7 18:25:58 2006 UTC revision 1734 by iliev, Sun May 4 18:40:13 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 Grigor Kirilov Iliev   *   Copyright (C) 2005-2007 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;  package org.jsampler.view;
24    
25    import java.awt.Dialog;
26  import java.awt.Dimension;  import java.awt.Dimension;
27    import java.awt.Frame;
28    
29    import java.awt.event.ActionEvent;
30    import java.awt.event.KeyEvent;
31  import java.awt.event.WindowAdapter;  import java.awt.event.WindowAdapter;
32  import java.awt.event.WindowEvent;  import java.awt.event.WindowEvent;
33    
34  import java.util.Vector;  import java.util.Vector;
35  import java.util.logging.Level;  import java.util.logging.Level;
36    
37    import javax.swing.AbstractAction;
38    import javax.swing.JComponent;
39  import javax.swing.JFrame;  import javax.swing.JFrame;
40    import javax.swing.KeyStroke;
41    
42  import org.jsampler.CC;  import org.jsampler.CC;
43  import org.jsampler.JSampler;  import org.jsampler.JSampler;
44  import org.jsampler.Prefs;  import org.jsampler.Prefs;
45    import org.jsampler.Server;
46    
47  import org.jsampler.event.SamplerChannelListEvent;  import org.jsampler.event.SamplerChannelListEvent;
48  import org.jsampler.event.SamplerChannelListListener;  import org.jsampler.event.SamplerChannelListListener;
49    
50    
51  /**  /**
52   * Defines the skeleton of a JSampler's main frame.   * Defines the skeleton of a JSampler's main frame.
53   * @author Grigor Iliev   * @author Grigor Iliev
54   */   */
55  public abstract class JSMainFrame extends JFrame {  public abstract class JSMainFrame extends JFrame {
56          private final Vector<JSChannelsPane> chnPaneList = new Vector<JSChannelsPane>();          private final Vector<JSChannelsPane> chnPaneList = new Vector<JSChannelsPane>();
57            private boolean autoUpdateChannelListUI = true;
58                    
59          /** Creates a new instance of <code>JSMainFrame</code>. */          /** Creates a new instance of <code>JSMainFrame</code>. */
60          public          public
# Line 58  public abstract class JSMainFrame extend Line 68  public abstract class JSMainFrame extend
68                  });                  });
69                                    
70                  CC.getSamplerModel().addSamplerChannelListListener(new EventHandler());                  CC.getSamplerModel().addSamplerChannelListListener(new EventHandler());
71                    
72                    getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put (
73                            KeyStroke.getKeyStroke(KeyEvent.VK_G, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK),
74                            "RunGarbageCollector"
75                    );
76                    
77                    getRootPane().getActionMap().put ("RunGarbageCollector", new AbstractAction() {
78                            public void
79                            actionPerformed(ActionEvent e) {
80                                    System.gc();
81                            }
82                    });
83          }          }
84                    
85          /**          /**
# Line 71  public abstract class JSMainFrame extend Line 93  public abstract class JSMainFrame extend
93          }          }
94                    
95          /**          /**
96             * Invoked on startup when no JSampler home directory is specified
97             * or the specified JSampler home directory doesn't exist.
98             * This method should ask the user to specify a JSampler
99             * home directory and then set the specified JSampler home directory using
100             * {@link org.jsampler.CC#setJSamplerHome} method.
101             * @see org.jsampler.CC#getJSamplerHome
102             * @see org.jsampler.CC#setJSamplerHome
103             */
104            public abstract void installJSamplerHome();
105            
106            /**
107             * Shows a detailed error information about the specified exception.
108             */
109            public abstract void showDetailedErrorMessage(Frame owner, String err, String details);
110            
111            /**
112             * Shows a detailed error information about the specified exception.
113             */
114            public abstract void showDetailedErrorMessage(Dialog owner, String err, String details);
115            
116            /**
117           * Returns a list containing all <code>JSChannelsPane</code>s added to the view.           * Returns a list containing all <code>JSChannelsPane</code>s added to the view.
118           * @return A list containing all <code>JSChannelsPane</code>s added to the view.           * @return A list containing all <code>JSChannelsPane</code>s added to the view.
119           * @see #addChannelsPane           * @see #addChannelsPane
# Line 134  public abstract class JSMainFrame extend Line 177  public abstract class JSMainFrame extend
177          public abstract JSChannelsPane getSelectedChannelsPane();          public abstract JSChannelsPane getSelectedChannelsPane();
178                    
179          /**          /**
180             * Gets the server address to which to connect. If the server should be
181             * manually selected, a dialog asking the user to choose a server is displayed.
182             */
183            public abstract Server getServer();
184            
185            /**
186             * Gets the server address to which to connect. If the server should be
187             * manually selected, a dialog asking the user to choose a server is displayed.
188             * @param manualSelect Determines whether the server should be manually selected.
189             */
190            public abstract Server getServer(boolean manualSelect);
191            
192            /**
193           * Sets the <code>JSChannelsPane</code> to be selected.           * Sets the <code>JSChannelsPane</code> to be selected.
194           * @param pane The <code>JSChannelsPane</code> to be shown.           * @param pane The <code>JSChannelsPane</code> to be shown.
195           */           */
# Line 147  public abstract class JSMainFrame extend Line 203  public abstract class JSMainFrame extend
203                   */                   */
204                  public void                  public void
205                  channelAdded(SamplerChannelListEvent e) {                  channelAdded(SamplerChannelListEvent e) {
206                          Integer id = e.getChannelModel().getChannelID();                          Integer id = e.getChannelModel().getChannelId();
207                          if(findChannel(id) != null) {                          if(findChannel(id) != null) {
208                                  CC.getLogger().log(Level.WARNING, "JSMainFrame.channelExist!", id);                                  CC.getLogger().log(Level.WARNING, "JSMainFrame.channelExist!", id);
209                                  return;                                  return;
# Line 163  public abstract class JSMainFrame extend Line 219  public abstract class JSMainFrame extend
219                   */                   */
220                  public void                  public void
221                  channelRemoved(SamplerChannelListEvent e) {                  channelRemoved(SamplerChannelListEvent e) {
222                          removeChannel(e.getChannelModel().getChannelID());                          removeChannel(e.getChannelModel().getChannelId());
223                  }                  }
224          }          }
225                    
# Line 177  public abstract class JSMainFrame extend Line 233  public abstract class JSMainFrame extend
233                  if(id < 0) return null;                  if(id < 0) return null;
234                                    
235                  for(JSChannelsPane cp : getChannelsPaneList()) {                  for(JSChannelsPane cp : getChannelsPaneList()) {
236                          for(JSChannel c : cp.getChannels()) if(c.getChannelID() == id) return c;                          for(JSChannel c : cp.getChannels()) if(c.getChannelId() == id) return c;
237                  }                  }
238                                    
239                  return null;                  return null;
# Line 195  public abstract class JSMainFrame extend Line 251  public abstract class JSMainFrame extend
251                                    
252                  for(JSChannelsPane cp : getChannelsPaneList()) {                  for(JSChannelsPane cp : getChannelsPaneList()) {
253                          for(JSChannel c : cp.getChannels()) {                          for(JSChannel c : cp.getChannels()) {
254                                  if(c.getChannelID() == id) {                                  if(c.getChannelId() == id) {
255                                          cp.removeChannel(c);                                          cp.removeChannel(c);
256                                          return c;                                          return c;
257                                  }                                  }
# Line 204  public abstract class JSMainFrame extend Line 260  public abstract class JSMainFrame extend
260                                    
261                  return null;                  return null;
262          }          }
263            
264            /**
265             * Determines whether the channel list UI should be automatically updated
266             * when channel is added/removed. The default value is <code>true</code>.
267             */
268            public boolean
269            getAutoUpdateChannelListUI() { return autoUpdateChannelListUI; }
270            
271            /**
272             * Determines whether the channel list UI should be automatically updated
273             * when channel is added/removed.
274             */
275            public void
276            setAutoUpdateChannelListUI(boolean b) {
277                    if(b == autoUpdateChannelListUI) return;
278                    
279                    autoUpdateChannelListUI = b;
280                    for(JSChannelsPane cp : getChannelsPaneList()) {
281                            cp.setAutoUpdate(b);
282                    }
283            }
284            
285            /**
286             * Updates the channel list UI.
287             */
288            public void
289            updateChannelListUI() {
290                    for(JSChannelsPane cp : getChannelsPaneList()) {
291                            cp.updateChannelListUI();
292                    }
293            }
294  }  }

Legend:
Removed from v.911  
changed lines
  Added in v.1734

  ViewVC Help
Powered by ViewVC