// javadoc inherited
  protected void writeMenuItem(DOMOutputBuffer outputBuffer, MenuItem menuItem)
      throws ProtocolException {

    InternalDevice device = pageContext.getDevice();
    boolean isAccesskeyPrefixKeyNeeded =
        !device.getBooleanPolicyValue(
            DevicePolicyConstants.SUPPORTS_WML_ACCESSKEY_AUTOMAGIC_NUMBER_DISPLAY);

    // Extract the href from the menu item.
    LinkAssetReference reference = menuItem.getHref();
    String href = reference.getURL();

    // Extract the text from the menu item.
    String text = menuItem.getText();

    // Add the dummy access key prefix to the text if necessary.
    if (isAccesskeyPrefixKeyNeeded) {
      text = AccesskeyConstants.DUMMY_ACCESSKEY_VALUE_STRING + " " + text;
    }

    // Report what we are about to do for debugging.
    if (logger.isDebugEnabled()) {
      logger.debug("writing numeric shortcut menu item with href=" + href + ", text=" + text);
    }

    // Open the annotation element.
    // @todo 2005060816 annotate child with style information if it's not inherited from the parent
    Element annotator =
        outputBuffer.openStyledElement(AccesskeyConstants.ACCESSKEY_ANNOTATION_ELEMENT, menuItem);

    // Open the anchor element.
    Element anchor = outputBuffer.openElement("a");

    // Copy attributes into the anchor element.
    menuRendererContext.writeTitleAttribute(anchor, menuItem);
    anchor.setAttribute("href", href);
    // Add the dummy accesskey attribute as well.
    anchor.setAttribute("accesskey", AccesskeyConstants.DUMMY_ACCESSKEY_VALUE_STRING);

    // Write out the menu text as the content of the link.
    outputBuffer.appendEncoded(text);

    // Close the anchor element.
    outputBuffer.closeElement(anchor);

    // Close the annotation element.
    outputBuffer.closeElement(annotator);

    // Add BR to force hardcoded vertical alignment.
    // This is compatible with actual Openwave numeric shortcut rendering
    // which is always vertical.
    // NOTE: This means that the mariner-menu-orientation style is ignored.
    outputBuffer.addStyledElement("br", menuItem);
  }
  /**
   * Apply the <code>CSSRemappingRule</code> instances to the specified <code>Element</code>.
   *
   * @param element the context <code>Element</code>.
   */
  public void apply(Element element) {

    // Don't act on elements that this rule shouldn't be applied to. This
    // could be omitted on the understanding that the client will use this
    // object properly, but leaving the check in for now.
    if (!elementName.equals(element.getName())) {
      return;
    }

    for (Iterator iterator = rules.iterator(); iterator.hasNext(); ) {
      ElementRule rule = (ElementRule) iterator.next();
      rule.apply(element);
    }
  }
Exemple #3
0
  public void addToHead(Element element) {

    if (logger.isDebugEnabled()) {
      logger.debug("Adding " + this + " to head of " + element);
    }

    if (CHECK_INVARIANTS) {
      checkInvariants();
    }

    element.addHead(this);

    if (CHECK_INVARIANTS) {
      checkInvariants();
    }
  }