Exemple #1
0
void
App::RefsReceived(BMessage *msg)
{
	entry_ref ref;
	int32 i = 0;
	while (msg->FindRef("refs",i,&ref) == B_OK)
	{
		bool isPaladin = Project::IsProject(ref);
		bool isBeIDE = IsBeIDEProject(ref);
		
		if (gBuildMode && isPaladin)
			BuildProject(ref);
		else
		if (isPaladin || isBeIDE)
			LoadProject(ref);
		else
			OpenFile(ref);
		i++;
	}
}
Exemple #2
0
void
App::LoadProject(const entry_ref &givenRef)
{
	if (!givenRef.name)
		return;
	
	entry_ref ref(givenRef);
	
	bool isBeIDE = IsBeIDEProject(ref);
	if (isBeIDE)
	{
		// We were given a BeIDE project, so we will see if it has already
		// been converted to a Paladin project. If it has, open the Paladin
		// project. If not, convert it and open it, if successful.
		DPath beidePath(ref);
		BString palPath = beidePath.GetFolder();
		palPath << "/" << beidePath.GetBaseName() << ".pld";
		BEntry entry(palPath.String());
		if (entry.Exists())
			entry.GetRef(&ref);
		else
		{
			if (BeIDE2Paladin(beidePath.GetFullPath(), palPath) == B_OK)
			{
				entry.SetTo(palPath.String());
				entry.GetRef(&ref);
			}
			else
				return;
		}
	}
		
	for (int32 i = 0; i < CountWindows(); i++)
	{
		ProjectWindow *win = dynamic_cast<ProjectWindow*>(WindowAt(i));
		if (!win)
			continue;
		Project *winProject = win->GetProject();
		if (!winProject)
			continue;
		BEntry entry(winProject->GetPath().GetFullPath());
		if (entry.InitCheck() != B_OK)
			continue;
		entry_ref projRef;
		entry.GetRef(&projRef);
		if (ref == projRef)
			return;
	}
	
	BPath path(&ref);
	Project *proj = new Project;
	
	if (proj->Load(path.Path()) != B_OK)
	{
		delete proj;
		return;
	}
	
	// This will be true only if the project file lacks an entry.
	if (proj->SourceControl() == SCM_INIT && !gBuildMode &&
		!proj->IsReadOnly())
	{
		// No given in the project. Attempt to detect one and if there isn't
		// any, see if the user would like to use the default SCM. At the same
		// time, if the user doesn't *want* to use source control, we won't
		// bother him.
		scm_t scm = DetectSCM(proj->GetPath().GetFolder());
		if (scm == SCM_NONE && gDefaultSCM != SCM_NONE)
		{
			BString scmMsg = B_TRANSLATE(
				"This project is not under source control. Would you "
				"like to use %sourcecontrol% for this project?\n"
				"You will only be asked this one time.");
			scmMsg.ReplaceFirst("%sourcecontrol%", SCM2LongName(gDefaultSCM));
			int32 result = ShowAlert(scmMsg.String(), B_TRANSLATE("No"), B_TRANSLATE("Yes"));
			if (result == 1)
				proj->SetSourceControl(gDefaultSCM);
		}
	}
	
	UpdateRecentItems(ref);
	
	gCurrentProject = proj;
	gProjectList->Lock();
	gProjectList->AddItem(proj);
	gProjectList->Unlock();
	
	BRect r(0,0,200,300);
	/*
	r.OffsetTo(gProjectWindowPoint);
	gProjectWindowPoint.x += 25;
	gProjectWindowPoint.y += 25;
	*/
	ProjectWindow *projwin = new ProjectWindow(r,gCurrentProject);
	projwin->Show();
	
	if (proj->IsReadOnly())
	{
		BString errmsg = B_TRANSLATE(
			"This project is on a read-only disk. You will not be able "
			"to build it, but you can still view its files and do anything "
			"else that does not require saving to the disk.");
		ShowAlert(errmsg.String());
	}
}