public void follow(File sourceFile, Line sourceLine) {
   Line line = findLineForOccurrence(sourceFile, sourceLine);
   if (line == null) return;
   for (EditorIterator it = new EditorIterator(); it.hasNext(); ) {
     Editor ed = it.next();
     if (ed.getBuffer() == this) {
       ed.moveDotTo(line, 0);
       ed.updateDisplay();
     }
   }
 }
 // Move dot to line (in all editors) and call findOccurrenceAtDot().
 private void findOccurrence(Editor editor, Line line) {
   if (line instanceof OccurrenceLine) {
     for (EditorIterator it = new EditorIterator(); it.hasNext(); ) {
       Editor ed = it.next();
       if (ed.getBuffer() == this) {
         ed.moveDotTo(line, 0);
         ed.updateDisplay();
       }
     }
     findOccurrenceAtDot(editor, false);
   }
 }
 public void findOccurrenceAtDot(Editor editor, boolean killList) {
   Position pos = editor.getDotCopy();
   if (pos == null) return;
   Line sourceLine = null;
   int sourceLineNumber = 0;
   Buffer buf = null;
   String canonicalPath = null;
   setLastDotPos(pos);
   final Line line = pos.getLine();
   if ((line instanceof OccurrenceLine)) {
     sourceLine = ((OccurrenceLine) line).getSourceLine();
     Line ln = line;
     if (!ln.getText().startsWith("File: "))
       sourceLineNumber = Utilities.parseInt(ln.getText()) - 1;
     while (ln != null) {
       if (ln.getText().startsWith("File: ")) {
         canonicalPath = ln.getText().substring(6);
         break;
       }
       ln = ln.previous();
     }
   } else if (line instanceof FileLine) canonicalPath = ((FileLine) line).getCanonicalPath();
   if (buf == null && canonicalPath != null)
     buf = Editor.getBuffer(File.getInstance(canonicalPath));
   if (buf != null) {
     if (!buf.isLoaded()) {
       if (!buf.initialized()) buf.initialize();
       buf.load();
       if (!buf.isLoaded()) {
         editor.status("Unable to load buffer");
         return;
       }
     }
     if (line instanceof FileLine) {
       // Mark file visited.
       ((FileLine) line).markVisited();
       // Advance dot to next line.
       Position dot = editor.getDot();
       if (dot.equals(pos) && dot.getNextLine() != null) {
         dot.moveTo(dot.getNextLine(), 0);
         editor.moveCaretToDotCol();
       }
     }
     Line target;
     if (sourceLine != null) {
       if (buf.contains(sourceLine)) target = sourceLine;
       else target = buf.getLine(sourceLine.lineNumber());
     } else target = buf.getLine(sourceLineNumber);
     gotoSource(editor, buf, target, killList);
   }
 }
 public void findPreviousOccurrence(Editor editor) {
   Line line;
   for (line = editor.getDotLine().previous(); line != null; line = line.previous()) {
     if (line instanceof OccurrenceLine) break;
   }
   if (line instanceof OccurrenceLine) findOccurrence(editor, line);
 }
Пример #5
0
 private static synchronized void initialize() {
   if (list == null) {
     Editor.protect(MailboxProperties.class);
     list = new ArrayList<Entry>();
     File file = getFile();
     if (file.isFile()) {
       XMLReader xmlReader = Utilities.getDefaultXMLReader();
       if (xmlReader != null) {
         try {
           xmlReader.setContentHandler(new Handler());
           InputSource inputSource = new InputSource(file.getInputStream());
           xmlReader.parse(inputSource);
         } catch (Exception e) {
           Log.error(e);
         }
       }
     }
     // Delete old mailboxes.xml in ~/.j (if any).
     File oldFile = File.getInstance(Directories.getEditorDirectory(), "mailboxes.xml");
     if (oldFile != null && oldFile.isFile()) oldFile.delete();
   }
 }