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 |
* |
* |
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); |
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 |
|
|
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(); |
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(); |
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; |
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 |
|
|
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()]); |
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 |
|
|
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 |
|
|
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()]); |
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(); |
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 |
|
|
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 |
|
|
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; |
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; |
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; |
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; |
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 |
|
|
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(); |
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 |
|
|
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(); |
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()) { |