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

Diff of /jsampler/trunk/src/org/jsampler/DefaultLSConsoleModel.java

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

revision 1785 by iliev, Thu Feb 14 16:52:36 2008 UTC revision 1786 by iliev, Wed Oct 8 22:38:15 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-2006 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 114  public class DefaultLSConsoleModel imple Line 114  public class DefaultLSConsoleModel imple
114                  CC.getTaskQueue().add(cnt);                  CC.getTaskQueue().add(cnt);
115          }          }
116                    
117            public void
118            disconnect() {
119                    try { if(getSocket() != null) getSocket().close(); }
120                    catch(Exception x) { CC.getLogger().info(HF.getErrorMessage(x)); }
121            }
122            
123          private void          private void
124          changeSocket(Socket sock) {          changeSocket(Socket sock) {
125                  setSocket(sock);                  setSocket(sock);
# Line 131  public class DefaultLSConsoleModel imple Line 137  public class DefaultLSConsoleModel imple
137           * Registers the specified listener for receiving event messages.           * Registers the specified listener for receiving event messages.
138           * @param l The <code>LSConsoleListener</code> to register.           * @param l The <code>LSConsoleListener</code> to register.
139           */           */
140            @Override
141          public void          public void
142          addLSConsoleListener(LSConsoleListener l) { listeners.add(l); }          addLSConsoleListener(LSConsoleListener l) { listeners.add(l); }
143                    
# Line 138  public class DefaultLSConsoleModel imple Line 145  public class DefaultLSConsoleModel imple
145           * Removes the specified listener.           * Removes the specified listener.
146           * @param l The <code>LSConsoleListener</code> to remove.           * @param l The <code>LSConsoleListener</code> to remove.
147           */           */
148            @Override
149          public void          public void
150          removeLSConsoleListener(LSConsoleListener l) { listeners.remove(l); }          removeLSConsoleListener(LSConsoleListener l) { listeners.remove(l); }
151                    
152          /** Executes the command specified in the command line. */          /** Executes the command specified in the command line. */
153            @Override
154          public void          public void
155          execCommand() {          execCommand() {
156                  String cmd = getCommandLineText();                  String cmd = getCommandLineText();
# Line 168  public class DefaultLSConsoleModel imple Line 177  public class DefaultLSConsoleModel imple
177           * Gets the last executed command.           * Gets the last executed command.
178           * @return The last command executed in the LS Console.           * @return The last command executed in the LS Console.
179           */           */
180            @Override
181          public String          public String
182          getLastExecutedCommand() {          getLastExecutedCommand() {
183                  int size = sessionHistory.size();                  int size = sessionHistory.size();
# Line 178  public class DefaultLSConsoleModel imple Line 188  public class DefaultLSConsoleModel imple
188           * Sets the text in the command line.           * Sets the text in the command line.
189           * @param cmdLine The new command line text.           * @param cmdLine The new command line text.
190           */           */
191            @Override
192          public void          public void
193          setCommandLineText(String cmdLine) {          setCommandLineText(String cmdLine) {
194                  if(this.cmdLine.equals(cmdLine)) return;                  if(this.cmdLine.equals(cmdLine)) return;
# Line 191  public class DefaultLSConsoleModel imple Line 202  public class DefaultLSConsoleModel imple
202           * Gets the text in the command line.           * Gets the text in the command line.
203           * @return The command line's text.           * @return The command line's text.
204           */           */
205            @Override
206          public String          public String
207          getCommandLineText() { return cmdLine; }          getCommandLineText() { return cmdLine; }
208                    
# Line 198  public class DefaultLSConsoleModel imple Line 210  public class DefaultLSConsoleModel imple
210           * Gets the command history of the current session, including blank lines and comments.           * Gets the command history of the current session, including blank lines and comments.
211           * @return The command history of the current session, including blank lines and comments.           * @return The command history of the current session, including blank lines and comments.
212           */           */
213            @Override
214          public String[]          public String[]
215          getSessionHistory() {          getSessionHistory() {
216                  return sessionHistory.toArray(new String[sessionHistory.size()]);                  return sessionHistory.toArray(new String[sessionHistory.size()]);
# Line 207  public class DefaultLSConsoleModel imple Line 220  public class DefaultLSConsoleModel imple
220           * Clears the session history.           * Clears the session history.
221           * @see #getSessionHistory           * @see #getSessionHistory
222           */           */
223            @Override
224          public void          public void
225          clearSessionHistory() { sessionHistory.removeAllElements(); }          clearSessionHistory() { sessionHistory.removeAllElements(); }
226                    
# Line 214  public class DefaultLSConsoleModel imple Line 228  public class DefaultLSConsoleModel imple
228           * Adds the specified <code>command</code> to command history.           * Adds the specified <code>command</code> to command history.
229           * @param command The command to be added to command history.           * @param command The command to be added to command history.
230           */           */
231            @Override
232          public void          public void
233          addToCommandHistory(String command) { cmdHistory.add(command); }          addToCommandHistory(String command) { cmdHistory.add(command); }
234                    
# Line 221  public class DefaultLSConsoleModel imple Line 236  public class DefaultLSConsoleModel imple
236           * Gets the complete command history, excluding blank lines and comments.           * Gets the complete command history, excluding blank lines and comments.
237           * @return The complete command history, excluding blank lines and comments.           * @return The complete command history, excluding blank lines and comments.
238           */           */
239            @Override
240          public String[]          public String[]
241          getCommandHistory() {          getCommandHistory() {
242                  return cmdHistory.toArray(new String[cmdHistory.size()]);                  return cmdHistory.toArray(new String[cmdHistory.size()]);
# Line 230  public class DefaultLSConsoleModel imple Line 246  public class DefaultLSConsoleModel imple
246           * Clears the complete/multisession command history.           * Clears the complete/multisession command history.
247           * @see #getCommandHistory           * @see #getCommandHistory
248           */           */
249            @Override
250          public void          public void
251          clearCommandHistory() {          clearCommandHistory() {
252                  cmdHistory.clear();                  cmdHistory.clear();
# Line 240  public class DefaultLSConsoleModel imple Line 257  public class DefaultLSConsoleModel imple
257           * Determines the maximum number of lines to be kept in the command history.           * Determines the maximum number of lines to be kept in the command history.
258           * @return The maximum number of lines to be kept in the command history.           * @return The maximum number of lines to be kept in the command history.
259           */           */
260            @Override
261          public int          public int
262          getCommandHistorySize() { return commandHistorySize; }          getCommandHistorySize() { return commandHistorySize; }
263                    
# Line 247  public class DefaultLSConsoleModel imple Line 265  public class DefaultLSConsoleModel imple
265           * Sets the maximum number of lines to be kept in the command history.           * Sets the maximum number of lines to be kept in the command history.
266           * @param size Determines the maximum number of lines to be kept in the command history.           * @param size Determines the maximum number of lines to be kept in the command history.
267           */           */
268            @Override
269          public void          public void
270          setCommandHistorySize(int size) { commandHistorySize = size; }          setCommandHistorySize(int size) { commandHistorySize = size; }
271                    
# Line 254  public class DefaultLSConsoleModel imple Line 273  public class DefaultLSConsoleModel imple
273           * Gets a list of all LSCP commands.           * Gets a list of all LSCP commands.
274           * @return A list of all LSCP commands.           * @return A list of all LSCP commands.
275           */           */
276            @Override
277          public String[]          public String[]
278          getCommandList() { return cmdList; }          getCommandList() { return cmdList; }
279                    
280          /** Browses the command history one line up. */          /** Browses the command history one line up. */
281            @Override
282          public void          public void
283          browseCommandHistoryUp() {          browseCommandHistoryUp() {
284                  if(cmdHistory.size() == 0) return;                  if(cmdHistory.size() == 0) return;
# Line 275  public class DefaultLSConsoleModel imple Line 296  public class DefaultLSConsoleModel imple
296          }          }
297                    
298          /** Browses the command history one line down. */          /** Browses the command history one line down. */
299            @Override
300          public void          public void
301          browseCommandHistoryDown() {          browseCommandHistoryDown() {
302                  if(cmdHistory.size() == 0 || cmdHistoryIdx == -1) return;                  if(cmdHistory.size() == 0 || cmdHistoryIdx == -1) return;
# Line 289  public class DefaultLSConsoleModel imple Line 311  public class DefaultLSConsoleModel imple
311          }          }
312                    
313          /** Browses to the first line of the command history. */          /** Browses to the first line of the command history. */
314            @Override
315          public void          public void
316          browseCommandHistoryFirst() {          browseCommandHistoryFirst() {
317                  if(cmdHistory.size() == 0) return;                  if(cmdHistory.size() == 0) return;
# Line 297  public class DefaultLSConsoleModel imple Line 320  public class DefaultLSConsoleModel imple
320          }          }
321                    
322          /** Browses to the last line of the command history. */          /** Browses to the last line of the command history. */
323            @Override
324          public void          public void
325          browseCommandHistoryLast() {          browseCommandHistoryLast() {
326                  if(cmdHistory.size() == 0) return;                  if(cmdHistory.size() == 0) return;
# Line 312  public class DefaultLSConsoleModel imple Line 336  public class DefaultLSConsoleModel imple
336           * @return All commands that contains the string returned by {@link #getCommandLineText}.           * @return All commands that contains the string returned by {@link #getCommandLineText}.
337           * @see #getCommandHistory           * @see #getCommandHistory
338           */           */
339            @Override
340          public String[]          public String[]
341          searchCommandHistory() { return searchCommandHistory(getCommandLineText()); }          searchCommandHistory() { return searchCommandHistory(getCommandLineText()); }
342                    
# Line 321  public class DefaultLSConsoleModel imple Line 346  public class DefaultLSConsoleModel imple
346           * @return All commands that contains <code>substring</code>.           * @return All commands that contains <code>substring</code>.
347           * @see #getCommandList           * @see #getCommandList
348           */           */
349            @Override
350          public String[]          public String[]
351          searchCommandHistory(String substring) {          searchCommandHistory(String substring) {
352                  tmpVector.removeAllElements();                  tmpVector.removeAllElements();
# Line 335  public class DefaultLSConsoleModel imple Line 361  public class DefaultLSConsoleModel imple
361           * @return All commands that contains the string returned by {@link #getCommandLineText}.           * @return All commands that contains the string returned by {@link #getCommandLineText}.
362           * @see #getCommandList           * @see #getCommandList
363           */           */
364            @Override
365          public String[]          public String[]
366          searchCommandList() { return searchCommandList(getCommandLineText()); }          searchCommandList() { return searchCommandList(getCommandLineText()); }
367                    
# Line 344  public class DefaultLSConsoleModel imple Line 371  public class DefaultLSConsoleModel imple
371           * @return All commands that contains <code>substring</code>.           * @return All commands that contains <code>substring</code>.
372           * @see #getCommandList           * @see #getCommandList
373           */           */
374            @Override
375          public String[]          public String[]
376          searchCommandList(String substring) {          searchCommandList(String substring) {
377                  tmpVector.removeAllElements();                  tmpVector.removeAllElements();
# Line 410  public class DefaultLSConsoleModel imple Line 438  public class DefaultLSConsoleModel imple
438                                    
439                  LSConsoleThread() {super("LS-Console-Thread"); }                  LSConsoleThread() {super("LS-Console-Thread"); }
440                                    
441                    @Override
442                  public void                  public void
443                  run() {                  run() {
444                          while(!mustTerminate()) {                          while(!mustTerminate()) {

Legend:
Removed from v.1785  
changed lines
  Added in v.1786

  ViewVC Help
Powered by ViewVC