void ProjectWindow::AddNewFile(BString name, bool create_pair) { BMessage msg(M_ADD_FILES); DPath projfile(fProject->GetPath().GetFolder()); projfile << name; entry_ref ref = gFileFactory.CreateSourceFile(projfile.GetFolder(), projfile.GetFileName(), create_pair ? SOURCEFILE_PAIR : 0); if (!ref.name || strlen(ref.name) == 0) return; AddFile(ref); if (fSourceControl) fSourceControl->AddToRepository(projfile.GetFullPath()); msg.AddRef("refs",&ref); if (create_pair && fSourceControl) { entry_ref partnerRef = GetPartnerRef(ref); DPath partnerPath(partnerRef); fSourceControl->AddToRepository(projfile.GetFullPath()); msg.AddRef("refs",&partnerRef); if (!gDontManageHeaders) AddFile(partnerRef); fSourceControl->AddToRepository(partnerPath.GetFullPath()); } be_app->PostMessage(&msg); }
void FindWindow::SetProject(Project *proj) { fFileList.MakeEmpty(); if (!proj) return; for (int32 i = 0; i < proj->CountGroups(); i++) { SourceGroup *group = proj->GroupAt(i); for (int32 j = 0; j < group->filelist.CountItems(); j++) { SourceFile *file = group->filelist.ItemAt(j); fFileList.AddItem(new BString(file->GetPath().GetFullPath())); entry_ref partnerRef = GetPartnerRef(file->GetPath().GetRef()); if (partnerRef.name) { DPath partnerPath(partnerRef); fFileList.AddItem(new BString(partnerPath.GetFullPath())); } } } }
void ProjectWindow::ActOnSelectedFiles(const int32 &command) { SCMOutputWindow *win = NULL; switch (command) { case M_ADD_SELECTION_TO_REPO: { if (!fSourceControl) return; win = new SCMOutputWindow(TR("Add to Repository")); win->Show(); break; } case M_REMOVE_SELECTION_FROM_REPO: { if (!fSourceControl) return; win = new SCMOutputWindow(TR("Remove from Repository")); win->Show(); break; } case M_REVERT_SELECTION: { if (!fSourceControl) return; win = new SCMOutputWindow(TR("Revert")); win->Show(); break; } case M_DIFF_SELECTION: { if (!fSourceControl) return; win = new SCMOutputWindow(TR("Show Differences")); win->Show(); break; } default: break; } for (int32 i = 0; i < fProjectList->CountItems(); i++) { SourceFileItem *item = dynamic_cast<SourceFileItem*>(fProjectList->ItemAt(i)); if (item && item->IsSelected()) { SourceFile *file = item->GetData(); BString relPath = file->GetPath().GetFullPath(); if (relPath.FindFirst(fProject->GetPath().GetFolder()) == 0) { relPath.RemoveFirst(fProject->GetPath().GetFolder()); relPath.RemoveFirst("/"); } BString relPartnerPath; entry_ref partnerRef = GetPartnerRef(file->GetPath().GetRef()); if (partnerRef.name) { DPath partnerPath(partnerRef); relPartnerPath = partnerPath.GetFullPath(); if (relPartnerPath.FindFirst(fProject->GetPath().GetFolder()) == 0) { relPartnerPath.RemoveFirst(fProject->GetPath().GetFolder()); relPartnerPath.RemoveFirst("/"); } } switch (command) { case M_REBUILD_FILE: { if (file->UsesBuild()) { file->RemoveObjects(*fProject->GetBuildInfo()); item->SetDisplayState(SFITEM_NEEDS_BUILD); fProjectList->InvalidateItem(fProjectList->IndexOf(item)); } break; } case M_ADD_SELECTION_TO_REPO: { fSourceControl->AddToRepository(relPath.String()); if (relPartnerPath.CountChars() > 0) fSourceControl->AddToRepository(relPartnerPath.String()); break; } case M_REMOVE_SELECTION_FROM_REPO: { fSourceControl->RemoveFromRepository(relPath.String()); if (relPartnerPath.CountChars() > 0) fSourceControl->RemoveFromRepository(relPartnerPath.String()); break; } case M_REVERT_SELECTION: { fSourceControl->Revert(relPath.String()); break; } case M_DIFF_SELECTION: { fSourceControl->Diff(relPath.String()); break; } default: { return; } } } } }