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

项目:jasperreports    文件:JRGenericElementParameterFactory.java   
@Override
public Object createObject(Attributes attrs) throws Exception
{
    JRDesignGenericElementParameter param = new JRDesignGenericElementParameter();

    String name = attrs.getValue(JRXmlConstants.ATTRIBUTE_name);
    param.setName(name);

    String skipWhenNullAttr = attrs.getValue(JRXmlConstants.ATTRIBUTE_skipWhenNull);
    if (skipWhenNullAttr != null)
    {
        param.setSkipWhenEmpty(Boolean.valueOf(skipWhenNullAttr).booleanValue());
    }

    return param;
}
项目:ireport-fork    文件:GenericElementParametersPanel.java   
@SuppressWarnings("unchecked")
private void jButtonCopyFromMasterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCopyFromMasterActionPerformed

    javax.swing.table.DefaultTableModel model = (javax.swing.table.DefaultTableModel)jTable.getModel();

    List reportParameters = IReportManager.getInstance().getActiveReport().getParametersList();

    for (int i=0; i<reportParameters.size(); ++i) {
        JRDesignParameter jrParameter = (JRDesignParameter)reportParameters.get(i);
        if (jrParameter.isSystemDefined()) continue;

        // Check if a similar parameter already exists...
        if (!findParameter(parameters, jrParameter.getName())) {
            JRDesignGenericElementParameter parameter = new JRDesignGenericElementParameter();
            parameter.setName(jrParameter.getName() );
            JRDesignExpression exp = new JRDesignExpression();
            exp.setText("$P{" + jrParameter.getName() + "}");
            exp.setValueClassName( jrParameter.getValueClassName() );
            parameter.setValueExpression(exp);
            parameters.add(parameter);
            model.addRow(new Object[]{parameter, Misc.getExpressionText(parameter.getValueExpression())});
        }
    }
    jTable.updateUI();

}
项目:jasperreports    文件:TableReport.java   
protected void addElementParameter(JRDesignGenericElement element, String name, Object value)
{
    JRDesignGenericElementParameter param = new JRDesignGenericElementParameter();
    param.setName(name);

    JRDesignExpression valueExpression = builtinEvaluatorFactory.createConstantExpression(value);
    param.setValueExpression(valueExpression);

    element.addParameter(param);
}
项目:jasperreports    文件:TableReport.java   
protected void addElementParameter(JRDesignGenericElement element, String name, JRExpression expression)
{
    JRDesignGenericElementParameter param = new JRDesignGenericElementParameter();
    param.setName(name);
    param.setValueExpression(expression);
    element.addParameter(param);
}
项目:ireport-fork    文件:GenericElementParameterDialog.java   
private void jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOKActionPerformed

    String newName = this.jTextFieldName.getText().trim();
    if (newName.length() <= 0)
    {
        javax.swing.JOptionPane.showMessageDialog(this,
                I18n.getString("GenerciElementParameterDialog.Message.Warning"),
                I18n.getString("GenerciElementParameterDialog.Message.Error"),
                javax.swing.JOptionPane.WARNING_MESSAGE );
        return;
    }

    if (oldName != null && 
        !oldName.equals(newName) &&
        currentParameters != null &&
        findParameter(currentParameters,newName))
    {
        javax.swing.JOptionPane.showMessageDialog(this,
                I18n.getString("GenerciElementParameterDialog.Message.Warning2"),
                I18n.getString("GenerciElementParameterDialog.Message.Error2"),
                javax.swing.JOptionPane.WARNING_MESSAGE );
        return;
    }

    tmpParameter = new JRDesignGenericElementParameter();

    tmpParameter.setName(this.jTextFieldName.getText().trim());
    JRDesignExpression exp = new JRDesignExpression();
    exp.setText(this.jRTextExpressionAreaDefaultExpression.getText());
    exp.setValueClassName("java.lang.Object");
    tmpParameter.setValueExpression(exp);
    setVisible(false);
    this.setDialogResult( javax.swing.JOptionPane.OK_OPTION);
    dispose();
}
项目:ireport-fork    文件:GenericElementParametersPanel.java   
/**
  * This method will duplicate the map. The panel will work on a copy of the map.
  **/
 @SuppressWarnings("unchecked")
 public void setParameters(List oldParameters) {

     this.parameters.clear();
     DefaultTableModel model = (DefaultTableModel)this.jTable.getModel();
     model.setRowCount(0);
     // Create a copy of the map content...
     Iterator iterator = oldParameters.iterator();
     while (iterator.hasNext())
     {
         JRDesignGenericElementParameter oldParameter = (JRDesignGenericElementParameter)iterator.next();

         JRDesignGenericElementParameter parameter = new JRDesignGenericElementParameter();
         parameter.setName(oldParameter.getName() );
         if (oldParameter.getValueExpression() != null)
         {
             JRDesignExpression exp = new JRDesignExpression();
             exp.setText(oldParameter.getValueExpression().getText());
             exp.setValueClassName(oldParameter.getValueExpression().getValueClassName());
             parameter.setValueExpression(exp);
         }
         parameters.add(parameter);

         model.addRow(new Object[]{parameter,Misc.getExpressionText(parameter.getValueExpression()) });
     }
}
项目:ireport-fork    文件:GenericElementParametersPanel.java   
@SuppressWarnings("unchecked")
private void jButtonModifyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonModifyActionPerformed

    DefaultTableModel model = (DefaultTableModel)jTable.getModel();

    int row = jTable.getSelectedRow();
    if (row < 0) return;

    row = ((JXTable)jTable).convertRowIndexToModel(row);

    JRDesignGenericElementParameter parameter = (JRDesignGenericElementParameter) model.getValueAt(row,0);
    int paramIndex = parameters.indexOf(parameter);

    GenericElementParameterDialog jrpd = null;
    Window pWin = SwingUtilities.getWindowAncestor(this);
    if (pWin instanceof Dialog) jrpd = new GenericElementParameterDialog((Dialog)pWin, getParameters());
    else if (pWin instanceof Frame) jrpd = new GenericElementParameterDialog((Frame)pWin, getParameters());
    else jrpd = new GenericElementParameterDialog((Dialog)null, getParameters());


    jrpd.setExpressionContext( getExpressionContext() );
    jrpd.setParameter(parameter);
    jrpd.setVisible(true);

    if (jrpd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION) {
        parameter = jrpd.getParameter();
        parameters.remove(paramIndex);
        parameters.add(paramIndex, parameter);
        model.setValueAt(parameter, row, 0);
        model.setValueAt(Misc.getExpressionText( parameter.getValueExpression()), row, 1);

        jTable.updateUI();
    }
}
项目:ireport-fork    文件:GenericElementParameterDialog.java   
/** Setter for property tmpParameter.
 * @param tmpParameter New value of property tmpParameter.
 *
 */
public void setParameter(JRDesignGenericElementParameter tmpParameter) {
    this.jTextFieldName.setText( tmpParameter.getName() );
    oldName =tmpParameter.getName();                            
    this.jRTextExpressionAreaDefaultExpression.setText( Misc.getExpressionText(tmpParameter.getValueExpression()) );
}
项目:ireport-fork    文件:GenericElementParametersPanel.java   
@SuppressWarnings("unchecked")
private void jButtonAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAddActionPerformed

    Object pWin = SwingUtilities.getWindowAncestor(this);
    GenericElementParameterDialog jrpd = null;
    if (pWin instanceof Dialog) jrpd = new GenericElementParameterDialog((Dialog)pWin, getParameters());
    else jrpd = new GenericElementParameterDialog((Frame)pWin, getParameters());

    jrpd.setExpressionContext( getExpressionContext() );
    jrpd.setVisible(true);

    if (jrpd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION) {

        JRDesignGenericElementParameter parameter = jrpd.getParameter();
        parameters.add(parameter);

        DefaultTableModel model = (DefaultTableModel)jTable.getModel();
        model.addRow(new Object[]{parameter, Misc.getExpressionText(parameter.getValueExpression())});

    }

}
项目:dynamicreports-jasper    文件:AbstractExpressionTransform.java   
protected JRGenericElementParameter getGenericElementParameterExpression(DRIDesignParameterExpression parameterExpression) {
    JRDesignGenericElementParameter jrParameterExpression = new JRDesignGenericElementParameter();
    jrParameterExpression.setName(parameterExpression.getName());
    jrParameterExpression.setValueExpression(getExpression(parameterExpression.getValueExpression()));
    return jrParameterExpression;
}
项目:ireport-fork    文件:GenericElementParameterDialog.java   
/** Getter for property tmpParameter.
 * @return Value of property tmpParameter.
 *
 */
public JRDesignGenericElementParameter getParameter() {
    return tmpParameter;
}