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

项目:jasperreports    文件:JRStringExpressionFactory.java   
@Override
public Object createObject(Attributes atts)
{
    JRDesignExpression expression = new JRDesignExpression();

    String className = atts.getValue(JRXmlConstants.ATTRIBUTE_class);
    if (className == null)
    {
        expression.setValueClass(java.lang.String.class);
    }
    else
    {
        expression.setValueClassName(className);
    }

    return expression;
}
项目:jasperreports    文件:JRSubreportExpressionFactory.java   
@Override
public Object createObject(Attributes atts)
{
    JRDesignExpression expression = new JRDesignExpression();

    String value = atts.getValue(JRXmlConstants.ATTRIBUTE_class);

    if (value != null)
    {
        // being backward compatible
        if(value.equals("dori.jasper.engine.JasperReport"))
        {
            value = JasperReport.class.getName();
        }
        expression.setValueClassName(value);
    }
    else
    {
        expression.setValueClass(java.lang.String.class);
    }

    return expression;
}
项目:jasperreports    文件:JRVariableExpressionFactory.java   
@Override
public Object createObject(Attributes atts)
{
    JRDesignVariable variable = (JRDesignVariable)digester.peek();

    JRDesignExpression expression = new JRDesignExpression();
    if (
        variable.getCalculationValue() == CalculationEnum.COUNT
        || variable.getCalculationValue() == CalculationEnum.DISTINCT_COUNT
        )
    {
        expression.setValueClassName(java.lang.Object.class.getName());
    }
    else
    {
        expression.setValueClassName(variable.getValueClassName());
    }

    return expression;
}
项目:jasperreports    文件:JRCrosstabMeasureExpressionFactory.java   
@Override
public Object createObject(Attributes attributes)
{
    JRDesignCrosstabMeasure measure = (JRDesignCrosstabMeasure) digester.peek();

    JRDesignExpression expression = new JRDesignExpression();
    if (
        measure.getCalculationValue() == CalculationEnum.COUNT
        || measure.getCalculationValue() == CalculationEnum.DISTINCT_COUNT
        )
    {
        expression.setValueClassName(Object.class.getName());
    }
    else
    {
        expression.setValueClassName(measure.getValueClassName());
    }

    return expression;
}
项目:PDFReporter-Studio    文件:AImpObject.java   
protected AFileResource findFile(MReportUnit mrunit,
        IProgressMonitor monitor, JasperDesign jd, Set<String> fileset,
        JRDesignExpression exp, IFile file) {
    String str = ExpressionUtil.cachedExpressionEvaluation(exp, jrConfig);
    if (str == null || fileset.contains(str))
        return null;

    File f = findFile(file, str);
    if (f != null && f.exists()) {
        PublishOptions popt = new PublishOptions();
        popt.setjExpression(exp);
        if (!f.getName().contains(":"))
            popt.setExpression("\"repo:" + f.getName() + "\"");
        fileset.add(str);

        return addResource(monitor, mrunit, fileset, f, popt);
    }
    return null;
}
项目:PDFReporter-Studio    文件:HtmlFigureEditPart.java   
@Override
public void performRequest(Request req) {
    if (RequestConstants.REQ_OPEN.equals(req.getType())) {
        if(!ExpressionEditorSupportUtil.isExpressionEditorDialogOpen()) {
            JRExpressionEditor wizard = new JRExpressionEditor();
            MHtml m = (MHtml) getModel();
            wizard.setValue((JRDesignExpression) m
                    .getPropertyValue(HtmlComponent.PROPERTY_HTMLCONTENT_EXPRESSION));
            ExpressionContext ec=ModelUtils.getElementExpressionContext((JRDesignElement)m.getValue(), m);
            wizard.setExpressionContext(ec);
            WizardDialog dialog = ExpressionEditorSupportUtil.getExpressionEditorWizardDialog(Display.getDefault()
                    .getActiveShell(), wizard);
            if (dialog.open() == Dialog.OK) {
                SetValueCommand cmd = new SetValueCommand();
                cmd.setTarget((IPropertySource) getModel());
                cmd.setPropertyId(HtmlComponent.PROPERTY_HTMLCONTENT_EXPRESSION);
                cmd.setPropertyValue(wizard.getValue());
                getViewer().getEditDomain().getCommandStack().execute(cmd);
            }
        }
    } else
        super.performRequest(req);
}
项目:PDFReporter-Studio    文件:WTextExpression.java   
/**
 * Sets the expression for the widget.
 * 
 * @param exp
 *          the expression to set
 */
public void setExpression(JRDesignExpression exp) {
    isRefreshing = true;
    this.expression = exp;

    // PAY ATTENTION: Checks are needed in order to avoid notification
    // loop due to the modifyEvent raised after a setText call.
    if (exp != null && !exp.getText().equals(textExpression.getText())) {
        textExpression.setText(exp.getText());
        textExpression.setToolTipText(exp.getText());
        if (exp.getText().length() >= oldpos)
            textExpression.setSelection(oldpos, oldpos);

    } else if (exp == null && !textExpression.getText().isEmpty()) {
        textExpression.setText(""); //$NON-NLS-1$
        textExpression.setToolTipText(""); //$NON-NLS-1$
    }

    // Notifies the listeners of the new expression
    fireModifyEvent();

    isRefreshing = false;
}
项目:PDFReporter-Studio    文件:ExpressionListFieldEditor.java   
@Override
protected String getNewInputObject() {
    if(!ExpressionEditorSupportUtil.isExpressionEditorDialogOpen()) {
        JRExpressionEditor wizard = new JRExpressionEditor();
        WizardDialog dialog = 
                ExpressionEditorSupportUtil.getExpressionEditorWizardDialog(getShell(),wizard);
        if (dialog.open() == Dialog.OK) {
            JRDesignExpression newExp = wizard.getValue();
            if(newExp!=null &&
                    !Misc.nvl(newExp.getText()).equals("")){
                return newExp.getText();
            }
        }
    }
    return null;
}
项目:PDFReporter-Studio    文件:GanttSeries.java   
@Override
public JRDesignGanttSeries createSerie(JRDesignExpression expr, JRGanttSeries prev) {
    JRDesignGanttSeries f = new JRDesignGanttSeries();
    f.setSeriesExpression(expr);
    if (prev == null) {
        f.setPercentExpression(new JRDesignExpression("0"));
        f.setStartDateExpression(new JRDesignExpression("new java.util.Date()"));
        f.setEndDateExpression(new JRDesignExpression("new java.util.Date()"));
        f.setTaskExpression(new JRDesignExpression("\"Task\""));
    } else {
        f.setPercentExpression(ExprUtil.clone(prev.getPercentExpression()));
        f.setStartDateExpression(ExprUtil.clone(prev.getStartDateExpression()));
        f.setEndDateExpression(ExprUtil.clone(prev.getEndDateExpression()));
        f.setTaskExpression(ExprUtil.clone(prev.getTaskExpression()));
        f.setLabelExpression(ExprUtil.clone(prev.getLabelExpression()));
    }
    return f;
}
项目:PDFReporter-Studio    文件:TimePeriodSerie.java   
@Override
public JRDesignTimePeriodSeries createSerie(JRDesignExpression expr, JRTimePeriodSeries prev) {
    JRDesignTimePeriodSeries f = new JRDesignTimePeriodSeries();
    f.setSeriesExpression(expr);
    if (prev == null) {
        f.setValueExpression(new JRDesignExpression("0"));
        f.setStartDateExpression(new JRDesignExpression("new java.util.Date()"));
        f.setEndDateExpression(new JRDesignExpression("new java.util.Date()"));
    } else {
        f.setValueExpression(ExprUtil.clone(prev.getValueExpression()));
        f.setStartDateExpression(ExprUtil.clone(prev.getStartDateExpression()));
        f.setEndDateExpression(ExprUtil.clone(prev.getEndDateExpression()));
        f.setLabelExpression(ExprUtil.clone(prev.getLabelExpression()));
    }
    return f;
}
项目: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    文件:CrosstabWizard.java   
public static void setBucketExpression(JRDesignCrosstabBucket bucket,
        String oldExpText, AgregationFunctionEnum function) {
    JRDesignExpression exp = (JRDesignExpression) bucket.getExpression();
    if (function == AgregationFunctionEnum.UNIQUE)
        exp.setText(oldExpText);
    else if (function == AgregationFunctionEnum.YEAR) {
        exp.setText("new SimpleDateFormat(\"yyyy\").format(" + oldExpText
                + ")");
        bucket.setValueClassName(String.class.getName());
    } else if (function == AgregationFunctionEnum.MONTH) {
        exp.setText("new SimpleDateFormat(\"yyyy-MM\").format("
                + oldExpText + ")");
        bucket.setValueClassName(String.class.getName());
    } else if (function == AgregationFunctionEnum.WEEK) {
        exp.setText("new SimpleDateFormat(\"yyyy-ww\").format("
                + oldExpText + ")");
        bucket.setValueClassName(String.class.getName());
    } else if (function == AgregationFunctionEnum.DAY) {
        exp.setText("new SimpleDateFormat(\"yyyy-MM-dd\").format("
                + oldExpText + ")");
        bucket.setValueClassName(String.class.getName());
    }
    bucket.setExpression(exp);
}
项目:PDFReporter-Studio    文件:MBucket.java   
public void setPropertyValue(Object id, Object value) {
    JRDesignCrosstabBucket jrField = (JRDesignCrosstabBucket) getValue();

    if (id.equals(JRDesignCrosstabBucket.PROPERTY_ORDER))
        jrField.setOrder((SortOrderEnum) orderD.getEnumValue(value));
    else if (id
            .equals(JRDesignCrosstabBucket.PROPERTY_COMPARATOR_EXPRESSION))
        jrField.setComparatorExpression(ExprUtil.setValues(
                jrField.getComparatorExpression(), value));
    else if (id.equals(JRDesignCrosstabBucket.PROPERTY_ORDER_BY_EXPRESSION))
        jrField.setOrderByExpression(ExprUtil.setValues(
                jrField.getOrderByExpression(), value));
    else if (id.equals(JRDesignCrosstabBucket.PROPERTY_EXPRESSION))
        jrField.setExpression((JRDesignExpression) ExprUtil.setValues(
                jrField.getExpression(), value));
    else if (id.equals(JRDesignCrosstabBucket.PROPERTY_VALUE_CLASS))
        jrField.setValueClassName((String) value);
}
项目:PDFReporter-Studio    文件:MMap.java   
@Override
public JRDesignComponentElement createJRElement(JasperDesign jasperDesign) {
    JRDesignComponentElement designMap = new JRDesignComponentElement();
    StandardMapComponent component = new StandardMapComponent();
    JRDesignExpression exp1 = new JRDesignExpression();
    exp1.setText(MapDesignConverter.DEFAULT_LATITUDE.toString() + "f"); //$NON-NLS-1$
    JRDesignExpression exp2 = new JRDesignExpression();
    exp2.setText(MapDesignConverter.DEFAULT_LONGITUDE.toString() + "f"); //$NON-NLS-1$
    component.setLatitudeExpression(exp1);
    component.setLongitudeExpression(exp2);
    JRDesignExpression exp3 = new JRDesignExpression();
    exp3.setText(String.valueOf(MapComponent.DEFAULT_ZOOM));
    component.setZoomExpression(exp3);
    designMap.setComponent(component);
    designMap.setComponentKey(new ComponentKey("http://jasperreports.sourceforge.net/jasperreports/components", "c", //$NON-NLS-1$ //$NON-NLS-2$
            "map")); //$NON-NLS-1$
    StandardItemData markerData = safeGetMarkerData(component, null);
    markerData.setDataset(new JRDesignElementDataset());

    DefaultManager.INSTANCE.applyDefault(this.getClass(), designMap);

    return designMap;
}
项目:PDFReporter-Studio    文件:MarkerPropertyDialog.java   
private void fillValue(StandardItemProperty value) {
    isRefresh = true;
    if (isMandatory)
        cprop.setEnabled(false);
    evalue.setExpressionContext(expContext);
    cprop.setText(Misc.nvl(value.getName()));
    if (value.getValueExpression() != null) {
        buseexpr.setSelection(true);
        evalue.setExpression((JRDesignExpression) value.getValueExpression());
    } else {
        buseexpr.setSelection(false);
        tvalue.setText(Misc.nvl(value.getValue()));
    }
    changeValueOrExpression();
    isRefresh = false;
}
项目:PDFReporter-Studio    文件:ItemPropertyDialog.java   
private void initWidgets() {
    if(this.itemProperty==null){
        this.itemProperty = new StandardItemProperty("","",null); //$NON-NLS-1$ //$NON-NLS-2$
    }
    if(this.itemProperty.getValue()!=null){
        useExpressionCheckbox.setSelection(false);
        propertyName.setText(Misc.nvl(itemProperty.getName()));
        propertyValue.setText(itemProperty.getValue());
        propertyValueExpression.setVisible(false);
        propertyValueExpression.setEnabled(false);
        propertyValueExpression.setExpression(null);
        ((GridData)propertyValueExpression.getLayoutData()).exclude=true;
    }
    else{
        useExpressionCheckbox.setSelection(true);
        propertyName.setText(Misc.nvl(itemProperty.getName()));
        propertyValueExpression.setExpression((JRDesignExpression)itemProperty.getValueExpression());
        propertyValue.setVisible(false);
        propertyValue.setEnabled(false);
        ((GridData)propertyValue.getLayoutData()).exclude=true;
    }
}
项目:PDFReporter-Studio    文件:MapElementDialog.java   
private void initWidgets() {
    if(pname.getValue()!=null){
        useExpressionCheckbox.setSelection(false);
        propertyValue.setText(pname.getValue());
        propertyValueExpression.setVisible(false);
        propertyValueExpression.setEnabled(false);
        propertyValueExpression.setExpression(null);
        ((GridData)propertyValueExpression.getLayoutData()).exclude=true;
    }
    else{
        useExpressionCheckbox.setSelection(true);
        propertyValueExpression.setExpression((JRDesignExpression)pname.getValueExpression());
        propertyValue.setVisible(false);
        propertyValue.setEnabled(false);
        ((GridData)propertyValue.getLayoutData()).exclude=true;
    }
}
项目:PDFReporter-Studio    文件:JrxmlEditor.java   
public void gotoMarker(IMarker marker) {
    if (activePage == PAGE_DESIGNER) {
        try {
            Object expr = marker.getAttribute(JRErrorHandler.MARKER_ERROR_JREXPRESSION);
            if (expr != null && expr instanceof String) {
                JRDesignExpression expression = new JRDesignExpression();
                expression.setId(new Integer((String) expr));
                JasperDesign jd = getJasperDesign();
                JRExpressionCollector rc = JRExpressionCollector.collector(jrContext, jd);
                if (!VErrorPreview.openExpressionEditor(jrContext, rc, (JRDesignDataset) jd.getMainDataset(), expression))
                    for (JRDataset d : jd.getDatasetsList())
                        if (VErrorPreview.openExpressionEditor(jrContext, rc, (JRDesignDataset) d, expression))
                            return;
            }
        } catch (CoreException e) {
            e.printStackTrace();
        }
    }
    setActivePage(PAGE_XMLEDITOR);
    IDE.gotoMarker(xmlEditor, marker);
}
项目:PDFReporter-Studio    文件:DatasetDialog.java   
private void createFilterExpression(FormToolkit toolkit, CTabFolder tabFolder) {
    CTabItem bptab = new CTabItem(tabFolder, SWT.NONE);
    bptab.setText(Messages.DatasetDialog_filterexpression);

    Composite sectionClient = toolkit.createComposite(tabFolder);
    FillLayout fLayout = new FillLayout();
    fLayout.marginHeight = 5;
    fLayout.marginWidth = 5;
    sectionClient.setLayout(fLayout);

    filterExpression = new WTextExpression(sectionClient, SWT.NONE);
    filterExpression.setBackground(sectionClient.getBackground());
    filterExpression.setExpressionContext(new ExpressionContext(newdataset, mdataset.getJasperConfiguration()));
    filterExpression.setExpression((JRDesignExpression) newdataset.getFilterExpression());
    filterExpression.addModifyListener(new ExpressionModifiedListener() {

        @Override
        public void expressionModified(ExpressionModifiedEvent event) {
            newdataset.setFilterExpression(event.modifiedExpression);
        }
    });
    bptab.setControl(sectionClient);
}
项目:PDFReporter-Studio    文件:ExpressionWidget.java   
public void setExpression(JRDesignExpression exp) {
    this.expression = exp;
    setOnParent(exp);

    if (exp != null && exp.getText() != null) {

        if (!exp.getText().equals(expText.getText()))
        {
            expText.setText(exp.getText());
            expText.setToolTipText(expText.getText());
        }
    }
    else{
        expText.setText("");
        expText.setToolTipText("");
    }
}
项目:PDFReporter-Studio    文件:DatasetRunWidgetRadio.java   
private void setEnabledWidgets() {
    setSelection4Widget(radioUseParentConnection, isUseParentConnection);
    setSelection4Widget(radioUseConnectionExpression, isUseConnectionExpression);
    setSelection4Widget(radioUseDatasourceExpression, isUseDatasourceExpression);
    setSelection4Widget(radioUseEmptyDatasource, isUseEmptyDatasource);
    setSelection4Widget(radioNoConnection, isNoConnection);

    setEnabled4Widget(connectionExpressionBox, isUseConnectionExpression);
    setEnabled4Widget(datasourceExpressionBox, isUseDatasourceExpression);

    if (isUseConnectionExpression || isUseParentConnection)
        connectionExpressionBox.setExpression((JRDesignExpression) datasetrun.getConnectionExpression());
    else
        connectionExpressionBox.setExpression(null);

    if (isUseDatasourceExpression || isUseEmptyDatasource)
        datasourceExpressionBox.setExpression((JRDesignExpression) datasetrun.getDataSourceExpression());
    else
        datasourceExpressionBox.setExpression(null);
}
项目:PDFReporter-Studio    文件:SPExpression.java   
protected void createComponent(Composite parent) {
    expr = new WTextExpression(parent, SWT.NONE, 1);
    expr.addModifyListener(new ExpressionModifiedListener() {
        @Override
        public void expressionModified(ExpressionModifiedEvent event) {
            JRDesignExpression exp = expr.getExpression();
            section.changeProperty(pDescriptor.getId(), exp != null ? exp.clone() : null);
        }
    });
    if (parent.getLayout() instanceof GridLayout) {
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        expr.setLayoutData(gd);
    }
    expr.getTextControl().addFocusListener(focusListener);
    autocomplete = new AutoCompleteField(expr.getTextControl(), new TextContentAdapter(),
            InputHistoryCache.get(getHistoryKey()));
}
项目:PDFReporter-Studio    文件:CreateParameterDialog.java   
/**
 * Initialize the controls with the value of an edited JRParameter, if this is 
 * defined
 */
private void initializeFields(){
    if (selectedParam != null){
        expression.setExpression((JRDesignExpression)selectedParam.getExpression());
        paramterName.setText(paramterName.getText());
        int selectionIndex = -1;
        boolean found = false;
        for(String value : paramterName.getItems()){
            selectionIndex++;
            if (value.equals(selectedParam.getName())){
                found = true;
                paramterName.select(selectionIndex);
                break;
            }
        }
        if (!found){
            List<String> newItems = new ArrayList<String>();
            newItems.add(selectedParam.getName());
            newItems.addAll(Arrays.asList(comboInput));
            comboInput = newItems.toArray(new String[newItems.size()]);
            paramterName.setItems(comboInput);
            paramterName.select(0);
        }
    }
}
项目:PDFReporter-Studio    文件:SubreportPropertyPage.java   
protected void loadSettings() {
    JRParameter[] parameters = null;
    // load settings, if available..
    if (getSettings() != null && getSettings().containsKey(NewSubreportPage.SUBREPORT_PARAMETERS)) {
        parameters = (JRParameter[]) getSettings().get(NewSubreportPage.SUBREPORT_PARAMETERS);
    }

    if (lastParameters != parameters) {
        lastParameters = parameters;
        List<JRDesignSubreportParameter> sParameters = new ArrayList<JRDesignSubreportParameter>();

        if (lastParameters != null && lastParameters.length > 0) {
            // Create an array of subreport parameters to be used in in the table model...
            for (JRParameter p : lastParameters) {
                if (!p.isSystemDefined()) {
                    JRDesignSubreportParameter sp = new JRDesignSubreportParameter();
                    sp.setName(p.getName());
                    sp.setExpression(new JRDesignExpression());
                    sParameters.add(sp);
                }
            }
        }
        setValue(sParameters.toArray(new JRDesignSubreportParameter[sParameters.size()]));
    }
}
项目:PDFReporter-Studio    文件:JRExpressionCellEditor.java   
@Override
protected Object openDialogBox(Control cellEditorWindow) {
    if(!ExpressionEditorSupportUtil.isExpressionEditorDialogOpen()) {
        JRExpressionEditor wizard = new JRExpressionEditor();
        wizard.setValue((JRDesignExpression) getValue());
        wizard.setExpressionContext(expContext);
        WizardDialog dialog = ExpressionEditorSupportUtil.getExpressionEditorWizardDialog(cellEditorWindow.getShell(), wizard);
        dialog.create();
        if (dialog.open() == Dialog.OK) {
            JRDesignExpression value = wizard.getValue();
            // updateContents(value);
            return value;
        }
    }
    return null;
}
项目:PDFReporter-Studio    文件:ExprUtil.java   
@SuppressWarnings("unchecked")
public static <T extends JRExpression> T setValues(T e, Object value, String valueClassName) {
    if (value == null)
        return null;
    String text = "";
    JRDesignExpression expr = (JRDesignExpression) e;
    expr = createExpression(expr);
    if (value instanceof JRDesignExpression) {
        return checkEmpty((T) value);
    } else if (value instanceof String) {
        text = (String) value;
    }
    expr.setText(text);
    if (valueClassName != null)
        expr.setValueClassName(valueClassName);
    return checkEmpty((T) expr);
}
项目:PDFReporter-Studio    文件:ExprUtil.java   
/**
 * Create a JRDesignExpression by specifying the expression text. An optional value class name can be used as
 * expression class. Value class name should be specified only if strictly required, since it is deprecated by
 * JasperReports.
 * 
 * @param text
 *          - The text of the expression, or null for empty expressions
 * @param valueClassName
 *          - A string representing the class returned by the expression
 * 
 * @return a new JRDesignExpression
 */
@SuppressWarnings("deprecation")
public static JRDesignExpression createExpression(String text, String valueClassName) {
    JRDesignExpression exp = new JRDesignExpression();

    if (text != null) {
        exp.setText(text);
    }

    if (valueClassName != null) {
        exp.setValueClassName(valueClassName);
    }

    return exp;

}
项目:PDFReporter-Studio    文件:ImageSelectionDialog.java   
private void createCustomExprContainer() {
    cmpCustomExpression = new Composite(grpOptions, SWT.NONE);
    GridLayout cmpCustomExpressionlayout = new GridLayout();
    cmpCustomExpression.setLayout(cmpCustomExpressionlayout);

    customExpression = new WTextExpression(cmpCustomExpression, SWT.NONE,
            Messages.ImageSelectionDialog_EnterExpression, WTextExpression.LABEL_ON_TOP) {
        @Override
        public void setExpression(JRDesignExpression exp) {
            super.setExpression(exp);
            // Keep in synch the expression modification in the widget
            // with the final image expression.
            jrImgExpression = exp;
        }
    };
    customExpression.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
}
项目:PDFReporter-Studio    文件:ImageSelectionDialog.java   
@Override
protected void okPressed() {
    // Updates the expression that will be associated to the image element.
    // Covers all cases except the custom expression one because
    // it is already kept in synch.
    if (!btnCustomExpression.getSelection()) {
        if (imageExpressionText != null) {
            jrImgExpression = new JRDesignExpression();
            if (imageExpressionText.endsWith(".svg")) //$NON-NLS-1$
                jrImgExpression
                        .setText("net.sf.jasperreports.renderers.BatikRenderer.getInstanceFromLocation($P{JASPER_REPORTS_CONTEXT}, \"" + imageExpressionText + "\")");//$NON-NLS-1$ //$NON-NLS-2$
            else
                jrImgExpression.setText("\"" + imageExpressionText + "\"");//$NON-NLS-1$ //$NON-NLS-2$
        } else {
            jrImgExpression = null;
        }
    }

    super.okPressed();
}
项目: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());
    }
}
项目: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    文件:JRInitialValueExpressionFactory.java   
@Override
public Object createObject(Attributes atts)
{
    JRDesignVariable variable = (JRDesignVariable)digester.peek();

    JRDesignExpression expression = new JRDesignExpression();
    expression.setValueClassName(variable.getValueClassName());

    return expression;
}
项目:jasperreports    文件:JRDefaultValueExpressionFactory.java   
@Override
public Object createObject(Attributes atts)
{
    JRDesignParameter parameter = (JRDesignParameter)digester.peek();

    JRDesignExpression expression = new JRDesignExpression();
    expression.setValueClassName(parameter.getValueClassName());

    return expression;
}
项目:jasperreports    文件:JRExpressionFactory.java   
@Override
public Object createObject( Attributes attrs ){
    JRDesignExpression expression = new JRDesignExpression();
    expression.setValueClassName( String.class.getName() );

    ExpressionTypeEnum type = ExpressionTypeEnum.getByName(attrs.getValue(JRXmlConstants.ATTRIBUTE_type));
    if (type != null)
    {
        expression.setType(type);
    }

    return expression;
}
项目:jasperreports    文件:JRExpressionFactory.java   
@Override
public Object createObject(Attributes attrs)
{
    JRDesignExpression expression = new JRDesignExpression();
    expression.setValueClassName(Comparator.class.getName());
    return expression;
}
项目:jasperreports    文件:JRExpressionFactory.java   
@Override
public Object createObject(Attributes attrs)
{
    JRDesignExpression expression = new JRDesignExpression();
    String className = attrs.getValue(JRXmlConstants.ATTRIBUTE_class);
    if (className != null)
    {
        expression.setValueClassName(className);
    }
    else if (defaultValueClass != null)
    {
        expression.setValueClassName(defaultValueClass);
    }
    return expression;
}
项目:jasperreports    文件:JRCrosstabBucketExpressionFactory.java   
@Override
public Object createObject(Attributes attributes)
{
    JRDesignCrosstabBucket bucket = (JRDesignCrosstabBucket)digester.peek();

    String className = attributes.getValue(ATTRIBUTE_class);
    if (className != null)
    {
        bucket.setValueClassName(className);
    }

    return new JRDesignExpression();
}
项目:jasperreports    文件:JRCrosstabParameterValueExpressionFactory.java   
@Override
public Object createObject(Attributes atts)
{
    JRDesignParameter parameter = (JRDesignParameter)digester.peek();

    JRDesignExpression expression = new JRDesignExpression();
    expression.setValueClassName(parameter.getValueClassName());

    return expression;
}
项目:jasperreports    文件:JRDesignCrosstabBucket.java   
/**
 * Sets the grouping expression.
 * 
 * @param expression the grouping expression
 * @see net.sf.jasperreports.crosstabs.JRCrosstabBucket#getExpression()
 */
public void setExpression(JRDesignExpression expression)
{
    Object old = this.expression;
    this.expression = expression;
    getEventSupport().firePropertyChange(PROPERTY_EXPRESSION, old, this.expression);
}
项目: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());
    }
}