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

Diff of /jsampler/trunk/src/org/jsampler/task/InstrumentsDb.java

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

revision 1866 by iliev, Mon Sep 29 18:21:21 2008 UTC revision 1867 by iliev, Mon Mar 16 22:12:32 2009 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-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   *   *
# Line 22  Line 22 
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;
# Line 66  public class InstrumentsDb { Line 63  public class InstrumentsDb {
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                    
# Line 98  public class InstrumentsDb { Line 92  public class InstrumentsDb {
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                    
# Line 126  public class InstrumentsDb { Line 117  public class InstrumentsDb {
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; }
# Line 143  public class InstrumentsDb { Line 129  public class InstrumentsDb {
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;
# Line 176  public class InstrumentsDb { Line 163  public class InstrumentsDb {
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          /**          /**
# Line 204  public class InstrumentsDb { Line 186  public class InstrumentsDb {
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          /**          /**
# Line 235  public class InstrumentsDb { Line 212  public class InstrumentsDb {
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          /**          /**
# Line 267  public class InstrumentsDb { Line 239  public class InstrumentsDb {
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                    
# Line 289  public class InstrumentsDb { Line 258  public class InstrumentsDb {
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 {
# Line 345  public class InstrumentsDb { Line 308  public class InstrumentsDb {
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                    
# Line 367  public class InstrumentsDb { Line 327  public class InstrumentsDb {
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; }
# Line 391  public class InstrumentsDb { Line 346  public class InstrumentsDb {
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;
# Line 422  public class InstrumentsDb { Line 378  public class InstrumentsDb {
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                    
# Line 454  public class InstrumentsDb { Line 407  public class InstrumentsDb {
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                    
# Line 485  public class InstrumentsDb { Line 435  public class InstrumentsDb {
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          /**          /**
# Line 517  public class InstrumentsDb { Line 462  public class InstrumentsDb {
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                    
# Line 539  public class InstrumentsDb { Line 481  public class InstrumentsDb {
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 {
# Line 612  public class InstrumentsDb { Line 548  public class InstrumentsDb {
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                    
# Line 687  public class InstrumentsDb { Line 619  public class InstrumentsDb {
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                    
# Line 745  public class InstrumentsDb { Line 672  public class InstrumentsDb {
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                    
# Line 778  public class InstrumentsDb { Line 700  public class InstrumentsDb {
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;
# Line 786  public class InstrumentsDb { Line 709  public class InstrumentsDb {
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
# Line 849  public class InstrumentsDb { Line 767  public class InstrumentsDb {
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;
# Line 857  public class InstrumentsDb { Line 776  public class InstrumentsDb {
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
# Line 918  public class InstrumentsDb { Line 832  public class InstrumentsDb {
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                    
# Line 950  public class InstrumentsDb { Line 861  public class InstrumentsDb {
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                    
# Line 978  public class InstrumentsDb { Line 886  public class InstrumentsDb {
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
# Line 995  public class InstrumentsDb { Line 900  public class InstrumentsDb {
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;
# Line 1020  public class InstrumentsDb { Line 926  public class InstrumentsDb {
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  }  }

Legend:
Removed from v.1866  
changed lines
  Added in v.1867

  ViewVC Help
Powered by ViewVC