/[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 787 by iliev, Mon Oct 10 16:03:12 2005 UTC revision 1688 by iliev, Thu Feb 14 16:52:36 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;
27    import java.awt.Frame;
28    
29  import java.awt.event.WindowAdapter;  import java.awt.event.WindowAdapter;
30  import java.awt.event.WindowEvent;  import java.awt.event.WindowEvent;
31    
# Line 32  import javax.swing.JFrame; Line 36  import javax.swing.JFrame;
36    
37  import org.jsampler.CC;  import org.jsampler.CC;
38  import org.jsampler.JSampler;  import org.jsampler.JSampler;
39    import org.jsampler.Prefs;
40    import org.jsampler.Server;
41    
42  import org.jsampler.event.SamplerChannelListEvent;  import org.jsampler.event.SamplerChannelListEvent;
43  import org.jsampler.event.SamplerChannelListListener;  import org.jsampler.event.SamplerChannelListListener;
44    
45    
46  /**  /**
47   *   * Defines the skeleton of a JSampler's main frame.
48   * @author Grigor Iliev   * @author Grigor Iliev
49   */   */
50  public abstract class JSMainFrame extends JFrame {  public abstract class JSMainFrame extends JFrame {
51          private final Vector<JSChannelsPane> chnPaneList = new Vector<JSChannelsPane>();          private final Vector<JSChannelsPane> chnPaneList = new Vector<JSChannelsPane>();
52                    
53            /** Creates a new instance of <code>JSMainFrame</code>. */
54          public          public
55          JSMainFrame() {          JSMainFrame() {
56                  super(JSampler.NAME + ' ' + JSampler.VERSION);                  super(JSampler.NAME + ' ' + JSampler.VERSION);
# Line 50  public abstract class JSMainFrame extend Line 58  public abstract class JSMainFrame extend
58                  setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);                  setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
59                  addWindowListener(new WindowAdapter() {                  addWindowListener(new WindowAdapter() {
60                          public void                          public void
61                          windowClosing(WindowEvent we) { CC.cleanExit(); }                          windowClosing(WindowEvent we) { onWindowClose(); }
62                  });                  });
63                                    
64                  CC.getSamplerModel().addSamplerChannelListListener(new EventHandler());                  CC.getSamplerModel().addSamplerChannelListListener(new EventHandler());
65          }          }
66                    
67            /**
68             * Invoked when this window is about to close.
69             * Don't forget to call <code>super.onWindowClose()</code> at the end,
70             * when override this method.
71             */
72            protected void
73            onWindowClose() {
74                    CC.cleanExit();
75            }
76            
77            /**
78             * Invoked on startup when no JSampler home directory is specified
79             * or the specified JSampler home directory doesn't exist.
80             * This method should ask the user to specify a JSampler
81             * home directory and then set the specified JSampler home directory using
82             * {@link org.jsampler.CC#setJSamplerHome} method.
83             * @see org.jsampler.CC#getJSamplerHome
84             * @see org.jsampler.CC#setJSamplerHome
85             */
86            public abstract void installJSamplerHome();
87            
88            /**
89             * Shows a detailed error information about the specified exception.
90             */
91            public abstract void showDetailedErrorMessage(Frame owner, String err, String details);
92            
93            /**
94             * Shows a detailed error information about the specified exception.
95             */
96            public abstract void showDetailedErrorMessage(Dialog owner, String err, String details);
97            
98            /**
99             * Returns a list containing all <code>JSChannelsPane</code>s added to the view.
100             * @return A list containing all <code>JSChannelsPane</code>s added to the view.
101             * @see #addChannelsPane
102             * @see #removeChannelsPane
103             */
104          public Vector<JSChannelsPane>          public Vector<JSChannelsPane>
105          getChannelsPaneList() { return chnPaneList; }          getChannelsPaneList() { return chnPaneList; }
106                    
107            /**
108             * Return the <code>JSChannelsPane</code> at the specified position.
109             * @param idx The position of the <code>JSChannelsPane</code> to be returned.
110             * @return The <code>JSChannelsPane</code> at the specified position.
111             */
112          public JSChannelsPane          public JSChannelsPane
113          getChannelsPane(int idx) { return chnPaneList.get(idx); }          getChannelsPane(int idx) { return chnPaneList.get(idx); }
114                    
115            /**
116             * Adds the specified <code>JSChannelsPane</code> to the view.
117             * @param chnPane The <code>JSChannelsPane</code> to be added.
118             */
119          public void          public void
120          addChannelsPane(JSChannelsPane chnPane) { chnPaneList.add(chnPane); }          addChannelsPane(JSChannelsPane chnPane) { chnPaneList.add(chnPane); }
121                    
122            /**
123             * Removes the specified <code>JSChannelsPane</code> from the view.
124             * Override this method to remove <code>chnPane</code> from the view,
125             * and don't forget to call <code>super.removeChannelsPane(chnPane);</code>.
126             * @param chnPane The <code>JSChannelsPane</code> to be removed.
127             * @return <code>true</code> if the specified code>JSChannelsPane</code>
128             * is actually removed from the view, <code>false</code> otherwise.
129             */
130          public boolean          public boolean
131          removeChannelsPane(JSChannelsPane chnPane) { return chnPaneList.remove(chnPane); }          removeChannelsPane(JSChannelsPane chnPane) { return chnPaneList.remove(chnPane); }
132                    
133            /**
134             * Gets the current number of <code>JSChannelsPane</code>s added to the view.
135             * @return The current number of <code>JSChannelsPane</code>s added to the view.
136             */
137          public int          public int
138          getChannelsPaneCount() { return chnPaneList.size(); }          getChannelsPaneCount() { return chnPaneList.size(); }
139                    
140            /**
141             * Inserts the specified <code>JSChannelsPane</code> at the specified position
142             * in the view and in the code>JSChannelsPane</code> list.
143             * Where and how this pane will be shown depends on the view/GUI implementation.
144             * Note that some GUI implementation may have only one pane containing sampler channels.
145             * @param pane The <code>JSChannelsPane</code> to be inserted.
146             * @param idx Specifies the position of the <code>JSChannelsPane</code>.
147             * @see #getChannelsPaneList
148             */
149          public abstract void insertChannelsPane(JSChannelsPane pane, int idx);          public abstract void insertChannelsPane(JSChannelsPane pane, int idx);
150            
151            /**
152             * Gets the <code>JSChannelsPane</code> that is currently shown,
153             * or has the focus if more than one channels' panes are shown.
154             * If the GUI implementation has only one pane containing sampler channels,
155             * than this method should always return that pane (the <code>JSChannelsPane</code>
156             * with index 0).
157             * @return The selected <code>JSChannelsPane</code>.
158             */
159          public abstract JSChannelsPane getSelectedChannelsPane();          public abstract JSChannelsPane getSelectedChannelsPane();
160            
161            /**
162             * Gets the server address to which to connect. If the server should be
163             * manually selected, a dialog asking the user to choose a server is displayed.
164             */
165            public abstract Server getServer();
166            
167            /**
168             * Gets the server address to which to connect. If the server should be
169             * manually selected, a dialog asking the user to choose a server is displayed.
170             * @param manualSelect Determines whether the server should be manually selected.
171             */
172            public abstract Server getServer(boolean manualSelect);
173            
174            /**
175             * Sets the <code>JSChannelsPane</code> to be selected.
176             * @param pane The <code>JSChannelsPane</code> to be shown.
177             */
178          public abstract void setSelectedChannelsPane(JSChannelsPane pane);          public abstract void setSelectedChannelsPane(JSChannelsPane pane);
179                    
180          private class EventHandler implements SamplerChannelListListener {          private class EventHandler implements SamplerChannelListListener {
# Line 83  public abstract class JSMainFrame extend Line 185  public abstract class JSMainFrame extend
185                   */                   */
186                  public void                  public void
187                  channelAdded(SamplerChannelListEvent e) {                  channelAdded(SamplerChannelListEvent e) {
188                          Integer id = e.getChannelModel().getChannelID();                          Integer id = e.getChannelModel().getChannelId();
189                          if(findChannel(id) != null) {                          if(findChannel(id) != null) {
190                                  CC.getLogger().log(Level.WARNING, "JSMainFrame.channelExist!", id);                                  CC.getLogger().log(Level.WARNING, "JSMainFrame.channelExist!", id);
191                                  return;                                  return;
# Line 99  public abstract class JSMainFrame extend Line 201  public abstract class JSMainFrame extend
201                   */                   */
202                  public void                  public void
203                  channelRemoved(SamplerChannelListEvent e) {                  channelRemoved(SamplerChannelListEvent e) {
204                          removeChannel(e.getChannelModel().getChannelID());                          removeChannel(e.getChannelModel().getChannelId());
205                  }                  }
206          }          }
207                    
# Line 113  public abstract class JSMainFrame extend Line 215  public abstract class JSMainFrame extend
215                  if(id < 0) return null;                  if(id < 0) return null;
216                                    
217                  for(JSChannelsPane cp : getChannelsPaneList()) {                  for(JSChannelsPane cp : getChannelsPaneList()) {
218                          for(JSChannel c : cp.getChannels()) if(c.getChannelID() == id) return c;                          for(JSChannel c : cp.getChannels()) if(c.getChannelId() == id) return c;
219                  }                  }
220                                    
221                  return null;                  return null;
# Line 131  public abstract class JSMainFrame extend Line 233  public abstract class JSMainFrame extend
233                                    
234                  for(JSChannelsPane cp : getChannelsPaneList()) {                  for(JSChannelsPane cp : getChannelsPaneList()) {
235                          for(JSChannel c : cp.getChannels()) {                          for(JSChannel c : cp.getChannels()) {
236                                  if(c.getChannelID() == id) {                                  if(c.getChannelId() == id) {
237                                          cp.removeChannel(c);                                          cp.removeChannel(c);
238                                          return c;                                          return c;
239                                  }                                  }

Legend:
Removed from v.787  
changed lines
  Added in v.1688

  ViewVC Help
Powered by ViewVC