| @@ -64,7 +64,19 @@ public: | |||||
| //============================================================================== | //============================================================================== | ||||
| struct Type : public OpenDocumentManager::DocumentType | 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 <const char*> (mb.getData()), mb.getSize())) | |||||
| return true; | |||||
| return false; | |||||
| } | |||||
| Document* openFile (Project* project, const File& file) { return new SourceCodeDocument (project, file); } | Document* openFile (Project* project, const File& file) { return new SourceCodeDocument (project, file); } | ||||
| }; | }; | ||||
| @@ -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 isAndroid() const { return true; } | ||||
| bool isPossibleForCurrentProject() { return projectType.isGUIApplication(); } | |||||
| bool usesMMFiles() const { return false; } | bool usesMMFiles() const { return false; } | ||||
| bool canCopeWithDuplicateFiles() { return false; } | bool canCopeWithDuplicateFiles() { return false; } | ||||
| void launchProject() | |||||
| { | |||||
| } | |||||
| void createPropertyEditors (PropertyListBuilder& props) | void createPropertyEditors (PropertyListBuilder& props) | ||||
| { | { | ||||
| ProjectExporter::createPropertyEditors (props); | ProjectExporter::createPropertyEditors (props); | ||||
| @@ -48,11 +48,19 @@ public: | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| bool isPossibleForCurrentProject() { return true; } | |||||
| bool usesMMFiles() const { return false; } | bool usesMMFiles() const { return false; } | ||||
| bool isVisualStudio() const { return true; } | bool isVisualStudio() const { return true; } | ||||
| bool canCopeWithDuplicateFiles() { return false; } | bool canCopeWithDuplicateFiles() { return false; } | ||||
| bool launchProject() | |||||
| { | |||||
| #if JUCE_WINDOWS | |||||
| return getSLNFile().startAsProcess(); | |||||
| #else | |||||
| return false; | |||||
| #endif | |||||
| } | |||||
| void createPropertyEditors (PropertyListBuilder& props) | void createPropertyEditors (PropertyListBuilder& props) | ||||
| { | { | ||||
| ProjectExporter::createPropertyEditors (props); | ProjectExporter::createPropertyEditors (props); | ||||
| @@ -529,17 +537,6 @@ public: | |||||
| static const char* getValueTreeTypeName() { return "VS2008"; } | static const char* getValueTreeTypeName() { return "VS2008"; } | ||||
| int getVisualStudioVersion() const { return 9; } | 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) | static MSVCProjectExporterVC2008* createForSettings (Project& project, const ValueTree& settings) | ||||
| { | { | ||||
| if (settings.hasType (getValueTreeTypeName())) | if (settings.hasType (getValueTreeTypeName())) | ||||
| @@ -880,15 +877,6 @@ public: | |||||
| static const char* getValueTreeTypeName() { return "VS2005"; } | static const char* getValueTreeTypeName() { return "VS2005"; } | ||||
| int getVisualStudioVersion() const { return 8; } | int getVisualStudioVersion() const { return 8; } | ||||
| int getLaunchPreferenceOrderForCurrentOS() | |||||
| { | |||||
| #if JUCE_WINDOWS | |||||
| return 2; | |||||
| #else | |||||
| return 0; | |||||
| #endif | |||||
| } | |||||
| static MSVCProjectExporterVC2005* createForSettings (Project& project, const ValueTree& settings) | static MSVCProjectExporterVC2005* createForSettings (Project& project, const ValueTree& settings) | ||||
| { | { | ||||
| if (settings.hasType (getValueTreeTypeName())) | if (settings.hasType (getValueTreeTypeName())) | ||||
| @@ -918,17 +906,6 @@ public: | |||||
| static const char* getValueTreeTypeName() { return "VS2010"; } | static const char* getValueTreeTypeName() { return "VS2010"; } | ||||
| int getVisualStudioVersion() const { return 10; } | 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) | static MSVCProjectExporterVC2010* createForSettings (Project& project, const ValueTree& settings) | ||||
| { | { | ||||
| if (settings.hasType (getValueTreeTypeName())) | if (settings.hasType (getValueTreeTypeName())) | ||||
| @@ -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 usesMMFiles() const { return false; } | ||||
| bool isLinux() const { return true; } | bool isLinux() const { return true; } | ||||
| bool canCopeWithDuplicateFiles() { return false; } | bool canCopeWithDuplicateFiles() { return false; } | ||||
| void launchProject() | |||||
| { | |||||
| // what to do on linux? | |||||
| } | |||||
| void createPropertyEditors (PropertyListBuilder& props) | void createPropertyEditors (PropertyListBuilder& props) | ||||
| { | { | ||||
| ProjectExporter::createPropertyEditors (props); | ProjectExporter::createPropertyEditors (props); | ||||
| @@ -83,15 +83,6 @@ public: | |||||
| Value getPostBuildScriptValue() { return getSetting (Ids::postbuildCommand); } | Value getPostBuildScriptValue() { return getSetting (Ids::postbuildCommand); } | ||||
| String getPostBuildScript() const { return settings [Ids::postbuildCommand]; } | String getPostBuildScript() const { return settings [Ids::postbuildCommand]; } | ||||
| int getLaunchPreferenceOrderForCurrentOS() | |||||
| { | |||||
| #if JUCE_MAC | |||||
| return iOS ? 1 : 2; | |||||
| #else | |||||
| return 0; | |||||
| #endif | |||||
| } | |||||
| bool isAvailableOnCurrentOS() | bool isAvailableOnCurrentOS() | ||||
| { | { | ||||
| #if JUCE_MAC | #if JUCE_MAC | ||||
| @@ -101,7 +92,6 @@ public: | |||||
| #endif | #endif | ||||
| } | } | ||||
| bool isPossibleForCurrentProject() { return projectType.isGUIApplication() || ! iOS; } | |||||
| bool usesMMFiles() const { return true; } | bool usesMMFiles() const { return true; } | ||||
| bool isXcode() const { return true; } | bool isXcode() const { return true; } | ||||
| bool isOSX() const { return ! iOS; } | bool isOSX() const { return ! iOS; } | ||||
| @@ -147,9 +137,13 @@ public: | |||||
| "Some shell-script that will be run after a build completes."); | "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 | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -104,25 +104,6 @@ ProjectExporter* ProjectExporter::createExporter (Project& project, const ValueT | |||||
| return exp; | return exp; | ||||
| } | } | ||||
| ProjectExporter* ProjectExporter::createPlatformDefaultExporter (Project& project) | |||||
| { | |||||
| ScopedPointer <ProjectExporter> 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) | bool ProjectExporter::canProjectBeLaunched (Project* project) | ||||
| { | { | ||||
| if (project != nullptr) | if (project != nullptr) | ||||
| @@ -137,7 +118,8 @@ bool ProjectExporter::canProjectBeLaunched (Project* project) | |||||
| MSVCProjectExporterVC2008::getValueTreeTypeName(), | MSVCProjectExporterVC2008::getValueTreeTypeName(), | ||||
| MSVCProjectExporterVC2010::getValueTreeTypeName(), | MSVCProjectExporterVC2010::getValueTreeTypeName(), | ||||
| #elif JUCE_LINUX | #elif JUCE_LINUX | ||||
| MakefileProjectExporter::getValueTreeTypeName(), | |||||
| // (this doesn't currently launch.. not really sure what it would do on linux) | |||||
| //MakefileProjectExporter::getValueTreeTypeName(), | |||||
| #endif | #endif | ||||
| nullptr | nullptr | ||||
| @@ -43,18 +43,14 @@ public: | |||||
| static ProjectExporter* createNewExporter (Project&, const int index); | static ProjectExporter* createNewExporter (Project&, const int index); | ||||
| static ProjectExporter* createNewExporter (Project&, const String& name); | static ProjectExporter* createNewExporter (Project&, const String& name); | ||||
| static ProjectExporter* createExporter (Project&, const ValueTree& settings); | static ProjectExporter* createExporter (Project&, const ValueTree& settings); | ||||
| static ProjectExporter* createPlatformDefaultExporter (Project&); | |||||
| static bool canProjectBeLaunched (Project*); | static bool canProjectBeLaunched (Project*); | ||||
| static String getCurrentPlatformExporterName(); | 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 bool usesMMFiles() const = 0; | ||||
| virtual void createPropertyEditors (PropertyListBuilder&); | virtual void createPropertyEditors (PropertyListBuilder&); | ||||
| virtual void launchProject() = 0; | |||||
| virtual bool launchProject() = 0; | |||||
| virtual void create (const OwnedArray<LibraryModule>&) const = 0; // may throw a SaveError | virtual void create (const OwnedArray<LibraryModule>&) const = 0; // may throw a SaveError | ||||
| virtual bool shouldFileBeCompiledByDefault (const RelativePath& path) const; | virtual bool shouldFileBeCompiledByDefault (const RelativePath& path) const; | ||||
| virtual bool canCopeWithDuplicateFiles() = 0; | virtual bool canCopeWithDuplicateFiles() = 0; | ||||
| @@ -109,20 +109,6 @@ File ModuleList::getDefaultModulesFolder (Project* project) | |||||
| { | { | ||||
| if (project != nullptr) | if (project != nullptr) | ||||
| { | { | ||||
| { | |||||
| // Try the platform default exporter first.. | |||||
| ScopedPointer <ProjectExporter> 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();) | for (Project::ExporterIterator exporter (*project); exporter.next();) | ||||
| { | { | ||||
| const File f (getModulesFolderForExporter (*exporter)); | const File f (getModulesFolderForExporter (*exporter)); | ||||
| @@ -452,10 +452,9 @@ void ProjectContentComponent::openInIDE() | |||||
| { | { | ||||
| if (project != nullptr) | if (project != nullptr) | ||||
| { | { | ||||
| ScopedPointer <ProjectExporter> exporter (ProjectExporter::createPlatformDefaultExporter (*project)); | |||||
| if (exporter != nullptr) | |||||
| exporter->launchProject(); | |||||
| for (Project::ExporterIterator exporter (*project); exporter.next();) | |||||
| if (exporter->launchProject()) | |||||
| break; | |||||
| } | } | ||||
| } | } | ||||