From b11527d75120cfa97f59d00823d66d94ce02f319 Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 4 Sep 2012 21:08:52 +0100 Subject: [PATCH] Introjucer: launching a project now opens the first possible exporter in the list. --- .../Code Editor/jucer_SourceCodeEditor.h | 14 ++++++- .../jucer_ProjectExport_Android.h | 15 +------ .../Project Saving/jucer_ProjectExport_MSVC.h | 41 ++++--------------- .../Project Saving/jucer_ProjectExport_Make.h | 16 +------- .../jucer_ProjectExport_XCode.h | 18 +++----- .../Project Saving/jucer_ProjectExporter.cpp | 22 +--------- .../Project Saving/jucer_ProjectExporter.h | 6 +-- .../Source/Project/jucer_Module.cpp | 14 ------- .../Project/jucer_ProjectContentComponent.cpp | 7 ++-- 9 files changed, 36 insertions(+), 117 deletions(-) diff --git a/extras/Introjucer/Source/Code Editor/jucer_SourceCodeEditor.h b/extras/Introjucer/Source/Code Editor/jucer_SourceCodeEditor.h index 7cf55980f4..3e585f6b65 100644 --- a/extras/Introjucer/Source/Code Editor/jucer_SourceCodeEditor.h +++ b/extras/Introjucer/Source/Code Editor/jucer_SourceCodeEditor.h @@ -64,7 +64,19 @@ public: //============================================================================== struct Type : public OpenDocumentManager::DocumentType { - bool canOpenFile (const File& file) { return file.hasFileExtension ("cpp;h;hpp;mm;m;c;cc;cxx;txt;inc;tcc;xml;plist;rtf;html;htm;php;py;rb;cs"); } + bool canOpenFile (const File& file) + { + if (file.hasFileExtension ("cpp;h;hpp;mm;m;c;cc;cxx;txt;inc;tcc;xml;plist;rtf;html;htm;php;py;rb;cs")) + return true; + + MemoryBlock mb; + if (file.loadFileAsData (mb) + && CharPointer_UTF8::isValidString (static_cast (mb.getData()), mb.getSize())) + return true; + + return false; + } + Document* openFile (Project* project, const File& file) { return new SourceCodeDocument (project, file); } }; diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h index 68d246e74b..d807384f2f 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h @@ -73,24 +73,11 @@ public: } //============================================================================== - int getLaunchPreferenceOrderForCurrentOS() - { - #if JUCE_ANDROID - return 1; - #else - return 0; - #endif - } - + bool launchProject() { return false; } bool isAndroid() const { return true; } - bool isPossibleForCurrentProject() { return projectType.isGUIApplication(); } bool usesMMFiles() const { return false; } bool canCopeWithDuplicateFiles() { return false; } - void launchProject() - { - } - void createPropertyEditors (PropertyListBuilder& props) { ProjectExporter::createPropertyEditors (props); diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h index c51d70465a..d9945049d9 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h @@ -48,11 +48,19 @@ public: } //============================================================================== - bool isPossibleForCurrentProject() { return true; } bool usesMMFiles() const { return false; } bool isVisualStudio() const { return true; } bool canCopeWithDuplicateFiles() { return false; } + bool launchProject() + { + #if JUCE_WINDOWS + return getSLNFile().startAsProcess(); + #else + return false; + #endif + } + void createPropertyEditors (PropertyListBuilder& props) { ProjectExporter::createPropertyEditors (props); @@ -529,17 +537,6 @@ public: static const char* getValueTreeTypeName() { return "VS2008"; } int getVisualStudioVersion() const { return 9; } - void launchProject() { getSLNFile().startAsProcess(); } - - int getLaunchPreferenceOrderForCurrentOS() - { - #if JUCE_WINDOWS - return 4; - #else - return 0; - #endif - } - static MSVCProjectExporterVC2008* createForSettings (Project& project, const ValueTree& settings) { if (settings.hasType (getValueTreeTypeName())) @@ -880,15 +877,6 @@ public: static const char* getValueTreeTypeName() { return "VS2005"; } int getVisualStudioVersion() const { return 8; } - int getLaunchPreferenceOrderForCurrentOS() - { - #if JUCE_WINDOWS - return 2; - #else - return 0; - #endif - } - static MSVCProjectExporterVC2005* createForSettings (Project& project, const ValueTree& settings) { if (settings.hasType (getValueTreeTypeName())) @@ -918,17 +906,6 @@ public: static const char* getValueTreeTypeName() { return "VS2010"; } int getVisualStudioVersion() const { return 10; } - int getLaunchPreferenceOrderForCurrentOS() - { - #if JUCE_WINDOWS - return 3; - #else - return 0; - #endif - } - - void launchProject() { getSLNFile().startAsProcess(); } - static MSVCProjectExporterVC2010* createForSettings (Project& project, const ValueTree& settings) { if (settings.hasType (getValueTreeTypeName())) diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Make.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Make.h index 94e2d11179..4c63fc9818 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Make.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Make.h @@ -57,25 +57,11 @@ public: } //============================================================================== - int getLaunchPreferenceOrderForCurrentOS() - { - #if JUCE_LINUX - return 1; - #else - return 0; - #endif - } - - bool isPossibleForCurrentProject() { return true; } + bool launchProject() { return false; } bool usesMMFiles() const { return false; } bool isLinux() const { return true; } bool canCopeWithDuplicateFiles() { return false; } - void launchProject() - { - // what to do on linux? - } - void createPropertyEditors (PropertyListBuilder& props) { ProjectExporter::createPropertyEditors (props); diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h index 57a206a62b..519282431e 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h @@ -83,15 +83,6 @@ public: Value getPostBuildScriptValue() { return getSetting (Ids::postbuildCommand); } String getPostBuildScript() const { return settings [Ids::postbuildCommand]; } - int getLaunchPreferenceOrderForCurrentOS() - { - #if JUCE_MAC - return iOS ? 1 : 2; - #else - return 0; - #endif - } - bool isAvailableOnCurrentOS() { #if JUCE_MAC @@ -101,7 +92,6 @@ public: #endif } - bool isPossibleForCurrentProject() { return projectType.isGUIApplication() || ! iOS; } bool usesMMFiles() const { return true; } bool isXcode() const { return true; } bool isOSX() const { return ! iOS; } @@ -147,9 +137,13 @@ public: "Some shell-script that will be run after a build completes."); } - void launchProject() + bool launchProject() { - getProjectBundle().startAsProcess(); + #if JUCE_MAC + return getProjectBundle().startAsProcess(); + #else + return false; + #endif } //============================================================================== diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.cpp b/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.cpp index 7203adddbb..b7368c6b0c 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.cpp +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.cpp @@ -104,25 +104,6 @@ ProjectExporter* ProjectExporter::createExporter (Project& project, const ValueT return exp; } -ProjectExporter* ProjectExporter::createPlatformDefaultExporter (Project& project) -{ - ScopedPointer best; - int bestPref = 0; - - for (Project::ExporterIterator exporter (project); exporter.next();) - { - const int pref = exporter->getLaunchPreferenceOrderForCurrentOS(); - - if (pref > bestPref) - { - bestPref = pref; - best = exporter.exporter; - } - } - - return best.release(); -} - bool ProjectExporter::canProjectBeLaunched (Project* project) { if (project != nullptr) @@ -137,7 +118,8 @@ bool ProjectExporter::canProjectBeLaunched (Project* project) MSVCProjectExporterVC2008::getValueTreeTypeName(), MSVCProjectExporterVC2010::getValueTreeTypeName(), #elif JUCE_LINUX - MakefileProjectExporter::getValueTreeTypeName(), + // (this doesn't currently launch.. not really sure what it would do on linux) + //MakefileProjectExporter::getValueTreeTypeName(), #endif nullptr diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.h index 1020ab9f3e..e4b97ebd08 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.h @@ -43,18 +43,14 @@ public: static ProjectExporter* createNewExporter (Project&, const int index); static ProjectExporter* createNewExporter (Project&, const String& name); static ProjectExporter* createExporter (Project&, const ValueTree& settings); - static ProjectExporter* createPlatformDefaultExporter (Project&); static bool canProjectBeLaunched (Project*); static String getCurrentPlatformExporterName(); //============================================================================= - // return 0 if this can't be opened in the current OS, or a higher value, where higher numbers are more preferable. - virtual int getLaunchPreferenceOrderForCurrentOS() = 0; - virtual bool isPossibleForCurrentProject() = 0; virtual bool usesMMFiles() const = 0; virtual void createPropertyEditors (PropertyListBuilder&); - virtual void launchProject() = 0; + virtual bool launchProject() = 0; virtual void create (const OwnedArray&) const = 0; // may throw a SaveError virtual bool shouldFileBeCompiledByDefault (const RelativePath& path) const; virtual bool canCopeWithDuplicateFiles() = 0; diff --git a/extras/Introjucer/Source/Project/jucer_Module.cpp b/extras/Introjucer/Source/Project/jucer_Module.cpp index 4e52af9b11..1cc8d3827a 100644 --- a/extras/Introjucer/Source/Project/jucer_Module.cpp +++ b/extras/Introjucer/Source/Project/jucer_Module.cpp @@ -109,20 +109,6 @@ File ModuleList::getDefaultModulesFolder (Project* project) { if (project != nullptr) { - { - // Try the platform default exporter first.. - ScopedPointer exp (ProjectExporter::createPlatformDefaultExporter (*project)); - - if (exp != nullptr) - { - const File f (getModulesFolderForExporter (*exp)); - - if (ModuleList::isModulesFolder (f)) - return f; - } - } - - // If that didn't work, try all the other exporters.. for (Project::ExporterIterator exporter (*project); exporter.next();) { const File f (getModulesFolderForExporter (*exporter)); diff --git a/extras/Introjucer/Source/Project/jucer_ProjectContentComponent.cpp b/extras/Introjucer/Source/Project/jucer_ProjectContentComponent.cpp index 08e45ba344..09f2bcd6da 100644 --- a/extras/Introjucer/Source/Project/jucer_ProjectContentComponent.cpp +++ b/extras/Introjucer/Source/Project/jucer_ProjectContentComponent.cpp @@ -452,10 +452,9 @@ void ProjectContentComponent::openInIDE() { if (project != nullptr) { - ScopedPointer exporter (ProjectExporter::createPlatformDefaultExporter (*project)); - - if (exporter != nullptr) - exporter->launchProject(); + for (Project::ExporterIterator exporter (*project); exporter.next();) + if (exporter->launchProject()) + break; } }