Example #1
0
 public SlimController(SlimRenderVisitor renderer, SlimFileContext fileContext) {
   this.fileContext = fileContext;
   this.fileContext.addListener(this);
   for (SlimFileWrapper file : this.fileContext.getFiles()) {
     numberOfLines += file.getLines().size();
   }
   this.renderer = renderer;
 }
Example #2
0
 public SlimLineWrapper getLine(int linenum) {
   int totalLinesReached = 0, lastTotal = 0;
   for (SlimFileWrapper file : this.fileContext.getFiles()) {
     Collection<SlimLineWrapper> lines = file.getLines();
     lastTotal = totalLinesReached;
     totalLinesReached += lines.size();
     if (linenum < totalLinesReached) {
       SlimLineWrapper[] array = lines.toArray(new SlimLineWrapper[lines.size()]);
       return array[linenum - lastTotal];
     }
   }
   return null;
 }
Example #3
0
 public Set<SlimFileWrapper> getFilesForLines(int startLine, int endLine) {
   Set<SlimFileWrapper> files = new HashSet<SlimFileWrapper>();
   int fileEnd = 0, fileStart = 0;
   for (SlimFileWrapper file : this.fileContext.getFiles()) {
     Collection<SlimLineWrapper> lines = file.getLines();
     fileStart = fileEnd;
     fileEnd += lines.size();
     if ((fileStart > startLine && fileStart < endLine)
         || (fileEnd > startLine && fileEnd < endLine)
         || (startLine > fileStart && startLine < fileEnd)
         || (endLine > fileStart && endLine < fileEnd)) {
       files.add(file);
     }
   }
   return files;
 }
Example #4
0
 @Override
 public void onNewFileLoaded(SlimFileWrapper newFile) {
   numberOfLines += newFile.getLines().size();
   renderer.refresh();
 }