@Override public void visitTextField(JRTextField textField) { JRBaseTextField baseTextField = null; if (textField != null) { baseTextField = (JRBaseTextField)get(textField); if (baseTextField == null) { baseTextField = new JRBaseTextField(textField, this); } } setVisitResult(baseTextField); }
/** * Initializes the text field properties. */ protected JRBaseTextField(JRTextField textField, JRBaseObjectFactory factory) { super(textField, factory); isStretchWithOverflow = textField.isStretchWithOverflow(); evaluationTimeValue = textField.getEvaluationTimeValue(); pattern = textField.getOwnPattern(); isBlankWhenNull = textField.isOwnBlankWhenNull(); linkType = textField.getLinkType(); linkTarget = textField.getLinkTarget(); hyperlinkParameters = JRBaseHyperlink.copyHyperlinkParameters(textField, factory); evaluationGroup = factory.getGroup(textField.getEvaluationGroup()); expression = factory.getExpression(textField.getExpression()); patternExpression = factory.getExpression(textField.getPatternExpression()); anchorNameExpression = factory.getExpression(textField.getAnchorNameExpression()); hyperlinkReferenceExpression = factory.getExpression(textField.getHyperlinkReferenceExpression()); hyperlinkWhenExpression = factory.getExpression(textField.getHyperlinkWhenExpression()); hyperlinkAnchorExpression = factory.getExpression(textField.getHyperlinkAnchorExpression()); hyperlinkPageExpression = factory.getExpression(textField.getHyperlinkPageExpression()); hyperlinkTooltipExpression = factory.getExpression(textField.getHyperlinkTooltipExpression()); bookmarkLevel = textField.getBookmarkLevel(); }
@Override public JRPrintElement convert(ReportConverter reportConverter, JRElement element) { JRBasePrintText printText = new JRBasePrintText(reportConverter.getDefaultStyleProvider()); JRTextField textField = (JRTextField)element; copyTextElement(reportConverter, textField, printText); printText.setMarkup(JRCommonText.MARKUP_NONE);//text fields are never converted to styled print text elements printText.setAnchorName(JRExpressionUtil.getExpressionText(textField.getAnchorNameExpression())); printText.setBookmarkLevel(textField.getBookmarkLevel()); printText.setLinkType(textField.getLinkType()); printText.setPattern(textField.getOwnPattern()); printText.setText(JRExpressionUtil.getExpressionText(textField.getExpression())); JRTextMeasurerUtil.getInstance(reportConverter.getJasperReportsContext()).measureTextElement(printText); return printText; }
public static TimeZone resolveFormatTimeZone(String timeZoneId, TimeZone reportTimeZone) { if (timeZoneId == null || timeZoneId.isEmpty()) { return null; } if (timeZoneId.equals(JRTextField.FORMAT_TIMEZONE_SYSTEM)) { // using the default JVM timezone return TimeZone.getDefault(); } if (timeZoneId.equals(JRParameter.REPORT_TIME_ZONE)) { // using the report timezone return reportTimeZone; } // note that this returns GMT if the ID is unknown, leaving that as is return getTimeZone(timeZoneId); }
/** * */ public boolean isBlankWhenNull(JRTextField element) { Boolean ownBlankWhenNull = element.isOwnBlankWhenNull(); if (ownBlankWhenNull != null) { return ownBlankWhenNull.booleanValue(); } JRStyle baseStyle = getBaseStyle(element); if (baseStyle != null) { Boolean blankWhenNull = baseStyle.isBlankWhenNull(); if (blankWhenNull != null) { return blankWhenNull.booleanValue(); } } return false; }
protected String getDatePattern(Object value) { String pattern = getPattern(); if (pattern != null || value == null) { return pattern; } String property; if (value instanceof java.sql.Date) { property = JRTextField.PROPERTY_PATTERN_DATE; } else if (value instanceof java.sql.Time) { property = JRTextField.PROPERTY_PATTERN_TIME; } else { property = JRTextField.PROPERTY_PATTERN_DATETIME; } return getLocalizedProperty(property); }
protected String getNumberPattern(Object value) { String pattern = getPattern(); if (pattern != null || value == null) { return pattern; } String property; if (value instanceof java.lang.Byte || value instanceof java.lang.Short || value instanceof java.lang.Integer || value instanceof java.lang.Long || value instanceof java.math.BigInteger) { property = JRTextField.PROPERTY_PATTERN_INTEGER; } else { property = JRTextField.PROPERTY_PATTERN_NUMBER; } return getLocalizedProperty(property); }
@Override public void visitTextField(JRTextField textField) { JRFillTextField fillTextField = null; if (textField != null) { fillTextField = (JRFillTextField)get(textField); if (fillTextField == null) { fillTextField = new JRFillTextField(filler, textField, this); } } setVisitResult(fillTextField); }
/** * */ public static HeaderLabelBuiltinExpression alterHeaderLabel(JRDesignFrame frame, String suffix) { HeaderLabelBuiltinExpression evaluator = null; JRElement[] elements = frame.getElements(); JRElement element = (elements == null || elements.length == 0) ? null : elements[0]; if (element instanceof JRStaticText) { JRElement elementProxy = getProxy((JRStaticText)element, suffix); frame.getChildren().set(0, elementProxy); } else if (element instanceof JRTextField) { evaluator = new HeaderLabelBuiltinExpression(((JRTextField)element).getExpression(), suffix); } return evaluator; }
private JRTextField getTargetTextField() { ConditionalFormattingData cfData = getConditionalFormattingData(); List<BaseColumn> allCols = TableUtil.getAllColumns(table); StandardColumn col = (StandardColumn)allCols.get(cfData.getColumnIndex()); JRTextField result = null; if (EditTextElementData.APPLY_TO_DETAIL_ROWS.equals(cfData.getApplyTo())) { result = TableUtil.getCellElement(JRTextField.class, col.getDetailCell(), true); } else if (EditTextElementData.APPLY_TO_GROUP_SUBTOTAL.equals(cfData.getApplyTo())) { result = TableUtil.getCellElement(JRTextField.class, col, TableUtil.COLUMN_GROUP_FOOTER, cfData.getGroupName(), table); } else if (EditTextElementData.APPLY_TO_GROUPHEADING.equals(cfData.getApplyTo())) { result = TableUtil.getCellElement(JRTextField.class, col, TableUtil.COLUMN_GROUP_HEADER, cfData.getGroupName(), table); } else if (EditTextElementData.APPLY_TO_TABLE_TOTAL.equals(cfData.getApplyTo())) { result = TableUtil.getCellElement(JRTextField.class, col, TableUtil.TABLE_FOOTER, null, table); } return result; }
public static boolean hasSingleChunkExpression(JRTextField textField) { if (textField != null) { JRExpression textExpression = textField.getExpression(); JRExpressionChunk[] chunks = textExpression == null ? null : textExpression.getChunks(); if (chunks == null || chunks.length != 1 || (chunks[0].getType() != JRExpressionChunk.TYPE_FIELD && chunks[0].getType() != JRExpressionChunk.TYPE_VARIABLE)) { return false; } return true; } return false; }
protected JRExpression getColumnHeaderLabelExpression(Cell header) { List<JRChild> detailElements = header == null ? null : header.getChildren(); // only consider cells with a single text fields if (detailElements == null || detailElements.size() != 1) { return null; } JRChild detailElement = detailElements.get(0); if (detailElement instanceof JRTextField) { return ((JRTextField) detailElement).getExpression(); } if (detailElement instanceof JRStaticText) { return builtinEvaluatorFactory.createConstantExpression(((JRStaticText)detailElement).getText()); } return null; }
public static List<ElementDescription> getElementProperties(Object holder){ List<ElementDescription> result = new ArrayList<ElementDescription>(); result.addAll(getGenericHints()); if (holder instanceof JasperDesign) { result.addAll(getExporterHints()); result.addAll(addHints(SCOPE_REPORT)); } else if(holder instanceof JRTextField) { result.addAll(addHints(SCOPE_TEXT_ELEMENT)); } else if(holder instanceof JRElement) { result.addAll(addHints(SCOPE_ELEMENT)); } return result; }
public static List<ElementDescription> getElementProperties(Class<?> holderType){ List<ElementDescription> result = new ArrayList<ElementDescription>(); result.addAll(getGenericHints()); if (JasperDesign.class.isAssignableFrom(holderType)) { result.addAll(getExporterHints()); result.addAll(addHints(SCOPE_REPORT)); } else if(JRTextField.class.isAssignableFrom(holderType)) { result.addAll(addHints(SCOPE_TEXT_ELEMENT)); } else if(JRElement.class.isAssignableFrom(holderType)) { result.addAll(addHints(SCOPE_ELEMENT)); } return result; }
@SuppressWarnings("unchecked") public JRPropertiesMapProperty(JRPropertiesHolder holder) { super( "properties", JRPropertiesMap.class, I18n.getString("JRPropertiesMapProperty.Property.Properties"),I18n.getString("JRPropertiesMapProperty.Property.Propertiesdetail"), true,true); setValue("canEditAsText", Boolean.FALSE); this.propertiesHolder = holder; if (holder instanceof JasperDesign) { setValue("reportProperties", Boolean.TRUE); setValue("hintType", com.jaspersoft.ireport.designer.sheet.editors.JRPropertyDialog.SCOPE_REPORT); } else if(holder instanceof JRTextField) { setValue("hintType", com.jaspersoft.ireport.designer.sheet.editors.JRPropertyDialog.SCOPE_TEXT_ELEMENT); } else if(holder instanceof JRElement) { setValue("hintType", com.jaspersoft.ireport.designer.sheet.editors.JRPropertyDialog.SCOPE_ELEMENT); } }
@SuppressWarnings("unchecked") public PropertyExpressionsProperty(JRDesignElement element, JRDesignDataset dataset) { super( "properties", List.class, "Properties expressions","List of property expressions for this element", true,true); setValue("canEditAsText", Boolean.FALSE); setValue("useList", Boolean.TRUE); setValue("canUseExpression", Boolean.TRUE); this.setValue(ExpressionContext.ATTRIBUTE_EXPRESSION_CONTEXT, new ExpressionContext(dataset)); if(element instanceof JRTextField) { setValue("hintType", com.jaspersoft.ireport.designer.sheet.editors.JRPropertyDialog.SCOPE_TEXT_ELEMENT); } else { setValue("hintType", com.jaspersoft.ireport.designer.sheet.editors.JRPropertyDialog.SCOPE_ELEMENT); } this.element = element; }
public TextInputComponent(TextInputComponent component, JRBaseObjectFactory objectFactory) { this.textField = (JRTextField)objectFactory.getVisitResult(component.textField); this.multiLine = component.isMultiLine(); this.context = new BaseComponentContext(component.getContext(), objectFactory); }
@Override public void visitTextField(JRTextField textField) { JRPrintElement printText = TextFieldConverter.getInstance().convert(reportConverter, textField); addElement(parentFrame, printText); addContour(reportConverter, parentFrame, printText); }
@Override public void visitTextField(JRTextField textField) { try { xmlWriter.writeTextField(textField); } catch (IOException e) { throw new JRRuntimeException(e); } }
/** * */ public void writeTextField(JRTextField textField) throws IOException { writer.startElement(JRXmlConstants.ELEMENT_textField, getNamespace()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_isStretchWithOverflow, textField.isStretchWithOverflow(), false); writer.addAttribute(JRXmlConstants.ATTRIBUTE_evaluationTime, textField.getEvaluationTimeValue(), EvaluationTimeEnum.NOW); if (textField.getEvaluationGroup() != null) { writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_evaluationGroup, textField.getEvaluationGroup().getName()); } writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_pattern, textField.getOwnPattern()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_isBlankWhenNull, textField.isOwnBlankWhenNull()); writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_hyperlinkType, textField.getLinkType(), HyperlinkTypeEnum.NONE.getName()); writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_hyperlinkTarget, textField.getLinkTarget(), HyperlinkTargetEnum.SELF.getName()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_bookmarkLevel, textField.getBookmarkLevel(), JRAnchor.NO_BOOKMARK); writeReportElement(textField); writeBox(textField.getLineBox()); writeTextElement(textField); writeExpression(JRXmlConstants.ELEMENT_textFieldExpression, textField.getExpression(), true); if(isNewerVersionOrEqual(JRConstants.VERSION_4_1_1)) { writer.writeExpression(JRXmlConstants.ELEMENT_patternExpression, textField.getPatternExpression()); } writeExpression(JRXmlConstants.ELEMENT_anchorNameExpression, textField.getAnchorNameExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkReferenceExpression, textField.getHyperlinkReferenceExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkWhenExpression, textField.getHyperlinkWhenExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkAnchorExpression, textField.getHyperlinkAnchorExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkPageExpression, textField.getHyperlinkPageExpression(), false); writeExpression(JRXmlConstants.ELEMENT_hyperlinkTooltipExpression, textField.getHyperlinkTooltipExpression(), false); writeHyperlinkParameters(textField.getHyperlinkParameters()); writer.closeElement(); }
/** * */ public String getPattern(JRTextField element) { String ownPattern = element.getOwnPattern(); if (ownPattern != null) { return ownPattern; } JRStyle baseStyle = getBaseStyle(element); if (baseStyle != null) { return baseStyle.getPattern(); } return null; }
public void verifyElement(JRElement element) { if (element instanceof JRStaticText) { verifyStaticText((JRStaticText)element); } else if (element instanceof JRTextField) { verifyTextField((JRTextField)element); } else if (element instanceof JRImage) { verifyImage((JRImage)element); } else if (element instanceof JRSubreport) { verifySubreport((JRSubreport)element); } else if (element instanceof JRCrosstab) { verifyCrosstab((JRDesignCrosstab) element); } else if (element instanceof JRChart) { verifyChart((JRChart) element); } else if (element instanceof JRFrame) { verifyFrame((JRFrame) element); } else if (element instanceof JRComponentElement) { verifyComponentElement((JRComponentElement) element); } else if (element instanceof JRGenericElement) { verifyGenericElement((JRGenericElement) element); } }
/** * */ private void verifyTextField(JRTextField textField) { verifyReportElement(textField); verifyAnchor(textField); verifyHyperlink(textField); }
/** * */ protected JRFillTextField( JRBaseFiller filler, JRTextField textField, JRFillObjectFactory factory ) { super(filler, textField, factory); this.textTemplates = new HashMap<Pair<JRStyle,TextFormat>, JRTemplateElement>(); evaluationGroup = factory.getGroup(textField.getEvaluationGroup()); this.localizedProperties = new HashMap<String, String>(); }
protected JRDesignComponentElement createIconLabelElement(SortOrderEnum order, JRFillTextElement textElement, BuiltinExpressionEvaluatorFactory builtinExpressions) { JRTextElement parentElement = (JRTextElement) textElement.getParent(); JRDesignComponentElement designIconLabelElement = IconLabelComponentUtil.getInstance(filler.getJasperReportsContext()).createIconLabelComponentElement(parentElement, textElement); IconLabelComponent iconLabelComponent = (IconLabelComponent)designIconLabelElement.getComponent(); JRDesignTextField labelTextField = (JRDesignTextField)iconLabelComponent.getLabelTextField(); JRDesignTextField iconTextField = (JRDesignTextField)iconLabelComponent.getIconTextField(); designIconLabelElement.setStyle(textElement.getInitStyle()); labelTextField.setStyle(textElement.getInitStyle()); iconTextField.setStyle(textElement.getInitStyle()); if (textElement instanceof JRTextField) { labelTextField.setExpression(((JRTextField) textElement).getExpression()); } else if (textElement instanceof JRStaticText) { String text = ((JRStaticText) textElement).getText(); labelTextField.setExpression(builtinExpressions.createConstantExpression(text)); } String iconText = order == SortOrderEnum.ASCENDING ? filler.getPropertiesUtil().getProperty(TableReport.PROPERTY_UP_ARROW_CHAR) : (order == SortOrderEnum.DESCENDING ? filler.getPropertiesUtil().getProperty(TableReport.PROPERTY_DOWN_ARROW_CHAR) : ""); iconTextField.setExpression(builtinExpressions.createConstantExpression(" " + iconText)); designIconLabelElement.getPropertiesMap().setProperty( MatcherExporterFilter.PROPERTY_MATCHER_EXPORT_FILTER_KEY, TableReport.TABLE_HEADER_ICON_LABEL_MATCHER_EXPORT_KEY ); return designIconLabelElement; }
/** * */ protected JRTemplateText(JROrigin origin, JRDefaultStyleProvider defaultStyleProvider, JRTextField textField) { super(origin, defaultStyleProvider); setTextField(textField); }
/** * */ protected void setTextField(JRTextField textField) { setTextElement(textField); setLinkType(textField.getLinkType()); setLinkTarget(textField.getLinkTarget()); }
public IconLabelComponent(IconLabelComponent component, JRBaseObjectFactory objectFactory) { this.lineBox = component.getLineBox().clone(this); this.labelTextField = (JRTextField)objectFactory.getVisitResult(component.getLabelTextField()); this.iconTextField = (JRTextField)objectFactory.getVisitResult(component.getIconTextField()); this.iconPosition = component.getIconPosition(); this.labelFill = component.getLabelFill(); this.horizontalImageAlign = component.getOwnHorizontalImageAlign(); this.verticalImageAlign = component.getOwnVerticalImageAlign(); this.context = new BaseComponentContext(component.getContext(), objectFactory); }
public static boolean isFilterable(JRTextField textField) { if (textField != null) { return EvaluationTimeEnum.NOW.equals(textField.getEvaluationTimeValue()); } return false; }
@Override protected JRDesignFrame createColumnCell(Column column, JRElementGroup parentGroup, Cell cell) { JRDesignFrame frame = (JRDesignFrame) createColumnCell(column, parentGroup, cell, true); addHeaderToolbarElement(column, frame, TableUtil.getCellElement(JRTextField.class, column.getDetailCell(), true)); return frame; }
protected void addIconLabelComponent(Column column, JRDesignFrame frame, String suffix) { List<JRChild> children = frame.getChildren(); if (children.size() > 0) { JRBaseTextElement headerTextElement = (JRBaseTextElement)children.get(0); if (headerTextElement != null) { JRComponentElement componentElement = IconLabelComponentUtil.getInstance(fillContext.getFiller().getJasperReportsContext()).createIconLabelComponentElement(headerTextElement); IconLabelComponent iconLabelComponent = (IconLabelComponent)componentElement.getComponent(); JRDesignTextField labelTextField = (JRDesignTextField)iconLabelComponent.getLabelTextField(); if (headerTextElement instanceof JRTextField) { labelTextField.setExpression(((JRTextField) headerTextElement).getExpression()); } else if (headerTextElement instanceof JRStaticText) { labelTextField.setExpression(builtinEvaluatorFactory.createConstantExpression(((JRStaticText)headerTextElement).getText())); } JRDesignTextField iconTextField = (JRDesignTextField)iconLabelComponent.getIconTextField(); iconTextField.setExpression(builtinEvaluatorFactory.createConstantExpression(suffix)); componentElement.getPropertiesMap().setProperty(MatcherExporterFilter.PROPERTY_MATCHER_EXPORT_FILTER_KEY, TABLE_HEADER_ICON_LABEL_MATCHER_EXPORT_KEY); JRBaseElement element = (JRBaseElement)frame.getChildren().get(0); element.getPropertiesMap().setProperty(MatcherExporterFilter.PROPERTY_MATCHER_EXPORT_FILTER_KEY, TABLE_HEADER_LABEL_MATCHER_EXPORT_KEY); //frame.getChildren().remove(0); frame.getChildren().add(componentElement); } } }
protected void addColumnLabelParameters(JRDesignGenericElement element, TableComponent table) { List<BaseColumn> columns = TableUtil.getAllColumns(table); for(int i = 0, ln = columns.size(); i < ln; i++) { BaseColumn column = columns.get(i); JRExpression columnHeaderExpression = getColumnHeaderLabelExpression(column.getColumnHeader()); boolean interactiveColumn = columnInteractivityMapping.get(column).first() && (TableUtil.getCellElement(JRTextField.class, ((Column)column).getDetailCell(), true) != null); String paramName = HeaderToolbarElement.PARAM_COLUMN_LABEL_PREFIX + i + "|" + column.getUUID().toString() + "|" + interactiveColumn; addElementParameter(element, paramName, columnHeaderExpression); } }
protected TimeZone getFormatTimeZone(JRTextField textField, Class<?> valueClass) { //FIXME this duplicates the logic in JRFillTextField.determineOwnTimeZone() String formatTimeZone = null; if (textField.hasProperties()) { formatTimeZone = textField.getPropertiesMap().getProperty(JRTextField.PROPERTY_FORMAT_TIMEZONE); } if (formatTimeZone == null || formatTimeZone.isEmpty()) { if (java.sql.Date.class.isAssignableFrom(valueClass)) { formatTimeZone = propertiesUtil.getProperty(parentReport, JRTextField.PROPERTY_SQL_DATE_FORMAT_TIMEZONE); } else if (java.sql.Timestamp.class.isAssignableFrom(valueClass)) { formatTimeZone = propertiesUtil.getProperty(parentReport, JRTextField.PROPERTY_SQL_TIMESTAMP_FORMAT_TIMEZONE); } else if (java.sql.Time.class.isAssignableFrom(valueClass)) { formatTimeZone = propertiesUtil.getProperty(parentReport, JRTextField.PROPERTY_SQL_TIME_FORMAT_TIMEZONE); } } if (formatTimeZone == null || formatTimeZone.isEmpty()) { formatTimeZone = propertiesUtil.getProperty(parentReport, JRTextField.PROPERTY_FORMAT_TIMEZONE); } TimeZone reportTimeZone = fillContext.getFillDataset().getTimeZone(); return JRDataUtils.resolveFormatTimeZone(formatTimeZone, reportTimeZone); }
@Override public String getDisplayText() { if (getValue() != null) { JRTextField jrTextField = (JRTextField) getValue(); if (jrTextField.getExpression() != null) return jrTextField.getExpression().getText(); } return getIconDescriptor().getTitle(); }