/[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 842 by iliev, Thu Mar 16 18:08:34 2006 UTC revision 1143 by iliev, Mon Apr 2 21:18:31 2007 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-2006 Grigor Iliev <grigor@grigoriliev.com>
5   *   *
6   *   This file is part of JSampler.   *   This file is part of JSampler.
7   *   *
# Line 40  import org.jsampler.event.SamplerChannel Line 40  import org.jsampler.event.SamplerChannel
40  import org.jsampler.event.SamplerChannelListListener;  import org.jsampler.event.SamplerChannelListListener;
41    
42  /**  /**
43   *   * Defines the skeleton of a JSampler's main frame.
44   * @author Grigor Iliev   * @author Grigor Iliev
45   */   */
46  public abstract class JSMainFrame extends JFrame {  public abstract class JSMainFrame extends JFrame {
47          private final Vector<JSChannelsPane> chnPaneList = new Vector<JSChannelsPane>();          private final Vector<JSChannelsPane> chnPaneList = new Vector<JSChannelsPane>();
48                    
49            /** Creates a new instance of <code>JSMainFrame</code>. */
50          public          public
51          JSMainFrame() {          JSMainFrame() {
52                  super(JSampler.NAME + ' ' + JSampler.VERSION);                  super(JSampler.NAME + ' ' + JSampler.VERSION);
# Line 59  public abstract class JSMainFrame extend Line 60  public abstract class JSMainFrame extend
60                  CC.getSamplerModel().addSamplerChannelListListener(new EventHandler());                  CC.getSamplerModel().addSamplerChannelListListener(new EventHandler());
61          }          }
62                    
63          private void          /**
64             * Invoked when this window is about to close.
65             * Don't forget to call <code>super.onWindowClose()</code> at the end,
66             * when override this method.
67             */
68            protected void
69          onWindowClose() {          onWindowClose() {
                 if(Prefs.getSaveWindowProperties()) {  
                         Prefs.setWindowMaximized (  
                                 (getExtendedState() & MAXIMIZED_BOTH) == MAXIMIZED_BOTH  
                         );  
                           
                         setVisible(false);  
                         if(Prefs.getWindowMaximized()) {  
                                 //setExtendedState(getExtendedState() & ~MAXIMIZED_BOTH);  
                                 CC.cleanExit();  
                                 return;  
                         }  
                           
                         java.awt.Point p = getLocation();  
                         Dimension d = getSize();  
                         StringBuffer sb = new StringBuffer();  
                         sb.append(p.x).append(',').append(p.y).append(',');  
                         sb.append(d.width).append(',').append(d.height);  
                         Prefs.setWindowSizeAndLocation(sb.toString());  
                 }  
                   
70                  CC.cleanExit();                  CC.cleanExit();
71          }          }
72                    
73            /**
74             * Invoked on startup when no JSampler home directory is specified
75             * or the specified JSampler home directory doesn't exist.
76             * This method should ask the user to specify a JSampler
77             * home directory and then set the specified JSampler home directory using
78             * {@link org.jsampler.CC#setJSamplerHome} method.
79             * @see org.jsampler.CC#getJSamplerHome
80             * @see org.jsampler.CC#setJSamplerHome
81             */
82            public abstract void installJSamplerHome();
83            
84            /**
85             * Returns a list containing all <code>JSChannelsPane</code>s added to the view.
86             * @return A list containing all <code>JSChannelsPane</code>s added to the view.
87             * @see #addChannelsPane
88             * @see #removeChannelsPane
89             */
90          public Vector<JSChannelsPane>          public Vector<JSChannelsPane>
91          getChannelsPaneList() { return chnPaneList; }          getChannelsPaneList() { return chnPaneList; }
92                    
93            /**
94             * Return the <code>JSChannelsPane</code> at the specified position.
95             * @param idx The position of the <code>JSChannelsPane</code> to be returned.
96             * @return The <code>JSChannelsPane</code> at the specified position.
97             */
98          public JSChannelsPane          public JSChannelsPane
99          getChannelsPane(int idx) { return chnPaneList.get(idx); }          getChannelsPane(int idx) { return chnPaneList.get(idx); }
100                    
101            /**
102             * Adds the specified <code>JSChannelsPane</code> to the view.
103             * @param chnPane The <code>JSChannelsPane</code> to be added.
104             */
105          public void          public void
106          addChannelsPane(JSChannelsPane chnPane) { chnPaneList.add(chnPane); }          addChannelsPane(JSChannelsPane chnPane) { chnPaneList.add(chnPane); }
107                    
108            /**
109             * Removes the specified <code>JSChannelsPane</code> from the view.
110             * Override this method to remove <code>chnPane</code> from the view,
111             * and don't forget to call <code>super.removeChannelsPane(chnPane);</code>.
112             * @param chnPane The <code>JSChannelsPane</code> to be removed.
113             * @return <code>true</code> if the specified code>JSChannelsPane</code>
114             * is actually removed from the view, <code>false</code> otherwise.
115             */
116          public boolean          public boolean
117          removeChannelsPane(JSChannelsPane chnPane) { return chnPaneList.remove(chnPane); }          removeChannelsPane(JSChannelsPane chnPane) { return chnPaneList.remove(chnPane); }
118                    
119            /**
120             * Gets the current number of <code>JSChannelsPane</code>s added to the view.
121             * @return The current number of <code>JSChannelsPane</code>s added to the view.
122             */
123          public int          public int
124          getChannelsPaneCount() { return chnPaneList.size(); }          getChannelsPaneCount() { return chnPaneList.size(); }
125                    
126            /**
127             * Inserts the specified <code>JSChannelsPane</code> at the specified position
128             * in the view and in the code>JSChannelsPane</code> list.
129             * Where and how this pane will be shown depends on the view/GUI implementation.
130             * Note that some GUI implementation may have only one pane containing sampler channels.
131             * @param pane The <code>JSChannelsPane</code> to be inserted.
132             * @param idx Specifies the position of the <code>JSChannelsPane</code>.
133             * @see #getChannelsPaneList
134             */
135          public abstract void insertChannelsPane(JSChannelsPane pane, int idx);          public abstract void insertChannelsPane(JSChannelsPane pane, int idx);
136            
137            /**
138             * Gets the <code>JSChannelsPane</code> that is currently shown,
139             * or has the focus if more than one channels' panes are shown.
140             * If the GUI implementation has only one pane containing sampler channels,
141             * than this method should always return that pane (the <code>JSChannelsPane</code>
142             * with index 0).
143             * @return The selected <code>JSChannelsPane</code>.
144             */
145          public abstract JSChannelsPane getSelectedChannelsPane();          public abstract JSChannelsPane getSelectedChannelsPane();
146            
147            /**
148             * Sets the <code>JSChannelsPane</code> to be selected.
149             * @param pane The <code>JSChannelsPane</code> to be shown.
150             */
151          public abstract void setSelectedChannelsPane(JSChannelsPane pane);          public abstract void setSelectedChannelsPane(JSChannelsPane pane);
152                    
153          private class EventHandler implements SamplerChannelListListener {          private class EventHandler implements SamplerChannelListListener {
# Line 111  public abstract class JSMainFrame extend Line 158  public abstract class JSMainFrame extend
158                   */                   */
159                  public void                  public void
160                  channelAdded(SamplerChannelListEvent e) {                  channelAdded(SamplerChannelListEvent e) {
161                          Integer id = e.getChannelModel().getChannelID();                          Integer id = e.getChannelModel().getChannelId();
162                          if(findChannel(id) != null) {                          if(findChannel(id) != null) {
163                                  CC.getLogger().log(Level.WARNING, "JSMainFrame.channelExist!", id);                                  CC.getLogger().log(Level.WARNING, "JSMainFrame.channelExist!", id);
164                                  return;                                  return;
# Line 127  public abstract class JSMainFrame extend Line 174  public abstract class JSMainFrame extend
174                   */                   */
175                  public void                  public void
176                  channelRemoved(SamplerChannelListEvent e) {                  channelRemoved(SamplerChannelListEvent e) {
177                          removeChannel(e.getChannelModel().getChannelID());                          removeChannel(e.getChannelModel().getChannelId());
178                  }                  }
179          }          }
180                    
# Line 141  public abstract class JSMainFrame extend Line 188  public abstract class JSMainFrame extend
188                  if(id < 0) return null;                  if(id < 0) return null;
189                                    
190                  for(JSChannelsPane cp : getChannelsPaneList()) {                  for(JSChannelsPane cp : getChannelsPaneList()) {
191                          for(JSChannel c : cp.getChannels()) if(c.getChannelID() == id) return c;                          for(JSChannel c : cp.getChannels()) if(c.getChannelId() == id) return c;
192                  }                  }
193                                    
194                  return null;                  return null;
# Line 159  public abstract class JSMainFrame extend Line 206  public abstract class JSMainFrame extend
206                                    
207                  for(JSChannelsPane cp : getChannelsPaneList()) {                  for(JSChannelsPane cp : getChannelsPaneList()) {
208                          for(JSChannel c : cp.getChannels()) {                          for(JSChannel c : cp.getChannels()) {
209                                  if(c.getChannelID() == id) {                                  if(c.getChannelId() == id) {
210                                          cp.removeChannel(c);                                          cp.removeChannel(c);
211                                          return c;                                          return c;
212                                  }                                  }

Legend:
Removed from v.842  
changed lines
  Added in v.1143

  ViewVC Help
Powered by ViewVC