Java Code Examples for org.apache.wicket.markup.html.link.BookmarkablePageLink#add()

The following examples show how to use org.apache.wicket.markup.html.link.BookmarkablePageLink#add() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LogoutPanel.java    From webanno with Apache License 2.0 6 votes vote down vote up
public LogoutPanel(String id)
{
    super(id);
    
    add(new StatelessLink<Void>("logout")
    {
        private static final long serialVersionUID = -4031945370627254798L;

        @Override
        public void onClick()
        {
            AuthenticatedWebSession.get().signOut();
            getSession().invalidate();
            setResponsePage(getApplication().getHomePage());
        }
    });
    
    String username = Optional.ofNullable(userRepository.getCurrentUser())
            .map(User::getUsername).orElse("");
    BookmarkablePageLink<Void> profileLink = new BookmarkablePageLink<>("profile",
            ManageUsersPage.class, new PageParameters().add(
                    ManageUsersPage.PARAM_USER, username));
    profileLink.add(enabledWhen(SecurityUtil::isProfileSelfServiceAllowed));
    profileLink.add(visibleWhen(() -> isNotBlank(username)));
    profileLink.add(new Label("username", username));
    add(profileLink);
    
    WebMarkupContainer logoutTimer = new WebMarkupContainer("logoutTimer");
    logoutTimer.add(visibleWhen(() -> getAutoLogoutTime() > 0));
    add(logoutTimer);
}
 
Example 2
Source File: NavigationPanel.java    From the-app with Apache License 2.0 5 votes vote down vote up
private Component homePageLink() {
    BookmarkablePageLink<Void> pageLink = new BookmarkablePageLink<>("home", ShopApplication.get().getHomePage());
    pageLink.add(new AttributeAppender("class", Model.of("homePageLink"), " "));
    if (((ShopSession) ShopSession.get()).isMicroServiceMode()) {
        return new ExternalLink("home", "http://shop.microservice.io");
    }
    return pageLink;
}
 
Example 3
Source File: MenuItem.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public MenuItem(String id, IModel itemText, Class itemPageClass, PageParameters pageParameters, boolean first, Class menusCurrentPageClass) {
	super(id);

	boolean currentPage = itemPageClass.equals(menusCurrentPageClass);

	// link version
	menuItemLinkHolder = new WebMarkupContainer("menuItemLinkHolder");
	menuItemLink = new BookmarkablePageLink("menuItemLink", itemPageClass, pageParameters);
	menuLinkText = new Label("menuLinkText", itemText);
	menuLinkText.setRenderBodyOnly(true);
	menuItemLink.add(menuLinkText);
	menuItemLinkHolder.add(menuItemLink);
	menuItemLinkHolder.setVisible(!currentPage);
	add(menuItemLinkHolder);

	// span version
	menuItemLabel = new Label("menuItemLabel", itemText);
	menuItemLabel.setVisible(currentPage);
	add(menuItemLabel);
	
	//add current page styling
	AttributeModifier currentPageStyling = new AttributeModifier("class", new Model("current"));
	if(currentPage) {
		menuItemLabel.add(currentPageStyling);
	}

	if(first) {
		add(new AttributeModifier("class", new Model("firstToolBarItem")));
	}
}
 
Example 4
Source File: SiteLinkPanel.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public SiteLinkPanel(String id, IModel model) {
	super(id);
	final String siteId = ((Site) model.getObject()).getId();
	final String siteTitle = ((Site) model.getObject()).getTitle();
	PageParameters param = new PageParameters().set("siteId", siteId);
	BookmarkablePageLink link = new BookmarkablePageLink("link", OverviewPage.class, param);
	link.add(new Label("label", siteTitle));
	add(link);
}
 
Example 5
Source File: MenuPanel.java    From ontopia with Apache License 2.0 5 votes vote down vote up
public MenuPanel(String id, List<MenuItem> menuItemList, final int selectedMenuItemIndex) {
  super(id);

  ListView<MenuItem> menuItems = new ListView<MenuItem>("menuItems", menuItemList) {
    int counter = 0;

    @Override
    protected void populateItem(ListItem<MenuItem> item) {
      MenuItem menuItem = item.getModelObject();
      BookmarkablePageLink<Page> link = new BookmarkablePageLink<Page>("menuItemLink",
          menuItem.getPageClass(), menuItem.getPageParameters());
      link.add(menuItem.getCaption());
      item.add(link);

      if (counter == selectedMenuItemIndex) {
        if (counter > 0)          
          item.add(new SimpleAttributeModifier("class", "delimiter selected"));
        else
          item.add(new SimpleAttributeModifier("class", "selected"));
      } else {
        if (counter > 0)
          item.add(new SimpleAttributeModifier("class", "delimiter"));          
      }
      counter++;
    }
  };
  add(menuItems);
}
 
Example 6
Source File: NavigationPanel.java    From AppStash with Apache License 2.0 5 votes vote down vote up
private Component homePageLink() {
    BookmarkablePageLink<Void> pageLink = new BookmarkablePageLink<>("home", ShopApplication.get().getHomePage());
    pageLink.add(new AttributeAppender("class", Model.of("homePageLink"), " "));
    if (((ShopSession) ShopSession.get()).isMicroServiceMode()) {
        return new ExternalLink("home", "http://shop.microservice.io");
    }
    return pageLink;
}
 
Example 7
Source File: MenuItem.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public MenuItem(String id, IModel itemText, Class itemPageClass, PageParameters pageParameters, boolean first, Class menusCurrentPageClass) {
	super(id);

	boolean currentPage = itemPageClass.equals(menusCurrentPageClass);

	// link version
	menuItemLinkHolder = new WebMarkupContainer("menuItemLinkHolder");
	menuItemLink = new BookmarkablePageLink("menuItemLink", itemPageClass, pageParameters);
	menuLinkText = new Label("menuLinkText", itemText);
	menuLinkText.setRenderBodyOnly(true);
	menuItemLink.add(menuLinkText);
	menuItemLinkHolder.add(menuItemLink);
	menuItemLinkHolder.setVisible(!currentPage);
	add(menuItemLinkHolder);

	// span version
	menuItemLabel = new Label("menuItemLabel", itemText);
	menuItemLabel.setVisible(currentPage);
	add(menuItemLabel);
	
	//add current page styling
	AttributeModifier currentPageStyling = new AttributeModifier("class", new Model("current"));
	if(currentPage) {
		menuItemLabel.add(currentPageStyling);
	}

	if(first) {
		add(new AttributeModifier("class", new Model("firstToolBarItem")));
	}
}
 
Example 8
Source File: SiteLinkPanel.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public SiteLinkPanel(String id, IModel model) {
	super(id);
	final String siteId = ((Site) model.getObject()).getId();
	final String siteTitle = ((Site) model.getObject()).getTitle();
	PageParameters param = new PageParameters().set("siteId", siteId);
	BookmarkablePageLink link = new BookmarkablePageLink("link", OverviewPage.class, param);
	link.add(new Label("label", siteTitle));
	add(link);
}
 
Example 9
Source File: JQueryButtonPanel.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onBeforeRender()
{
  if (initialized == false) {
    initialized = true;
    final BookmarkablePageLink<String> link;
    if (params == null) {
      link = new BookmarkablePageLink<String>("button", pageClass);
    } else {
      link = new BookmarkablePageLink<String>("button", pageClass, params);
    }
    if (type != null) {
      link.add(AttributeModifier.replace("data-icon", type.getCssId()));
    }
    add(link);
    if (label != null) {
      link.add(new Label("label", label));
    } else {
      link.add(WicketUtils.getInvisibleComponent("label"));
    }
    if (this.relExternal == true) {
      link.add(AttributeModifier.replace("rel", "external"));
    }
    if (this.relDialog == true) {
      link.add(AttributeModifier.replace("data-rel", "dialog"));
    }
    if (this.noText == true) {
      link.add(AttributeModifier.replace("data-iconpos", "notext"));
    }
    //      if (alignment == Alignment.LEFT) {
    //        link.add(AttributeModifier.add("class", "ui-btn-left"));
    //      }
  }
  super.onBeforeRender();
}
 
Example 10
Source File: ProjectsOverviewPage.java    From inception with Apache License 2.0 4 votes vote down vote up
private WebMarkupContainer createProjectList()
{
    ListView<Project> listview = new ListView<Project>(MID_PROJECT,
            LoadableDetachableModel.of(this::listProjects))
    {
        private static final long serialVersionUID = -755155675319764642L;

        @Override
        protected void populateItem(ListItem<Project> aItem)
        {
            PageParameters pageParameters = new PageParameters().add(
                    ProjectDashboardPage.PAGE_PARAM_PROJECT_ID, aItem.getModelObject().getId());
            BookmarkablePageLink<Void> projectLink = new BookmarkablePageLink<>(
                    MID_PROJECT_LINK, ProjectDashboardPage.class, pageParameters);
            projectLink.add(new Label(MID_NAME, aItem.getModelObject().getName()));
            DateLabel createdLabel = DateLabel.forDatePattern(MID_CREATED,
                () -> aItem.getModelObject().getCreated(), "yyyy-MM-dd");
            addActionsDropdown(aItem);
            aItem.add(projectLink);
            createdLabel.add(visibleWhen(() -> createdLabel.getModelObject() != null));
            aItem.add(createdLabel);
            aItem.add(createRoleBadges(aItem.getModelObject()));
        }

        @Override
        protected void onConfigure()
        {
            super.onConfigure();

            if (getModelObject().isEmpty()) {
                warn("There are no projects accessible to you matching the filter criteria.");
                emptyListLabel.setVisible(true);
            }
            else {
                emptyListLabel.setVisible(false);
            }
        }
    };
    
    WebMarkupContainer projectList = new WebMarkupContainer(MID_PROJECTS);
    projectList.setOutputMarkupPlaceholderTag(true);
    projectList.add(listview);
    
    return projectList;
}