wxEmptyString, wxT(""), wxT("*.bbg"), wxOPEN | wxFILE_MUST_EXIST);
printf("SCP: wxGUIEditorGraphicBBS::OnOpenDiagram \n");
if (openFileDialog->ShowModal() == wxID_OK) {
- wxString fileName = openFileDialog->GetPath();
+ wxString filePath = openFileDialog->GetPath();
ifstream inputStream;
- std::string fName = (const char*) (fileName.mb_str());
+ std::string fName = (const char*) (filePath.mb_str());
inputStream.open(fName.c_str());
assert(inputStream.good()); // fails
- _tabsMgr->addNewTab(openFileDialog->GetFilename());
+
+ if(_tabsMgr->FindTab(crea::wx2std(filePath))!=-1) //RaC2012 avoid opening same diagram twice
+ {
+ inputStream.close();
+ printf("RaC: Diagram already opened\n");
+ return;
+ }
+ wxString fileName = openFileDialog->GetFilename();
+ _tabsMgr->addNewTab(fileName);
_tabsMgr->loadDiagram(inputStream, fName);
_tabsMgr->saveTempActualDiagram("load diagram");
GetToolBar()->EnableTool(ID_UNDO, false);
//return ( (wxGEditorTabPanel) _notebook->GetPage(id)->GetFullPath( ) );
}
+ //=========================================================================
+
+ int wxTabPanelsManager::FindTab(std::string filename)
+ {
+ std::map<int, wxGEditorTabPanel*>::iterator it;
+ for (it = _panels.begin(); it != _panels.end(); ++it)
+ {
+ wxGEditorTabPanel *obj = it->second;
+ int id = it->first;
+ if(obj->GetFullPath()==filename)
+ return id;
+ }
+ return -1;
+ }
//=========================================================================
std::string wxTabPanelsManager::GetCbPackageName()