void SaveProjectAsCommand::execute(void) { std::vector<WindowEventProducer::FileDialogFilter> KEProjectFileFilters; KEProjectFileFilters.push_back(WindowEventProducer::FileDialogFilter("Project File","xml")); KEProjectFileFilters.push_back(WindowEventProducer::FileDialogFilter("All Files","*")); //Project File BoostPath InitialProjectFilePath(MainApplication::the()->getProject()->getFilePath()); if(!boost::filesystem::exists(InitialProjectFilePath)) { const Char8* ProjectName(getName(MainApplication::the()->getProject())); InitialProjectFilePath = BoostPath(std::string("./") + ( ProjectName ? ProjectName : "Project") + ".xml"); } BoostPath ProjectFilePath; ProjectFilePath = MainApplication::the()->getMainWindow()->saveFileDialog("Save Project As ...",KEProjectFileFilters,InitialProjectFilePath.filename(),InitialProjectFilePath.parent_path(), true); if(!ProjectFilePath.empty()) { if(ProjectFilePath.extension().empty()) { ProjectFilePath = ProjectFilePath.string() + ".xml"; } MainApplication::the()->saveProject(ProjectFilePath); } }
void handleTreeNodeExport(ActionEventDetails* const details, Tree* const editorTree) { boost::any SelectedComp(editorTree->getLastSelectedPathComponent()); //Get the tree selection try { FieldContainerTreeModel::ContainerFieldIdPair ThePair(boost::any_cast<FieldContainerTreeModel::ContainerFieldIdPair>(SelectedComp)); if(ThePair._FieldID == 0 && ThePair._Container != NULL) { std::vector<WindowEventProducer::FileDialogFilter> ExportFileFilters; ExportFileFilters.push_back(WindowEventProducer::FileDialogFilter("Field Container File","xml")); ExportFileFilters.push_back(WindowEventProducer::FileDialogFilter("All Files","*")); //Export File BoostPath InitialFilePath("./Export.xml"); WindowEventProducer* MainWindow(editorTree->getParentWindow()->getParentDrawingSurface()->getEventProducer()); BoostPath ExportFilePath; ExportFilePath =MainWindow->saveFileDialog("Save Field Container", ExportFileFilters, InitialFilePath.filename(), InitialFilePath.parent_path(), true); if(!ExportFilePath.empty()) { if(ExportFilePath.extension().empty()) { ExportFilePath = ExportFilePath.string() + ".xml"; } FCFileType::FCPtrStore Containers; Containers.insert(ThePair._Container); FCFileType::FCTypeVector IgnoreTypes; FCFileHandler::the()->write(Containers,ExportFilePath,IgnoreTypes); } } } catch(boost::bad_any_cast &ex) { SWARNING << ex.what() << std::endl; } }