bool MainWindowList::openFile (const File& file) { for (int i = windows.size(); --i >= 0;) { MainWindow* const w = windows.getUnchecked(i); if (w->getProject() != nullptr && w->getProject()->getFile() == file) { w->toFront (true); return true; } } if (file.hasFileExtension (Project::projectFileExtension)) { MainWindow* const w = getOrCreateEmptyWindow(); bool ok = w->openFile (file); w->makeVisible(); avoidSuperimposedWindows (w); return ok; } if (file.exists()) return getOrCreateFrontmostWindow()->openFile (file); return false; }
bool MainWindowList::openFile (const File& file) { for (int i = windows.size(); --i >= 0;) { MainWindow* const w = windows.getUnchecked(i); if (w->getProject() != nullptr && w->getProject()->getFile() == file) { w->toFront (true); return true; } } if (file.hasFileExtension (Project::projectFileExtension)) { ScopedPointer<Project> newDoc (new Project (file)); if (newDoc->loadFrom (file, true)) { MainWindow* const w = getOrCreateEmptyWindow(); w->setProject (newDoc); newDoc.release()->setChangedFlag (false); w->makeVisible(); avoidSuperimposedWindows (w); jassert (w->getProjectContentComponent() != nullptr); w->getProjectContentComponent()->reloadLastOpenDocuments(); return true; } } else if (file.exists()) { MainWindow* const w = getOrCreateFrontmostWindow(); return w->openFile (file); } return false; }
void MainWindowList::openDocument (OpenDocumentManager::Document* doc, bool grabFocus) { Desktop& desktop = Desktop::getInstance(); for (int i = desktop.getNumComponents(); --i >= 0;) { if (MainWindow* const mw = dynamic_cast<MainWindow*> (desktop.getComponent(i))) { if (ProjectContentComponent* pcc = mw->getProjectContentComponent()) { if (pcc->hasFileInRecentList (doc->getFile())) { mw->toFront (true); mw->getProjectContentComponent()->showDocument (doc, grabFocus); return; } } } } getOrCreateFrontmostWindow()->getProjectContentComponent()->showDocument (doc, grabFocus); }
void MainWindowList::openDocument (OpenDocumentManager::Document* doc, bool grabFocus) { getOrCreateFrontmostWindow()->getProjectContentComponent()->showDocument (doc, grabFocus); }