| /** |
| * |
| * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation |
| */ |
| package org.eclipse.osbp.xtext.reportdsl.common.item; |
| |
| import org.eclipse.birt.report.model.api.Expression; |
| import org.eclipse.birt.report.model.api.ReportItemHandle; |
| import org.eclipse.birt.report.model.api.TextDataHandle; |
| import org.eclipse.birt.report.model.api.activity.SemanticException; |
| import org.eclipse.osbp.utils.entityhelper.DataType; |
| import org.eclipse.osbp.xtext.reportdsl.jvmmodel.ReportGeneratorWorkSet; |
| import org.slf4j.Logger; |
| import org.slf4j.LoggerFactory; |
| |
| public class TextDataItem extends ABaseItem { |
| |
| private static final Logger LOGGER = LoggerFactory.getLogger(TextDataItem.class); |
| private final TextDataHandle fItem; |
| |
| |
| public TextDataItem(ReportGeneratorWorkSet workset, String contentType, String source, String tableAttributeName) { |
| super(workset); |
| fItem = workset.newTextDataItem(""); |
| try { |
| if (CONTENT_TYPE_HTML.equals(contentType) && "expr".equals(source)){ |
| Expression expr = new Expression("row[\"" + tableAttributeName + "\"]", null); |
| fItem.setExpressionProperty("valueExpr", expr); |
| fItem.setContentType(CONTENT_TYPE_HTML); |
| } else { |
| throw new SemanticException(fItem.getElement(), "Incorrect content type '" + contentType + "' or source + '" + source + "'!"); |
| } |
| } catch (SemanticException e) { |
| LOGGER.error("{}", e); |
| } |
| } |
| |
| |
| @Override |
| public ReportItemHandle getHandle() { |
| return fItem; |
| } |
| |
| |
| |
| } |