当前位置: 首页>>代码示例>>Java>>正文


Java NavigationPanel类代码示例

本文整理汇总了Java中com.gitblit.wicket.panels.NavigationPanel的典型用法代码示例。如果您正苦于以下问题:Java NavigationPanel类的具体用法?Java NavigationPanel怎么用?Java NavigationPanel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NavigationPanel类属于com.gitblit.wicket.panels包,在下文中一共展示了NavigationPanel类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupPage

import com.gitblit.wicket.panels.NavigationPanel; //导入依赖的package包/类
@Override
protected void setupPage(String repositoryName, String pageName) {
	boolean authenticateView = GitBlit.getBoolean(Keys.web.authenticateViewPages, false);
	boolean authenticateAdmin = GitBlit.getBoolean(Keys.web.authenticateAdminPages, true);
	boolean allowAdmin = GitBlit.getBoolean(Keys.web.allowAdministration, true);

	if (authenticateAdmin) {
		showAdmin = allowAdmin && GitBlitWebSession.get().canAdmin();
		// authentication requires state and session
		setStatelessHint(false);
	} else {
		showAdmin = allowAdmin;
		if (authenticateView) {
			// authentication requires state and session
			setStatelessHint(false);
		} else {
			// no authentication required, no state and no session required
			setStatelessHint(true);
		}
	}
	
	if (authenticateView || authenticateAdmin) {
		if (GitBlitWebSession.get().isLoggedIn()) {
			UserMenu userFragment = new UserMenu("userPanel", "userMenuFragment", RootPage.this);
			add(userFragment);
		} else {
			LoginForm loginForm = new LoginForm("userPanel", "loginFormFragment", RootPage.this);
			add(loginForm);
		}
	} else {
		add(new Label("userPanel").setVisible(false));
	}
	
	boolean showRegistrations = GitBlit.canFederate()
			&& GitBlit.getBoolean(Keys.web.showFederationRegistrations, false);

	// navigation links
	List<PageRegistration> pages = new ArrayList<PageRegistration>();
	if (!authenticateView || (authenticateView && GitBlitWebSession.get().isLoggedIn())) {
		pages.add(new PageRegistration(GitBlitWebSession.get().isLoggedIn() ? "gb.myDashboard" : "gb.dashboard", DashboardPage.class,
				getRootPageParameters()));
		pages.add(new PageRegistration("gb.repositories", RepositoriesPage.class,
				getRootPageParameters()));
		pages.add(new PageRegistration("gb.activity", ActivityPage.class, getRootPageParameters()));
		if (GitBlit.getBoolean(Keys.web.allowLuceneIndexing, true)) {
			pages.add(new PageRegistration("gb.search", LuceneSearchPage.class));
		}
		if (showAdmin) {
			pages.add(new PageRegistration("gb.users", UsersPage.class));
		}
		if (showAdmin || showRegistrations) {
			pages.add(new PageRegistration("gb.federation", FederationPage.class));
		}

		if (!authenticateView || (authenticateView && GitBlitWebSession.get().isLoggedIn())) {
			addDropDownMenus(pages);
		}
	}
	
	NavigationPanel navPanel = new NavigationPanel("navPanel", getRootNavPageClass(), pages);
	add(navPanel);

	// display an error message cached from a redirect
	String cachedMessage = GitBlitWebSession.get().clearErrorMessage();
	if (!StringUtils.isEmpty(cachedMessage)) {
		error(cachedMessage);
	} else if (showAdmin) {
		int pendingProposals = GitBlit.self().getPendingFederationProposals().size();
		if (pendingProposals == 1) {
			info(getString("gb.OneProposalToReview"));
		} else if (pendingProposals > 1) {
			info(MessageFormat.format(getString("gb.nFederationProposalsToReview"),
					pendingProposals));
		}
	}

	super.setupPage(repositoryName, pageName);
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:79,代码来源:RootPage.java

示例2: RepositoryPage

import com.gitblit.wicket.panels.NavigationPanel; //导入依赖的package包/类
public RepositoryPage(PageParameters params) {
	super(params);
	repositoryName = WicketUtils.getRepositoryName(params);
	String root =StringUtils.getFirstPathElement(repositoryName);
	if (StringUtils.isEmpty(root)) {
		projectName = GitBlit.getString(Keys.web.repositoryRootGroupName, "main");
	} else {
		projectName = root;
	}
	objectId = WicketUtils.getObject(params);
	
	if (StringUtils.isEmpty(repositoryName)) {
		error(MessageFormat.format(getString("gb.repositoryNotSpecifiedFor"), getPageName()), true);
	}

	if (!getRepositoryModel().hasCommits) {
		setResponsePage(EmptyRepositoryPage.class, params);
	}
	
	if (getRepositoryModel().isCollectingGarbage) {
		error(MessageFormat.format(getString("gb.busyCollectingGarbage"), getRepositoryModel().name), true);
	}

	if (objectId != null) {
		RefModel branch = null;
		if ((branch = JGitUtils.getBranch(getRepository(), objectId)) != null) {
			UserModel user = GitBlitWebSession.get().getUser();
			if (user == null) {
				// workaround until get().getUser() is reviewed throughout the app
				user = UserModel.ANONYMOUS;
			}
			boolean canAccess = user.canView(getRepositoryModel(),
							branch.reference.getName());
			if (!canAccess) {
				error(getString("gb.accessDenied"), true);
			}
		}
	}

	// register the available page links for this page and user
	registeredPages = registerPages();

	// standard page links
	List<PageRegistration> pages = new ArrayList<PageRegistration>(registeredPages.values());
	NavigationPanel navigationPanel = new NavigationPanel("navPanel", getClass(), pages);
	add(navigationPanel);

	add(new ExternalLink("syndication", SyndicationServlet.asLink(getRequest()
			.getRelativePathPrefixToContextRoot(), repositoryName, null, 0)));

	// add floating search form
	SearchForm searchForm = new SearchForm("searchForm", repositoryName);
	add(searchForm);
	searchForm.setTranslatedAttributes();

	// set stateless page preference
	setStatelessHint(true);
}
 
开发者ID:BullShark,项目名称:IRCBlit,代码行数:59,代码来源:RepositoryPage.java


注:本文中的com.gitblit.wicket.panels.NavigationPanel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。