void PhpPlugin::OnNewProjectFinish(clNewProjectEvent& e) { if(e.GetTemplateName() != "PHP Project") { e.Skip(); return; } if(m_mgr->IsWorkspaceOpen()) { ::wxMessageBox( _("Can't create PHP project. Close your current workspace first"), "PHP", wxOK | wxICON_ERROR | wxCENTER); return; } if(!PHPWorkspace::Get()->IsOpen()) { // No PHP workspace is open, create a new one wxFileName workspacePath(e.GetProjectFolder(), e.GetProjectName()); workspacePath.SetExt(PHPStrings::PHP_WORKSPACE_EXT); DoOpenWorkspace(workspacePath.GetFullPath(), true); } if(PHPWorkspace::Get()->IsOpen()) { PHPProject::CreateData cd; cd.importFilesUnderPath = true; cd.name = e.GetProjectName(); cd.path = e.GetProjectFolder(); m_workspaceView->CallAfter(&PHPWorkspaceView::CreateNewProject, cd); } }
void PhpPlugin::OnNewWorkspace(clCommandEvent& e) { e.Skip(); if(e.GetString() == PHPWorkspace::Get()->GetWorkspaceType()) { e.Skip(false); // Create a PHP workspace NewPHPWorkspaceDlg newWspDlg(m_mgr->GetTheApp()->GetTopWindow()); if(newWspDlg.ShowModal() == wxID_OK) { PHPWorkspace::Get()->Create(newWspDlg.GetWorkspacePath()); DoOpenWorkspace(newWspDlg.GetWorkspacePath(), false /* create if missing */, newWspDlg.IsCreateProject()); } } }
void PhpPlugin::OnOpenWorkspace(clCommandEvent& e) { const wxString WPS_EXT = "phpwsp"; wxString workspace_file = e.GetFileName(); if(!workspace_file.IsEmpty() && wxFileName(workspace_file).GetExt() != WPS_EXT) { // the event already contains a workspace name - don't do anything with the event e.Skip(); return; } wxString filename; if(!workspace_file.IsEmpty()) { filename = workspace_file; } else { // Prompt the user to see if he wants to open a PHP workspace or standard workspace wxString filter; PluginSettings settings; PluginSettings::Load(settings); filter = "All Files (*)|*|Standard Workspace (*.workspace)|*.workspace|PHP Workspace (*.phpwsp)|*.phpwsp"; filename = wxFileSelector(wxT("Open workspace"), wxT(""), wxT(""), wxT(""), filter, wxFD_FILE_MUST_EXIST | wxFD_OPEN); } if(filename.IsEmpty()) { return; } if(PHPWorkspace::Get()->IsOpen()) { PHPWorkspace::Get()->Close(); } wxFileName fn(filename); if(fn.GetExt() == PHPStrings::PHP_WORKSPACE_EXT) { DoOpenWorkspace(fn.GetFullPath()); } else { // set the file selection and pass it on to codelite e.SetFileName(fn.GetFullPath()); e.Skip(); } }
void PhpPlugin::OnNewWorkspace(wxCommandEvent& e) { NewWorkspaceSelectionDlg dlg(FRAME); if(dlg.ShowModal() == wxID_OK) { if(dlg.GetIsPHPWorkspace()) { // Create a PHP workspace NewPHPWorkspaceDlg newWspDlg(m_mgr->GetTheApp()->GetTopWindow()); if(newWspDlg.ShowModal() == wxID_OK) { PHPWorkspace::Get()->Create(newWspDlg.GetWorkspacePath()); DoOpenWorkspace(newWspDlg.GetWorkspacePath()); } } else { // Call skip so the normal new workspace dialog will popup e.Skip(); } } }
void PhpPlugin::OnNewWorkspace(clCommandEvent& e) { e.Skip(); if(e.GetString() == PHPWorkspace::Get()->GetWorkspaceType()) { e.Skip(false); // Create a PHP workspace NewPHPWorkspaceDlg newWspDlg(m_mgr->GetTheApp()->GetTopWindow()); if(newWspDlg.ShowModal() == wxID_OK) { // Ensure that the workspace path exists wxFileName workspaceFile(newWspDlg.GetWorkspacePath()); if(!workspaceFile.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL)) { ::wxMessageBox(wxString::Format(_("Could not create workspace folder:\n%s"), workspaceFile.GetPath()), "CodeLite", wxICON_ERROR | wxOK | wxCENTER); return; } PHPWorkspace::Get()->Create(newWspDlg.GetWorkspacePath()); DoOpenWorkspace(newWspDlg.GetWorkspacePath(), false /* create if missing */, newWspDlg.IsCreateProject()); } } }
void PhpPlugin::OnOpenWorkspace(clCommandEvent& e) { e.Skip(); wxFileName workspaceFile(e.GetFileName()); JSONRoot root(workspaceFile); if(!root.isOk()) return; wxString type = root.toElement().namedObject("metadata").namedObject("type").toString(); bool hasProjects = root.toElement().hasNamedObject("projects"); if(type == "php" || hasProjects) { // this is our to handle e.Skip(false); } else { return; } // Check if this is a PHP workspace if(PHPWorkspace::Get()->IsOpen()) { PHPWorkspace::Get()->Close(true, true); } DoOpenWorkspace(workspaceFile.GetFullPath()); }