Java 类net.sf.jasperreports.engine.design.JRDesignTextField 实例源码

项目:jasperreports    文件:HeaderToolbarElementUtils.java   
public static void copyOwnTextElementStyle(EditTextElementData textElementData, JRDesignTextElement textElement, Locale locale) {
    textElementData.setFontName(textElement.getOwnFontName());
    textElementData.setFontSize(textElement.getOwnFontsize() != null ? NumberFormat.getNumberInstance(locale).format(textElement.getOwnFontsize()) : null);
    textElementData.setFloatFontSize(textElement.getOwnFontsize() != null ? textElement.getOwnFontsize() : null);
    textElementData.setFontBold(textElement.isOwnBold());
    textElementData.setFontItalic(textElement.isOwnItalic());
    textElementData.setFontUnderline(textElement.isOwnUnderline());
    textElementData.setFontColor(textElement.getOwnForecolor() != null ? JRColorUtil.getColorHexa(textElement.getOwnForecolor()) : null);
    textElementData.setFontBackColor(textElement.getOwnBackcolor() != null ? JRColorUtil.getColorHexa(textElement.getOwnBackcolor()) : null);
    textElementData.setFontHAlign(textElement.getOwnHorizontalTextAlign() != null ? textElement.getOwnHorizontalTextAlign().getName() : null);
    textElementData.setMode(textElement.getOwnModeValue() != null ? textElement.getOwnModeValue().getName() : null);

    if (textElement instanceof JRDesignTextField && TableUtil.hasSingleChunkExpression((JRDesignTextField) textElement)) {
        textElementData.setFormatPattern(((JRDesignTextField) textElement).getOwnPattern());
    }
}
项目:jasperreports    文件:HeaderToolbarElementUtils.java   
public static void copyTextElementStyle(EditTextElementData textElementData, JRDesignTextElement textElement, Locale locale) {
    textElementData.setFontName(JRStringUtil.htmlEncode(textElement.getFontName()));
    textElementData.setFontSize(NumberFormat.getNumberInstance(locale).format(textElement.getFontsize()));
    textElementData.setFloatFontSize(textElement.getFontsize());
    textElementData.setFontBold(textElement.isBold());
    textElementData.setFontItalic(textElement.isItalic());
    textElementData.setFontUnderline(textElement.isUnderline());
    textElementData.setFontColor(JRColorUtil.getColorHexa(textElement.getForecolor()));
    textElementData.setFontBackColor(JRColorUtil.getColorHexa(textElement.getBackcolor()));
    textElementData.setFontHAlign(textElement.getHorizontalTextAlign().getName());
    textElementData.setMode(textElement.getModeValue().getName());

    if (textElement instanceof JRDesignTextField && TableUtil.hasSingleChunkExpression((JRDesignTextField) textElement)) {
        textElementData.setFormatPattern(JRStringUtil.htmlEncode(((JRDesignTextField) textElement).getPattern()));
    }
}
项目:PDFReporter-Studio    文件:CrosstabWizard.java   
private void createDetailCells(JRDesignCrosstab jdc) {
    List<JRCrosstabCell> cells = jdc.getCellsList();
    JRCrosstabMeasure[] measures = jdc.getMeasures();
    if (measures != null && cells != null)
        for (JRCrosstabCell c : cells) {
            int y = 0;
            if (c.getHeight() != null && measures.length > 0) {
                int h = c.getHeight() / measures.length;
                for (int i = 0; i < measures.length; i++) {
                    JRDesignExpression exp = new JRDesignExpression();
                    exp.setText("$V{" + measures[i].getName() + "}"); //$NON-NLS-1$ //$NON-NLS-2$

                    JRDesignTextField tf = (JRDesignTextField) new MTextField()
                            .createJRElement(getConfig().getJasperDesign());
                    tf.setX(0);
                    tf.setY(y);
                    tf.setWidth(c.getWidth());
                    tf.setHeight(h);
                    tf.setExpression(exp);
                    ((JRDesignCellContents) c.getContents()).addElement(tf);
                    y += h;
                }
            }
        }
}
项目:PDFReporter-Studio    文件:TableTemplateEngine.java   
/**
 * Check if a JRDesignTextField element is a placeholder for the text field appearance in
 * the detail
 * 
 * @param element the element
 * @return true if it is a place holder, false otherwise
 */
private boolean isDetailPlaceholder(JRDesignTextField element){
    JRExpression expression = element.getExpression();
    if (expression != null && expression.getText() != null){
        String text = expression.getText().toLowerCase();
        if (text.startsWith("\"")) { //$NON-NLS-1$
            text = text.substring(1);
        }
        if (text.endsWith("\"")) { //$NON-NLS-1$
            text = text.substring(0, text.length() - 1);
        }
        if (text.equals(FIELD_MARKER) || text.equals(FIELD_COMPATIBILITY_MARKER)){
            return true;
        }
    }
    return false;
}
项目:PDFReporter-Studio    文件:TableTemplateEngine.java   
/**
 * Check if a JRDesignTextField element is a placeholder for the text field appearance in
 * the detail
 * 
 * @param element the element
 * @return true if it is a place holder, false otherwise
 */
private boolean isGroupPlaceholder(JRDesignTextField element){
    JRExpression expression = element.getExpression();
    if (expression != null && expression.getText() != null){
        String text = expression.getText().toLowerCase();
        if (text.startsWith("\"")) { //$NON-NLS-1$
            text = text.substring(1);
        }
        if (text.endsWith("\"")) { //$NON-NLS-1$
            text = text.substring(0, text.length() - 1);
        }
        if (text.equals(GROUP_MARKER)){
            return true;
        }
    }
    return false;
}
项目:PDFReporter-Studio    文件:DefaultTemplateEngine.java   
/**
 * Find a JRDesignTextField element having exp as expression value.
 * 
 * @param band
 * @param exp
 * @return the first matching element or null.
 */
public static JRDesignTextField findTextFieldElement(JRElementGroup band, String exp) {
    JRElement[] elements = band.getElements();
    for (int i = 0; i < elements.length; ++i) {
        JRElement ele = elements[i];
        if (ele instanceof JRDesignTextField) {
            String s = ExprUtil.getExpressionText(((JRDesignTextField) ele).getExpression());
            if (s.startsWith("\"")) { //$NON-NLS-1$
                s = s.substring(1);
            }
            if (s.endsWith("\"")) { //$NON-NLS-1$
                s = s.substring(0, s.length() - 1);
            }
            if (s.equalsIgnoreCase(exp))
                return (JRDesignTextField) ele;
        } else if (ele instanceof JRElementGroup) {
            JRDesignTextField ele2 = findTextFieldElement((JRElementGroup) ele, exp);
            if (ele2 != null)
                return ele2;
        }
    }
    return null;
}
项目:PDFReporter-Studio    文件:EditTextFieldExpressionCommand.java   
public int showDialog() {
    if(!ExpressionEditorSupportUtil.isExpressionEditorDialogOpen()) {
        JRExpressionEditor wizard = new JRExpressionEditor();
        wizard.setValue(JRCloneUtils.nullSafeClone(originalExpression));
        ExpressionContext ec = ModelUtils.getElementExpressionContext((JRDesignTextField) textField.getValue(), textField);
        wizard.setExpressionContext(ec);

        WizardDialog dialog = ExpressionEditorSupportUtil.getExpressionEditorWizardDialog(UIUtils.getShell(), wizard);
        if (dialog.open() == Dialog.OK) {
            isExpressionChanged = true;
            newExpression=wizard.getValue();
            return Window.OK;
        }
    }
    isExpressionChanged=false;
    return Window.CANCEL;
}
项目:PDFReporter-Studio    文件:MTextField.java   
/**
 * Wait the changes of the expression
 */
@Override
public void propertyChange(PropertyChangeEvent evt) {
    if (JRDesignExpression.PROPERTY_TEXT.equals(evt.getPropertyName()) && element != null){
        ANode parent = element.getParent();
        //Refresh also the container if it is a table or something like that
        while (parent != null){
            if (parent instanceof IGraphicalPropertiesHandler){
                ((IGraphicalPropertiesHandler)parent).setChangedProperty(true);
                if (parent.getValue() instanceof JRChangeEventsSupport){
                    ((JRChangeEventsSupport)parent.getValue()).getEventSupport().firePropertyChange(FORCE_GRAPHICAL_REFRESH, null, null);
                }

            }
            parent = parent.getParent();
        }
        //Notify the change to the element, no need to set the the refresh to true, it will be done by
        //the property change since the PROPERTY_EXPRESSION is a graphical property
        element.getValue().getEventSupport().firePropertyChange(JRDesignTextField.PROPERTY_EXPRESSION, evt.getOldValue(), evt.getNewValue());
    }
}
项目:PDFReporter-Studio    文件:ReportGenerator.java   
/**
 * Find in band a JRDesignTextField element having exp as expression value.
 * 
 * @param band
 * @param exp
 * @return the first matching element or null.
 */
public static JRDesignTextField findTextFieldElement(JRElementGroup band, String exp) {
    JRElement[] elements = band.getElements();
    for (int i = 0; i < elements.length; ++i) {
        JRElement ele = elements[i];
        if (ele instanceof JRDesignTextField) {
            String s = ExprUtil.getExpressionText(((JRDesignTextField) ele).getExpression());
            if (s.startsWith("\"")) {
                s = s.substring(1);
            }
            if (s.endsWith("\"")) {
                s = s.substring(0, s.length() - 1);
            }
            if (s.equalsIgnoreCase(exp))
                return (JRDesignTextField) ele;
        } else if (ele instanceof JRElementGroup) {
            JRDesignTextField ele2 = findTextFieldElement((JRElementGroup) ele, exp);
            if (ele2 != null)
                return ele2;
        }
    }
    return null;
}
项目:PDFReporter-Studio    文件:ConvertTextIntoStatic.java   
@Override
public void execute() {
    MStaticText modelText = new MStaticText();

    JRDesignStaticText labelObject = (JRDesignStaticText)modelText.createJRElement(elementToCopy.getJasperDesign());
    JRDesignTextField textObject = (JRDesignTextField)elementToCopy.getValue();

    cloneTextField(labelObject, textObject);


    modelText.setValue(labelObject);
    Rectangle position = new Rectangle(textObject.getX(),textObject.getY(),textObject.getWidth(),textObject.getHeight());

    int oldIndex = ModelUtils.getChildrenPosition(elementToCopy);
    cmd = new CreateElementCommand(parent, modelText, position, oldIndex);
    cmd.setJasperDesign(parent.getJasperDesign());
    cmd.execute();
}
项目:PDFReporter-Studio    文件:ConvertStaticIntoText.java   
@Override
public void execute() {
    MTextField modelText = new MTextField();

    JRDesignStaticText labelObject = (JRDesignStaticText)elementToCopy.getValue();
    JRDesignTextField textObject =  (JRDesignTextField)modelText.createJRElement(elementToCopy.getJasperDesign());

    cloneTextField(textObject, labelObject);

    modelText.setValue(textObject);
    Rectangle position = new Rectangle(labelObject.getX(),labelObject.getY(),labelObject.getWidth(),labelObject.getHeight());

    int oldIndex = ModelUtils.getChildrenPosition(elementToCopy);
    cmd = new CreateElementCommand(parent, modelText, position, oldIndex);
    cmd.setJasperDesign(parent.getJasperDesign());
    cmd.execute();
}
项目:ireport-fork    文件:ModelUtils.java   
public static void fixElementsExpressions(JRDesignElementGroup group, String oldName, String newName, byte chunckType, String newClassName) {

    List list = group.getChildren();
    for (int i=0; i<list.size(); ++i)
    {
        Object obj = list.get(i);
        if (obj == null) continue;
        if (obj instanceof JRDesignElementGroup)
        {
            fixElementsExpressions((JRDesignElementGroup)obj,oldName,newName,chunckType,newClassName);
        }
        else if (obj instanceof JRDesignTextField)
        {
            fixElementExpressionText((JRDesignTextField)obj,oldName,newName,chunckType,newClassName);
        }
        else if (obj instanceof JRDesignImage)
        {
            fixElementExpressionImage((JRDesignImage)obj,oldName,newName,chunckType,newClassName);
        }


    }

}
项目:ireport-fork    文件:CrosstabGroupNode.java   
@Override
public void setString(String value) {
   if (getBucket().getExpression() != null)
   {
       getBucket().setValueClassName(value);
       ((JRDesignExpression)getBucket().getExpression()).setValueClassName(value);

       // Introspect the crosstab and change the class for all the expressions which use this group name...
       List<JRDesignElement> elements = ModelUtils.getAllElements(crosstab);
       for (JRDesignElement ele : elements)
       {
           if (ele instanceof JRDesignTextField)
           {
               JRDesignTextField dtf = (JRDesignTextField)ele;
               if (dtf.getExpression() != null &&
                   dtf.getExpression().getText() != null &&
                   dtf.getExpression().getText().trim().equals("$V{" + group.getName() + "}"))
               {
                   ((JRDesignExpression)dtf.getExpression()).setValueClassName(value);
               }
           }
       }
   }

}
项目:ireport-fork    文件:TextElementPropertiesFactory.java   
/**
 * Get the static text properties...
 */
public static Sheet.Set getTextFieldPropertySet(JRDesignTextField element, JasperDesign jd)
{

    JRDesignDataset dataset = ModelUtils.getElementDataset(element, jd);
    Sheet.Set propertySet = Sheet.createPropertiesSet();
    propertySet.setName("TEXTFIELD_ELEMENT_PROPERTIES");
    propertySet.setDisplayName("Text field properties");
    propertySet.put(new TextFieldExpressionProperty(element, dataset));
    propertySet.put(new TextFieldExpressionClassNameProperty(element));
    propertySet.put(new BlankWhenNullProperty(element));
    propertySet.put(new TextFieldPatternProperty(element));
    propertySet.put(new TextfieldPatternExpressionProperty(element,dataset));
    propertySet.put(new StretchWithOverflowProperty( element ));
    propertySet.put(new TextFieldEvaluationTimeProperty(element, dataset));
    propertySet.put(new TextFieldEvaluationGroupProperty(element, dataset));

    //propertySet.put(new LeftProperty( element ));
    return propertySet;
}
项目:ireport-fork    文件:TextElementPropertiesFactory.java   
/**
 * Convenient way to get all the properties of an element.
 * Properties positions could be reordered to have a better order.
 */
public static List<Sheet.Set> getPropertySets(JRDesignElement element, JasperDesign jd)
{
    List<Sheet.Set> sets = new ArrayList<Sheet.Set>();

    if (element instanceof  JRDesignStaticText)
    {
        sets.add( getStaticTextPropertySet((JRDesignStaticText)element, jd ));
    }
    else if (element instanceof  JRDesignTextField)
    {
        sets.add( getTextFieldPropertySet((JRDesignTextField)element, jd ));
    }

    if (element instanceof  JRDesignTextElement)
    {
        sets.add( getTextPropertySet((JRDesignTextElement)element, jd) );
    }

    return sets;
}
项目:ireport-fork    文件:NewTypesUtils.java   
private JRDesignTextField createField(JasperDesign jd, JRDesignExpression exp, int w, int h, String styleName)
{
    JRDesignTextField element = new JRDesignTextField();
    element.setX(0);
    element.setY(0);
    element.setWidth(w);
    element.setHeight(h);

    if (styleName != null && jd.getStylesMap().containsKey(styleName))
    {
        element.setStyle( (JRStyle) jd.getStylesMap().get(styleName) );
    }

    try {
        CreateTextFieldAction.setMatchingClassExpression(exp,exp.getValueClassName(), true);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    element.setExpression(exp);
    return element;
}
项目:ireport-fork    文件:CreateTextFieldFromFieldAction.java   
@Override
public JRDesignElement createReportElement(JasperDesign jasperDesign)
{
    JRDesignTextField element = (JRDesignTextField)super.createReportElement( jasperDesign );

    JRDesignField field = (JRDesignField)getPaletteItem().getData();

    ((JRDesignExpression)element.getExpression()).setText("$F{"+ field.getName() + "}");
    setMatchingClassExpression(
        ((JRDesignExpression)element.getExpression()), 
        field.getValueClassName(), 
        true
        );

    return element;
}
项目:ireport-fork    文件:CreateTotalPagesTextfieldAction.java   
@Override
public JRDesignElement createReportElement(JasperDesign jd)
{
     JRDesignTextField element = (JRDesignTextField)super.createReportElement( jd );

    ((JRDesignExpression)element.getExpression()).setText("$V{PAGE_NUMBER}");
    ((JRDesignExpression)element.getExpression()).setValueClassName("java.lang.Integer");

    element.setEvaluationTime( EvaluationTimeEnum.REPORT);
    setMatchingClassExpression(
        ((JRDesignExpression)element.getExpression()),
        "java.lang.Integer",
        true
        );

    return element;
}
项目:ireport-fork    文件:CreatePageNumberTextfieldAction.java   
@Override
public JRDesignElement createReportElement(JasperDesign jd)
{
    JRDesignTextField element = (JRDesignTextField)super.createReportElement( jd );

    ((JRDesignExpression)element.getExpression()).setText("$V{PAGE_NUMBER}");
    ((JRDesignExpression)element.getExpression()).setValueClassName("java.lang.Integer");

    setMatchingClassExpression(
        ((JRDesignExpression)element.getExpression()),
        "java.lang.Integer",
        true
        );

    return element;
}
项目:ireport-fork    文件:ElementF2Action.java   
public void actionPerformed(ActionEvent e) {
    // Look for selected elements...
    JrxmlVisualView view = IReportManager.getInstance().getActiveVisualView();

    if (view == null) return;

    AbstractReportObjectScene scene = view.getReportDesignerPanel().getActiveScene();
    if (scene == null) return;

    if (scene.getSelectedObjects().isEmpty()) return;

    Object selectedObject = scene.getSelectedObjects().iterator().next();

    if (selectedObject instanceof JRDesignTextField)
    {
       // Find the node for this element...
        Node node = IReportManager.getInstance().findNodeOf(selectedObject, view.getExplorerManager().getRootContext());
        if (node != null)
        {
            SystemAction.get(EditTextfieldExpressionAction.class).performAction(new Node[]{node});
        }
    }


}
项目:kfs    文件:TravelReportFactoryServiceImpl.java   
public JRBand createTitle(final ReportInfo report, final String title) throws Exception {
    final JRDesignBand retval = new JRDesignBand();
    retval.setHeight(93);

    final JRDesignTextField headerLine1 = h1("$P{report}.getInstitution()").toTextField();
    addDesignElementTo(retval, headerLine1, 0, 0, 356, 30);
    final JRDesignStaticText headerLine2 = h5(title + " for # ").toStaticText();
    addDesignElementTo(retval, headerLine2, 0, 31, 426, 24);
    final JRDesignTextField headerLine3 = h5("$P{report}.getTripId()").toTextField();
    addDesignElementTo(retval, headerLine3, 275, 31, 146, 24);
    final JRDesignStaticText headerLine4 = h5("Purpose: ").toStaticText();
    addDesignElementTo(retval, headerLine4, 0, 52, 100, 20);
    final JRDesignStaticText headerLine5 = h5("Dates: ").toStaticText();
    addDesignElementTo(retval, headerLine5, 0, 72, 100, 20);
    final JRDesignTextField headerLine4Field1 = h5("$P{report}.getPurpose()").toTextField();
    addDesignElementTo(retval, headerLine4Field1, 65, 52, 472, 20);
    final JRDesignTextField headerLine5Field1 = h5("$P{report}.getBeginDate()").toTextField(java.util.Date.class);
    addDesignElementTo(retval, headerLine5Field1, 45, 72, 75, 20);
    final JRDesignTextField headerLine5Field2 = h5("$P{report}.getEndDate()").toTextField(java.util.Date.class);
    addDesignElementTo(retval, headerLine5Field2, 150, 72, 75, 20);

    return retval;
}
项目:kfs    文件:TravelReportFactoryServiceImpl.java   
/**
 * Constructs a header for the {@link JRDesignGroup}
 *
 * @return {@link JRBand} instance that is your header
 */
protected JRBand createGroupHeader(final ReportInfo report) {
    final JRDesignBand retval = new JRDesignBand();
    retval.setHeight(PAGEHEADER_HEIGHT * 4);

    final JRDesignTextField expenseType = h4("$F{expenseType}").toTextField();
    addDesignElementTo(retval, expenseType, 0, PAGEHEADER_HEIGHT, CT_HEADER_WIDTH, CELL_HEIGHT + 10);

    final JRDesignStaticText nameField = h5("Expense").toStaticText();
    addDesignElementTo(retval, nameField, (CELL_WIDTH * 3 + 5) * 0, PAGEHEADER_HEIGHT * 2 + CELL_HEIGHT, CELL_WIDTH * 3, CELL_HEIGHT);

    final JRDesignStaticText dateField = h5("Date").toStaticText();
    addDesignElementTo(retval, dateField, (CELL_WIDTH * 3 + 5) * 1, PAGEHEADER_HEIGHT * 2 + CELL_HEIGHT, CELL_WIDTH * 3, CELL_HEIGHT);

    final JRDesignStaticText amountField = h5("Amount").toStaticText();
    addDesignElementTo(retval, amountField, (CELL_WIDTH * 3 + 5) * 2, PAGEHEADER_HEIGHT * 2 + CELL_HEIGHT, CELL_WIDTH * 3, CELL_HEIGHT);

    return retval;
}
项目:kfs    文件:TravelReportFactoryServiceImpl.java   
/**
 * Convenience method for creating {@link JRDesignCrosstabCell} instances. It is possible to be part of a row group and a column group.
 *
 * @param type is a {@link Class} is used to determine how to render the {@link JRDesignTextField} contained
 * in the {@link JRDesignCrosstabCell}
 * @param value is the {@link String} value to render in the {@link JRDesignCrosstabCell}
 * @param rowGroup is the name of the rowgroup this cell is part of.
 * @param colGroup is the name of the column group this cell is part of.
 */
protected JRDesignCrosstabCell crosstabCell(final Class type, final String value, final String rowGroup, final String colGroup) {
    LOG.debug("Creating cell with row group = "+ rowGroup+ " and column group = "+ colGroup);
    final JRDesignCrosstabCell retval = new JRDesignCrosstabCell();
    final JRDesignCellContents contents = new JRDesignCellContents();
    final JRDesignTextField field = normal(value).toTextField(type);
    addDesignElementTo(contents, field, 0, 0, CELL_WIDTH, CELL_HEIGHT);
    contents.setMode(MODE_OPAQUE);
    contents.setBackcolor(Color.LIGHT_GRAY);

    final JRDesignFrame frame = new JRDesignFrame();
    frame.copyBox(new TravelReportLineBox(contents));
    contents.setBox(frame);
    retval.setWidth(CELL_WIDTH);
    retval.setHeight(CELL_HEIGHT);
    retval.setContents(contents);
    retval.setRowTotalGroup(rowGroup);
    retval.setColumnTotalGroup(colGroup);
    return retval;
}
项目:com.opendoorlogistics    文件:ReportBuilderUtils.java   
private static JRDesignTextField createTextField(ODLTableDefinition table, int columnIndex) {
    JRDesignTextField textField = new JRDesignTextField();
    textField.setVerticalAlignment(VerticalAlignEnum.MIDDLE);

    JRDesignExpression expression = new JRDesignExpression();
    String fld = "$F{" + table.getColumnName(columnIndex) + "}";
    if (table.getColumnType(columnIndex) == ODLColumnType.DOUBLE) {
        String combined = fld + "!=null ? new DecimalFormat(\"###,###.###\").format(" + fld + "):\"\"";
        expression.setText(combined);
    } else {
        expression.setText(fld);
    }
    textField.setExpression(expression);
    textField.setPrintWhenDetailOverflows(false);
    return textField;
}
项目:openbravo-brazil    文件:ReportDesignBO.java   
private void addFieldValue(GridColumnVO columnVO) throws JRException {
  JRDesignBand bDetalle = (JRDesignBand) jasperDesign.getDetailSection().getBands()[0];

  JRDesignField f = new JRDesignField();
  f.setName(columnVO.getDbName());
  f.setValueClass(columnVO.getFieldClass());
  jasperDesign.addField(f);

  JRDesignExpressionChunk chunk = new JRDesignExpressionChunk();
  chunk.setText(columnVO.getDbName());
  chunk.setType(JRDesignExpressionChunk.TYPE_FIELD);
  JRDesignExpression expression = new JRDesignExpression();
  expression.addChunk(chunk);
  JRDesignTextField textField = new JRDesignTextField();
  textField.setWidth(columnVO.getWidth());
  textField.setHeight(bDetalle.getHeight());
  textField.setX(px);
  textField.setExpression(expression);
  textField.setBlankWhenNull(true);
  textField.setFontName(gridReportVO.getDetailBandStyle().getFontName());
  textField.setFontSize(new Float(gridReportVO.getDetailBandStyle().getFontSize()));
  textField.setForecolor(gridReportVO.getDetailBandStyle().getForeColor());
  textField.setBold(gridReportVO.getDetailBandStyle().isBold());
  textField.setItalic(gridReportVO.getDetailBandStyle().isItalic());
  textField.setUnderline(gridReportVO.getDetailBandStyle().isUnderline());
  textField.setStretchWithOverflow(true);
  textField.setStretchType(StretchTypeEnum.RELATIVE_TO_TALLEST_OBJECT);

  bDetalle.addElement(textField);
}
项目:jasperreports    文件:TextInputTextFieldFactory.java   
@Override
public JRDesignTextField getTextField()
{
    TextInputComponent textInputComponent = (TextInputComponent)digester.peek();
    JRDesignTextField textField = (JRDesignTextField)textInputComponent.getTextField();
    return textField;
}
项目:jasperreports    文件:JRTextFieldFactory.java   
/**
 *
 */
public JRDesignTextField getTextField()
{
    JasperDesign jasperDesign = (JasperDesign)digester.peek(digester.getCount() - 2);

    return new JRDesignTextField(jasperDesign);
}
项目:jasperreports    文件:JRFillCrosstab.java   
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;
}
项目:jasperreports    文件:HeaderToolbarElementJsonHandler.java   
private EditTextElementData setColumnValueData(Integer columnIndex, CommandTarget target, Map<String, Object> contextMap,
        JasperReportsContext jasperReportsContext, ReportContext reportContext, Locale locale) {
    EditTextElementData textElementData = new EditTextElementData();

    if (target != null){
        JRIdentifiable identifiable = target.getIdentifiable();
        JRDesignComponentElement componentElement = identifiable instanceof JRDesignComponentElement ? (JRDesignComponentElement)identifiable : null;
        StandardTable table = componentElement == null ? null : (StandardTable)componentElement.getComponent();

        List<BaseColumn> tableColumns = TableUtil.getAllColumns(table);

        if (columnIndex != null) {
            StandardColumn column = (StandardColumn) tableColumns.get(columnIndex);

            JRDesignTextField textElement = TableUtil.getCellElement(JRDesignTextField.class, column.getDetailCell(), true);

            if (textElement != null) {
                textElementData.setColumnIndex(columnIndex);
                JRDesignTextElement styledElement = resolveElementStyle(textElement, reportContext, target);
                HeaderToolbarElementUtils.copyTextElementStyle(textElementData, styledElement, locale);
            }
        }
    }
    contextMap.put("colValueData", JacksonUtil.getInstance(jasperReportsContext).getJsonString(textElementData));

    return textElementData;
}
项目:jasperreports    文件:EditTextElementCommand.java   
private void applyColumnHeaderData(EditTextElementData textElementData, JRDesignTextElement textElement, boolean execute) {
    if (EditTextElementData.APPLY_TO_HEADING.equals(textElementData.getApplyTo())) {
        if (textElement instanceof JRDesignTextField) {
            JRDesignTextField designTextField = (JRDesignTextField)textElement;
            if (execute) {
                if (oldText == null) {
                    oldText = (designTextField.getExpression()).getText();
                }
                ((JRDesignExpression)designTextField.getExpression()).setText("\"" + JRStringUtil.escapeJavaStringLiteral(textElementData.getHeadingName()) + "\"");
            } else {
                ((JRDesignExpression)designTextField.getExpression()).setText(oldText);
            }

        } else if (textElement instanceof JRDesignStaticText){
            JRDesignStaticText staticText = (JRDesignStaticText)textElement;
            if (execute) {
                if (oldText == null) {
                    oldText = staticText.getText();
                }
                staticText.setText(textElementData.getHeadingName());
            } else {
                staticText.setText(oldText);
            }
        }
    }

    textElement.setFontName(textElementData.getFontName());
    textElement.setFontSize(textElementData.getFloatFontSize());
    textElement.setBold(textElementData.getFontBold());
    textElement.setItalic(textElementData.getFontItalic());
    textElement.setUnderline(textElementData.getFontUnderline());
    textElement.setForecolor(textElementData.getFontColor() != null ? JRColorUtil.getColor("#" + textElementData.getFontColor(), textElement.getForecolor()) : null);
    textElement.setHorizontalTextAlign(HorizontalTextAlignEnum.getByName(textElementData.getFontHAlign()));
    textElement.setBackcolor(textElementData.getFontBackColor() != null ? JRColorUtil.getColor("#" + textElementData.getFontBackColor(), Color.white) : null);
    textElement.setMode(ModeEnum.getByName(textElementData.getMode()));

    if (textElement instanceof JRDesignTextField && TableUtil.hasSingleChunkExpression((JRDesignTextField) textElement)) {
        ((JRDesignTextField) textElement).setPattern(textElementData.getFormatPattern());
    }
}
项目:jasperreports    文件:IconTextFieldFactory.java   
@Override
public JRDesignTextField getTextField()
{
    IconLabelComponent iconLabelComponent = (IconLabelComponent)digester.peek();
    JRDesignTextField labelTextField = (JRDesignTextField)iconLabelComponent.getIconTextField();
    return labelTextField;
}
项目:jasperreports    文件:LabelTextFieldFactory.java   
@Override
public JRDesignTextField getTextField()
{
    IconLabelComponent iconLabelComponent = (IconLabelComponent)digester.peek();
    JRDesignTextField labelTextField = (JRDesignTextField)iconLabelComponent.getLabelTextField();
    return labelTextField;
}
项目:jasperreports    文件:TableReport.java   
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);
        }
    }
}
项目:PDFReporter-Studio    文件:CreateMeasureFieldCommand.java   
@Override
public void execute() {
    MTextField mElement = new MTextField();
    JRDesignTextField textElement =  mElement.createJRElement(parent.getJasperDesign());
    String measureName = "$V{"+(String)child.getPropertyActualValue(JRDesignCrosstabMeasure.PROPERTY_NAME)+"}";
    textElement.setExpression(new JRDesignExpression(measureName));
    newElement = textElement;
    parent.getValue().addElement(textElement);
    setElementBounds(textElement,mElement);
}
项目:PDFReporter-Studio    文件:TableTemplateEngine.java   
/**
 * Create a group column of the table, with a width of the whole table. the content in the new column
     * The size and position of the content will be relative to the width of the new column that 
 * may be different from the one of the template.
 * 
 *  
 * @param groupCell cell of the group where the element read from the template are placed
 * @param groupIndex number of the group
 * @param newGroupWidth width of the group in the resulting table
 * @param groupExpression the expression of the groupfield
 * @param jd the jasperdesign
 */
private void createGroupCell(DesignCell groupCell, int groupIndex, int newGroupWidth, JRDesignExpression groupExpression, JasperDesign jd){
    List<JRDesignElement> groupHeaderContent = null;
    if (tableGroupField.size() > groupIndex){
        groupHeaderContent = tableGroupField.get(groupIndex);
    } else if (!tableGroupField.isEmpty()){
        groupHeaderContent = tableGroupField.get(tableGroupField.size()-1);
    }
    if (groupHeaderContent != null){
        for(JRDesignElement element : groupHeaderContent){
            JRDesignElement copyElement = (JRDesignElement)element.clone();
            copyElement.setX(getRelativeWidth(newGroupWidth, copyElement.getX(), templateGroupWidth));
            copyElement.setWidth(getRelativeWidth(newGroupWidth, copyElement.getWidth(), templateGroupWidth));

            if (copyElement instanceof JRDesignTextField){
                JRDesignTextField field = (JRDesignTextField)copyElement;
                if (isGroupPlaceholder(field)){
                    field.setExpression(groupExpression);
                }
            }

            groupCell.addElement(copyElement);
        }
    } else {
        JRDesignTextField sText = new MTextField().createJRElement(jd);
        sText.setWidth(newGroupWidth);
        sText.setHeight(groupCell.getHeight());
        sText.setX(0);
        sText.setY(0);
        sText.setExpression(groupExpression);
        groupCell.addElement(sText);
    }
}
项目:PDFReporter-Studio    文件:TableTemplateEngine.java   
/**
 * Find a JRDesignTextField inside a table element having exp as expression.
 * 
 * @param parent table where to search
 * @param exp the expression of the element
 * @return the first matching element or null.
 */
public static JRDesignTextField findTextFieldElement(StandardTable parent, String exp) {
    StandardColumn col = getStandadColumn(parent.getColumns().get(0));
    if (col != null){
        JRDesignTextField result = null;
        if (col.getTableHeader() != null) result = DefaultTemplateEngine.findTextFieldElement(col.getTableHeader(), exp);
        if (col.getColumnHeader() != null && result == null) result = DefaultTemplateEngine.findTextFieldElement(col.getColumnHeader(), exp);
        if (col.getDetailCell() != null && result == null) result = DefaultTemplateEngine.findTextFieldElement(col.getDetailCell(), exp);
        return result;
    }
    return null;
}
项目:PDFReporter-Studio    文件:JasperServerTemplateEngine.java   
/**
 * Find a JRDesignTextField inside a table element having exp as expression.
 * 
 * @param parent table where to search
 * @param exp the expression of the element
 * @return the first matching element or null.
 */
public static JRDesignTextField findTextFieldElement(StandardTable parent, String exp) {
    StandardColumn col = (StandardColumn)parent.getColumns().get(0);
    if (col != null){
        JRDesignTextField result = DefaultTemplateEngine.findTextFieldElement(col.getTableHeader(), exp);
        if (result == null) result = DefaultTemplateEngine.findTextFieldElement(col.getColumnHeader(), exp);
        if (result == null) result = DefaultTemplateEngine.findTextFieldElement(col.getDetailCell(), exp);
        return result;
    }
    return null;
}
项目:PDFReporter-Studio    文件:TextFieldSection.java   
@Override
protected void initializeProvidedProperties() {
    super.initializeProvidedProperties();
    addProvidedProperties(JRDesignTextField.PROPERTY_EXPRESSION, Messages.common_expression);
    addProvidedProperties(JRDesignTextField.PROPERTY_EVALUATION_TIME, Messages.common_evaluation_time);
    addProvidedProperties(JRDesignStyle.PROPERTY_BLANK_WHEN_NULL, Messages.common_blank_when_null);
    addProvidedProperties(JRBaseTextField.PROPERTY_STRETCH_WITH_OVERFLOW, Messages.MTextField_stretch_with_overflow);
    addProvidedProperties(JRDesignStyle.PROPERTY_PATTERN, Messages.common_pattern);
    addProvidedProperties(JRDesignTextField.PROPERTY_PATTERN_EXPRESSION, Messages.MTextField_patternExpressionTitle);
}
项目:PDFReporter-Studio    文件:MTextField.java   
@Override
public Object getPropertyActualValue(Object id) {
    JRDesignTextField jrElement = (JRDesignTextField) getValue();
    if (id.equals(JRDesignStyle.PROPERTY_BLANK_WHEN_NULL))
        return jrElement.isBlankWhenNull();
    if (id.equals(JRDesignStyle.PROPERTY_PATTERN))
        return jrElement.getPattern();
    return super.getPropertyActualValue(id);
}
项目:PDFReporter-Studio    文件:MTextField.java   
/**
 * When the value of the element is set, it will be removed also all the ExpressionNameChange from 
 * the expression of its value and will be set a new ExpressionNameChange on the expression for the actual 
 * model. This is done to avoid duplicate of the listener if for expample the JRElement is moved from a model
 * to another
 */
@Override
public void setValue(Object value) {
    super.setValue(value);
    JRDesignTextField jrElement = (JRDesignTextField) getValue();
    JRDesignExpression expression = (JRDesignExpression)jrElement.getExpression();
    if (expression != null){
        removeListeners(expression);
        expression.getEventSupport().addPropertyChangeListener(new ExpressionNameChanged(this));
    }
}