diff --git a/Code/Mantid/DataHandling/src/SaveCSV.cpp b/Code/Mantid/DataHandling/src/SaveCSV.cpp index c5f8730802d8ac595fe072418ede1322267e68c3..2aa40b33792d5986d7aac21493e4f9a75c0112c3 100644 --- a/Code/Mantid/DataHandling/src/SaveCSV.cpp +++ b/Code/Mantid/DataHandling/src/SaveCSV.cpp @@ -67,7 +67,7 @@ void SaveCSV::init() declareProperty( new WorkspaceProperty<MatrixWorkspace>("InputWorkspace","",Direction::Input), "The filename of the output CSV file" ); - declareProperty(new FileProperty("Filename", "",FileProperty::Save), + declareProperty(new FileProperty("Filename", "",FileProperty::Save, ".csv"), "The name of the workspace containing the data you want to save to\n" "a CSV file" ); declareProperty("Separator", ",", diff --git a/Code/Mantid/Kernel/inc/MantidKernel/FileProperty.h b/Code/Mantid/Kernel/inc/MantidKernel/FileProperty.h index 8c0474f6a56fcaf14e09462ebb8a7fd2ce42fffd..cb036dd471ee248f370f7079365fae1e82df6614 100644 --- a/Code/Mantid/Kernel/inc/MantidKernel/FileProperty.h +++ b/Code/Mantid/Kernel/inc/MantidKernel/FileProperty.h @@ -47,6 +47,8 @@ public: ///Overridden setValue method virtual std::string setValue(const std::string & filename); + /// Returns the main file extension that's used + std::string getDefaultExt() const {return m_defaultExt;} private: /// Check that a given directory exists @@ -55,6 +57,8 @@ private: std::string convertExtension(const std::string & filepath) const; /// The action type of this property, i.e. load/save unsigned int m_action; + ///The default file extension associated with the type of file this property will handle + std::string m_defaultExt; }; } diff --git a/Code/Mantid/Kernel/src/FileProperty.cpp b/Code/Mantid/Kernel/src/FileProperty.cpp index 140a8931c5c405a1a54bb4e99a19c812a9ba84e5..91a0ac1ab637fe45bc7fe73aa0b6423de3aa9fcd 100644 --- a/Code/Mantid/Kernel/src/FileProperty.cpp +++ b/Code/Mantid/Kernel/src/FileProperty.cpp @@ -16,7 +16,7 @@ using namespace Mantid::Kernel; * Constructor * @param name The name of the property * @param default_value A default value for the property - * @param exts The set of allowed extensions + * @param exts The allowed extensions, the front entry in the vector will be the default extension * @param action An enum indicating whether this should be a load/save property * @param direction An optional direction (default=Input) */ @@ -25,6 +25,7 @@ FileProperty::FileProperty(const std::string & name, const std::string& default_ : PropertyWithValue<std::string>(name, default_value, new FileValidator(exts, (action == FileProperty::Load) ), direction), m_action(action) { + m_defaultExt = exts.size() > 0 ? exts.front() : ""; } /** @@ -39,7 +40,7 @@ FileProperty::FileProperty(const std::string & name, const std::string& default_ const std::string & ext, unsigned int direction) : PropertyWithValue<std::string>(name, default_value, new FileValidator(std::vector<std::string>(1,ext), (action == FileProperty::Load) ), direction), - m_action(action) + m_action(action), m_defaultExt(ext) { } diff --git a/Code/Mantid/Kernel/test/FilePropertyTest.h b/Code/Mantid/Kernel/test/FilePropertyTest.h index ad0b158a7952a084cb3f1cc9a6d4f528194b3c0b..e97c88f8ff440bd17bfbd8561b2aa3ad29ce9213 100644 --- a/Code/Mantid/Kernel/test/FilePropertyTest.h +++ b/Code/Mantid/Kernel/test/FilePropertyTest.h @@ -25,6 +25,7 @@ public: // Check type TS_ASSERT_EQUALS(fp->isLoadProperty(), true) + TS_ASSERT_EQUALS(fp->getDefaultExt(), "") ///Test a GEM file in the test directory std::string msg = fp->setValue("GEM38370.raw"); @@ -39,7 +40,8 @@ public: new Mantid::Kernel::FileProperty("Filename","", Mantid::Kernel::FileProperty::Load, exts); // Check type TS_ASSERT_EQUALS(fp->isLoadProperty(), true) - + TS_ASSERT_EQUALS(fp->getDefaultExt(), "raw") + ///Test a GEM file in the test directory std::string msg = fp->setValue("GEM38370.raw"); TS_ASSERT_EQUALS(msg, "")