text
stringlengths 0
2.2M
|
---|
JucerDocument* JucerDocument::createForCppFile (Project* p, const File& file)
|
{
|
OpenDocumentManager& odm = ProjucerApplication::getApp().openDocumentManager;
|
if (SourceCodeDocument* cpp = dynamic_cast<SourceCodeDocument*> (odm.openFile (p, file)))
|
if (dynamic_cast<SourceCodeDocument*> (odm.openFile (p, file.withFileExtension (".h"))) != nullptr)
|
return createDocument (cpp);
|
return nullptr;
|
}
|
//==============================================================================
|
class JucerComponentDocument : public SourceCodeDocument
|
{
|
public:
|
JucerComponentDocument (Project* p, const File& f)
|
: SourceCodeDocument (p, f)
|
{
|
}
|
void saveAsync (std::function<void (bool)> callback) override
|
{
|
SourceCodeDocument::saveAsync ([parent = WeakReference<JucerComponentDocument> { this }, callback] (bool saveResult)
|
{
|
if (parent == nullptr)
|
return;
|
if (! saveResult)
|
{
|
callback (false);
|
return;
|
}
|
parent->saveHeaderAsync ([parent, callback] (bool headerSaveResult)
|
{
|
if (parent != nullptr)
|
callback (headerSaveResult);
|
});
|
});
|
}
|
void saveHeaderAsync (std::function<void (bool)> callback)
|
{
|
auto& odm = ProjucerApplication::getApp().openDocumentManager;
|
if (auto* header = odm.openFile (nullptr, getFile().withFileExtension (".h")))
|
{
|
header->saveAsync ([parent = WeakReference<JucerComponentDocument> { this }, callback] (bool saveResult)
|
{
|
if (parent == nullptr)
|
return;
|
if (saveResult)
|
ProjucerApplication::getApp()
|
.openDocumentManager
|
.closeFileWithoutSaving (parent->getFile().withFileExtension (".h"));
|
callback (saveResult);
|
});
|
return;
|
}
|
callback (false);
|
}
|
std::unique_ptr<Component> createEditor() override
|
{
|
if (ProjucerApplication::getApp().isGUIEditorEnabled())
|
{
|
std::unique_ptr<JucerDocument> jucerDoc (JucerDocument::createForCppFile (getProject(), getFile()));
|
if (jucerDoc != nullptr)
|
return std::make_unique<JucerDocumentEditor> (jucerDoc.release());
|
}
|
return SourceCodeDocument::createEditor();
|
}
|
struct Type : public OpenDocumentManager::DocumentType
|
{
|
Type() {}
|
bool canOpenFile (const File& f) override { return JucerDocument::isValidJucerCppFile (f); }
|
Document* openFile (Project* p, const File& f) override { return new JucerComponentDocument (p, f); }
|
};
|
JUCE_DECLARE_WEAK_REFERENCEABLE (JucerComponentDocument)
|
};
|
OpenDocumentManager::DocumentType* createGUIDocumentType();
|
OpenDocumentManager::DocumentType* createGUIDocumentType()
|
{
|
return new JucerComponentDocument::Type();
|
}
|
//==============================================================================
|
struct NewGUIComponentWizard : public NewFileWizard::Type
|
{
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.