boolean matchInThisDocument = modes.getSearch().search(topic, Search.FORWARDS);
if (matchInThisDocument) {
return true;
}
DocumentManager documentManager = modes.getDocumentManager();
// FUTURE: It is possible to use a document manager
// specifically to coordinate help files when the program is
// embedded in another program. The document manager would no
// longer be null.
if (documentManager==null) {
Ket.out.println(" !!! Can't load another document: document manager is null !!! ");
return false;
}
// BUG: Restrict search to help files: check that these files are help files.
// Search (via document manager) all other open documents;
// Request focus for that frame [how]?
for (Document document : documentManager.getDocs()) {
if (document!=modes.getDocument()) { // Don't bother re-checking this document.
boolean ok = selectWithinAnotherDocument(document, topic);
if (ok) {
return true;
}
}
}
// Load the non-open help files as plain text;
for (String filename : helpFiles) {
boolean helpFileMatches = searchJar(filename, topic);
//?+ boolean helpFileMatches = searchPlainText(filename, topic);
if (helpFileMatches) {
Document document = new Document(documentManager, null, filename); // TODO: Use this.getDocument()'s clipboard?
documentManager.addDocument(document);
//- boolean ok = selectWithinAnotherDocument(document, topic);
selectWithinAnotherDocument(document, topic);
return true;
}
}