void AStylePlugin::OnFormatProject( wxCommandEvent& /*event*/ ) { ProjectManager* manager = Manager::Get()->GetProjectManager(); wxTreeCtrl *tree = manager->GetUI().GetTree(); if ( !tree ) return; wxTreeItemId treeItem = manager->GetUI().GetTreeSelection(); if ( !treeItem.IsOk() ) return; const FileTreeData *data = static_cast<FileTreeData*>( tree->GetItemData( treeItem ) ); if ( !data ) return; switch ( data->GetKind() ) { case FileTreeData::ftdkProject: { cbProject* prj = data->GetProject(); wxProgressDialog progressDlg(_("Please wait"), _("Formatting..."), prj->GetFilesCount(), 0, wxPD_CAN_ABORT|wxPD_AUTO_HIDE|wxPD_SMOOTH ); progressDlg.Show(); int i = 0; for (FilesList::iterator it = prj->GetFilesList().begin(); it != prj->GetFilesList().end(); ++it) { ProjectFile* pf = *it; wxString filename = pf->file.GetFullPath(); FileType fileType = FileTypeOf( filename ); if ( fileType == ftSource || fileType == ftHeader || fileType == ftTemplateSource ) { FormatFile( filename ); if ( false == progressDlg.Update( i++, wxString(_("Formatting ")) + pf->relativeFilename ) ) break; } } } break; case FileTreeData::ftdkFile: { ProjectFile* f = data->GetProjectFile(); if ( f ) FormatFile( f->file.GetFullPath() ); } break; default: break; } }
void ClassWizard::OnLaunch(cb_unused wxCommandEvent& event) { ProjectManager* prjMan = Manager::Get()->GetProjectManager(); cbProject* prj = prjMan->GetActiveProject(); ClassWizardDlg dlg(Manager::Get()->GetAppWindow()); PlaceWindow(&dlg); if (dlg.ShowModal() == wxID_OK) { if (!prj) { cbMessageBox( _("The new class has been created."), _("Information"), wxOK | wxICON_INFORMATION, Manager::Get()->GetAppWindow()); } else if( cbMessageBox( _("The new class has been created.\n" "Do you want to add it to the current project?"), _("Add to project?"), wxYES_NO | wxYES_DEFAULT | wxICON_QUESTION, Manager::Get()->GetAppWindow()) == wxID_YES) { wxArrayInt targets; prjMan->AddFileToProject(dlg.GetHeaderFilename(), prj, targets); if ( (targets.GetCount() != 0) && (dlg.IsValidImplementationFilename()) ) prjMan->AddFileToProject(dlg.GetImplementationFilename(), prj, targets); if (dlg.AddPathToProject()) { // Add the include Path to the Build targets.... for (size_t i = 0; i < targets.GetCount(); ++i) { ProjectBuildTarget* buildTarget = prj->GetBuildTarget(targets[i]); // Get the top level build Target if (buildTarget) { wxString include_dir = dlg.GetIncludeDir(); if (!include_dir.IsEmpty()) buildTarget->AddIncludeDir(include_dir); } else { wxString information; information.Printf(_("Could not find build target ID = %i.\nThe include directory won't be added to this target. Please do it manually"), targets[i]); cbMessageBox(information, _("Information"), wxOK | wxICON_INFORMATION, Manager::Get()->GetAppWindow()); } } } prjMan->GetUI().RebuildTree(); } } }