コード例 #1
0
ファイル: SCMImportWindow.cpp プロジェクト: jscipione/Paladin
SCMImportWindow::SCMImportWindow(void)
  :	DWindow(BRect(0,0,350,300), "Import from Repository")
{
	MakeCenteredOnShow(true);
	
	BView *top = GetBackgroundView();
	
	BMenu *menu = new BMenu("Providers");
	
	for (int32 i = 0; i < fProviderMgr.CountImporters(); i++)
	{
		SCMProjectImporter *importer = fProviderMgr.ImporterAt(i);
		if (!importer)
			continue;
		
		BMessage *msg = new BMessage(M_USE_PROVIDER);
		menu->AddItem(new BMenuItem(importer->GetName(), msg));
	}
	
	// Disable custom commands for now	
//	menu->AddSeparatorItem();
//	menu->AddItem(new BMenuItem("Custom", new BMessage(M_USE_CUSTOM_PROVIDER)));
	
	menu->SetLabelFromMarked(true);
	menu->ItemAt(0L)->SetMarked(true);
	
	BRect r(Bounds());
	r.InsetBy(10.0, 10.0);
	r.bottom = 40.0;
	fProviderField = new BMenuField(r, "repofield", "Provider: ", menu,
								B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	float pw, ph;
	fProviderField->GetPreferredSize(&pw, &ph);
	fProviderField->ResizeTo(r.Width(), ph);
	top->AddChild(fProviderField);
	r = fProviderField->Frame();
	
	menu = new BMenu("Methods");
	if (gHgAvailable)
		menu->AddItem(new BMenuItem("Mercurial", new BMessage(M_UPDATE_COMMAND)));
	
	if (gGitAvailable)
		menu->AddItem(new BMenuItem("Git", new BMessage(M_UPDATE_COMMAND)));
	
	if (gSvnAvailable)
		menu->AddItem(new BMenuItem("Subversion", new BMessage(M_UPDATE_COMMAND)));
	menu->SetLabelFromMarked(true);
	menu->ItemAt(0L)->SetMarked(true);
	fProvider = fProviderMgr.ImporterAt(0);
		
	r.OffsetBy(0.0, r.Height() + 10.0);
	fSCMField = new BMenuField(r, "scmfield", "Method: ", menu,
								B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	top->AddChild(fSCMField);
		
	r.OffsetBy(0.0, r.Height() + 10.0);
	fProjectBox = new AutoTextControl(r, "project", "Project: ", "",
									new BMessage(M_UPDATE_COMMAND),
									B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	fProjectBox->GetPreferredSize(&pw, &ph);
	fProjectBox->ResizeTo(r.Width(), ph);
	r = fProjectBox->Frame();
	top->AddChild(fProjectBox);
	
	r.OffsetBy(0.0, r.Height() + 10.0);
	fAnonymousBox = new BCheckBox(r, "anonymous", "Anonymous check-out",
									new BMessage(M_TOGGLE_ANONYMOUS));
	top->AddChild(fAnonymousBox);
	fAnonymousBox->ResizeToPreferred();
	fAnonymousBox->SetValue(B_CONTROL_ON);
	
	r.OffsetBy(0.0, fAnonymousBox->Bounds().Height() + 10.0);
	fUserNameBox = new AutoTextControl(r, "username", "Username: "******"",
									new BMessage(M_UPDATE_COMMAND),
									B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	top->AddChild(fUserNameBox);
	fUserNameBox->SetEnabled(false);
	
	r.OffsetBy(0.0, r.Height() + 10.0);
	fRepository = new AutoTextControl(r, "repository", "Repository (opt.): ", "",
									new BMessage(M_UPDATE_COMMAND),
									B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	fRepository->GetPreferredSize(&pw, &ph);
	fRepository->ResizeTo(r.Width(), ph);
	r = fRepository->Frame();
	top->AddChild(fRepository);
	
	r.OffsetBy(0.0, r.Height() + 10.0);
	fCommandLabel = new BStringView(r, "commandlabel", "Command: ",
									B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	fCommandLabel->ResizeToPreferred();
	top->AddChild(fCommandLabel);
	
	r.OffsetBy(0.0, fCommandLabel->Bounds().Height() + 5.0);
	r.bottom = r.top + 75.0;
	r.right -= B_V_SCROLL_BAR_WIDTH;
	BRect textRect = r.OffsetToCopy(0.0, 0.0).InsetByCopy(10.0, 10.0);
	fCommandView = new BTextView(r, "command", textRect, B_FOLLOW_ALL);
	
	BScrollView *scroll = new BScrollView("scrollview", fCommandView,
											B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,
											0, false, true);
	top->AddChild(scroll);
	fCommandView->MakeEditable(false);
	
	fOK = new BButton(r, "ok", "Import", new BMessage(M_SCM_IMPORT),
					B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	fOK->ResizeToPreferred();
	fOK->MoveTo(Bounds().right - 10.0 - fOK->Bounds().Width(),
				scroll->Frame().bottom + 10.0);
	
	ResizeTo(Bounds().Width(),  fOK->Frame().bottom + 10.0);
	scroll->SetResizingMode(B_FOLLOW_ALL);
	
	top->AddChild(fOK);
	fOK->MakeDefault(true);
	fOK->SetEnabled(false);
	
	UpdateCommand();
	fProviderField->MakeFocus(true);
}
コード例 #2
0
SCMImportWindow::SCMImportWindow(void)
  :	DWindow(BRect(0,0,350,350), B_TRANSLATE("Import from repository"))
{
	MakeCenteredOnShow(true);
	
	BMenu *menu = new BMenu(B_TRANSLATE("Providers"));
	
	for (int32 i = 0; i < fProviderMgr.CountImporters(); i++)
	{
		SCMProjectImporter *importer = fProviderMgr.ImporterAt(i);
		if (!importer)
			continue;
		
		BMessage *msg = new BMessage(M_USE_PROVIDER);
		menu->AddItem(new BMenuItem(importer->GetName(), msg));
	}
	
	// Disable custom commands for now	
//	menu->AddSeparatorItem();
//	menu->AddItem(new BMenuItem("Custom", new BMessage(M_USE_CUSTOM_PROVIDER)));
	
	menu->SetLabelFromMarked(true);
	menu->ItemAt(0L)->SetMarked(true);
	
	fProviderField = new BMenuField("repofield", B_TRANSLATE("Provider:"), menu);
	
	menu = new BMenu(B_TRANSLATE("Methods"));
	if (gHgAvailable)
		menu->AddItem(new BMenuItem(B_TRANSLATE("Mercurial"), new BMessage(M_UPDATE_COMMAND)));
	
	if (gGitAvailable)
		menu->AddItem(new BMenuItem(B_TRANSLATE("Git"), new BMessage(M_UPDATE_COMMAND)));
	
	if (gSvnAvailable)
		menu->AddItem(new BMenuItem(B_TRANSLATE("Subversion"), new BMessage(M_UPDATE_COMMAND)));
	menu->SetLabelFromMarked(true);
	menu->ItemAt(0L)->SetMarked(true);
	fProvider = fProviderMgr.ImporterAt(0);
		
	fSCMField = new BMenuField("scmfield", B_TRANSLATE("Method:"), menu);
		
	fProjectBox = new AutoTextControl("project", B_TRANSLATE("Project:"), "",
									new BMessage(M_UPDATE_COMMAND));
	
	fAnonymousBox = new BCheckBox("anonymous", B_TRANSLATE("Anonymous check-out"),
									new BMessage(M_TOGGLE_ANONYMOUS));
	fAnonymousBox->SetValue(B_CONTROL_ON);
	
	fUserNameBox = new AutoTextControl("username", B_TRANSLATE("Username:"******"",
									new BMessage(M_UPDATE_COMMAND));
	fUserNameBox->SetEnabled(false);
	
	fRepository = new AutoTextControl("repository", B_TRANSLATE("Repository owner:"), "",
									new BMessage(M_UPDATE_COMMAND));	
	
	fCommandLabel = new BStringView("commandlabel", B_TRANSLATE("Command:"));	
	fCommandView = new BTextView("command");
	
	BScrollView *scroll = new BScrollView("scrollview", fCommandView,
											0, false, true);
	fCommandView->MakeEditable(false);
	
	fOK = new BButton("ok", B_TRANSLATE("Import"), new BMessage(M_SCM_IMPORT));
	
	BLayoutBuilder::Group<>(this, B_VERTICAL)
		.SetInsets(10)
		.Add(fProviderField)
		.Add(fSCMField)
		.Add(fRepository)
		.Add(fProjectBox)
		.Add(fAnonymousBox)
		.Add(fUserNameBox)
		.Add(fCommandLabel)
		.Add(scroll)
		.Add(fOK)
	.End();
		
	fOK->MakeDefault(true);
	fOK->SetEnabled(false);
	
	UpdateCommand();
	fProviderField->MakeFocus(true);
	
}