void clTreeCtrlPanel::OnCloseFolder(wxCommandEvent& event) { wxTreeItemId item = GetTreeCtrl()->GetFocusedItem(); CHECK_ITEM_RET(item); if(!IsTopLevelFolder(item)) return; GetTreeCtrl()->Delete(item); }
void SFTPTreeView::OnContextMenu(wxTreeListEvent& event) { CHECK_ITEM_RET(event.GetItem()); MyClientData* cd = GetItemData(event.GetItem()); wxMenu menu; if(cd) { // Just incase, make sure the item is selected m_treeListCtrl->Select(event.GetItem()); if(!cd->IsFolder()) { menu.Append(ID_OPEN, _("Open")); menu.Append(ID_OPEN_WITH_DEFAULT_APP, _("Open with Default Application...")); menu.AppendSeparator(); menu.Append(ID_OPEN_CONTAINING_FOLDER, _("Download and Open Containing Folder...")); menu.AppendSeparator(); } else { menu.Append(ID_NEW, _("Create new directory...")); menu.Append(ID_NEW_FILE, _("Create new file...")); menu.AppendSeparator(); menu.Append(ID_REFRESH_FOLDER, _("Refresh")); menu.AppendSeparator(); } menu.Append(ID_DELETE, _("Delete")); #ifdef __WXMAC__ menu.Enable(ID_DELETE, false); #endif menu.Append(ID_RENAME, _("Rename")); } m_treeListCtrl->PopupMenu(&menu); }
void SFTPTreeView::OnContextMenu(wxTreeListEvent& event) { CHECK_ITEM_RET(event.GetItem()); MyClientData* cd = GetItemData(event.GetItem()); CHECK_PTR_RET(cd); // Just incase, make sure the item is selected m_treeListCtrl->Select(event.GetItem()); wxMenu menu; if ( !cd->IsFolder() ) { menu.Append(ID_OPEN, _("Open")); menu.AppendSeparator(); } else { menu.Append(ID_NEW, _("Create directory")); menu.AppendSeparator(); } menu.Append(ID_DELETE, _("Delete")); #ifdef __WXMAC__ menu.Enable(ID_DELETE, false); #endif menu.Append(ID_RENAME, _("Rename")); m_treeListCtrl->PopupMenu( &menu ); }
void PSCustomBuildPage::OnEditTarget(wxCommandEvent& event) { wxUnusedVar(event); wxDataViewItem item = m_dvListCtrlTargets->GetSelection(); CHECK_ITEM_RET(item); DoEditTarget(item); }
void OpenResourceDialog::DoSelectItem(const wxDataViewItem& item) { CHECK_ITEM_RET(item); m_dataview->UnselectAll(); m_dataview->Select(item); m_dataview->EnsureVisible(item); }
void PHPWorkspaceView::DoDeleteSelectedFileItem() { wxTreeItemId item = DoGetSingleSelection(); CHECK_ITEM_RET(item); ItemData* itemData = DoGetItemData(item); if(!itemData || !itemData->IsFile()) return; wxString msg, caption; caption << _("Removing file '") << wxFileName(itemData->GetFile()).GetFullName() << "'"; msg << _("Removing file '") << wxFileName(itemData->GetFile()).GetFullName() << "' from project '" << itemData->GetProjectName() << "'\n" << _("You can select to remove the file from the project and optionally from the file system\n") << _("From where should codelite remove the file?"); wxMessageDialog dlg(EventNotifier::Get()->TopFrame(), msg, caption, wxYES_NO | wxCANCEL | wxCANCEL_DEFAULT); dlg.SetYesNoCancelLabels("File system && project", "Project only", "Cancel"); int answer = dlg.ShowModal(); if(answer == wxID_YES || answer == wxID_NO) { wxString fileName = itemData->GetFile(); // Remove from from project if(PHPWorkspace::Get()->DelFile(itemData->GetProjectName(), itemData->GetFolderPath(), fileName)) { m_treeCtrlView->Delete(item); } else { return; } if(answer == wxID_YES) { ::wxRemoveFile(fileName); } } }
void PHPWorkspaceView::OnNewFolder(wxCommandEvent& e) { wxUnusedVar(e); wxString name = wxGetTextFromUser(_("New Folder Name:"), _("New Folder")); if(name.IsEmpty()) return; wxString project = DoGetSelectedProject(); if(project.IsEmpty()) return; wxTreeItemId parent = m_treeCtrlView->GetSelection(); CHECK_ITEM_RET(parent); ItemData* itemData = DoGetItemData(parent); CHECK_PTR_RET(itemData); if(!itemData->IsFolder() && !itemData->IsProject()) return; PHPProject::Ptr_t proj = PHPWorkspace::Get()->GetProject(project); CHECK_PTR_RET(proj); wxString folder; if(itemData->IsFolder()) { folder << itemData->GetFolderPath() << "/" << name; } else { folder << name; } PHPFolder::Ptr_t pFolder = proj->AddFolder(folder); proj->Save(); // Update the UI DoAddFolder(parent, pFolder, proj); }
void clTreeCtrlPanel::DoRenameItem(const wxTreeItemId& item, const wxString& oldname, const wxString& newname) { // Update the UI + client data clTreeCtrlData* d = GetItemData(item); if(d->IsFile()) { wxFileName fn(d->GetPath()); fn.SetFullName(newname); d->SetPath(fn.GetFullPath()); } else if(d->IsFolder()) { // FIXME: } GetTreeCtrl()->SetItemText(item, newname); // Update the parent's cache wxTreeItemId parent = GetTreeCtrl()->GetItemParent(item); CHECK_ITEM_RET(parent); clTreeCtrlData* parentData = GetItemData(parent); // Update the parent cache if(parentData->GetIndex()) { parentData->GetIndex()->Delete(oldname); parentData->GetIndex()->Add(newname, item); } }
void clTreeCtrlPanel::OnItemExpanding(wxTreeEvent& event) { event.Skip(); wxTreeItemId item = event.GetItem(); CHECK_ITEM_RET(item); DoExpandItem(item, true); }
void LLDBThreadsView::OnItemActivated(wxDataViewEvent& event) { CHECK_ITEM_RET(event.GetItem()); LLDBThreadViewClientData* cd = reinterpret_cast<LLDBThreadViewClientData*>(m_dvListCtrlThreads->GetItemData(event.GetItem())); if(cd && !cd->GetThread().IsActive()) { m_plugin->GetLLDB()->SelectThread(cd->GetThread().GetId()); } }
void clTreeCtrlPanel::DoExpandItem(const wxTreeItemId& parent, bool expand) { clTreeCtrlData* cd = GetItemData(parent); CHECK_PTR_RET(cd); // we only know how to expand folders... if(!cd->IsFolder()) return; wxString folderPath = cd->GetPath(); if(!m_treeCtrl->ItemHasChildren(parent)) return; // Test the first item for dummy wxTreeItemIdValue cookie; wxTreeItemId child = m_treeCtrl->GetFirstChild(parent, cookie); CHECK_ITEM_RET(child); cd = GetItemData(child); CHECK_PTR_RET(cd); // If not dummy - already expanded do nothing here if(!cd->IsDummy()) return; m_treeCtrl->Delete(child); cd = NULL; // Get the top level folders wxDir dir(folderPath); if(!dir.IsOpened()) return; wxBusyCursor bc; wxString filename; bool cont = dir.GetFirst(&filename, wxEmptyString); while(cont) { wxFileName fullpath(folderPath, filename); if(wxFileName::DirExists(fullpath.GetFullPath())) { // a folder if(!(m_options & kShowHiddenFolders) && FileUtils::IsHidden(fullpath)) { cont = dir.GetNext(&filename); continue; } DoAddFolder(parent, fullpath.GetFullPath()); } else { if(!(m_options & kShowHiddenFiles) && FileUtils::IsHidden(fullpath)) { cont = dir.GetNext(&filename); continue; } DoAddFile(parent, fullpath.GetFullPath()); } cont = dir.GetNext(&filename); } // Sort the parent if(GetTreeCtrl()->ItemHasChildren(parent)) { GetTreeCtrl()->SortChildren(parent); if(expand) { GetTreeCtrl()->Expand(parent); } SelectItem(parent); } }
void LocalsView::OnLocalExpanded(wxDataViewEvent& event) { /// We keep track on expanded and collapsed items by their fullname CHECK_ITEM_RET(event.GetItem()); wxStringClientData* cd = dynamic_cast<wxStringClientData*>(m_dataviewModel->GetClientObject(event.GetItem())); CHECK_PTR_RET(cd); m_localsExpandedItemsFullname.insert( cd->GetData() ); }
void PSCustomBuildPage::DoUpdateTarget(wxDataViewItem item, const wxString& target, const wxString& cmd) { CHECK_ITEM_RET(item); int row = m_dvListCtrlTargets->ItemToRow(item); m_dvListCtrlTargets->SetValue(target, row, 0); m_dvListCtrlTargets->SetValue(cmd, row, 1); }
void NodeJSDebuggerPane::OnItemActivated(wxDataViewEvent& event) { CHECK_ITEM_RET(event.GetItem()); FrameData* cd = (FrameData*)m_dvListCtrlCallstack->GetItemData(event.GetItem()); CHECK_PTR_RET(cd); NodeJSDebugger::Ptr_t debugger = NodeJSWorkspace::Get()->GetDebugger(); if(!debugger) return; debugger->SelectFrame(cd->index); }
void OpenResourceDialog::OnEntryActivated(wxDataViewEvent& event) { CHECK_ITEM_RET(event.GetItem()); m_dataviewModel->GetClientObject(event.GetItem()); OpenResourceDialogItemData* data = dynamic_cast<OpenResourceDialogItemData*>(m_dataviewModel->GetClientObject(event.GetItem())); if(data) { EndModal(wxID_OK); } }
void AccelTableDlg::DoItemActivated() { wxDataViewItem sel = m_dvListCtrl->GetSelection(); CHECK_ITEM_RET(sel); AccelItemData* itemData = DoGetItemData(sel); if(!itemData) return; // build the selected entry MenuItemData mid = itemData->m_menuItemData; if(clKeyboardManager::Get()->PopupNewKeyboardShortcutDlg(this, mid) == wxID_OK) { // search the list for similar accelerator MenuItemData who; if(HasAccelerator(mid.accel, who)) { if(who.action == mid.action) { return; } if(wxMessageBox(wxString::Format(_("'%s' is already assigned to: '%s'\nWould you like to replace it?"), mid.accel, who.action), _("CodeLite"), wxYES_NO | wxCENTER | wxICON_QUESTION, this) != wxYES) { return; } // Remove the old entry wxDataViewItem oldItem = FindAccel(mid); if(oldItem.IsOk()) { AccelItemData* cd = DoGetItemData(oldItem); if(cd) { cd->m_menuItemData.accel.Clear(); int row = m_dvListCtrl->ItemToRow(oldItem); m_dvListCtrl->SetValue(wxString(), row, 2); MenuItemDataMap_t::iterator iter = m_accelMap.find(cd->m_menuItemData.resourceID); if(iter != m_accelMap.end()) { iter->second.accel.Clear(); // Clear the accelerator } } } } // Update the client data itemData->m_menuItemData = mid; // Update the UI int row = m_dvListCtrl->ItemToRow(sel); if(row == wxNOT_FOUND) return; m_dvListCtrl->SetValue(mid.accel, row, 2); // and update the map MenuItemDataMap_t::iterator iter = m_accelMap.find(itemData->m_menuItemData.resourceID); if(iter != m_accelMap.end()) { iter->second.accel = itemData->m_menuItemData.accel; } } }
void GitCommitListDlg::OnRevertCommit(wxCommandEvent& e) { wxDataViewItem sel = m_dvListCtrlCommitList->GetSelection(); CHECK_ITEM_RET(sel); wxVariant v; m_dvListCtrlCommitList->GetValue(v, m_dvListCtrlCommitList->ItemToRow(sel), 0); wxString commitID = v.GetString(); m_git->CallAfter(&GitPlugin::RevertCommit, commitID); }
void GitCommitListDlg::OnCopyCommitHashToClipboard(wxCommandEvent& e) { wxDataViewItem sel = m_dvListCtrlCommitList->GetSelection(); CHECK_ITEM_RET(sel); wxVariant v; m_dvListCtrlCommitList->GetValue(v, m_dvListCtrlCommitList->ItemToRow(sel), 0); wxString commitID = v.GetString(); ::CopyToClipboard(commitID); }
void GitConsole::OnFileActivated(wxDataViewEvent& event) { CHECK_ITEM_RET(event.GetItem()); wxArrayString files; GitClientData* gcd = dynamic_cast<GitClientData*>(m_dvFilesModel->GetClientObject(event.GetItem())); if(gcd) { GIT_MESSAGE("Showing diff for: %s", gcd->GetPath().c_str()); files.push_back(gcd->GetPath()); m_git->ShowDiff(files); } }
void PHPWorkspaceView::OnEditorChanged(wxCommandEvent& e) { e.Skip(); IEditor* editor = reinterpret_cast<IEditor*>(e.GetClientData()); wxUnusedVar(editor); CHECK_PTR_RET(editor); wxFileName filename = editor->GetFileName(); // FIXME : Load all breakpoints for this file and apply them to the UI // Locate the editor for this file PHPProject::Ptr_t pProject(NULL); const PHPProject::Map_t& projects = PHPWorkspace::Get()->GetProjects(); PHPProject::Map_t::const_iterator iter = projects.begin(); for(; iter != projects.end(); ++iter) { if(filename.GetPath().StartsWith(iter->second->GetFilename().GetPath())) { // found our project pProject = iter->second; break; } } CHECK_PTR_RET(pProject); PHPFolder::Ptr_t pFolder = pProject->FolderByFileFullPath(filename.GetFullPath()); CHECK_PTR_RET(pFolder); wxTreeItemId projectItem = DoGetProjectItem(pProject->GetName()); CHECK_ITEM_RET(projectItem); wxTreeItemId folderItem = DoGetFolderItem(projectItem, pFolder); CHECK_ITEM_RET(folderItem); wxTreeItemId fileItem = DoGetFileItem(folderItem, filename.GetFullPath()); CHECK_ITEM_RET(fileItem); m_treeCtrlView->SelectItem(fileItem); m_treeCtrlView->EnsureVisible(fileItem); }
void clTreeCtrlPanel::SelectItem(const wxTreeItemId& item) { CHECK_ITEM_RET(item); wxArrayTreeItemIds items; if(GetTreeCtrl()->GetSelections(items)) { for(size_t i = 0; i < items.size(); ++i) { GetTreeCtrl()->SelectItem(items.Item(i), false); } } GetTreeCtrl()->SelectItem(item); GetTreeCtrl()->EnsureVisible(item); }
void clTreeCtrlPanel::UpdateItemDeleted(const wxTreeItemId& item) { wxTreeItemId parent = GetTreeCtrl()->GetItemParent(item); CHECK_ITEM_RET(parent); clTreeCtrlData* parentData = GetItemData(parent); wxString text = GetTreeCtrl()->GetItemText(item); // Update the parent cache if(parentData->GetIndex()) { parentData->GetIndex()->Delete(text); } }
void SFTPTreeView::OnContextMenu(wxTreeListEvent& event) { CHECK_ITEM_RET(event.GetItem()); MyClientData* cd = GetItemData(event.GetItem()); wxMenu menu; if(cd) { // Just incase, make sure the item is selected m_treeListCtrl->Select(event.GetItem()); if(!cd->IsFolder()) { menu.Append(ID_OPEN, _("Open")); menu.AppendSeparator(); } else { menu.Append(ID_NEW, _("Create new directory...")); menu.Append(ID_NEW_FILE, _("Create new file...")); menu.AppendSeparator(); menu.Append(ID_REFRESH_FOLDER, _("Refresh")); menu.AppendSeparator(); } menu.Append(ID_DELETE, _("Delete")); #ifdef __WXMAC__ menu.Enable(ID_DELETE, false); #endif menu.Append(ID_RENAME, _("Rename")); } #if defined(__WXMSW__) || defined(__WXOSX__) if(cd) { menu.AppendSeparator(); } // Append headers column menu items menu.Append(ID_SHOW_TYPE_COL, _("Show 'Type' column"), "", wxITEM_CHECK); menu.Append(ID_SHOW_SIZE_COL, _("Show 'Size' column"), "", wxITEM_CHECK); menu.Check(ID_SHOW_TYPE_COL, IsTypeColumnShown()); menu.Check(ID_SHOW_SIZE_COL, IsSizeColumnShown()); // Due to bug in wxWidgets, don't allow the user to remove columns once the // tree is populated menu.Enable(ID_SHOW_TYPE_COL, !IsConnected()); menu.Enable(ID_SHOW_SIZE_COL, !IsConnected()); #endif m_treeListCtrl->PopupMenu(&menu); }
void OpenWindowsPanel::OnTabActivated(wxDataViewEvent& event) { event.Skip(); CHECK_WORKSPACE_CLOSING(); wxDataViewItem item = event.GetItem(); CHECK_ITEM_RET(item); TabClientData* data = reinterpret_cast<TabClientData*>(m_dvListCtrl->GetItemData(item)); if(data->IsFile()) { m_mgr->OpenFile(data->tab.filename.GetFullPath()); } else { m_mgr->SelectPage(m_mgr->FindPage(data->tab.text)); } }
void PSCustomBuildPage::DoEditTarget(wxDataViewItem item) { CHECK_ITEM_RET(item); wxVariant varname, varcommand; m_dvListCtrlTargets->GetValue(varname, m_dvListCtrlTargets->ItemToRow(item), 0); m_dvListCtrlTargets->GetValue(varcommand, m_dvListCtrlTargets->ItemToRow(item), 1); wxString target = varname.GetString(); wxString cmd = varcommand.GetString(); ProjectCustomBuildTragetDlg dlg(this, target, cmd); if(dlg.ShowModal() == wxID_OK) { DoUpdateTarget(item, dlg.GetTargetName(), dlg.GetTargetCommand()); GetDlg()->SetIsDirty(true); } #ifdef __WXMAC__ GetDlg()->Raise(); #endif }
void PHPWorkspaceView::OnRenameFile(wxCommandEvent& e) { wxTreeItemId item = DoGetSingleSelection(); CHECK_ITEM_RET(item); ItemData *data = DoGetItemData(item); CHECK_PTR_RET(data); CHECK_ID_FILE(data); wxFileName old_file_name = data->GetFile(); wxString new_name = ::wxGetTextFromUser(_("New file name:"), _("Rename file"), old_file_name.GetFullName() ); if ( new_name.IsEmpty() ) return; if ( new_name == old_file_name.GetFullName() ) return; // Check to see if we got a file with the old path opened bool reopenFile = false; IEditor *editor = m_mgr->FindEditor(old_file_name.GetFullPath()); if ( editor ) { m_mgr->ClosePage( editor->GetFileName().GetFullName() ); reopenFile = true; editor = NULL; } PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetProject(DoGetSelectedProject()); CHECK_PTR_RET(pProject); if ( pProject->RenameFile(old_file_name.GetFullPath(), new_name) ) { // Locate the folder pProject->Save(); m_treeCtrlView->SetItemText(item, new_name); // Update the item data old_file_name.SetFullName(new_name); data->SetFile( old_file_name.GetFullPath() ); // Open the file if it was opened earlier // old_file_name now contains the new full path to the new file if ( reopenFile ) { m_mgr->OpenFile( old_file_name.GetFullPath() ); } } }
void PHPWorkspaceView::OnMakeIndexPHP(wxCommandEvent& e) { e.Skip(); wxTreeItemId item = DoGetSingleSelection(); CHECK_ITEM_RET(item); ItemData* itemData = DoGetItemData(item); CHECK_PTR_RET(itemData); CHECK_ID_FILE(itemData); wxString projectName = itemData->GetProjectName(); if(projectName.IsEmpty()) return; PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetProject(projectName); CHECK_PTR_RET(pProject); PHPProjectSettingsData& settings = pProject->GetSettings(); settings.SetIndexFile(itemData->GetFile()); pProject->Save(); }
void PHPWorkspaceView::OnAddFile(wxCommandEvent& e) { wxTreeItemId folderItem = DoGetSingleSelection(); CHECK_ITEM_RET(folderItem); ItemData* data = DoGetItemData(folderItem); CHECK_PTR_RET(data); if(!data->IsFolder()) return; PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetProject(data->GetProjectName()); CHECK_PTR_RET(pProject); PHPFolder::Ptr_t pFolder = pProject->Folder(data->GetFolderPath()); CHECK_PTR_RET(pFolder); wxFileDialog dlg(wxTheApp->GetTopWindow(), _("Add file"), pFolder->GetFullPath(pProject->GetFilename().GetPath()), wxT(""), wxT("PHP Files (*.php)|*.php|PHP include files (*.inc)|*.inc|All files (*)|*"), wxFD_FILE_MUST_EXIST | wxFD_OPEN | wxFD_MULTIPLE); if(dlg.ShowModal() == wxID_OK) { wxArrayString paths; dlg.GetPaths(paths); if(paths.IsEmpty()) return; // if the file is not under the project's tree - do not add it // Use the folder taken from the file's full path and the pFolder as the base folder for adding the file if(!paths.Item(0).StartsWith(pProject->GetFilename().GetPath())) { ::wxMessageBox(_("Can not add file to project. File must be under the project directory tree"), "CodeLite", wxOK | wxCENTER | wxICON_WARNING); return; } DoAddFilesToFolder(paths, pProject, true); pProject->Save(); } }
void NodeJSDebuggerPane::OnBreakpointSelected(wxDataViewEvent& event) { wxVariant v; int line; wxString file; // sanity CHECK_ITEM_RET(event.GetItem()); wxDataViewItem item = event.GetItem(); int row = m_dvListCtrlBreakpoints->ItemToRow(item); // sanity if(row >= m_dvListCtrlBreakpoints->GetItemCount()) return; m_dvListCtrlBreakpoints->GetValue(v, row, 1); line = v.GetInteger(); m_dvListCtrlBreakpoints->GetValue(v, row, 2); file = v.GetString(); CallAfter(&NodeJSDebuggerPane::DoOpenFile, file, line); }
void LLDBTooltip::OnItemExpanding(wxTreeEvent& event) { CHECK_ITEM_RET(event.GetItem()); LLDBVariableClientData* data = ItemData(event.GetItem()); wxTreeItemIdValue cookie; wxTreeItemId child = m_treeCtrl->GetFirstChild(event.GetItem(), cookie); if(m_treeCtrl->GetItemText(child) == "<dummy>") { // dummy item, remove it m_treeCtrl->DeleteChildren(event.GetItem()); m_plugin->GetLLDB()->RequestVariableChildren(data->GetVariable()->GetLldbId()); // Store the treeitemid parent in cache m_itemsPendingExpansion.insert(std::make_pair(data->GetVariable()->GetLldbId(), event.GetItem())); } else { event.Skip(); } }