int XDebugManager::GetPort() const { PHPConfigurationData phpGlobalSettings; phpGlobalSettings.Load(); int port = phpGlobalSettings.GetXdebugPort(); return port; }
PHPProjectSetupDlg::PHPProjectSetupDlg(wxWindow* parent) : PHPProjectSetupDlgBase(parent) { PHPConfigurationData conf; conf.Load(); m_filePickerPhpExe->SetPath(conf.GetPhpExe()); WindowAttrManager::Load(this, "PHPProjectSetupDlgBase"); }
void PhpPlugin::OnFindInFilesDismissed(clCommandEvent& e) { e.Skip(); if(PHPWorkspace::Get()->IsOpen()) { // store the find in files mask PHPConfigurationData conf; conf.Load().SetFindInFilesMask(e.GetString()).Save(); } }
void PHPXDebugSetupWizard::OnFinished(wxWizardEvent& event) { PHPConfigurationData conf; conf.Load(); long portNum(9000); m_textCtrlPort->GetValue().ToCLong(&portNum); conf.SetXdebugIdeKey(m_textCtrlKey->GetValue()).SetXdebugPort(portNum).SetXdebugHost(m_textCtrlIP->GetValue()); conf.Save(); }
PHPXDebugSetupWizard::PHPXDebugSetupWizard(wxWindow* parent) : PHPXDebugSetupWizardBase(parent) { PHPConfigurationData conf; conf.Load(); m_textCtrlIP->ChangeValue(conf.GetXdebugHost()); m_textCtrlKey->ChangeValue(conf.GetXdebugIdeKey()); m_textCtrlPort->ChangeValue(wxString() << conf.GetXdebugPort()); }
void XDebugDiagDlg::OnRecommend(wxCommandEvent& event) { wxString endOfLine; #ifdef __WXMSW__ endOfLine = "\r\n"; #else endOfLine = "\n"; #endif PHPConfigurationData config; config.Load(); wxString recommendation; recommendation << "xdebug.remote_enable=1" << endOfLine << "xdebug.remote_connect_back=1" << endOfLine << "xdebug.ide_key=\"" << config.GetXdebugIdeKey() << "\"" <<endOfLine; ::CopyToClipboard(recommendation); ::wxMessageBox(_("Recommended settings have been copied to your clipboard\nOpen your php.ini file and paste them")); }
void XDebugManager::DoStartDebugger() { wxDELETE( m_readerThread ); m_readerThread = new XDebugComThread(this, GetPort() ); m_readerThread->Start(); // Starting event XDebugEvent eventStarting(wxEVT_XDEBUG_SESSION_STARTING); EventNotifier::Get()->ProcessEvent( eventStarting ); PHPConfigurationData conf; conf.Load(); if ( !conf.HasFlag(PHPConfigurationData::kDontPromptForMissingFileMapping) && GetFileMapping(PHPWorkspace::Get()->GetActiveProject()).empty() ) { // Issue a warning wxString message; message << _("This project has no file mapping defined. This may result in breakpoints not applied\n") << _("To fix this, set file mapping from Project Settings -> Debug"); wxRichMessageDialog dlg(EventNotifier::Get()->TopFrame(), message, "CodeLite", wxICON_WARNING|wxOK|wxOK_DEFAULT|wxCANCEL); dlg.ShowCheckBox(_("Remember my answer and don't show this message again")); dlg.SetOKCancelLabels(_("OK, Continue to Debug"), _("Stop the debugger")); int dlgResult = dlg.ShowModal(); conf.EnableFlag( PHPConfigurationData::kDontPromptForMissingFileMapping, dlg.IsCheckBoxChecked() ).Save(); if ( dlgResult == wxID_CANCEL ) { // Stop the debugger DoStopDebugger(); return; } } // Now we can run the project if ( !PHPWorkspace::Get()->RunProject(true, "", conf.GetXdebugIdeKey()) ) { DoStopDebugger(); return; } // Notify about debug session started XDebugEvent eventStart(wxEVT_XDEBUG_SESSION_STARTED); EventNotifier::Get()->AddPendingEvent( eventStart ); }
void PhpPlugin::OnFileSaved(clCommandEvent& e) { e.Skip(); if(PHPWorkspace::Get()->IsOpen()) { DoSyncFileWithRemote(e.GetString()); } // Run php lint IEditor* editor = m_mgr->GetActiveEditor(); CHECK_PTR_RET(editor); PHPConfigurationData conf; conf.Load(); if(::IsPHPFile(editor) && conf.IsRunLint()) { if(m_mgr->GetActiveEditor()) { m_mgr->GetActiveEditor()->DelAllCompilerMarkers(); } m_lint->CheckCode(e.GetFileName()); } }
void PhpPlugin::FinalizeStartup() { // Create the debugger windows (hidden) wxWindow* parent = m_mgr->GetDockingManager()->GetManagedWindow(); m_debuggerPane = new PHPDebugPane(parent); m_mgr->GetDockingManager()->AddPane(m_debuggerPane, wxAuiPaneInfo() .Name("XDebug") .Caption("Call Stack & Breakpoints") .Hide() .CloseButton() .MaximizeButton() .Bottom() .Position(3)); m_xdebugLocalsView = new LocalsView(parent); m_mgr->GetDockingManager()->AddPane( m_xdebugLocalsView, wxAuiPaneInfo().Name("XDebugLocals").Caption("Locals").Hide().CloseButton().MaximizeButton().Bottom()); m_xdebugEvalPane = new EvalPane(parent); m_mgr->GetDockingManager()->AddPane( m_xdebugEvalPane, wxAuiPaneInfo().Name("XDebugEval").Caption("PHP").Hide().CloseButton().MaximizeButton().Bottom().Position(2)); // Check to see if the have a PHP executable setup // if not - update it PHPConfigurationData data; data.Load(); PHPLocator locator; if(locator.Locate()) { // update a PHP executable in the settings if(data.GetPhpExe().IsEmpty()) { data.SetPhpExe(locator.GetPhpExe().GetFullPath()); } data.Save(); } }
void PhpPlugin::DoOpenWorkspace(const wxString& filename, bool createIfMissing, bool createProjectFromSources) { // notify codelite to close the currently opened workspace wxCommandEvent eventClose(wxEVT_COMMAND_MENU_SELECTED, XRCID("close_workspace")); eventClose.SetEventObject(FRAME); FRAME->GetEventHandler()->ProcessEvent(eventClose); // Open the PHP workspace if(!PHPWorkspace::Get()->Open(filename, m_workspaceView, createIfMissing)) { wxMessageBox(_("Failed to open workspace: corrupted workspace file"), wxT("CodeLite"), wxOK | wxICON_WARNING | wxCENTER, FRAME); return; } // Keep the old clang state before we disable it const TagsOptionsData& options = TagsManagerST::Get()->GetCtagsOptions(); m_clangOldFlag = (options.GetClangOptions() & CC_CLANG_ENABLED); m_mgr->EnableClangCodeCompletion(false); m_workspaceView->LoadWorkspaceView(); // Select the 'PHP' tab m_mgr->GetWorkspaceView()->SelectPage(PHPStrings::PHP_WORKSPACE_VIEW_LABEL); if(createProjectFromSources) { PHPConfigurationData conf; PHPProject::CreateData cd; conf.Load(); cd.importFilesUnderPath = true; cd.name = PHPWorkspace::Get()->GetWorkspaceName(); cd.phpExe = conf.GetPhpExe(); cd.path = PHPWorkspace::Get()->GetFilename().GetPath(); cd.projectType = PHPProjectSettingsData::kRunAsCLI; m_workspaceView->CallAfter(&PHPWorkspaceView::CreateNewProject, cd); } }
PhpPlugin::PhpPlugin(IManager* manager) : IPlugin(manager) , m_clangOldFlag(false) , m_browser(NULL) , m_debuggerPane(NULL) , m_xdebugLocalsView(NULL) , m_xdebugEvalPane(NULL) , m_showWelcomePage(false) { m_longName = wxT("PHP Plugin for the codelite IDE"); m_shortName = wxT("PHP"); // Instantiate the bitmaps, we do this so they will be populated in wxXmlResource // Sigleton class PHPImages images; PHPWorkspace::Get()->SetPluginManager(m_mgr); XDebugManager::Initialize(this); // Add our UI // create tab (possibly detached) Notebook* book = m_mgr->GetWorkspacePaneNotebook(); if(IsWorkspaceViewDetached()) { // Make the window child of the main panel (which is the grand parent of the notebook) DockablePane* cp = new DockablePane( book->GetParent()->GetParent(), book, PHPStrings::PHP_WORKSPACE_VIEW_TITLE, wxNullBitmap, wxSize(200, 200)); m_workspaceView = new PHPWorkspaceView(cp, m_mgr); cp->SetChildNoReparent(m_workspaceView); } else { m_workspaceView = new PHPWorkspaceView(book, m_mgr); book->InsertPage(0, m_workspaceView, PHPStrings::PHP_WORKSPACE_VIEW_TITLE, true); } PHPCodeCompletion::Instance()->SetManager(m_mgr); PHPEditorContextMenu::Instance()->ConnectEvents(); PHPParserThread::Instance()->Start(); // Pass the manager class to the context menu manager PHPEditorContextMenu::Instance()->SetManager(m_mgr); // Connect events EventNotifier::Get()->Connect( wxEVT_CC_SHOW_QUICK_OUTLINE, clCodeCompletionEventHandler(PhpPlugin::OnShowQuickOutline), NULL, this); EventNotifier::Get()->Connect( wxEVT_DBG_UI_DELTE_ALL_BREAKPOINTS, clDebugEventHandler(PhpPlugin::OnXDebugDeleteAllBreakpoints), NULL, this); EventNotifier::Get()->Connect( wxEVT_CMD_CREATE_NEW_WORKSPACE, wxCommandEventHandler(PhpPlugin::OnNewWorkspace), NULL, this); EventNotifier::Get()->Connect( wxEVT_NEW_PROJECT_WIZARD_SHOWING, clNewProjectEventHandler(PhpPlugin::OnNewProject), NULL, this); EventNotifier::Get()->Connect( wxEVT_NEW_PROJECT_WIZARD_FINISHED, clNewProjectEventHandler(PhpPlugin::OnNewProjectFinish), NULL, this); EventNotifier::Get()->Connect( wxEVT_CMD_IS_WORKSPACE_OPEN, clCommandEventHandler(PhpPlugin::OnIsWorkspaceOpen), NULL, this); EventNotifier::Get()->Connect( wxEVT_CMD_CLOSE_WORKSPACE, clCommandEventHandler(PhpPlugin::OnCloseWorkspace), NULL, this); EventNotifier::Get()->Connect( wxEVT_CMD_OPEN_WORKSPACE, clCommandEventHandler(PhpPlugin::OnOpenWorkspace), NULL, this); EventNotifier::Get()->Connect( wxEVT_CMD_RELOAD_WORKSPACE, clCommandEventHandler(PhpPlugin::OnReloadWorkspace), NULL, this); EventNotifier::Get()->Connect( wxEVT_CMD_OPEN_RESOURCE, wxCommandEventHandler(PhpPlugin::OnOpenResource), NULL, this); EventNotifier::Get()->Connect( wxEVT_CMD_GET_WORKSPACE_FILES, wxCommandEventHandler(PhpPlugin::OnGetWorkspaceFiles), NULL, this); EventNotifier::Get()->Connect(wxEVT_CMD_GET_CURRENT_FILE_PROJECT_FILES, wxCommandEventHandler(PhpPlugin::OnGetCurrentFileProjectFiles), NULL, this); EventNotifier::Get()->Connect( wxEVT_CMD_GET_ACTIVE_PROJECT_FILES, wxCommandEventHandler(PhpPlugin::OnGetActiveProjectFiles), NULL, this); EventNotifier::Get()->Connect( wxEVT_CMD_GET_FIND_IN_FILES_MASK, clCommandEventHandler(PhpPlugin::OnGetFiFMask), NULL, this); EventNotifier::Get()->Connect(wxEVT_FILE_SAVED, clCommandEventHandler(PhpPlugin::OnFileSaved), NULL, this); EventNotifier::Get()->Connect(wxEVT_PHP_LOAD_URL, PHPEventHandler(PhpPlugin::OnLoadURL), NULL, this); EventNotifier::Get()->Connect( wxEVT_ALL_EDITORS_CLOSED, wxCommandEventHandler(PhpPlugin::OnAllEditorsClosed), NULL, this); EventNotifier::Get()->Bind(wxEVT_XDEBUG_CONNECTED, &PhpPlugin::OnDebugSatrted, this); EventNotifier::Get()->Bind(wxEVT_XDEBUG_SESSION_ENDED, &PhpPlugin::OnDebugEnded, this); EventNotifier::Get()->Connect(wxEVT_GOING_DOWN, clCommandEventHandler(PhpPlugin::OnGoingDown), NULL, this); CallAfter(&PhpPlugin::DoCreateDebuggerPanes); // Extract all CC files from PHP.zip into the folder ~/.codelite/php-plugin/cc wxFileName phpResources(clStandardPaths::Get().GetDataDir(), "PHP.zip"); if(phpResources.Exists()) { clZipReader zipReader(phpResources); wxFileName targetDir(clStandardPaths::Get().GetUserDataDir(), ""); targetDir.AppendDir("php-plugin"); // Don't extract the zip if one of the files on disk is newer or equal to the zip timestamp wxFileName fnSampleFile(targetDir.GetPath(), "basic.php"); fnSampleFile.AppendDir("cc"); if(!fnSampleFile.Exists() || // the sample file does not exists // Or the resource file (PHP.zip) is newer than the sample file (phpResources.GetModificationTime().GetTicks() > fnSampleFile.GetModificationTime().GetTicks())) { targetDir.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL); zipReader.Extract("*", targetDir.GetPath()); // Make sure we add this path to the general PHP settings targetDir.AppendDir("cc"); // the CC files are located under an internal folder named "cc" (lowercase) PHPConfigurationData config; if(config.Load().GetCcIncludePath().Index(targetDir.GetPath()) == wxNOT_FOUND) { config.Load().GetCcIncludePath().Add(targetDir.GetPath()); config.Save(); } } } else { CL_WARNING("PHP: Could not locate PHP resources 'PHP.zip' => '%s'", phpResources.GetFullPath()); } }
PhpPlugin::PhpPlugin(IManager* manager) : IPlugin(manager) , m_clangOldFlag(false) , m_browser(NULL) , m_debuggerPane(NULL) , m_xdebugLocalsView(NULL) , m_xdebugEvalPane(NULL) , m_showWelcomePage(false) , m_toggleToolbar(false) { m_lint.Reset(new PHPLint(this)); // Add new workspace type clWorkspaceManager::Get().RegisterWorkspace(new PHPWorkspace()); m_longName = _("PHP Plugin for the codelite IDE"); m_shortName = wxT("PHP"); // Instantiate the bitmaps, we do this so they will be populated in wxXmlResource // Sigleton class PHPWorkspace::Get()->SetPluginManager(m_mgr); XDebugManager::Initialize(this); // BitmapLoader::RegisterImage(FileExtManager::TypeWorkspacePHP, images.Bitmap("m_bmpPhpWorkspace")); // Add our UI // create tab (possibly detached) m_workspaceView = new PHPWorkspaceView(m_mgr->GetWorkspaceView()->GetBook(), m_mgr); m_mgr->GetWorkspaceView()->AddPage(m_workspaceView, PHPStrings::PHP_WORKSPACE_VIEW_LABEL); PHPCodeCompletion::Instance()->SetManager(m_mgr); PHPEditorContextMenu::Instance()->ConnectEvents(); PHPParserThread::Instance()->Start(); // Pass the manager class to the context menu manager PHPEditorContextMenu::Instance()->SetManager(m_mgr); // Connect events EventNotifier::Get()->Connect( wxEVT_CC_SHOW_QUICK_OUTLINE, clCodeCompletionEventHandler(PhpPlugin::OnShowQuickOutline), NULL, this); EventNotifier::Get()->Connect( wxEVT_DBG_UI_DELTE_ALL_BREAKPOINTS, clDebugEventHandler(PhpPlugin::OnXDebugDeleteAllBreakpoints), NULL, this); EventNotifier::Get()->Connect( wxEVT_CMD_CREATE_NEW_WORKSPACE, clCommandEventHandler(PhpPlugin::OnNewWorkspace), NULL, this); EventNotifier::Get()->Connect( wxEVT_NEW_PROJECT_WIZARD_SHOWING, clNewProjectEventHandler(PhpPlugin::OnNewProject), NULL, this); EventNotifier::Get()->Connect( wxEVT_NEW_PROJECT_WIZARD_FINISHED, clNewProjectEventHandler(PhpPlugin::OnNewProjectFinish), NULL, this); EventNotifier::Get()->Connect( wxEVT_CMD_IS_WORKSPACE_OPEN, clCommandEventHandler(PhpPlugin::OnIsWorkspaceOpen), NULL, this); EventNotifier::Get()->Connect( wxEVT_CMD_CLOSE_WORKSPACE, clCommandEventHandler(PhpPlugin::OnCloseWorkspace), NULL, this); EventNotifier::Get()->Connect( wxEVT_CMD_OPEN_WORKSPACE, clCommandEventHandler(PhpPlugin::OnOpenWorkspace), NULL, this); EventNotifier::Get()->Connect( wxEVT_CMD_RELOAD_WORKSPACE, clCommandEventHandler(PhpPlugin::OnReloadWorkspace), NULL, this); EventNotifier::Get()->Connect( wxEVT_CMD_OPEN_RESOURCE, wxCommandEventHandler(PhpPlugin::OnOpenResource), NULL, this); EventNotifier::Get()->Connect( wxEVT_CMD_GET_WORKSPACE_FILES, wxCommandEventHandler(PhpPlugin::OnGetWorkspaceFiles), NULL, this); EventNotifier::Get()->Connect(wxEVT_CMD_GET_CURRENT_FILE_PROJECT_FILES, wxCommandEventHandler(PhpPlugin::OnGetCurrentFileProjectFiles), NULL, this); EventNotifier::Get()->Connect( wxEVT_CMD_GET_ACTIVE_PROJECT_FILES, wxCommandEventHandler(PhpPlugin::OnGetActiveProjectFiles), NULL, this); EventNotifier::Get()->Connect( wxEVT_CMD_FIND_IN_FILES_DISMISSED, clCommandEventHandler(PhpPlugin::OnFindInFilesDismissed), NULL, this); EventNotifier::Get()->Connect(wxEVT_FILE_SAVED, clCommandEventHandler(PhpPlugin::OnFileSaved), NULL, this); EventNotifier::Get()->Bind(wxEVT_FILES_MODIFIED_REPLACE_IN_FILES, &PhpPlugin::OnReplaceInFiles, this); EventNotifier::Get()->Connect(wxEVT_PHP_LOAD_URL, PHPEventHandler(PhpPlugin::OnLoadURL), NULL, this); EventNotifier::Get()->Connect( wxEVT_ALL_EDITORS_CLOSED, wxCommandEventHandler(PhpPlugin::OnAllEditorsClosed), NULL, this); EventNotifier::Get()->Bind(wxEVT_XDEBUG_SESSION_STARTED, &PhpPlugin::OnDebugStarted, this); EventNotifier::Get()->Bind(wxEVT_XDEBUG_SESSION_ENDED, &PhpPlugin::OnDebugEnded, this); EventNotifier::Get()->Connect(wxEVT_GOING_DOWN, clCommandEventHandler(PhpPlugin::OnGoingDown), NULL, this); EventNotifier::Get()->Bind(wxEVT_FILE_SYSTEM_UPDATED, &PhpPlugin::OnFileSysetmUpdated, this); EventNotifier::Get()->Bind(wxEVT_SAVE_SESSION_NEEDED, &PhpPlugin::OnSaveSession, this); CallAfter(&PhpPlugin::FinalizeStartup); // Extract all CC files from PHP.zip into the folder ~/.codelite/php-plugin/cc wxFileName phpResources(clStandardPaths::Get().GetDataDir(), "PHP.zip"); if(phpResources.Exists()) { clZipReader zipReader(phpResources); wxFileName targetDir(clStandardPaths::Get().GetUserDataDir(), ""); targetDir.AppendDir("php-plugin"); // Don't extract the zip if one of the files on disk is newer or equal to the zip timestamp wxFileName fnSampleFile(targetDir.GetPath(), "basic.php"); fnSampleFile.AppendDir("cc"); PHPConfigurationData config; if(!fnSampleFile.Exists() || // the sample file does not exists // Or the resource file (PHP.zip) is newer than the sample file (phpResources.GetModificationTime().GetTicks() > fnSampleFile.GetModificationTime().GetTicks())) { targetDir.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL); zipReader.Extract("*", targetDir.GetPath()); // Make sure we add this path to the general PHP settings targetDir.AppendDir("cc"); // the CC files are located under an internal folder named "cc" (lowercase) if(config.Load().GetCcIncludePath().Index(targetDir.GetPath()) == wxNOT_FOUND) { config.Load().GetCcIncludePath().Add(targetDir.GetPath()); config.Save(); } } else if(fnSampleFile.Exists()) { // Ensure that we have the core PHP code completion methods if(config.Load().GetCcIncludePath().Index(fnSampleFile.GetPath()) == wxNOT_FOUND) { config.Load().GetCcIncludePath().Add(fnSampleFile.GetPath()); config.Save(); } } } else { CL_WARNING("PHP: Could not locate PHP resources 'PHP.zip' => '%s'", phpResources.GetFullPath()); } }
wxString PHPWorkspace::GetFilesMask() const { // set the default find in files mask PHPConfigurationData conf; return conf.Load().GetFindInFilesMask(); }