Example #1
0
 /* (non-Javadoc)
  * @see org.eclipse.jdt.internal.compiler.parser.AbstractCommentParser#pushParamName(java.lang.Object)
  */
 protected boolean pushParamName(boolean isTypeParam) {
   int idIndex = isTypeParam ? 1 : 0;
   final SimpleName name = new SimpleName(this.ast);
   name.internalSetIdentifier(new String(this.identifierStack[idIndex]));
   int nameStart = (int) (this.identifierPositionStack[idIndex] >>> 32);
   int nameEnd = (int) (this.identifierPositionStack[idIndex] & 0x00000000FFFFFFFFL);
   name.setSourceRange(nameStart, nameEnd - nameStart + 1);
   TagElement paramTag = this.ast.newTagElement();
   paramTag.setTagName(TagElement.TAG_PARAM);
   if (isTypeParam) { // specific storage for @param <E> (see bug 79809)
     // '<' was stored in identifiers stack
     TextElement text = this.ast.newTextElement();
     text.setText(new String(this.identifierStack[0]));
     int txtStart = (int) (this.identifierPositionStack[0] >>> 32);
     int txtEnd = (int) (this.identifierPositionStack[0] & 0x00000000FFFFFFFFL);
     text.setSourceRange(txtStart, txtEnd - txtStart + 1);
     paramTag.fragments().add(text);
     // add simple name
     paramTag.fragments().add(name);
     // '>' was stored in identifiers stack
     text = this.ast.newTextElement();
     text.setText(new String(this.identifierStack[2]));
     txtStart = (int) (this.identifierPositionStack[2] >>> 32);
     txtEnd = (int) (this.identifierPositionStack[2] & 0x00000000FFFFFFFFL);
     text.setSourceRange(txtStart, txtEnd - txtStart + 1);
     paramTag.fragments().add(text);
     // set param tag source range
     paramTag.setSourceRange(this.tagSourceStart, txtEnd - this.tagSourceStart + 1);
   } else {
     paramTag.setSourceRange(this.tagSourceStart, nameEnd - this.tagSourceStart + 1);
     paramTag.fragments().add(name);
   }
   pushOnAstStack(paramTag, true);
   return true;
 }
 private HtmlFormInputElement getRecipient(boolean isToAdmin) {
   if (isToAdmin) {
     TextElement te = new TextElement("recipient", "SUPER_ADMIN", "");
     te.setType("hidden");
     te.setFormName("writemessage");
     return te;
   }
   String[] users = UserManager.getAllUsers();
   SelectElement se = new SelectElement(users, users, "recipient", "Получатель", "");
   se.setFormName("writemessage");
   return se;
 }
Example #3
0
  /* (non-Javadoc)
   * @see org.eclipse.jdt.internal.compiler.parser.AbstractCommentParser#pushText(int, int)
   */
  protected void pushText(int start, int end) {

    // Create text element
    TextElement text = this.ast.newTextElement();
    text.setText(new String(this.source, start, end - start));
    text.setSourceRange(start, end - start);

    // Search previous tag on which to add the text element
    TagElement previousTag = null;
    int previousStart = start;
    if (this.astPtr == -1) {
      previousTag = this.ast.newTagElement();
      previousTag.setSourceRange(start, end - start);
      pushOnAstStack(previousTag, true);
    } else {
      previousTag = (TagElement) this.astStack[this.astPtr];
      previousStart = previousTag.getStartPosition();
    }

    // If we're in a inline tag, then retrieve previous tag in its fragments
    List fragments = previousTag.fragments();
    if (this.inlineTagStarted) {
      int size = fragments.size();
      if (size == 0) {
        // no existing fragment => just add the element
        TagElement inlineTag = this.ast.newTagElement();
        fragments.add(inlineTag);
        previousTag = inlineTag;
      } else {
        // If last fragment is a tag, then use it as previous tag
        ASTNode lastFragment = (ASTNode) fragments.get(size - 1);
        if (lastFragment.getNodeType() == ASTNode.TAG_ELEMENT) {
          previousTag = (TagElement) lastFragment;
          previousStart = previousTag.getStartPosition();
        }
      }
    }

    // Add the text
    previousTag.fragments().add(text);
    previousTag.setSourceRange(previousStart, end - previousStart);
    this.textStart = -1;
  }
Example #4
0
  @Override
  public String getLiteral() {
    final StringBuilder builder = new StringBuilder();

    final String tagsAsString =
        Joiner.on(" ").join(Iterables.transform(tags, Tag.FUNCTION_TOSOURCESTRING));
    if (!StringUtils.isBlank(tagsAsString)) {
      builder.append("  ");
      builder.append(tagsAsString);
      builder.append("\n");
    }

    if (!StringUtils.isBlank(markup.getLiteral())) {
      builder.append(markup.getLiteral());
      builder.append(" ");
    }
    if (!StringUtils.isBlank(title.getLiteral())) {
      builder.append(title.getLiteral());
      builder.append("\n\n");
    }
    if (!StringUtils.isBlank(body.getLiteral())) {
      builder.append(body.getLiteral());
      builder.append("\n\n");
    }

    return builder.toString();
  }
Example #5
0
 @Override
 public int hashCode() {
   int hash = super.hashCode();
   hash = 97 * hash + text.hashCode();
   if (boxProvider != null) {
     hash = 97 * hash + boxProvider.hashCode();
   } else {
     hash = 97 * hash + box.hashCode();
   }
   hash = 97 * hash + hAlign.hashCode();
   hash = 97 * hash + vAlign.hashCode();
   return hash;
 }
Example #6
0
 @Override
 public String toString() {
   return "BoxTextElemStyle{"
       + super.toString()
       + " "
       + text.toStringImpl()
       + " box="
       + box
       + " hAlign="
       + hAlign
       + " vAlign="
       + vAlign
       + '}';
 }
Example #7
0
 @Override
 public boolean equals(Object obj) {
   if (!super.equals(obj)) return false;
   if (obj == null || getClass() != obj.getClass()) return false;
   final BoxTextElemStyle other = (BoxTextElemStyle) obj;
   if (!text.equals(other.text)) return false;
   if (boxProvider != null) {
     if (!boxProvider.equals(other.boxProvider)) return false;
   } else if (other.boxProvider != null) return false;
   else {
     if (!box.equals(other.box)) return false;
   }
   if (hAlign != other.hAlign) return false;
   if (vAlign != other.vAlign) return false;
   return true;
 }
Example #8
0
  public static BoxTextElemStyle create(Environment env, BoxProvider boxProvider, Rectangle box) {
    initDefaultParameters();
    Cascade c = env.mc.getCascade(env.layer);

    TextElement text = TextElement.create(c, DEFAULT_TEXT_COLOR, false);
    if (text == null) return null;
    // Skip any primtives that don't have text to draw. (Styles are recreated for any tag change.)
    // The concrete text to render is not cached in this object, but computed for each
    // repaint. This way, one BoxTextElemStyle object can be used by multiple primitives (to save
    // memory).
    if (text.labelCompositionStrategy.compose(env.osm) == null) return null;

    HorizontalTextAlignment hAlign = HorizontalTextAlignment.RIGHT;
    Keyword hAlignKW = c.get("text-anchor-horizontal", Keyword.RIGHT, Keyword.class);
    if (equal(hAlignKW.val, "left")) {
      hAlign = HorizontalTextAlignment.LEFT;
    } else if (equal(hAlignKW.val, "center")) {
      hAlign = HorizontalTextAlignment.CENTER;
    } else if (equal(hAlignKW.val, "right")) {
      hAlign = HorizontalTextAlignment.RIGHT;
    }
    VerticalTextAlignment vAlign = VerticalTextAlignment.BOTTOM;
    String vAlignStr = c.get("text-anchor-vertical", Keyword.BOTTOM, Keyword.class).val;
    if (equal(vAlignStr, "above")) {
      vAlign = VerticalTextAlignment.ABOVE;
    } else if (equal(vAlignStr, "top")) {
      vAlign = VerticalTextAlignment.TOP;
    } else if (equal(vAlignStr, "center")) {
      vAlign = VerticalTextAlignment.CENTER;
    } else if (equal(vAlignStr, "bottom")) {
      vAlign = VerticalTextAlignment.BOTTOM;
    } else if (equal(vAlignStr, "below")) {
      vAlign = VerticalTextAlignment.BELOW;
    }

    return new BoxTextElemStyle(c, text, boxProvider, box, hAlign, vAlign);
  }
 /*
  * @see ASTVisitor#visit(TextElement)
  * @since 3.0
  */
 @Override
 public boolean visit(TextElement node) {
   this.fBuffer.append(node.getText());
   return false;
 }