Package org.pentaho.reporting.engine.classic.core

Examples of org.pentaho.reporting.engine.classic.core.ReportAttributeMap


      if (ObjectUtilities.equal(visualElement.getElementTypeName(), targetElementType.getMetaData().getName()))
      {
        continue;
      }

      final ReportAttributeMap oldAttributes = visualElement.getAttributes();

      final ElementMetaData data = visualElement.getMetaData();
      final AttributeMetaData[] datas = data.getAttributeDescriptions();
      for (int j = 0; j < datas.length; j++)
      {
        final AttributeMetaData metaData = datas[j];
        final AttributeMetaData attributeMetaData =
            targetMetaData.getAttributeDescription(metaData.getNameSpace(), metaData.getName());
        if (attributeMetaData == null)
        {
          visualElement.setAttribute(metaData.getNameSpace(), metaData.getName(), null);
          visualElement.setAttributeExpression(metaData.getNameSpace(), metaData.getName(), null);
        }
      }

      visualElement.setElementType(targetElementType);

      // -------------------- manipulate the value and field attributes so that we preserve as much as possible ---------------------  
      // get the source and destination types
      final ElementType srcType = (ElementType) oldAttributes.getAttribute(CORE_NAMESPACE, ELEMENT_TYPE_ATTRIBUE);
      // Check if the source-type is a message field. In that case, we have to map the pattern into a field and
      // format definition
      if (srcType instanceof MessageType)
      {
        final String message = (String) oldAttributes.getAttribute(CORE_NAMESPACE, VALUE_ATTRIBUTE);
        visualElement.setAttribute(CORE_NAMESPACE, VALUE_ATTRIBUTE, null);
        try
        {

          final MessageFormatSupport fmt = new MessageFormatSupport();
          fmt.setFormatString(message);
          final String rawFormat = fmt.getCompiledFormat();
          final MessageFormat msg = new MessageFormat(rawFormat);
          final Format[] subFormats = msg.getFormats();

          if (targetElementType instanceof DateFieldType)
          {
            final int sdf = findFirstDateFormat(subFormats);
            if (sdf != -1)
            {
              final SimpleDateFormat df = (SimpleDateFormat) subFormats[sdf];

              final String[] fields = fmt.getFields();
              visualElement.setAttribute(CORE_NAMESPACE, FIELD_ATTRIBUTE, fields[sdf]);
              visualElement.setAttribute(CORE_NAMESPACE, FORMAT_ATTRIBUTE, df.toPattern());
            }
          }
          else if (targetElementType instanceof NumberFieldType)
          {
            final int sdf = findFirstNumberFormat(subFormats);
            if (sdf != -1)
            {
              final DecimalFormat df = (DecimalFormat) subFormats[sdf];

              final String[] fields = fmt.getFields();
              visualElement.setAttribute(CORE_NAMESPACE, FIELD_ATTRIBUTE, fields[sdf]);
              visualElement.setAttribute(CORE_NAMESPACE, FORMAT_ATTRIBUTE, df.toPattern());
            }
          }
          else
          {
            final String[] fields = fmt.getFields();
            if (fields.length > 0)
            {
              visualElement.setAttribute(CORE_NAMESPACE, FIELD_ATTRIBUTE, fields[0]);
            }
            else
            {
              visualElement.setAttribute(CORE_NAMESPACE, VALUE_ATTRIBUTE, message);
            }
          }
        }
        catch (Exception ex)
        {
          visualElement.setAttribute(CORE_NAMESPACE, VALUE_ATTRIBUTE, message);
        }
      }
      else if (targetElementType instanceof MessageType)
      {
        // validate that these are the correct combination to use this enhanced morphing.
        // This stuff only applies if we're morphing TO a Message Type field
        final String srcField = (String) oldAttributes.getAttribute(CORE_NAMESPACE, FIELD_ATTRIBUTE); // and morphing FROM Number, Date, or Text Type field
        final String formatString = (String) oldAttributes.getAttribute(CORE_NAMESPACE, FORMAT_ATTRIBUTE);
        final StringBuilder buffer = new StringBuilder();
        buffer.append("$(").append(srcField); //$NON-NLS-1$
        if (srcType instanceof NumberFieldType)
        {
          buffer.append(", number"); //$NON-NLS-1$
          if (formatString != null && formatString.length() > 0)
          {
            buffer.append(", ").append(formatString); //$NON-NLS-1$
          }
        }
        else if (srcType instanceof DateFieldType)
        {
          buffer.append(", date"); //$NON-NLS-1$
          if (formatString != null && formatString.length() > 0)
          {
            buffer.append(", ").append(formatString); //$NON-NLS-1$
          }
        }
        buffer.append(")"); //$NON-NLS-1$
        visualElement.setAttribute(CORE_NAMESPACE, VALUE_ATTRIBUTE, buffer.toString());
      }

      final ReportAttributeMap newAttributes = visualElement.getAttributes();
      undos.add(new MorphUndoEntry(visualElement.getObjectID(), oldAttributes, newAttributes));
    }

    getActiveContext().getUndo().addChange(ActionMessages.getString("MorphAction.UndoName"),
        new CompoundUndoEntry(undos.toArray(new UndoEntry[undos.size()])));
View Full Code Here


    return attributeList;
  }

  private void writeElementAttributes(final RenderNode element) throws IOException
  {
    final ReportAttributeMap attributes = element.getAttributes();
    final ElementType type = element.getElementType();
    writeAttributes(attributes, type);
  }
View Full Code Here

    this.drawArea = pageBounds;
  }

  private void writeElementAttributes(final RenderNode element) throws IOException
  {
    final ReportAttributeMap attributes = element.getAttributes();
    final ElementType type = element.getElementType();
    final String[] attributeNamespaces = attributes.getNameSpaces();
    Arrays.sort(attributeNamespaces);
    for (int i = 0; i < attributeNamespaces.length; i++)
    {
      final String namespace = attributeNamespaces[i];

      if (AttributeNames.Designtime.NAMESPACE.equals(namespace))
      {
        continue;
      }
      final String[] attributeNames = attributes.getNames(namespace);
      Arrays.sort(attributeNames);
      for (int j = 0; j < attributeNames.length; j++)
      {
        final String name = attributeNames[j];
        final Object value = attributes.getAttribute(namespace, name);
        if (value == null)
        {
          continue;
        }
View Full Code Here

      attrs.putAll(content);
      applyHtmlAttributes(attrs, attrList);
    }
    else if (background != null)
    {
      final ReportAttributeMap attrs = background.getAttributes();
      applyHtmlAttributes(attrs, attrList);
    }
    else if (content != null)
    {
      applyHtmlAttributes(content, attrList);
View Full Code Here

  protected void processRenderableContent(final RenderableReplacedContentBox node)
  {
    try
    {
      final ReportAttributeMap map = node.getAttributes();
      final AttributeList attrs = new AttributeList();
      HtmlTagHelper.applyHtmlAttributes(map, attrs);
      if (attrs.isEmpty() == false)
      {
        xmlWriter.writeTag(HtmlPrinter.XHTML_NAMESPACE, DIV_TAG, attrs, XmlWriterSupport.OPEN);
View Full Code Here

   */
  private void processReplacedContent(final RenderableReplacedContentBox node) throws IOException, ContentIOException
  {

    final RenderableReplacedContent rc = node.getContent();
    final ReportAttributeMap attrs = node.getAttributes();
    final long width = node.getWidth();
    final long height = node.getHeight();
    final long contentWidth = rc.getContentWidth();
    final long contentHeight = rc.getContentHeight();
    final StyleSheet styleSheet = node.getStyleSheet();
View Full Code Here

    if (bg == null)
    {
      return null;
    }
    final AttributeList attList = new AttributeList();
    final ReportAttributeMap attrs = bg.getAttributes();
    final Object nameAttr = attrs.getAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.NAME);
    if (nameAttr instanceof String)
    {
      attList.setAttribute(null, "content-idref",
          (String) nameAttr);
    }
View Full Code Here

  public RenderNode[] getRenderNodes(final ReportElement element,
                                     final StyleSheet elementStyle,
                                     final String text)
  {
    final ReportAttributeMap attrs = element.getAttributes();
    final RenderNode[] renderNodes;
    final RenderNode[] finishNodes;

    final TextCache.Result result = textCache.get
        (elementStyle.getId(), elementStyle.getChangeTracker(), attrs.getChangeTracker(), text);
    if (result != null)
    {
      renderNodes = result.getText();
      finishNodes = result.getFinish();
    }
    else
    {
      transformText(text);

      renderNodes = textFactory.createText
          (bufferArray, 0, buffer.getLength(), elementStyle, element.getElementType(), element.getObjectID(), attrs);
      finishNodes = textFactory.finishText();

      textCache.store(elementStyle.getId(), elementStyle.getChangeTracker(), attrs.getChangeTracker(), text,
          elementStyle, attrs, renderNodes, finishNodes);
    }

    if (renderNodes.length == 0)
    {
View Full Code Here

    }

    for (int i = nodes.length - 1; i >= 0; i -= 1)
    {
      final RenderNode node = nodes[i];
      final ReportAttributeMap attributes = node.getAttributes();
      final Object swingTooltip = attributes.getAttribute(AttributeNames.Swing.NAMESPACE, AttributeNames.Swing.TOOLTIP);
      if (swingTooltip != null)
      {
        return String.valueOf(swingTooltip);
      }

      final Object htmlTooltip = attributes.getAttribute(AttributeNames.Html.NAMESPACE, AttributeNames.Html.TITLE);
      if (htmlTooltip != null)
      {
        return String.valueOf(htmlTooltip);
      }
View Full Code Here

    return null;
  }

  public static ImageMap extractImageMap(final RenderableReplacedContentBox content)
  {
    final ReportAttributeMap attributes = content.getAttributes();
    Object rawObject = content.getContent().getRawObject();
    return extractImageMap(attributes, rawObject, content.getWidth(), content.getHeight());
  }
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.engine.classic.core.ReportAttributeMap

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.