use of com.revolsys.ui.model.Menu in project com.revolsys.open by revolsys.
the class MenuViewController method bootstrapMenu.
private void bootstrapMenu(final XmlWriter writer, final Collection<Menu> items, final int level, final JexlContext jexlContext) {
if (items.size() > 0) {
for (final Menu menu : items) {
if (menu.isVisible()) {
final List<Menu> menus = menu.getMenus();
if (menus.isEmpty()) {
writer.startTag(HtmlElem.LI);
final String cssClass = menu.getCssClass();
if (cssClass != null) {
writer.attribute(HtmlAttr.CLASS, cssClass);
}
bootStrapMenuLink(writer, menu, jexlContext);
writer.endTag(HtmlElem.LI);
} else {
BootstrapUtil.navbarDropdownStart(writer, menu);
bootstrapMenu(writer, menus, level + 1, jexlContext);
BootstrapUtil.navbarDropdownEnd(writer);
}
}
}
}
}
use of com.revolsys.ui.model.Menu in project com.revolsys.open by revolsys.
the class MenuViewController method bootstrapNavbar.
private void bootstrapNavbar(final HttpServletRequest request, final HttpServletResponse response, final Navbar navBar) throws IOException {
if (navBar != null) {
try (final OutputStream out = response.getOutputStream();
XmlWriter writer = new XmlWriter(out, false)) {
writer.setIndent(false);
final JexlHttpServletRequestContext jexlContext = new JexlHttpServletRequestContext(request);
final List<Menu> menus = new ArrayList<>();
for (final Menu menuItem : navBar.getMenus()) {
if (menuItem.isVisible()) {
menus.add(menuItem);
}
}
final String title = navBar.getTitle();
if (Property.hasValue(title) || !menus.isEmpty()) {
BootstrapUtil.navbarStart(writer, navBar, jexlContext);
bootstrapMenu(writer, menus, 1, jexlContext);
BootstrapUtil.navbarEnd(writer);
}
writer.flush();
}
}
}
use of com.revolsys.ui.model.Menu in project com.revolsys.open by revolsys.
the class DisplayConfigAction method addSiteNode.
private void addSiteNode(final ElementContainer view, final SiteNode siteNode) {
if (siteNode != null) {
final ElementContainer nodeView = new ElementContainer();
view.add(nodeView);
final String path = siteNode.getPath();
if (path == null) {
nodeView.add(new XmlTagElement(HtmlElem.H4, "/"));
} else {
nodeView.add(new XmlTagElement(HtmlElem.H4, path));
}
final SiteNodeController controller = siteNode.getController();
if (controller instanceof PageController) {
final PageController pageController = (PageController) controller;
final ElementContainer pageView = new ElementContainer(new DefinitionListLayout());
nodeView.add(pageView);
pageView.add("Actions");
final ElementContainer actionsView = new ElementContainer(new UnorderedListLayout());
pageView.add(actionsView);
for (final Iterator actions = pageController.getActions().iterator(); actions.hasNext(); ) {
final Action action = (Action) actions.next();
actionsView.add(action.getClass().getName());
}
pageView.add("Menus");
final ElementContainer menusView = new ElementContainer(new UnorderedListLayout());
pageView.add(menusView);
for (final Iterator menus = pageController.getMenus().entrySet().iterator(); menus.hasNext(); ) {
final Map.Entry entry = (Entry) menus.next();
final String name = (String) entry.getKey();
final Menu menu = (Menu) entry.getValue();
addMenu(menusView, name, menu);
}
}
final Collection nodes = siteNode.getNodes();
if (!nodes.isEmpty()) {
final ElementContainer childNodesView = new ElementContainer(new UnorderedListLayout());
nodeView.add(childNodesView);
for (final Iterator nodeIter = nodes.iterator(); nodeIter.hasNext(); ) {
final SiteNode childNode = (SiteNode) nodeIter.next();
addSiteNode(childNodesView, childNode);
}
}
}
}
use of com.revolsys.ui.model.Menu in project com.revolsys.open by revolsys.
the class MenuElement method menu.
private void menu(final XmlWriter out, final Collection<Menu> items, final int level) {
if (items.size() > 0) {
out.startTag(HtmlElem.UL);
for (final Menu menu : items) {
if (menu.isVisible()) {
out.startTag(HtmlElem.LI);
final String cssClass = menu.getCssClass();
if (cssClass != null) {
out.attribute(HtmlAttr.CLASS, cssClass);
}
menuLink(out, menu);
if (level < this.numLevels) {
menu(out, menu.getMenus(), level + 1);
}
out.endTag(HtmlElem.LI);
}
}
out.endTag(HtmlElem.UL);
}
}
use of com.revolsys.ui.model.Menu in project com.revolsys.open by revolsys.
the class HtmlUiBuilder method newObjectAddPage.
public Element newObjectAddPage(final Map<String, Object> defaultValues, final String prefix, final String preInsertMethod) throws IOException, ServletException {
final T object = newObject();
final HttpServletRequest request = HttpServletUtils.getRequest();
Property.set(object, defaultValues);
// if (!canAddObject(request)) {
// response.sendError(HttpServletResponse.SC_FORBIDDEN,
// "No permission to edit " + getTypeName() + " #" + getId());
// return null;
// }
final Map<String, Object> parameters = new HashMap<>();
final String pageName = getName(prefix, "add");
final Set<String> parameterNamesToSave = new HashSet<>();
final Form form = newTableForm(object, pageName);
for (final String param : parameterNamesToSave) {
form.addSavedParameter(param, request.getParameter(param));
}
form.initialize(request);
if (form.isPosted() && form.isMainFormTask()) {
if (form.isValid()) {
if ((Boolean) JavaBeanUtil.method(this, preInsertMethod, form, object)) {
insertObject(object);
parameters.put("message", "Saved");
final Object id = Property.get(object, getIdPropertyName());
parameters.put(getIdParameterName(), id);
postInsert(object);
final String viewName = getName(prefix, "view");
final String url = getPageUrl(viewName, parameters);
redirectAfterCommit(url);
return new TabElementContainer();
}
}
}
final Page page = getPage(pageName);
final String title = page.getExpandedTitle();
request.setAttribute("title", title);
final Menu actionMenu = new Menu();
addMenuItem(actionMenu, prefix, "list", "Cancel", "_top").addProperty("buttonClass", "btn-danger");
addMenuItem(actionMenu, prefix, "add", "Clear Fields").addProperty("buttonClass", "btn-warning");
final String name = form.getName();
final Menu saveMenu = new Menu("Save", "javascript:$('#" + name + "').submit()");
saveMenu.addProperty("buttonClass", "btn-primary");
actionMenu.addMenuItem(saveMenu);
final ButtonsToolbarElement buttonsToolbar = new ButtonsToolbarElement(actionMenu);
final ElementContainer view = new ElementContainer(form, buttonsToolbar);
final TabElementContainer tabs = new TabElementContainer();
tabs.add(title, view);
return tabs;
}
Aggregations