Examples of LabelWithAccessKey


Examples of org.apache.myfaces.tobago.renderkit.LabelWithAccessKey

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

    final UIButton button = (UIButton) component;
    final String clientId = button.getClientId(facesContext);
    final boolean disabled = button.isDisabled();
    final LabelWithAccessKey label = new LabelWithAccessKey(button);

    final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);

    writer.startElement(HtmlElements.BUTTON, button);
    writer.writeAttribute(HtmlAttributes.TYPE, HtmlButtonTypes.BUTTON, false);
    writer.writeNameAttribute(clientId);
    writer.writeIdAttribute(clientId);
    HtmlRendererUtils.writeDataAttributes(facesContext, writer, button);
    HtmlRendererUtils.renderTip(button, writer);
    writer.writeAttribute(HtmlAttributes.DISABLED, disabled);

    if (!disabled) {
      final CommandMap map = new CommandMap(new Command(facesContext, button));
      writer.writeAttribute(DataAttributes.COMMANDS, JsonUtils.encode(map), true);

      writer.writeAttribute(HtmlAttributes.HREF, "#", false);

      if (label.getAccessKey() != null) {
        writer.writeAttribute(HtmlAttributes.ACCESSKEY, Character.toString(label.getAccessKey()), false);
      }

      final Integer tabIndex = button.getTabIndex();
      if (tabIndex != null) {
        writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
      }
    }

    Style style = new Style(facesContext, button);
    writer.writeStyleAttribute(style);
    HtmlRendererUtils.renderDojoDndItem(component, writer, true);
    writer.writeClassAttribute(Classes.create(button));
    if (((UIButton) component).isDefaultCommand()) {
      final AbstractUIForm form = ComponentUtils.findAncestor(component, AbstractUIForm.class);
      writer.writeAttribute(DataAttributes.DEFAULT, form.getClientId(facesContext), false);
    }
    writer.flush(); // force closing the start tag

    String image = (String) button.getAttributes().get(Attributes.IMAGE);
    if (image != null) {
      if (ResourceManagerUtils.isAbsoluteResource(image)) {
        // absolute Path to image : nothing to do
      } else {
        image = getImageWithPath(facesContext, image, disabled);
      }
      writer.startElement(HtmlElements.IMG, null);
      writer.writeAttribute(HtmlAttributes.SRC, image, true);
      String tip = button.getTip();
      writer.writeAttribute(HtmlAttributes.ALT, tip != null ? tip : "", true);
      writer.endElement(HtmlElements.IMG);
    }

    if (label.getText() != null) {
      writer.startElement(HtmlElements.SPAN, null);
      HtmlRendererUtils.writeLabelWithAccessKey(writer, label);
      writer.endElement(HtmlElements.SPAN);
    }

    writer.endElement(HtmlElements.BUTTON);
    if (label.getAccessKey() != null) {
      if (LOG.isInfoEnabled()
          && !AccessKeyMap.addAccessKey(facesContext, label.getAccessKey())) {
        LOG.info("duplicated accessKey : " + label.getAccessKey());
      }
      HtmlRendererUtils.addClickAcceleratorKey(
          facesContext, button.getClientId(facesContext), label.getAccessKey());
    }
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.renderkit.LabelWithAccessKey

    Measure width = Measure.ZERO;
    boolean image = button.getImage() != null;
    if (image) {
      width = getResourceManager().getThemeMeasure(facesContext, button, "imageWidth");
    }
    LabelWithAccessKey label = new LabelWithAccessKey(button);

    width = width.add(RenderUtils.calculateStringWidth(facesContext, button, label.getText()));
    Measure padding = getResourceManager().getThemeMeasure(facesContext, button, "paddingWidth");
    // left padding, right padding and when an image and an text then a middle padding.
    width = width.add(padding.multiply(image && label.getText() != null ? 3 : 2));

    return width;
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.renderkit.LabelWithAccessKey

   * Can be overwritten in other themes.
   */
  protected void encodeTextContent(FacesContext facesContext, TobagoResponseWriter writer, UILabel label)
      throws IOException {
    String clientId = label.getClientId(facesContext);
    LabelWithAccessKey key = new LabelWithAccessKey(label);
    if (key.getAccessKey() != null) {
      writer.writeAttribute(HtmlAttributes.ACCESSKEY, Character.toString(key.getAccessKey()), false);
    }
    if (key.getText() != null) {
      HtmlRendererUtils.writeLabelWithAccessKey(writer, key);
    }
    if (key.getAccessKey() != null) {
      if (LOG.isInfoEnabled()
          && !AccessKeyMap.addAccessKey(facesContext, key.getAccessKey())) {
        LOG.info("Duplicated accessKey : " + key.getAccessKey());
      }
      HtmlRendererUtils.addClickAcceleratorKey(facesContext, clientId, key.getAccessKey());
    }
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.renderkit.LabelWithAccessKey

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

    final UITreeCommand command = (UITreeCommand) component;
    final String clientId = command.getClientId(facesContext);
    final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
    final LabelWithAccessKey label = new LabelWithAccessKey(command);

    if (command.isDisabled()) {
      writer.startElement(HtmlElements.SPAN, command);
    } else {
      writer.startElement(HtmlElements.A, command);
      final CommandMap map = new CommandMap(new Command(facesContext, command));
      writer.writeAttribute(DataAttributes.COMMANDS, JsonUtils.encode(map), true);
      writer.writeNameAttribute(clientId);
    }
    writer.writeStyleAttribute(createStyle(facesContext, command));
    writer.writeClassAttribute(Classes.create(command));
    writer.writeIdAttribute(clientId);
    HtmlRendererUtils.writeDataAttributes(facesContext, writer, command);
    if (label.getAccessKey() != null) {
      writer.writeAttribute(HtmlAttributes.ACCESSKEY, Character.toString(label.getAccessKey()), false);
    }
    HtmlRendererUtils.renderTip(command, writer);
    writer.flush();

//  label
    if (label.getText() != null) {
      HtmlRendererUtils.writeLabelWithAccessKey(writer, label);
    }

    if (label.getAccessKey() != null) {
      if (LOG.isInfoEnabled()
          && !AccessKeyMap.addAccessKey(facesContext, label.getAccessKey())) {
        LOG.info("duplicated accessKey : " + label.getAccessKey());
      }

      HtmlRendererUtils.addClickAcceleratorKey(facesContext, clientId, label.getAccessKey());
    }
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.renderkit.LabelWithAccessKey

        = "tobago-menuBar-item-span tobago-menuBar-item-span-"
        + (disabled ? "disabled" : "enabled")
        + (topMenu ? " tobago-menuBar-item-span-top" : "")
        + (pageMenu ? " tobago-menuBar-item-page-top" : "");

    final LabelWithAccessKey label = new LabelWithAccessKey(uiPanel);
    String image = (String) uiPanel.getAttributes().get(ATTR_IMAGE);


    addImage(writer, facesContext, image, disabled);

    writer.startElement(HtmlConstants.A, null);
    writer.writeClassAttribute(spanClass);
    writer.writeAttribute(HtmlAttributes.HREF, "#", null);
    writer.writeAttribute(HtmlAttributes.ONFOCUS, "tobagoMenuFocus(event)", null);
    writer.writeAttribute(HtmlAttributes.ONBLUR, "tobagoMenuBlur(event)", null);
    writer.writeAttribute(HtmlAttributes.ONKEYDOWN, "tobagoMenuKeyDown(event)", null);
    writer.writeAttribute(HtmlAttributes.ONKEYPRESS, "tobagoMenuKeyPress(event)", null);
    if (label.getText() != null) {
      if (label.getAccessKey() != null) {
        if (LOG.isInfoEnabled()
            && !AccessKeyMap.addAccessKey(facesContext, label.getAccessKey())) {
          LOG.info("dublicated accessKey : " + label.getAccessKey());
        }
        if (!disabled) {
          writer.writeIdAttribute(uiPanel.getClientId(facesContext));
          addAcceleratorKey(facesContext, uiPanel, label.getAccessKey());
        }
      }
      HtmlRendererUtil.writeLabelWithAccessKey(writer, label);
    }
    writer.endElement(HtmlConstants.A);
View Full Code Here

Examples of org.apache.myfaces.tobago.renderkit.LabelWithAccessKey

    addMenuItem(sb, var, facesContext, command, image, onClick);
  }

  private void addMenuItem(StringBuilder sb, String var, FacesContext facesContext,
                           UICommand command, String image, String onClick) throws IOException {
    final LabelWithAccessKey label = new LabelWithAccessKey(command);
    onClick = HtmlRendererUtil.appendConfirmationScript(onClick, command,
        facesContext);
    addMenuItem(sb, var, facesContext, command, label, image, onClick);
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.renderkit.LabelWithAccessKey

      throws IOException {
    onClick = HtmlRendererUtil.appendConfirmationScript(onClick, command,
        facesContext);
    List<SelectItem> items;

    LabelWithAccessKey label = new LabelWithAccessKey(command);


    UISelectOne radio = (UISelectOne) command.getFacet(FACET_ITEMS);
    if (radio == null) {
      items = ComponentUtil.getSelectItems(command);
      radio = ComponentUtil.createUIMenuSelectOneFacet(facesContext, command);
      radio.setId(facesContext.getViewRoot().createUniqueId());
    } else {
      items = ComponentUtil.getSelectItems(radio);
    }


    Object value = radio.getValue();

    boolean markFirst = !ComponentUtil.hasSelectedValue(items, value);
    String radioId = radio.getClientId(facesContext);
    String onClickPrefix = "menuSetRadioValue('" + radioId + "', '";
    String onClickPostfix = onClick != null ? "') ; " + onClick : "";
    for (SelectItem item : items) {
      final String labelText = item.getLabel();
      label.setAccessKey(null);
      if (labelText != null) {
        if (labelText.indexOf(LabelWithAccessKey.INDICATOR) > -1) {
          label.setText(null);
          label.setup(labelText);
        } else {
          label.setText(labelText);
        }
      } else {
        LOG.warn("Menu item has label=null. UICommand.getClientId()="
            + command.getClientId(facesContext));
      }
View Full Code Here

Examples of org.apache.myfaces.tobago.renderkit.LabelWithAccessKey

    }

    final String clientId = command.getClientId(facesContext);
    final boolean disabled
        = ComponentUtil.getBooleanAttribute(command, ATTR_DISABLED);
    final LabelWithAccessKey label = new LabelWithAccessKey(command);
    final UIComponent popupMenu = command.getFacet(FACET_MENUPOPUP);

    Map parentAttributes = command.getParent().getAttributes();
    String labelPosition = (String) parentAttributes.get(ATTR_LABEL_POSITION);
    String iconSize = (String) parentAttributes.get(ATTR_ICON_SIZE);

    onClick = HtmlRendererUtil.appendConfirmationScript(onClick, command,
        facesContext);

    String divClasses = "tobago-toolbar-button"
        + " tobago-toolbar-button-"  + (boxFacet ? "box-facet-" : "")
        + (selected ? "selected-" : "") + (disabled ? "disabled" : "enabled")
        + (boxFacet ? " tobago-toolbar-button-box-facet" : "");

    String tableClasses = "tobago-toolbar-button-table"
        + (boxFacet ? " tobago-toolbar-button-table-box-facet" : "")
        + " tobago-toolbar-button-table-" + (boxFacet ? "box-facet-" : "")
        + (selected ? "selected-" : "") + (disabled ? "disabled" : "enabled");


    String iconName = (String) command.getAttributes().get(ATTR_IMAGE);
    String image = getImage(facesContext, iconName, iconSize, disabled, selected);
    String graphicId = clientId + SUBCOMPONENT_SEP + "icon";

    String extraHoverClass = "";
    if (addExtraHoverClass) {
      if (!boxFacet) {
        extraHoverClass = " tobago-toolBar-button-hover-first";
      } else {
        extraHoverClass = " tobago-box-toolBar-button-hover-last";
      }
    }
    final String args = "this, 'tobago-toolBar-button-hover"
        + (boxFacet ? " tobago-toolBar-button-box-facet-hover" : "")
        + extraHoverClass + "', '" + graphicId + "'";
    final String mouseOverScript = "Tobago.toolbarMousesover(" + args + ");";
    final String mouseOutScript = "Tobago.toolbarMousesout(" + args + ");";

    writer.startElement(HtmlConstants.DIV, null);
    writer.writeClassAttribute(divClasses);
    if (!disabled) {
      writer.writeAttribute(HtmlAttributes.ONMOUSEOVER, mouseOverScript, null);
      writer.writeAttribute(HtmlAttributes.ONMOUSEOUT, mouseOutScript, null);
      writer.writeAttribute(HtmlAttributes.ONCLICK, onClick, null);
    }
    writer.startElement(HtmlConstants.TABLE, null);
    writer.writeAttribute(HtmlAttributes.CELLPADDING, "0", null);
    writer.writeAttribute(HtmlAttributes.CELLSPACING, "0", null);
    writer.writeAttribute(HtmlAttributes.SUMMARY, "", null);
    writer.writeAttribute(HtmlAttributes.BORDER, "0", null);
    writer.writeClassAttribute(tableClasses);
    writer.startElement(HtmlConstants.TR, null);

    boolean anchorOnLabel =
        label.getText() != null && !ToolBarTag.LABEL_OFF.equals(labelPosition);

    if (!ToolBarTag.ICON_OFF.equals(iconSize)) {
      HtmlRendererUtil.addImageSources(facesContext, writer,
          iconName != null ? iconName : "image/1x1.gif", graphicId);

      writer.startElement(HtmlConstants.TD, command);
      writer.writeAttribute(HtmlAttributes.ALIGN, "center", null);
      writer.writeAttribute(HtmlAttributes.TITLE, null, ATTR_TIP);

      boolean render1pxImage
          = (iconName == null && (!ToolBarTag.LABEL_BOTTOM.equals(
              labelPosition)
          && label.getText() != null));


      if (((!ToolBarTag.LABEL_OFF.equals(labelPosition)
            && label.getText() != null)
           || popupMenu != null)
          && !render1pxImage) {
        writer.writeAttribute(HtmlAttributes.STYLE, "padding-right: 3px;", null);
        // TODO: make this '3px' configurable
      }

      String className = "tobago-image-default tobago-toolBar-button-image"
          + " tobago-toolBar-button-image-" + iconSize;

      if (!anchorOnLabel) {
        renderAnchorBegin(facesContext, writer, command, label, disabled);
      }
      writer.startElement(HtmlConstants.IMG, command);
      writer.writeIdAttribute(graphicId);
      writer.writeAttribute(HtmlAttributes.SRC, image, null);
      writer.writeAttribute(HtmlAttributes.ALT, "", null);
      writer.writeAttribute(HtmlAttributes.TITLE, null, ATTR_TIP);
      writer.writeAttribute(HtmlAttributes.BORDER, "0", null);
      writer.writeClassAttribute(className);
      if (render1pxImage) {
        writer.writeAttribute(HtmlAttributes.STYLE, "width: 1px;", null);
      }

      writer.endElement(HtmlConstants.IMG);
      if (!anchorOnLabel) {
        writer.endElement(HtmlConstants.A);
      }
      writer.endElement(HtmlConstants.TD);
    }

    boolean popupOn2 = ToolBarTag.LABEL_BOTTOM.equals(labelPosition)
        && !ToolBarTag.ICON_OFF.equals(iconSize);
    if (popupOn2) {
      if (popupMenu != null) {
        renderPopupTd(facesContext, writer, command, popupMenu,
            true);
      }
      writer.endElement(HtmlConstants.TR);
      writer.startElement(HtmlConstants.TR, null);
    }

    if (!ToolBarTag.LABEL_OFF.equals(labelPosition)) {
      writer.startElement(HtmlConstants.TD, null);
      writer.writeClassAttribute("tobago-toolbar-label-td");
      writer.writeAttribute(HtmlAttributes.ALIGN, "center", null);
      if (popupMenu != null) {
        writer.writeAttribute(HtmlAttributes.STYLE, "padding-right: 3px;", null);
        // TODO: make this '3px' configurable
      }
      if (label.getText() != null) {
        renderAnchorBegin(facesContext, writer, command, label, disabled);
        HtmlRendererUtil.writeLabelWithAccessKey(writer, label);
        writer.endElement(HtmlConstants.A);
      }
      writer.endElement(HtmlConstants.TD);
View Full Code Here

Examples of org.apache.myfaces.tobago.renderkit.LabelWithAccessKey

        onclick = "tobago_selectTab('"
            + clientId + "'," + i + ','
            + tabs.length + ')';
      }

      LabelWithAccessKey label = new LabelWithAccessKey(tab);

      String outerClass;
      String innerClass;
      if (virtualTab == i) {
        outerClass = "tobago-tab-selected-outer";
        innerClass = "tobago-tab-selected-inner";
        activeTab = tab;
      } else {
        outerClass = "tobago-tab-unselected-outer";
        innerClass = "tobago-tab-unselected-inner";
      }

      writer.startElement(HtmlConstants.TD, tab);
      writer.writeAttribute(HtmlAttributes.TITLE, null, ATTR_TIP);

      writer.startElement(HtmlConstants.DIV, null);
      writer.writeClassAttribute(outerClass);

      writer.startElement(HtmlConstants.DIV, null);
      writer.writeClassAttribute(innerClass);

      writer.startElement(HtmlConstants.SPAN, null);
      writer.writeClassAttribute("tobago-tab-link");
      String tabId = clientId + "." + virtualTab + SUBCOMPONENT_SEP + i;
      writer.writeIdAttribute(tabId);
      if (onclick != null) {
        writer.writeAttribute(HtmlAttributes.ONCLICK, onclick, null);
      }
      if (label.getText() != null) {
        HtmlRendererUtil.writeLabelWithAccessKey(writer, label);
      } else {
        writer.writeText(Integer.toString(i+1), null);
      }
      writer.endElement(HtmlConstants.SPAN);

      if (label.getAccessKey() != null) {
        if (LOG.isWarnEnabled()
            && !AccessKeyMap.addAccessKey(facesContext, label.getAccessKey())) {
          LOG.warn("dublicated accessKey : " + label.getAccessKey());
        }
      HtmlRendererUtil.addClickAcceleratorKey(
          facesContext, tabId, label.getAccessKey());
      }
      writer.endElement(HtmlConstants.DIV);
      writer.endElement(HtmlConstants.DIV);
      writer.endElement(HtmlConstants.TD);
View Full Code Here

Examples of org.apache.myfaces.tobago.renderkit.LabelWithAccessKey

    onclick = HtmlRendererUtil.appendConfirmationScript(onclick, component, facesContext);

    TobagoResponseWriter writer
        = (TobagoResponseWriter) facesContext.getResponseWriter();

    LabelWithAccessKey label = new LabelWithAccessKey(component);

    if (ComponentUtil.getBooleanAttribute(component, ATTR_DISABLED)) {
      writer.startElement(HtmlConstants.SPAN, component);
    } else {
      writer.startElement(HtmlConstants.A, component);
      writer.writeAttribute(HtmlAttributes.HREF, href, null);
      if (onclick != null) {
        writer.writeAttribute(HtmlAttributes.ONCLICK, onclick, null);
      }
      writer.writeAttribute(HtmlAttributes.TARGET, null, ATTR_TARGET);
    }
    writer.writeComponentClass();
    writer.writeIdAttribute(clientId);
    writer.writeNameAttribute(clientId);
    writer.writeAttribute(HtmlAttributes.TITLE, null, ATTR_TIP);

    //TODO: check if this is still needed
    writer.writeText("", null); // force closing the start tag

//  image
    String image = (String) component.getAttributes().get(ATTR_IMAGE);
    if (image != null) {
      image = ResourceManagerUtil.getImageWithPath(facesContext, image);
      writer.startElement(HtmlConstants.IMG, null);
      writer.writeAttribute(HtmlAttributes.SRC, image, null);
      writer.writeAttribute(HtmlAttributes.ALT, "", null);
      writer.writeAttribute(HtmlAttributes.BORDER, "0", null); // TODO: is border=0 setting via style possible?
      writer.endElement(HtmlConstants.IMG);
    }

//  label
    if (label.getText() != null) {
      if (image != null) {
        writer.writeText(" ", null); // separator: e.g. &nbsp;
      }
      HtmlRendererUtil.writeLabelWithAccessKey(writer, label);
    }

      if (label.getAccessKey() != null) {
        if (LOG.isInfoEnabled()
            && !AccessKeyMap.addAccessKey(facesContext, label.getAccessKey())) {
          LOG.info("dublicated accessKey : " + label.getAccessKey());
        }

      HtmlRendererUtil.addClickAcceleratorKey(
          facesContext, clientId, label.getAccessKey());
      }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.