Пример #1
0
    void createNewFile (Project::Item parent)
    {
        const File newFile (askUserToChooseNewFile ("SourceCode.h", "*.h", parent));

        if (newFile != File::nonexistent)
            create (parent, newFile, "jucer_NewCppFileTemplate_h");
    }
Пример #2
0
    void createNewFile (Project::Item parent)
    {
        for (;;)
        {
            AlertWindow aw (TRANS ("Create new Component class"),
                            TRANS ("Please enter the name for the new class"),
                            AlertWindow::NoIcon, nullptr);

            aw.addTextEditor (getClassNameFieldName(), String::empty, String::empty, false);
            aw.addButton (TRANS ("Create Files"),  1, KeyPress (KeyPress::returnKey));
            aw.addButton (TRANS ("Cancel"),        0, KeyPress (KeyPress::escapeKey));

            if (aw.runModalLoop() == 0)
                break;

            const String className (aw.getTextEditorContents (getClassNameFieldName()).trim());

            if (className == CodeHelpers::makeValidIdentifier (className, false, true, false))
            {
                const File newFile (askUserToChooseNewFile (className + ".h", "*.h;*.cpp", parent));

                if (newFile != File::nonexistent)
                    createFiles (parent, className, newFile);

                break;
            }
        }
    }
Пример #3
0
    void createNewFile (Project&, Project::Item parent) override
    {
        const File newFile (askUserToChooseNewFile ("SourceCode.h", "*.h", parent));

        if (newFile != File())
            create (parent, newFile, "jucer_NewCppFileTemplate_h");
    }
Пример #4
0
    void createNewFile (Project::Item parent)
    {
        const File newFile (askUserToChooseNewFile ("SourceCode.h", "*.h;*.cpp", parent));

        if (newFile != File::nonexistent)
        {
            if (NewCppFileWizard::create (parent, newFile.withFileExtension ("h"),   "jucer_NewCppFileTemplate_h"))
                NewCppFileWizard::create (parent, newFile.withFileExtension ("cpp"), "jucer_NewCppFileTemplate_cpp");
        }
    }
Пример #5
0
    void createNewFile (Project::Item parent) override
    {
        const File newFile (askUserToChooseNewFile (String (defaultClassName) + ".h", "*.h;*.cpp", parent));

        if (newFile != File::nonexistent)
        {
            const File headerFile (newFile.withFileExtension (".h"));
            const File cppFile (newFile.withFileExtension (".cpp"));

            headerFile.replaceWithText (String::empty);
            cppFile.replaceWithText (String::empty);

            OpenDocumentManager& odm = IntrojucerApp::getApp().openDocumentManager;

            if (SourceCodeDocument* cpp = dynamic_cast <SourceCodeDocument*> (odm.openFile (nullptr, cppFile)))
            {
                if (SourceCodeDocument* header = dynamic_cast <SourceCodeDocument*> (odm.openFile (nullptr, headerFile)))
                {
                    ScopedPointer<JucerDocument> jucerDoc (new ComponentDocument (cpp));

                    if (jucerDoc != nullptr)
                    {
                        jucerDoc->setClassName (newFile.getFileNameWithoutExtension());

                        jucerDoc->flushChangesToDocuments();
                        jucerDoc = nullptr;

                        cpp->save();
                        header->save();
                        odm.closeDocument (cpp, true);
                        odm.closeDocument (header, true);

                        parent.addFile (headerFile, 0, true);
                        parent.addFile (cppFile, 0, true);
                    }
                }
            }
        }
    }
Пример #6
0
    void createNewFile (Project& project, Project::Item parent) override
    {
        auto newFile = askUserToChooseNewFile (String (defaultClassName) + ".h", "*.h;*.cpp", parent);

        if (newFile != File())
        {
            auto headerFile = newFile.withFileExtension (".h");
            auto cppFile = newFile.withFileExtension (".cpp");

            headerFile.replaceWithText (String());
            cppFile.replaceWithText (String());

            auto& odm = ProjucerApplication::getApp().openDocumentManager;

            if (auto* cpp = dynamic_cast<SourceCodeDocument*> (odm.openFile (nullptr, cppFile)))
            {
                if (auto* header = dynamic_cast<SourceCodeDocument*> (odm.openFile (nullptr, headerFile)))
                {
                    std::unique_ptr<JucerDocument> jucerDoc (new ComponentDocument (cpp));

                    if (jucerDoc != nullptr)
                    {
                        jucerDoc->setClassName (newFile.getFileNameWithoutExtension());

                        jucerDoc->flushChangesToDocuments (&project);
                        jucerDoc.reset();

                        cpp->save();
                        header->save();
                        odm.closeDocument (cpp, true);
                        odm.closeDocument (header, true);

                        parent.addFileRetainingSortOrder (headerFile, true);
                        parent.addFileRetainingSortOrder (cppFile, true);
                    }
                }
            }
        }
    }