Package org.apache.myfaces.tobago.component

Examples of org.apache.myfaces.tobago.component.UIMenu


    // all: sub menu to select any tab directly
    final UICommand all = (UICommand) CreateComponentUtils.createComponent(
        facesContext, UICommand.COMPONENT_TYPE, null, viewRoot.createUniqueId());
    all.setOmit(true); // avoid submit

    final UIMenu menu = (UIMenu) CreateComponentUtils.createComponent(
        facesContext, UIMenu.COMPONENT_TYPE, RendererTypes.MENU, viewRoot.createUniqueId());
    menu.setTransient(true);
    ComponentUtils.addCurrentMarkup(menu, Markup.TOP);
    FacetUtils.setDropDownMenu(all, menu);
    int index = 0;
    for (final UIComponent child : tabGroup.getChildren()) {
      if (child instanceof UITab) {
        final UITab tab = (UITab) child;
        if (tab.isRendered()) {
          final UIMenuCommand entry = (UIMenuCommand) CreateComponentUtils.createComponent(
              facesContext, UIMenuCommand.COMPONENT_TYPE, RendererTypes.MENU_COMMAND, viewRoot.createUniqueId());
          entry.setTransient(true);
          entry.setOmit(true); // avoid submit
          final LabelWithAccessKey label = new LabelWithAccessKey(tab);
          if (label.getLabel() != null) {
            entry.setLabel(label.getLabel());
          } else {
            entry.setLabel(Integer.toString(index + 1));
          }
          if (tab.isDisabled()) {
            entry.setDisabled(true);
          } else {
            ComponentUtils.putDataAttribute(entry, "tobago-index", index); // XXX todo, define a DataAttribute
          }
          menu.getChildren().add(entry);
        }
        index++;
      }
    }
    final UIToolBar toolBar = (UIToolBar) application.createComponent(UIToolBar.COMPONENT_TYPE);
View Full Code Here


  @Override
  public void prepareRender(final FacesContext facesContext, final UIComponent component) throws IOException {
    super.prepareRender(facesContext, component);

    final UIMenu menu = (UIMenu) component;
    final boolean firstLevel = !RendererTypes.MENU.equals(menu.getParent().getRendererType());
    if (firstLevel) {
      ComponentUtils.addCurrentMarkup(menu, Markup.TOP);
    }
  }
View Full Code Here

  }

  @Override
  public void encodeBegin(final FacesContext facesContext, final UIComponent component) throws IOException {

    final UIMenu menu = (UIMenu) component;
    final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);

    final LabelWithAccessKey label = new LabelWithAccessKey(menu);
    final boolean disabled = menu.isDisabled();
    final boolean firstLevel = !RendererTypes.MENU.equals(menu.getParent().getRendererType());
    final boolean isParentMenu = menu.getChildCount() > 0; // todo: may be not correct

    writer.startElement(HtmlElements.LI, menu);
    writer.writeClassAttribute(Classes.create(menu));
    StringBuilder backgroundImage = null;
    StringBuilder backgroundPosition = null;
    if (menu.getImage() != null) {
      backgroundImage = new StringBuilder();
      backgroundPosition = new StringBuilder();

      backgroundImage.append("url('");
      backgroundImage.append(
          ResourceManagerUtils.getImageOrDisabledImageWithPath(facesContext, menu.getImage(), menu.isDisabled()));
      backgroundImage.append("')");
      backgroundPosition.append("left center");
    }
    if (isParentMenu && !firstLevel) {
      if (backgroundImage == null) {
        backgroundImage = new StringBuilder();
        backgroundPosition = new StringBuilder();
      } else {
        backgroundImage.append(",");
        backgroundPosition.append(",");
      }

      backgroundImage.append("url('");
      backgroundImage.append(
          ResourceManagerUtils.getImageOrDisabledImageWithPath(facesContext, "image/MenuArrow.gif", menu.isDisabled()));
      backgroundImage.append("')");
      backgroundPosition.append("right center");
    }
    if (backgroundImage != null) {
      final Style style = new Style();
View Full Code Here

  }

  @Override
  public void encodeEnd(final FacesContext facesContext, final UIComponent component) throws IOException {

    final UIMenu menu = (UIMenu) component;
    final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);

    final boolean isParentMenu = menu.getChildCount() > 0; // todo: may be not correct
    if (isParentMenu) {
      writer.endElement(HtmlElements.OL);
    }
    writer.endElement(HtmlElements.LI);
View Full Code Here

  private UIToolBar createToolBar(final FacesContext facesContext, final UISheet sheet) {
    final Application application = facesContext.getApplication();
    final UICommand dropDown = (UICommand) CreateComponentUtils.createComponent(
        facesContext, UICommand.COMPONENT_TYPE, null, "dropDown");
    final UIMenu menu = (UIMenu) CreateComponentUtils.createComponent(
        facesContext, UIMenu.COMPONENT_TYPE, RendererTypes.MENU, "menu");
    FacetUtils.setDropDownMenu(dropDown, menu);
    final String sheetId = sheet.getClientId(facesContext);

    createMenuItem(facesContext, menu, "sheetMenuSelect", Markup.SHEET_SELECT_ALL, sheetId);
View Full Code Here

  @Override
  public void prepareRender(FacesContext facesContext, UIComponent component) throws IOException {
    super.prepareRender(facesContext, component);

    final UIMenu menu = (UIMenu) component;
    final boolean firstLevel = !RendererTypes.MENU.equals(menu.getParent().getRendererType());
    if (firstLevel) {
      menu.setCurrentMarkup(menu.getCurrentMarkup().add(Markup.TOP));
    }
  }
View Full Code Here

  }

  @Override
  public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {

    final UIMenu menu = (UIMenu) component;
    TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);

    final boolean disabled = menu.isDisabled();
    final boolean firstLevel = !RendererTypes.MENU.equals(menu.getParent().getRendererType());
    final boolean isParentMenu = menu.getChildCount() > 0; // todo: may be not correct
    final String clientId = menu.getClientId(facesContext);

    writer.startElement(HtmlElements.LI, menu);
    writer.writeClassAttribute(Classes.create(menu, firstLevel ? Markup.TOP : null));
    writer.writeIdAttribute(clientId);
    if (menu.getImage() != null) {
      Style style = new Style();
      style.setBackgroundImage("url(" + menu.getImage() + ")");
      writer.writeStyleAttribute(style);
    }
    writer.startElement(HtmlElements.A, menu);
    writer.writeAttribute(HtmlAttributes.HREF, "#", false);
View Full Code Here

  }

  @Override
  public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {

    UIMenu menu = (UIMenu) component;
    TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);

    boolean isParentMenu = menu.getChildCount() > 0; // todo: may be not correct
    if (isParentMenu) {
      writer.endElement(HtmlElements.OL);
    }
    writer.endElement(HtmlElements.LI);
View Full Code Here

    writer.writeIdAttribute(column.getClientId(facesContext));
    writer.writeClassAttribute(Classes.create(sheet, "selectorMenu"));
    writer.endElement(HtmlElements.DIV);

    if (UISheet.MULTI.equals(sheet.getSelectable())) {
      UIMenu menu = (UIMenu) CreateComponentUtils.createComponent(
          facesContext, UIMenu.COMPONENT_TYPE, RendererTypes.MENU, "selectorMenu");
      menu.setTransient(true);
      FacetUtils.setDropDownMenu(column, menu);
      menu.setImage("image/sheetSelectorMenu.gif");
      menu.setLabel("vv"); //todo remove this after fixing the image above

      String sheetId = column.getParent().getClientId(facesContext);

      createMenuItem(facesContext, menu, "sheetMenuSelect",
          "Tobago.Sheets.get('" + sheetId + "').selectAll()", "t_selectAll");
View Full Code Here

  @Test
  public void testContextMenu() {
    UIPanel panel = new UIPanel();
    Assert.assertNull(FacetUtils.getContextMenu(panel));
    UIMenu menu = new UIMenu();
    FacetUtils.setContextMenu(panel, menu);
    Assert.assertEquals(menu, FacetUtils.getContextMenu(panel));
  }
View Full Code Here

TOP

Related Classes of org.apache.myfaces.tobago.component.UIMenu

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.