Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package org.nasdanika.html.app.viewparts;
import java.util.List;
import java.util.Map.Entry;
import java.util.function.Consumer;
import org.nasdanika.common.Context;
import org.nasdanika.common.ProgressMonitor;
import org.nasdanika.html.Event;
import org.nasdanika.html.Fragment;
import org.nasdanika.html.HTMLElement;
import org.nasdanika.html.Tag;
import org.nasdanika.html.app.Action;
import org.nasdanika.html.app.ActionActivator;
import org.nasdanika.html.app.Label;
import org.nasdanika.html.app.NavigationActionActivator;
import org.nasdanika.html.app.ScriptActionActivator;
import org.nasdanika.html.app.ViewGenerator;
import org.nasdanika.html.app.ViewPart;
import org.nasdanika.html.app.impl.Util;
import org.nasdanika.html.bootstrap.Breakpoint;
import org.nasdanika.html.bootstrap.Color;
import org.nasdanika.html.bootstrap.Dropdown;
import org.nasdanika.html.bootstrap.Navbar;
/**
* Builds a navigation bar from the principal action.
* Uses the action as a brand and its context children to build a navigation menu.
* @author Pavel
*
*/
public class NavigationBarViewPart implements ViewPart {
protected List>> categoryGroups;
protected Action activeAction;
protected ViewPart brandPart;
/**
* Builds a navigation bar view part from a list of actions and an active action.
* The actions are grouped into categories to build the navbar.
* This constructor creates a navBar without brand.
* @param actions
* @param activeAction
*/
public NavigationBarViewPart(List actions, Action activeAction) {
this.categoryGroups = Util.groupByCategory(actions);
this.activeAction = activeAction;
}
/**
* Builds a navigation bar with a brand for a principal action.
* @param principalAction
* @param activeAction
*/
public NavigationBarViewPart(Action principalAction, Action activeAction) {
this(principalAction.getContextChildren(), activeAction);
brandPart = (viewGenerator, progressMonitor) -> principalAction.getActivator() == null ? viewGenerator.label(principalAction) : viewGenerator.link(principalAction);
}
@SuppressWarnings("unchecked")
@Override
public Object generate(ViewGenerator viewGenerator, ProgressMonitor progressMonitor) {
Tag brand = brandPart == null ? null : (Tag) brandPart.generate(viewGenerator, progressMonitor);
Navbar navBar = createNavbar(viewGenerator, brand);
boolean hasContent = brand != null && !brand.isEmpty();
for (Entry