ImportFilesDialogNew::ImportFilesDialogNew(wxWindow* parent) : ImportFilesDialogNewBase(parent) { ImportFilesSettings options; if(!EditorConfigST::Get()->ReadObject(wxT("import_dir_options"), &options)) { //first time, read the settings from the ctags options options.SetFileMask( TagsManagerST::Get()->GetCtagsOptions().GetFileSpec() ); bool noExt = TagsManagerST::Get()->GetCtagsOptions().GetFlags() & CC_PARSE_EXT_LESS_FILES ? true : false; size_t flags(0); if(noExt) { flags |= IFS_INCLUDE_FILES_WO_EXT; } options.SetFlags(flags); } options.SetBaseDir( PluginManager::Get()->GetSelectedTreeItemInfo(TreeFileView).m_fileName.GetPath() ); if(options.GetBaseDir().IsEmpty()) { options.SetBaseDir(wxGetCwd()); } m_dirPicker->SetPath(options.GetBaseDir()); m_textCtrSpec->SetValue( options.GetFileMask() ); m_checkBoxFilesWOExt->SetValue(options.GetFlags() & IFS_INCLUDE_FILES_WO_EXT ); WindowAttrManager::Load(this, wxT("ImportFilesDialog"), NULL); DoBuildTree(); }
void VirtualDirectorySelectorDlg::OnNewVD(wxCommandEvent& event) { static int counter = 0; wxTreeItemId id = m_treeCtrl->GetSelection(); if ( id.IsOk() == false ) return; wxString curpath = DoGetPath(m_treeCtrl, id, false); wxString name = m_suggestedName; if (name.empty()) { name << "Folder" << ++counter; } wxString newname = wxGetTextFromUser(_("New Virtual Folder Name:"), _("New Virtual Folder"), name); newname.Trim().Trim(false); if ( newname.IsEmpty() ) return; /* if ( newname.Contains(":") ) { // No, don't check this: we may have been passed a multi-segment path, or be trying to create one wxMessageBox(_("':' is not a valid virtual folder character"), "codelite"); return; }*/ curpath << ":" << newname; wxString errmsg; if( !WorkspaceST::Get()->CreateVirtualDirectory(curpath, errmsg, true) ) { wxMessageBox(_("Error occured while creating virtual folder:\n") + errmsg, "codelite", wxOK|wxICON_WARNING|wxCENTER); return; } m_initialPath = curpath; m_reloadTreeNeeded = true; DoBuildTree(); }
VirtualDirectorySelectorDlg::VirtualDirectorySelectorDlg( wxWindow* parent, Workspace *wsp, const wxString &initialPath, const wxString& projectname) : VirtualDirectorySelectorDlgBaseClass( parent ) , m_workspace(wsp) , m_projectName(projectname) , m_initialPath(initialPath) , m_images(NULL) , m_reloadTreeNeeded(false) { m_treeCtrl->SetFocus(); DoBuildTree(); WindowAttrManager::Load(this, wxT("VirtualDirectorySelectorDlg"), NULL); }
void ImportFilesDialogNew::OnItemExpanding(wxDataViewEvent& event) { event.Skip(); wxDataViewItemArray children; if ( m_dataviewModel->GetChildren(event.GetItem(), children) ) { wxDataViewItem child = children.Item(0); ImportFilesDlgData *cd = dynamic_cast<ImportFilesDlgData*>(m_dataviewModel->GetClientObject(child)); if ( cd && cd->IsDummy() ) { cd = dynamic_cast<ImportFilesDlgData*>(m_dataviewModel->GetClientObject(event.GetItem())); m_dataviewModel->DeleteItem( child ); wxDir dir ( cd->GetPath() ); DoBuildTree( event.GetItem(), dir, cd->IsChecked() ); } } }
void SFTPTreeView::DoOpenSession() { DoCloseSession(); wxString accountName = m_choiceAccount->GetStringSelection(); if(accountName.IsEmpty()) { return; } SFTPSettings settings; settings.Load(); m_account = SSHAccountInfo(); if(!settings.GetAccount(accountName, m_account)) { ::wxMessageBox(wxString() << _("Could not find account: ") << accountName, "codelite", wxICON_ERROR | wxOK); return; } clSSH::Ptr_t ssh( new clSSH(m_account.GetHost(), m_account.GetUsername(), m_account.GetPassword(), m_account.GetPort())); try { wxString message; m_plugin->GetManager()->SetStatusMessage(wxString() << _("Connecting to: ") << accountName << "..."); ssh->Connect(); if(!ssh->AuthenticateServer(message)) { if(::wxMessageBox(message, "SSH", wxYES_NO | wxCENTER | wxICON_QUESTION) == wxYES) { ssh->AcceptServerAuthentication(); } } ssh->Login(); m_sftp.reset(new clSFTP(ssh)); m_sftp->Initialize(); m_sftp->SetAccount(m_account.GetAccountName()); m_plugin->GetManager()->SetStatusMessage(wxString() << _("Done!")); DoBuildTree("/"); } catch(clException& e) { ::wxMessageBox(e.What(), "codelite", wxICON_ERROR | wxOK); DoCloseSession(); } }
void ImportFilesDialogNew::DoBuildTree() { m_dataviewModel->Clear(); wxString curpath = m_dirPicker->GetPath(); if ( !wxDir::Exists(curpath) ) { m_dirPicker->SetPath( ::wxGetCwd() ); } wxVector<wxVariant> cols; cols.push_back( MakeIconText(m_dirPicker->GetPath(), PluginManager::Get()->GetStdIcons()->LoadBitmap("mime/16/folder") ) ); cols.push_back(false); m_root = m_dataviewModel->AppendItem(wxDataViewItem(0), cols, new ImportFilesDlgData(m_dirPicker->GetPath(), false)); // For performance, we add only the direct children of the root node wxDir dir(m_dirPicker->GetPath()); if ( dir.IsOpened() && dir.HasSubDirs() ) { DoBuildTree(m_root, dir, false); } m_dataview->Expand(m_root); }
void ImportFilesDialogNew::OnDirChanged(wxFileDirPickerEvent& event) { wxUnusedVar(event); DoBuildTree(); }
void SFTPTreeView::DoOpenSession() { DoCloseSession(); wxString accountName = m_choiceAccount->GetStringSelection(); if(accountName.IsEmpty()) { return; } SFTPSettings settings; settings.Load(); m_account = SSHAccountInfo(); if(!settings.GetAccount(accountName, m_account)) { ::wxMessageBox(wxString() << _("Could not find account: ") << accountName, "codelite", wxICON_ERROR | wxOK); return; } wxString message; #ifndef _WIN64 wxProgressDialog dlg(_("SFTP"), wxString(' ', 100) + "\n\n", 10); dlg.Show(); dlg.Update(1, wxString() << _("Connecting to: ") << accountName << "..." << _("\n(this may take a few seconds)")); #else wxBusyCursor bc; clGetManager()->SetStatusMessage(wxString() << _("Connecting to: ") << accountName); #endif // We know that there is a bug that libssh succeeded on connecting only on the second attempt.. // to workaround it, we issue first connect with 1 second timeout, and then re-open the connection try { clSSH::Ptr_t ssh( new clSSH(m_account.GetHost(), m_account.GetUsername(), m_account.GetPassword(), m_account.GetPort())); ssh->Connect(wxNOT_FOUND); } catch(...) { } try { clSSH::Ptr_t ssh( new clSSH(m_account.GetHost(), m_account.GetUsername(), m_account.GetPassword(), m_account.GetPort())); ssh->Connect(5); #ifndef _WIN64 dlg.Update(5, _("Connected!")); dlg.Update(6, _("Authenticating server...")); #endif if(!ssh->AuthenticateServer(message)) { if(::wxMessageBox(message, "SSH", wxYES_NO | wxCENTER | wxICON_QUESTION) == wxYES) { #ifndef _WIN64 dlg.Update(7, _("Accepting server authentication server...")); #endif ssh->AcceptServerAuthentication(); } } else { #ifndef _WIN64 dlg.Update(7, _("Server authenticated")); #endif } #ifndef _WIN64 dlg.Update(8, _("Logging...")); #endif ssh->Login(); m_sftp.reset(new clSFTP(ssh)); m_sftp->Initialize(); m_sftp->SetAccount(m_account.GetAccountName()); m_plugin->GetManager()->SetStatusMessage(wxString() << _("Done!")); #ifndef _WIN64 dlg.Update(9, _("Fetching directory list...")); #endif DoBuildTree(m_account.GetDefaultFolder().IsEmpty() ? "/" : m_account.GetDefaultFolder()); #ifndef _WIN64 dlg.Update(10, _("Done")); #endif } catch(clException& e) { ::wxMessageBox(e.What(), "codelite", wxICON_ERROR | wxOK); DoCloseSession(); } }
void SFTPTreeView::OnGotoLocation(wxCommandEvent& event) { DoBuildTree(m_textCtrlQuickJump->GetValue()); }
void SFTPTreeView::DoOpenSession() { DoCloseSession(); if(!GetAccountFromUser(m_account)) { return; } wxString message; wxProgressDialog dlg(_("SFTP"), wxString(' ', 100) + "\n\n", 10); dlg.Show(); dlg.Update(1, wxString() << _("Connecting to: ") << m_account.GetAccountName() << "..." << _("\n(this may take a few seconds)")); // We know that there is a bug that libssh succeeded on connecting only on the second attempt.. // to workaround it, we issue first connect with 1 second timeout, and then re-open the connection try { clSSH::Ptr_t ssh( new clSSH(m_account.GetHost(), m_account.GetUsername(), m_account.GetPassword(), m_account.GetPort())); ssh->Connect(wxNOT_FOUND); } catch(...) { } try { clSSH::Ptr_t ssh( new clSSH(m_account.GetHost(), m_account.GetUsername(), m_account.GetPassword(), m_account.GetPort())); ssh->Connect(5); dlg.Update(5, _("Connected!")); dlg.Update(6, _("Authenticating server...")); if(!ssh->AuthenticateServer(message)) { if(::wxMessageBox(message, "SSH", wxYES_NO | wxCENTER | wxICON_QUESTION) == wxYES) { dlg.Update(7, _("Accepting server authentication server...")); ssh->AcceptServerAuthentication(); } } else { dlg.Update(7, _("Server authenticated")); } dlg.Update(8, _("Logging in..")); ssh->Login(); m_sftp.reset(new clSFTP(ssh)); m_sftp->Initialize(); m_sftp->SetAccount(m_account.GetAccountName()); m_plugin->GetManager()->SetStatusMessage(wxString() << _("Done!")); dlg.Update(9, _("Fetching directory list...")); DoBuildTree(m_account.GetDefaultFolder().IsEmpty() ? "/" : m_account.GetDefaultFolder()); dlg.Update(10, _("Done")); CallAfter(&SFTPTreeView::DoLoadSession); // If this is a new account, offer the user to save it SFTPSettings s; s.Load(); SSHAccountInfo dummy; if(!s.GetAccount(m_account.GetAccountName(), dummy)) { wxString message; message << _("Would you like to save this account?\n") << _("It will be saved as '") << m_account.GetAccountName() << "'"; wxStandardID res = ::PromptForYesNoCancelDialogWithCheckbox(message, "SFTPQuickConnectSaveDlg"); if(res == wxID_YES) { // This 'Connect' was via Quick Connect option SSHAccountInfo::Vect_t accounts = s.GetAccounts(); accounts.push_back(m_account); s.SetAccounts(accounts); s.Save(); } } } catch(clException& e) { ::wxMessageBox(e.What(), "CodeLite", wxICON_ERROR | wxOK); DoCloseSession(); } }