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);
   }
 }
Esempio n. 2
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();
   }
 }