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()); } }