1 |
/* |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
* |
4 |
* Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com> |
* Copyright (C) 2005-2009 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
* |
6 |
* This file is part of JSampler. |
* This file is part of JSampler. |
7 |
* |
* |
22 |
|
|
23 |
package org.jsampler.task; |
package org.jsampler.task; |
24 |
|
|
|
import java.util.logging.Level; |
|
|
|
|
25 |
import org.jsampler.CC; |
import org.jsampler.CC; |
|
import org.jsampler.HF; |
|
26 |
|
|
27 |
import org.linuxsampler.lscp.DbDirectoryInfo; |
import org.linuxsampler.lscp.DbDirectoryInfo; |
28 |
import org.linuxsampler.lscp.DbInstrumentInfo; |
import org.linuxsampler.lscp.DbInstrumentInfo; |
63 |
} |
} |
64 |
|
|
65 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
66 |
|
@Override |
67 |
public void |
public void |
68 |
run() { |
exec() throws Exception { |
69 |
try { setResult(CC.getClient().getDbDirectoryCount(dir, recursive)); } |
setResult(CC.getClient().getDbDirectoryCount(dir, recursive)); |
|
catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
70 |
} |
} |
71 |
} |
} |
72 |
|
|
92 |
} |
} |
93 |
|
|
94 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
95 |
|
@Override |
96 |
public void |
public void |
97 |
run() { |
exec() throws Exception { |
98 |
try { setResult(CC.getClient().getDbInstrumentCount(dir, recursive)); } |
setResult(CC.getClient().getDbInstrumentCount(dir, recursive)); |
|
catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
99 |
} |
} |
100 |
} |
} |
101 |
|
|
117 |
} |
} |
118 |
|
|
119 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
120 |
|
@Override |
121 |
public void |
public void |
122 |
run() { |
exec() throws Exception { setResult(CC.getClient().getDbDirectories(dir)); } |
|
try { setResult(CC.getClient().getDbDirectories(dir)); } |
|
|
catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
|
} |
|
123 |
|
|
124 |
public String |
public String |
125 |
getDirectory() { return dir; } |
getDirectory() { return dir; } |
129 |
* equal to this are removed if added using {@link org.jsampler.CC#scheduleTask}. |
* equal to this are removed if added using {@link org.jsampler.CC#scheduleTask}. |
130 |
* @see org.jsampler.CC#addTask |
* @see org.jsampler.CC#addTask |
131 |
*/ |
*/ |
132 |
|
@Override |
133 |
public boolean |
public boolean |
134 |
equals(Object obj) { |
equals(Object obj) { |
135 |
if(obj == null) return false; |
if(obj == null) return false; |
163 |
} |
} |
164 |
|
|
165 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
166 |
|
@Override |
167 |
public void |
public void |
168 |
run() { |
exec() throws Exception { setResult(CC.getClient().getDbDirectoryInfo(dir)); } |
|
try { setResult(CC.getClient().getDbDirectoryInfo(dir)); } |
|
|
catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
|
} |
|
169 |
} |
} |
170 |
|
|
171 |
/** |
/** |
186 |
} |
} |
187 |
|
|
188 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
189 |
|
@Override |
190 |
public void |
public void |
191 |
run() { |
exec() throws Exception { CC.getClient().addDbDirectory(dir); } |
|
try { CC.getClient().addDbDirectory(dir); } |
|
|
catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
|
} |
|
192 |
} |
} |
193 |
|
|
194 |
/** |
/** |
212 |
} |
} |
213 |
|
|
214 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
215 |
|
@Override |
216 |
public void |
public void |
217 |
run() { |
exec() throws Exception { CC.getClient().renameDbDirectory(dir, newName); } |
|
try { CC.getClient().renameDbDirectory(dir, newName); } |
|
|
catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
|
} |
|
218 |
} |
} |
219 |
|
|
220 |
/** |
/** |
239 |
} |
} |
240 |
|
|
241 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
242 |
|
@Override |
243 |
public void |
public void |
244 |
run() { |
exec() throws Exception { |
245 |
try { CC.getClient().setDbDirectoryDescription(dir, desc); } |
CC.getClient().setDbDirectoryDescription(dir, desc); |
|
catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
246 |
} |
} |
247 |
} |
} |
248 |
|
|
258 |
*/ |
*/ |
259 |
public |
public |
260 |
RemoveDirectories(DbDirectoryInfo[] directories) { |
RemoveDirectories(DbDirectoryInfo[] directories) { |
261 |
|
super(true); |
262 |
setTitle("InstrumentsDb.RemoveDirectories_task"); |
setTitle("InstrumentsDb.RemoveDirectories_task"); |
263 |
setDescription(i18n.getMessage("InstrumentsDb.RemoveDirectories.desc")); |
setDescription(i18n.getMessage("InstrumentsDb.RemoveDirectories.desc")); |
264 |
this.directories = directories; |
this.directories = directories; |
265 |
} |
} |
266 |
|
|
267 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
268 |
|
@Override |
269 |
public void |
public void |
270 |
run() { |
exec() throws Exception { removeDirectories(); } |
|
try { |
|
|
removeDirectories(); |
|
|
} catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
setErrorDetails(x); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
|
} |
|
271 |
|
|
272 |
private void |
private void |
273 |
removeDirectories() throws Exception { |
removeDirectories() throws Exception { |
308 |
} |
} |
309 |
|
|
310 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
311 |
|
@Override |
312 |
public void |
public void |
313 |
run() { |
exec() throws Exception { |
314 |
try { setResult(CC.getClient().findDbDirectories(dir, query)); } |
setResult(CC.getClient().findDbDirectories(dir, query)); |
|
catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
315 |
} |
} |
316 |
} |
} |
317 |
|
|
327 |
*/ |
*/ |
328 |
public |
public |
329 |
GetInstruments(String dir) { |
GetInstruments(String dir) { |
330 |
|
super(true); |
331 |
setTitle("InstrumentsDb.GetInstruments_task"); |
setTitle("InstrumentsDb.GetInstruments_task"); |
332 |
setDescription(i18n.getMessage("InstrumentsDb.GetInstruments.desc")); |
setDescription(i18n.getMessage("InstrumentsDb.GetInstruments.desc")); |
333 |
this.dir = dir; |
this.dir = dir; |
334 |
} |
} |
335 |
|
|
336 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
337 |
|
@Override |
338 |
public void |
public void |
339 |
run() { |
exec() throws Exception { setResult(CC.getClient().getDbInstruments(dir)); } |
|
try { setResult(CC.getClient().getDbInstruments(dir)); } |
|
|
catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
setErrorDetails(x); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
|
} |
|
340 |
|
|
341 |
public String |
public String |
342 |
getDirectory() { return dir; } |
getDirectory() { return dir; } |
346 |
* equal to this are removed if added using {@link org.jsampler.CC#scheduleTask}. |
* equal to this are removed if added using {@link org.jsampler.CC#scheduleTask}. |
347 |
* @see org.jsampler.CC#addTask |
* @see org.jsampler.CC#addTask |
348 |
*/ |
*/ |
349 |
|
@Override |
350 |
public boolean |
public boolean |
351 |
equals(Object obj) { |
equals(Object obj) { |
352 |
if(obj == null) return false; |
if(obj == null) return false; |
378 |
} |
} |
379 |
|
|
380 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
381 |
|
@Override |
382 |
public void |
public void |
383 |
run() { |
exec() throws Exception { |
384 |
try { setResult(CC.getClient().getDbInstrumentInfo(instr)); } |
setResult(CC.getClient().getDbInstrumentInfo(instr)); |
|
catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
385 |
} |
} |
386 |
} |
} |
387 |
|
|
407 |
} |
} |
408 |
|
|
409 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
410 |
|
@Override |
411 |
public void |
public void |
412 |
run() { |
exec() throws Exception { |
413 |
try { setResult(CC.getClient().findDbInstruments(dir, query)); } |
setResult(CC.getClient().findDbInstruments(dir, query)); |
|
catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
414 |
} |
} |
415 |
} |
} |
416 |
|
|
435 |
} |
} |
436 |
|
|
437 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
438 |
|
@Override |
439 |
public void |
public void |
440 |
run() { |
exec() throws Exception { CC.getClient().renameDbInstrument(instr, newName); } |
|
try { CC.getClient().renameDbInstrument(instr, newName); } |
|
|
catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
|
} |
|
441 |
} |
} |
442 |
|
|
443 |
/** |
/** |
462 |
} |
} |
463 |
|
|
464 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
465 |
|
@Override |
466 |
public void |
public void |
467 |
run() { |
exec() throws Exception { |
468 |
try { CC.getClient().setDbInstrumentDescription(instr, desc); } |
CC.getClient().setDbInstrumentDescription(instr, desc); |
|
catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
469 |
} |
} |
470 |
} |
} |
471 |
|
|
481 |
*/ |
*/ |
482 |
public |
public |
483 |
RemoveInstruments(DbInstrumentInfo[] instruments) { |
RemoveInstruments(DbInstrumentInfo[] instruments) { |
484 |
|
super(true); |
485 |
setTitle("InstrumentsDb.RemoveInstruments_task"); |
setTitle("InstrumentsDb.RemoveInstruments_task"); |
486 |
setDescription(i18n.getMessage("InstrumentsDb.RemoveInstruments.desc")); |
setDescription(i18n.getMessage("InstrumentsDb.RemoveInstruments.desc")); |
487 |
this.instruments = instruments; |
this.instruments = instruments; |
488 |
} |
} |
489 |
|
|
490 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
491 |
|
@Override |
492 |
public void |
public void |
493 |
run() { |
exec() throws Exception { removeInstruments(); } |
|
try { |
|
|
removeInstruments(); |
|
|
} catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
setErrorDetails(x); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
|
} |
|
494 |
|
|
495 |
private void |
private void |
496 |
removeInstruments() throws Exception { |
removeInstruments() throws Exception { |
548 |
} |
} |
549 |
|
|
550 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
551 |
|
@Override |
552 |
public void |
public void |
553 |
run() { |
exec() throws Exception { |
554 |
try { |
int i; |
555 |
int i; |
if(instrIndex != -1) { |
556 |
if(instrIndex != -1) { |
i = CC.getClient().addDbInstrument ( |
557 |
i = CC.getClient().addDbInstrument ( |
dbDir, filePath, instrIndex, true |
558 |
dbDir, filePath, instrIndex, true |
); |
559 |
); |
} else { |
560 |
} else { |
i = CC.getClient().addDbInstruments(dbDir, filePath, true); |
|
i = CC.getClient().addDbInstruments(dbDir, filePath, true); |
|
|
} |
|
|
|
|
|
setResult(i); |
|
|
} catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
561 |
} |
} |
562 |
|
|
563 |
|
setResult(i); |
564 |
} |
} |
565 |
} |
} |
566 |
|
|
619 |
} |
} |
620 |
|
|
621 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
622 |
|
@Override |
623 |
public void |
public void |
624 |
run() { |
exec() throws Exception { |
625 |
try { |
ScanMode scanMode = flat ? ScanMode.FLAT : ScanMode.RECURSIVE; |
626 |
ScanMode scanMode = flat ? ScanMode.FLAT : ScanMode.RECURSIVE; |
int i = CC.getClient().addDbInstruments ( |
627 |
int i = CC.getClient().addDbInstruments ( |
scanMode, dbDir, fsDir, true, insDir |
628 |
scanMode, dbDir, fsDir, true, insDir |
); |
629 |
); |
|
630 |
|
setResult(i); |
|
setResult(i); |
|
|
} |
|
|
catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
631 |
} |
} |
632 |
} |
} |
633 |
|
|
672 |
} |
} |
673 |
|
|
674 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
675 |
|
@Override |
676 |
public void |
public void |
677 |
run() { |
exec() throws Exception { |
678 |
try { |
int i = CC.getClient().addDbInstruments ( |
679 |
int i = CC.getClient().addDbInstruments ( |
ScanMode.NON_RECURSIVE, dbDir, fsDir, true, insDir |
680 |
ScanMode.NON_RECURSIVE, dbDir, fsDir, true, insDir |
); |
681 |
); |
setResult(i); |
|
setResult(i); |
|
|
} |
|
|
catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
682 |
} |
} |
683 |
} |
} |
684 |
|
|
700 |
*/ |
*/ |
701 |
public |
public |
702 |
Move(DbDirectoryInfo[] directories, DbInstrumentInfo[] instruments, String dest) { |
Move(DbDirectoryInfo[] directories, DbInstrumentInfo[] instruments, String dest) { |
703 |
|
super(true); |
704 |
setTitle("InstrumentsDb.Move_task"); |
setTitle("InstrumentsDb.Move_task"); |
705 |
setDescription(i18n.getMessage("InstrumentsDb.Move.desc")); |
setDescription(i18n.getMessage("InstrumentsDb.Move.desc")); |
706 |
this.directories = directories; |
this.directories = directories; |
709 |
} |
} |
710 |
|
|
711 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
712 |
|
@Override |
713 |
public void |
public void |
714 |
run() { |
exec() throws Exception { |
715 |
try { |
moveInstruments(); |
716 |
moveInstruments(); |
moveDirectories(); |
|
moveDirectories(); |
|
|
} catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
setErrorDetails(x); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
717 |
} |
} |
718 |
|
|
719 |
private void |
private void |
767 |
*/ |
*/ |
768 |
public |
public |
769 |
Copy(DbDirectoryInfo[] directories, DbInstrumentInfo[] instruments, String dest) { |
Copy(DbDirectoryInfo[] directories, DbInstrumentInfo[] instruments, String dest) { |
770 |
|
super(true); |
771 |
setTitle("InstrumentsDb.Copy_task"); |
setTitle("InstrumentsDb.Copy_task"); |
772 |
setDescription(i18n.getMessage("InstrumentsDb.Copy.desc")); |
setDescription(i18n.getMessage("InstrumentsDb.Copy.desc")); |
773 |
this.directories = directories; |
this.directories = directories; |
776 |
} |
} |
777 |
|
|
778 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
779 |
|
@Override |
780 |
public void |
public void |
781 |
run() { |
exec() throws Exception { |
782 |
try { |
copyInstruments(); |
783 |
copyInstruments(); |
copyDirectories(); |
|
copyDirectories(); |
|
|
} catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
setErrorDetails(x); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
784 |
} |
} |
785 |
|
|
786 |
private void |
private void |
832 |
} |
} |
833 |
|
|
834 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
835 |
|
@Override |
836 |
public void |
public void |
837 |
run() { |
exec() throws Exception { |
838 |
try { setResult(CC.getClient().findLostDbInstrumentFiles()); } |
setResult(CC.getClient().findLostDbInstrumentFiles()); |
|
catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
839 |
} |
} |
840 |
} |
} |
841 |
|
|
861 |
} |
} |
862 |
|
|
863 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
864 |
|
@Override |
865 |
public void |
public void |
866 |
run() { |
exec() throws Exception { |
867 |
try { CC.getClient().setDbInstrumentFilePath(oldPath, newPath); } |
CC.getClient().setDbInstrumentFilePath(oldPath, newPath); |
|
catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
868 |
} |
} |
869 |
} |
} |
870 |
|
|
886 |
} |
} |
887 |
|
|
888 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
889 |
|
@Override |
890 |
public void |
public void |
891 |
run() { |
exec() throws Exception { |
892 |
try { setResult(CC.getClient().getDbInstrumentsJobInfo(jobId)); } |
setResult(CC.getClient().getDbInstrumentsJobInfo(jobId)); |
|
catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
893 |
} |
} |
894 |
|
|
895 |
public int |
public int |
900 |
* equal to this are removed if added using {@link org.jsampler.CC#scheduleTask}. |
* equal to this are removed if added using {@link org.jsampler.CC#scheduleTask}. |
901 |
* @see org.jsampler.CC#addTask |
* @see org.jsampler.CC#addTask |
902 |
*/ |
*/ |
903 |
|
@Override |
904 |
public boolean |
public boolean |
905 |
equals(Object obj) { |
equals(Object obj) { |
906 |
if(obj == null) return false; |
if(obj == null) return false; |
926 |
} |
} |
927 |
|
|
928 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
929 |
|
@Override |
930 |
public void |
public void |
931 |
run() { |
exec() throws Exception { CC.getClient().formatInstrumentsDb(); } |
|
try { CC.getClient().formatInstrumentsDb(); } |
|
|
catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
|
} |
|
932 |
} |
} |
933 |
} |
} |