1 2 25 26 27 package org.aspectj.ajde.ui.swing; 28 29 import javax.swing.SwingUtilities ; 30 import org.aspectj.ajde.*; 31 32 38 public class GoToLineThread extends Thread { 39 private EditorAdapter editorAdapter = null; 40 41 private int lineNumber = 0; 42 private String fileToSeekTo = ""; 43 private boolean finished = false; 44 45 public boolean isFinished() { 46 return finished; 47 } 48 49 public boolean needsRetry() { 50 return !this.isAlive() && !finished; 51 } 52 53 public GoToLineThread(String fileToSeekTo, int lineNumber, EditorAdapter editorAdapter) { 54 this.lineNumber = lineNumber; 55 this.fileToSeekTo = fileToSeekTo; 56 this.editorAdapter = editorAdapter; 57 } 58 59 public void run() { 60 61 while(true) { 62 String file = editorAdapter.getCurrFile(); 63 if (file != null) { 64 if (file.equals(this.fileToSeekTo)) { 65 try { 66 SwingUtilities.invokeAndWait( new Runnable () { 67 public void run() { 68 editorAdapter.showSourceLine(lineNumber, true); 69 } 70 }); 71 } catch (Exception e) { 72 Ajde.getDefault().getErrorHandler().handleError("Could not seek to line.", e); 73 } 74 finished = true; 75 break; 76 } 77 shortPause(); 78 } 79 } 80 } 81 82 private void shortPause() { 83 try { 84 this.sleep(100); 85 } catch (InterruptedException e) { 86 throw new RuntimeException (e.getMessage()); 87 } 88 } 89 } | Popular Tags |