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

项目:jasperreports    文件:JRSubreportFactory.java   
@Override
public Object createObject(Attributes atts)
{
    JasperDesign jasperDesign = (JasperDesign)digester.peek(digester.getCount() - 2);

    JRDesignSubreport subreport = new JRDesignSubreport(jasperDesign);

    String isUsingCache = atts.getValue(JRXmlConstants.ATTRIBUTE_isUsingCache);
    if (isUsingCache != null && isUsingCache.length() > 0)
    {
        subreport.setUsingCache(Boolean.valueOf(isUsingCache));
    }

    String runToBottomAttr = atts.getValue(JRXmlConstants.ATTRIBUTE_runToBottom);
    if (runToBottomAttr != null)
    {
        subreport.setRunToBottom(Boolean.valueOf(runToBottomAttr));
    }

    return subreport;
}
项目:PDFReporter-Studio    文件:SubreportSection.java   
public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage) {
    super.createControls(parent, tabbedPropertySheetPage);

    parent.setLayout(new GridLayout(2, false));

    createWidget4Property(parent, JRBaseSubreport.PROPERTY_RUN_TO_BOTTOM);

    createWidget4Property(parent, JRBaseSubreport.PROPERTY_USING_CACHE);
    createWidget4Property(parent, JRDesignSubreport.PROPERTY_EXPRESSION);
    createWidget4Property(parent, JRDesignSubreport.PROPERTY_PARAMETERS_MAP_EXPRESSION);
    createWidget4Property(parent, JRDesignSubreport.PROPERTY_CONNECTION_EXPRESSION);
    createWidget4Property(parent, JRDesignSubreport.PROPERTY_DATASOURCE_EXPRESSION);

    Composite cmp = getWidgetFactory().createComposite(parent);
    cmp.setLayout(new GridLayout(2, false));
    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
    gd.horizontalSpan = 2;
    cmp.setLayoutData(gd);

    createWidget4Property(cmp, JRDesignSubreport.PROPERTY_RETURN_VALUES, false);

    createWidget4Property(cmp, JRDesignSubreport.PROPERTY_PARAMETERS, false);
}
项目:ireport-fork    文件:SubreportPropertiesFactory.java   
/**
 * Get the static text properties...
 */
public static Sheet.Set getSubreportPropertySet(JRDesignSubreport element, JasperDesign jd)
{

    JRDesignDataset dataset = ModelUtils.getElementDataset(element, jd);
    Sheet.Set propertySet = Sheet.createPropertiesSet();
    propertySet.setName("SUBREPORT_ELEMENT_PROPERTIES");
    propertySet.setDisplayName("Subreport properties");
    propertySet.put(new SubreportExpressionProperty(element, dataset));
    propertySet.put(new SubreportExpressionClassNameProperty(element));
    propertySet.put(new SubreportUsingCacheProperty(element));
    propertySet.put(new RunToBottomProperty(element));
    propertySet.put(new ParametersMapExpressionProperty(element, dataset));
    propertySet.put(new ConnectionTypeProperty(element) );
    propertySet.put(new ConnectionExpressionProperty(element, dataset));
    propertySet.put(new DataSourceExpressionProperty(element, dataset));
    propertySet.put(new SubreportParametersProperty(element, dataset));
    propertySet.put(new SubreportReturnValuesProperty(element, dataset));

    //propertySet.put(new LeftProperty( element ));
    return propertySet;
}
项目:kfs    文件:TravelReportFactoryServiceImpl.java   
/**
 * Create a subreport {@link JRDesignSubreport}. Since all kinds of reports are created through the {@link TravelReportFactoryServiceImpl} class,
 * even sub report instances will be considered normal reports and created individually. This method just marks where in the
 * parent report to place the sub report. This does not actually create another report.
 *
 * @param report is the parent report
 * @field is the field that is a {@link SubReport}
 * @return {@link JRDesignSubreport} to be added to report
 */
protected JRDesignSubreport createSubreport(final ReportInfo report, final Field field) throws Exception {
    final JRDesignSubreport retval = new JRDesignSubreport(new JasperDesign());
    final JRDesignExpression dsExpression = new JRDesignExpression();
    final String getterName = "get" + field.getName().substring(0, 1).toUpperCase() + field.getName().substring(1);
    dsExpression.setText("$P{report}." + getterName + "()");
    dsExpression.setValueClass(JRDataSource.class);
    retval.setDataSourceExpression(dsExpression);

    final JRDesignExpression expression = new JRDesignExpression();
    expression.setValueClass(JasperReport.class);
    expression.setText("$P{" + field.getName() + "Subreport}");
    retval.setExpression(expression);

    retval.setHeight(SUBREPORT_HEIGHT);

    return retval;
}
项目:com.opendoorlogistics    文件:ReportBuilderUtils.java   
static JRDesignSubreport createSubreport(int x, int y, int subheight, String subreportDesignExpression, String subreportDataExpression,
        JRDefaultStyleProvider defaultStyleProvider) {
    JRDesignSubreport sub = new JRDesignSubreport(defaultStyleProvider);
    sub.setHeight(subheight);
    sub.setX(x);
    sub.setY(y);
    sub.setPrintRepeatedValues(true);
    sub.setRemoveLineWhenBlank(true);

    //sub.setPrintInFirstWholeBand(true);

    if (subreportDataExpression != null) {
        sub.setDataSourceExpression(new JRDesignExpression(subreportDataExpression));
    }

    // expect the subreport template as a parameter to the main report - see
    // http://stackoverflow.com/questions/9785451/generate-jasper-report-with-subreport-from-java
    if (subreportDesignExpression != null) {
        JRDesignExpression subexpression = new JRDesignExpression(subreportDesignExpression);
        sub.setExpression(subexpression);
    }
    return sub;
}
项目:jasperreports    文件:StandardSubreportPartComponent.java   
/**
 *
 */
public void setParametersMapExpression(JRExpression parametersMapExpression)
{
    Object old = this.parametersMapExpression;
    this.parametersMapExpression = parametersMapExpression;
    getEventSupport().firePropertyChange(JRDesignSubreport.PROPERTY_PARAMETERS_MAP_EXPRESSION, old, this.parametersMapExpression);
}
项目:jasperreports    文件:StandardSubreportPartComponent.java   
/**
 *
 */
public void addParameter(JRSubreportParameter subreportParameter) throws JRException
{
    if (this.parametersMap.containsKey(subreportParameter.getName()))
    {
        throw 
        new JRException(
            JRDesignSubreport.EXCEPTION_MESSAGE_KEY_DUPLICATE_PARAMETER,
            new Object[]{subreportParameter.getName()});
    }

    this.parametersMap.put(subreportParameter.getName(), subreportParameter);
    getEventSupport().fireCollectionElementAddedEvent(JRDesignSubreport.PROPERTY_PARAMETERS, 
            subreportParameter, parametersMap.size() - 1);
}
项目:jasperreports    文件:StandardSubreportPartComponent.java   
/**
 *
 */
public JRSubreportParameter removeParameter(String name)
{
    JRSubreportParameter removed = this.parametersMap.remove(name);
    if (removed != null)
    {
        getEventSupport().fireCollectionElementRemovedEvent(JRDesignSubreport.PROPERTY_PARAMETERS, removed, -1);
    }
    return removed;
}
项目:jasperreports    文件:StandardSubreportPartComponent.java   
/**
 * Adds a return value to the subreport.
 * 
 * @param returnValue the return value to be added.
 */
public void addReturnValue(JRSubreportReturnValue returnValue)
{
    this.returnValues.add(returnValue);
    getEventSupport().fireCollectionElementAddedEvent(JRDesignSubreport.PROPERTY_RETURN_VALUES, 
            returnValue, returnValues.size() - 1);
}
项目:jasperreports    文件:StandardSubreportPartComponent.java   
/**
 * Removes a return value from the subreport.
 * 
 * @param returnValue the return value to be removed
 * @return <code>true</code> if the return value was found and removed 
 */
public boolean removeReturnValue(JRSubreportReturnValue returnValue)
{
    int idx = this.returnValues.indexOf(returnValue);
    if (idx >= 0)
    {
        this.returnValues.remove(idx);
        getEventSupport().fireCollectionElementRemovedEvent(JRDesignSubreport.PROPERTY_RETURN_VALUES, returnValue, idx);
        return true;
    }
    return false;
}
项目:jasperreports    文件:StandardSubreportPartComponent.java   
/**
 *
 */
public void setExpression(JRExpression expression)
{
    Object old = this.expression;
    this.expression = expression;
    getEventSupport().firePropertyChange(JRDesignSubreport.PROPERTY_EXPRESSION, old, this.expression);
}
项目:PDFReporter-Studio    文件:JrxmlPublishContributor.java   
private void publishJrxml(AMJrxmlContainer mres, IProgressMonitor monitor, JasperDesign jasper, Set<String> fileset, IFile file) throws Exception {
    if (monitor.isCanceled())
        return;
    MReportUnit mrunit = null;
    if (mres instanceof MReportUnit)
        mrunit = (MReportUnit) mres;
    else if (mres.getParent() instanceof MReportUnit)
        mrunit = (MReportUnit) mres.getParent();

    if (mrunit != null) {
        List<JRDesignElement> elements = ModelUtils.getAllElements(jasper);
        for (JRDesignElement ele : elements) {
            if (ele instanceof JRDesignImage)
                publishImage(mrunit, monitor, jasper, fileset, file, ele, version);
            else if (ele instanceof JRDesignSubreport) {
                publishSubreport(mrunit, monitor, jasper, fileset, file, ele, version);
            } else {
                publishElement(mrunit, monitor, jasper, fileset, file, ele, version);
            }
        }
        publishDataAdapters(mrunit, monitor, jasper, fileset, file, version);
        publishBundles(mrunit, monitor, jasper, fileset, file, version);
        publishTemplates(mrunit, monitor, jasper, fileset, file, version);
    }
    // here extend and give possibility to contribute to plugins
    Activator.getExtManager().publishJrxml(mres, monitor, jasper, fileset, file, version);
}
项目:PDFReporter-Studio    文件:SubreportSection.java   
@Override
protected void initializeProvidedProperties() {
    super.initializeProvidedProperties();
    addProvidedProperties(JRBaseSubreport.PROPERTY_RUN_TO_BOTTOM, Messages.MSubreport_run_to_bottom);
    addProvidedProperties(JRBaseSubreport.PROPERTY_USING_CACHE, Messages.common_using_cache);
    addProvidedProperties(JRDesignSubreport.PROPERTY_EXPRESSION, Messages.common_expression);
    addProvidedProperties(JRDesignSubreport.PROPERTY_PARAMETERS_MAP_EXPRESSION, Messages.common_parameters_map_expression);
    addProvidedProperties(JRDesignSubreport.PROPERTY_CONNECTION_EXPRESSION, Messages.common_connection_expression);
    addProvidedProperties(JRDesignSubreport.PROPERTY_DATASOURCE_EXPRESSION, Messages.MSubreport_datasource_expression);
    addProvidedProperties(JRDesignSubreport.PROPERTY_RETURN_VALUES, Messages.common_return_values);
    addProvidedProperties(JRDesignSubreport.PROPERTY_PARAMETERS, Messages.common_parameters);
}
项目:PDFReporter-Studio    文件:SubreportsUtil.java   
public static Map<File, IFile> getSubreportFiles(JasperReportsConfiguration jConfig, IFile file, JasperDesign jd,
        IProgressMonitor monitor) {
    Map<File, IFile> fmap = new HashMap<File, IFile>();
    try {
        List<JRDesignElement> elements = ModelUtils.getAllElements(jd);
        for (JRDesignElement ele : elements) {
            if (ele instanceof JRDesignSubreport)
                publishSubreport(jConfig, fmap, monitor, file, jd, (JRDesignSubreport) ele);
        }
    } finally {
        jConfig.init(file);
    }
    return fmap;
}
项目:PDFReporter-Studio    文件:MSubreport.java   
@Override
public Object getPropertyValue(Object id) {
    JRDesignSubreport jrElement = (JRDesignSubreport) getValue();
    if (id.equals(JRBaseSubreport.PROPERTY_RUN_TO_BOTTOM))
        return jrElement.isRunToBottom();
    if (id.equals(JRBaseSubreport.PROPERTY_USING_CACHE))
        return jrElement.getUsingCache();
    if (id.equals(JRDesignSubreport.PROPERTY_EXPRESSION))
        return ExprUtil.getExpression(jrElement.getExpression());
    if (id.equals(JRDesignSubreport.PROPERTY_PARAMETERS_MAP_EXPRESSION))
        return ExprUtil.getExpression(jrElement.getParametersMapExpression());
    if (id.equals(JRDesignSubreport.PROPERTY_CONNECTION_EXPRESSION))
        return ExprUtil.getExpression(jrElement.getConnectionExpression());
    if (id.equals(JRDesignSubreport.PROPERTY_DATASOURCE_EXPRESSION))
        return ExprUtil.getExpression(jrElement.getDataSourceExpression());
    if (id.equals(JRDesignSubreport.PROPERTY_PARAMETERS))
        return JRCloneUtils.cloneArray(jrElement.getParameters());
    if (id.equals(JRDesignSubreport.PROPERTY_RETURN_VALUES)) {
        if (returnValuesDTO == null) {
            returnValuesDTO = new JReportsDTO();
            returnValuesDTO.setjConfig(getJasperConfiguration());
            returnValuesDTO.setProp1(jrElement);
        }
        returnValuesDTO.setValue(JRCloneUtils.cloneList(jrElement.getReturnValuesList()));
        return returnValuesDTO;

    }

    return super.getPropertyValue(id);
}
项目:PDFReporter-Studio    文件:MSubreport.java   
@Override
public JRDesignElement createJRElement(JasperDesign jasperDesign) {
    JRDesignSubreport subreport = new JRDesignSubreport(jasperDesign);

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

    return subreport;
}
项目:PDFReporter-Studio    文件:MSubreport.java   
@Override
public void trasnferProperties(JRElement target){
    super.trasnferProperties(target);

    JRDesignSubreport jrSource = (JRDesignSubreport) getValue();
    if (jrSource != null){
        JRDesignSubreport jrTarget = (JRDesignSubreport)target;
        jrTarget.setRunToBottom(jrSource.isRunToBottom());
    }
}
项目:PDFReporter-Studio    文件:SubreportWizard.java   
@Override
public void addPages() {
    this.subreport = new MSubreport();
    subreport.setValue(subreport.createJRElement(getConfig().getJasperDesign()));
    subreport.setPropertyValue(JRDesignSubreport.PROPERTY_CONNECTION_EXPRESSION, "$P{REPORT_CONNECTION}");

    step0 = new NewSubreportPage();
    step0.setSubreport(subreport);
    addPage(step0);

    subreport.setJasperConfiguration(getConfig());

    step2 = new WizardConnectionPage();
    addPage(step2);

    step3 = new SubreportPropertyPage();
    addPage(step3);

    // Setting up the expressions context. This is not really useful, since
    // the subreport has not been added to the report yet and it will be fallback to the default dataset.
    // FIXME: pass a proper ANode to the wizard to let the code to lookup for a more appropriate dataset.
    ExpressionContext ec = ModelUtils.getElementExpressionContext((JRDesignElement)subreport.getValue(), subreport);
    step0.setExpressionContext(ec);
    step2.setExpressionContext(ec);
    // FIXME: add support to the step3 for setting the expression context
    //step3.setExpressionContext(ec);

}
项目:ireport-fork    文件:SubreportParametersProperty.java   
@SuppressWarnings("unchecked")
public SubreportParametersProperty(JRDesignSubreport element, JRDesignDataset dataset)
{
   super( JRDesignSubreport.PROPERTY_PARAMETERS, Map.class, "Parameters","Subreport parameters", true,true);

   setValue("canEditAsText", Boolean.FALSE);
   setValue("expressionContext", new ExpressionContext(dataset));
   //setValue("subreport", element);
   this.element = element;
   this.dataset = dataset;
}
项目:ireport-fork    文件:SubreportParametersProperty.java   
@SuppressWarnings("unchecked")
public void setValue(Object val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    if (val == null || !(val instanceof Map)) throw new IllegalArgumentException();

    // Fill this map with the content of the map we got here...
    // TODO: manage UNDO for a map object...
    Map parameters = (Map)val;
    element.getParametersMap().clear();
    element.getParametersMap().putAll(parameters);
    element.getEventSupport().firePropertyChange( JRDesignSubreport.PROPERTY_PARAMETERS , null, element.getParametersMap() );
}
项目:ireport-fork    文件:SubreportPropertiesFactory.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  JRDesignSubreport)
    {
        sets.add( getSubreportPropertySet((JRDesignSubreport)element, jd ));
    }

    return sets;
}
项目:ireport-fork    文件:SubreportReturnValuesProperty.java   
@SuppressWarnings("unchecked")
public SubreportReturnValuesProperty(JRDesignSubreport element, JRDesignDataset dataset)
{
   super( JRDesignSubreport.PROPERTY_RETURN_VALUES, List.class, "Return Values","Subreport return values.", true,true);

   setValue("canEditAsText", Boolean.FALSE);
   setValue("expressionContext", new ExpressionContext(dataset));
   //setValue("subreport", element);
   this.element = element;
   this.dataset = dataset;
}
项目:ireport-fork    文件:SubreportReturnValuesProperty.java   
@SuppressWarnings("unchecked")
public void setValue(Object val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    if (val == null || !(val instanceof List)) throw new IllegalArgumentException();

    // If val is the same as the old map, the user pressed cancel
    // in the editor.. so nothing to do...
    if (val == element.getReturnValuesList()) return;

    // Fill this map with the content of the map we got here...
    // TODO: manage UNDO for a map object...
    List returnValues = (List)val;
    element.getReturnValuesList().clear();
    element.getReturnValuesList().addAll(returnValues);
    element.getEventSupport().firePropertyChange( JRDesignSubreport.PROPERTY_RETURN_VALUES , null, element.getReturnValuesList() );
}
项目:ireport-fork    文件:SubreportExpressionClassNameProperty.java   
@SuppressWarnings("unchecked")
public SubreportExpressionClassNameProperty(JRDesignSubreport element)
{
    super(JRDesignExpression.PROPERTY_VALUE_CLASS_NAME, String.class,
          "Expression Class",
          "Expression Class");
    this.element = element;

    setValue("canEditAsText", true);
    setValue("oneline", true);
    setValue("suppressCustomEditor", false);
}
项目:ireport-fork    文件:ConnectionTypeProperty.java   
@SuppressWarnings("unchecked")
public ConnectionTypeProperty(JRDesignSubreport element)
{
    super("PROPERTY_CONNECTION_TYPE", Integer.class,
          "Connection type",
          "You can choose to fill this subreport using a connection or a datasource or without providing any data.");
    this.element = element;

    setValue("suppressCustomEditor", true);
}
项目:ireport-fork    文件:OpenSubreportAction.java   
protected File notifySubreportProviders(JrxmlEditorSupport ed, JRDesignSubreport subreportElement, File file)
{

    Lookup lookup = Lookups.forPath("ireport/SubreportOpenerProviders"); // NOI18N
    Collection<? extends SubreportOpenerProvider> subreportProviders = lookup.lookupAll(SubreportOpenerProvider.class);

    Iterator<? extends SubreportOpenerProvider> it = subreportProviders.iterator();
    while (it.hasNext ()) {

        SubreportOpenerProvider subreportOpenerProvider = it.next();

        try {
            File f = subreportOpenerProvider.openingSubreport(ed, subreportElement, file);
            if (f!=null)
            {
                file = f;
            }

        } catch (Throwable t)
        {
            t.printStackTrace();
        }
    }

    return file;

}
项目:ireport-fork    文件:OpenSubreportAction.java   
protected boolean enable(org.openide.nodes.Node[] activatedNodes) {
    if (activatedNodes == null || activatedNodes.length != 1) return false;

    // Check we have selected a subreport
    if (activatedNodes[0] instanceof ElementNode &&
        ((ElementNode)activatedNodes[0]).getElement() instanceof JRDesignSubreport)
    {
        return true;
    }
    return false;
}
项目:ireport-fork    文件:SubreportParametersProperty.java   
@SuppressWarnings("unchecked")
public SubreportParametersProperty(JRDesignSubreport element, JRDesignDataset dataset)
{
   super( JRDesignSubreport.PROPERTY_PARAMETERS, Map.class, I18n.getString("Global.Property.Parameters"),I18n.getString("Global.Property.Subreportparameters"), true,true);

   setValue("canEditAsText", Boolean.FALSE);
   setValue("expressionContext", new ExpressionContext(dataset));
   //setValue("subreport", element);
   this.element = element;
   this.dataset = dataset;
}
项目:ireport-fork    文件:SubreportParametersProperty.java   
@SuppressWarnings("unchecked")
public void setValue(Object val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    if (val == null || !(val instanceof Map)) throw new IllegalArgumentException();

    // If val is the same as the old map, the user pressed cancel
    // in the editor.. so nothing to do...
    if (val == element.getParametersMap()) return;
    // Fill this map with the content of the map we got here...
    // TODO: manage UNDO for a map object...
    Map parameters = (Map)val;
    element.getParametersMap().clear();
    element.getParametersMap().putAll(parameters);
    element.getEventSupport().firePropertyChange( JRDesignSubreport.PROPERTY_PARAMETERS , null, element.getParametersMap() );
}
项目:kfs    文件:TravelReportFactoryServiceImpl.java   
protected int subReportCount(final JRBand design) {
    int retval = 0;
    for (final Object obj : design.getElements()) {
        if (obj instanceof JRDesignSubreport) {
            retval++;
        }
    }

    return retval;
}
项目:com.opendoorlogistics    文件:SubreportsWithProviderBuilder.java   
private static void setupDatasourceParameters(JasperDesign report, boolean hasHeaderMap) {
    try {
        // ensure every subreport has the provider parameter
        for (JRBand band : report.getDetailSection().getBands()) {
            for (JRElement element : band.getElements()) {
                if (JRDesignSubreport.class.isInstance(element)) {
                    JRDesignSubreport sub = (JRDesignSubreport) element;
                    sub.removeParameter(ReportConstants.DATASOURCE_PROVIDER_PARAMETER);

                    JRDesignSubreportParameter param = new JRDesignSubreportParameter();
                    param.setName(ReportConstants.DATASOURCE_PROVIDER_PARAMETER);
                    param.setExpression(new JRDesignExpression("$P{" + ReportConstants.DATASOURCE_PROVIDER_PARAMETER + "}"));
                    sub.addParameter(param);
                }
            }
        }

        // ensure main report has correct provider parameters
        addParameter(report, ReportConstants.DATASOURCE_PROVIDER_PARAMETER);
        if (hasHeaderMap) {
            addParameter(report, ReportConstants.HEADER_MAP_PROVIDER_PARAMETER);
        }

    } catch (Throwable e) {
        throw new RuntimeException(e);
    }

}
项目:com.opendoorlogistics    文件:SubreportsWithProviderBuilder.java   
/**
 * Export the result files and return a list of the compile filenames
 * 
 * @param result
 * @param directory
 * @param prefix
 * @return
 * @throws JRException
 */
public static List<String> exportResultFiles(BuildResult result, String directory, String prefix, boolean exportJrxml, boolean exportCompiled) throws JRException {
    File dir = new File(directory);
    if (dir.exists() == false && !dir.mkdirs()) {
        return null;
    }

    ArrayList<String> absFilenames = new ArrayList<>();
    for (int i = 0; i < result.designs.size(); i++) {
        JasperDesign design = result.designs.get(i);

        // update subreport reference to use the prefix. Do this on a deep copy of the design
        design = (JasperDesign) Serialization.deepCopy(design);
        JRDesignSection details = (JRDesignSection) design.getDetailSection();
        if (details != null) {
            for (JRBand band : details.getBandsList()) {
                JRDesignBand designBand = (JRDesignBand) band;
                for (JRElement element : designBand.getElements()) {
                    if (JRDesignSubreport.class.isInstance(element)) {
                        JRDesignSubreport sub = (JRDesignSubreport) element;
                        JRDesignExpression expression = (JRDesignExpression) sub.getExpression();
                        String newExpression = "\"" + prefix + expression.getText().replaceAll("\"", "") + "\"";
                        expression.setText(newExpression);
                    }
                }
            }
        }

        if (exportJrxml) {
            JRXmlWriter.writeReport(design, dir.getAbsolutePath() + File.separator + prefix + result.baseFilenames.get(i) + ".jrxml", "UTF-8");
        }

        if (exportCompiled) {
            String absFilename = dir.getAbsolutePath() + File.separator + prefix + result.baseFilenames.get(i) + ".jasper";
            JasperCompileManager.compileReportToFile(design, absFilename);
            absFilenames.add(absFilename);
        }
    }
    return absFilenames;
}
项目:PDFReporter-Studio    文件:ImpSubreport.java   
protected JRDesignExpression getExpression(JRDesignElement img) {
    return (JRDesignExpression) ((JRDesignSubreport) img).getExpression();
}
项目:PDFReporter-Studio    文件:MSubreport.java   
/**
 * Creates the property descriptors.
 * 
 * @param desc
 *          the desc
 */
@Override
public void createPropertyDescriptors(List<IPropertyDescriptor> desc, Map<String, Object> defaultsMap) {
    super.createPropertyDescriptors(desc, defaultsMap);

    CheckBoxPropertyDescriptor runToBottomD = new CheckBoxPropertyDescriptor(JRBaseSubreport.PROPERTY_RUN_TO_BOTTOM,
            Messages.MSubreport_run_to_bottom, NullEnum.NULL);
    runToBottomD.setDescription(Messages.MSubreport_run_to_bottom_description);
    desc.add(runToBottomD);

    CheckBoxPropertyDescriptor useCacheD = new CheckBoxPropertyDescriptor(JRBaseSubreport.PROPERTY_USING_CACHE,
            Messages.common_using_cache, NullEnum.INHERITED);
    useCacheD.setDescription(Messages.MSubreport_using_cache_description);
    desc.add(useCacheD);

    JRExpressionPropertyDescriptor exprD = new JRExpressionPropertyDescriptor(JRDesignSubreport.PROPERTY_EXPRESSION,
            Messages.common_expression);
    exprD.setDescription(Messages.MSubreport_expression_description);
    desc.add(exprD);
    exprD.setHelpRefBuilder(new HelpReferenceBuilder(
            "net.sf.jasperreports.doc/docs/schema.reference.html?cp=0_1#subreportExpression"));

    JRExpressionPropertyDescriptor paramExprD = new JRExpressionPropertyDescriptor(
            JRDesignSubreport.PROPERTY_PARAMETERS_MAP_EXPRESSION, Messages.common_parameters_map_expression);
    paramExprD.setDescription(Messages.MSubreport_parameters_map_expression_description);
    desc.add(paramExprD);
    paramExprD.setHelpRefBuilder(new HelpReferenceBuilder(
            "net.sf.jasperreports.doc/docs/schema.reference.html?cp=0_1#parametersMapExpression"));

    JRExpressionPropertyDescriptor connExprD = new JRExpressionPropertyDescriptor(
            JRDesignSubreport.PROPERTY_CONNECTION_EXPRESSION, Messages.common_connection_expression);
    connExprD.setDescription(Messages.MSubreport_connection_expression_description);
    desc.add(connExprD);
    connExprD.setHelpRefBuilder(new HelpReferenceBuilder(
            "net.sf.jasperreports.doc/docs/schema.reference.html?cp=0_1#connectionExpression"));

    JRExpressionPropertyDescriptor dsExprD = new JRExpressionPropertyDescriptor(
            JRDesignSubreport.PROPERTY_DATASOURCE_EXPRESSION, Messages.MSubreport_datasource_expression);
    dsExprD.setDescription(Messages.MSubreport_datasource_expression_description);
    desc.add(dsExprD);
    dsExprD.setHelpRefBuilder(new HelpReferenceBuilder(
            "net.sf.jasperreports.doc/docs/schema.reference.html?cp=0_1#dataSourceExpression"));

    SubreportPropertiesPropertyDescriptor propertiesD = new SubreportPropertiesPropertyDescriptor(
            JRDesignSubreport.PROPERTY_PARAMETERS, Messages.common_parameters);
    propertiesD.setDescription(Messages.MSubreport_parameters_description);
    desc.add(propertiesD);
    propertiesD.setHelpRefBuilder(new HelpReferenceBuilder(
            "net.sf.jasperreports.doc/docs/schema.reference.html?cp=0_1#subreportParameter"));
    propertiesD.init(this);

    RVPropertyDescriptor returnValuesD = new RVPropertyDescriptor(JRDesignSubreport.PROPERTY_RETURN_VALUES,
            Messages.common_return_values);
    returnValuesD.setDescription(Messages.MSubreport_return_values_description);
    desc.add(returnValuesD);
    propertiesD.setHelpRefBuilder(new HelpReferenceBuilder(
            "net.sf.jasperreports.doc/docs/schema.reference.html?cp=0_1#returnValue"));

    returnValuesD.setCategory(Messages.MSubreport_subreport_properties_category);
    propertiesD.setCategory(Messages.MSubreport_subreport_properties_category);
    dsExprD.setCategory(Messages.MSubreport_subreport_properties_category);
    connExprD.setCategory(Messages.MSubreport_subreport_properties_category);
    paramExprD.setCategory(Messages.MSubreport_subreport_properties_category);
    exprD.setCategory(Messages.MSubreport_subreport_properties_category);
    useCacheD.setCategory(Messages.MSubreport_subreport_properties_category);
    runToBottomD.setCategory(Messages.MSubreport_subreport_properties_category);

    setHelpPrefix(desc, "net.sf.jasperreports.doc/docs/schema.reference.html?cp=0_1#subreport");
}
项目:PDFReporter-Studio    文件:SubreportWizard.java   
/**
 * Retutn the subreport object...
 * 
 * @return
 */
public MSubreport getSubreport() {

    JRSubreportParameter[] map = step3.getValue();

    if (map != null)
        subreport.setPropertyValue(JRDesignSubreport.PROPERTY_PARAMETERS, map);

    // Configure connection expression...
    JRDesignDatasetRun datasetRun = step2.getJRDesignDatasetRun();

    subreport.setPropertyValue(JRDesignSubreport.PROPERTY_PARAMETERS_MAP_EXPRESSION,
            datasetRun.getParametersMapExpression());
    subreport.setPropertyValue(JRDesignSubreport.PROPERTY_CONNECTION_EXPRESSION,
            datasetRun.getConnectionExpression());
    subreport.setPropertyValue(JRDesignSubreport.PROPERTY_DATASOURCE_EXPRESSION,
            datasetRun.getDataSourceExpression());

    // Create the subreport expression....
    if (step0.getSelectedOption() == NewSubreportPage.EXISTING_REPORT)
    {
        subreport.setPropertyValue( JRDesignSubreport.PROPERTY_EXPRESSION ,  step0.getSelectedSubreportExpression() );
    }
    else if (step0.getSelectedOption() == NewSubreportPage.NEW_REPORT)
    {
        // In this case the new report has been created by using a report wizard
        // which stores the location of a file in the
        // wizard settings...
        IPath path = (IPath) getSettings().get(JSSWizard.FILE_PATH);
        String fname = (String) getSettings().get(JSSWizard.FILE_NAME);

        IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
        IResource resource = root.findMember(path);
        IFile file = ((IContainer)resource).getFile(new Path(fname));

        IFile contextfile = (IFile) getConfig().get(FileUtils.KEY_FILE);

        String filepath = "";
        if (contextfile != null && file.getProject().equals(contextfile.getProject())) {
            filepath = file.getProjectRelativePath().toPortableString().replaceAll(file.getProject().getName() + "/", "");
        } else {
            filepath = file.getRawLocationURI().toASCIIString();
        }
        if (filepath.toLowerCase().endsWith(".jrxml"))
        {
            filepath = filepath.substring(0,filepath.lastIndexOf(".")) + ".jasper";
        }
        JRDesignExpression exp = new JRDesignExpression();
        exp.setText("\"" + filepath + "\""); //$NON-NLS-1$ $NON-NLS-1$

        /*if (map.length>0)
        {
            try {
                JasperReportsConfiguration jrContext = new JasperReportsConfiguration(DefaultJasperReportsContext.getInstance(), file);
                JasperDesign jd = new JRXmlLoader(JasperReportsConfiguration.getJRXMLDigester()).loadXML(new InputSource(file.getContents()));
                jrContext.setJasperDesign(jd);
                for(JRSubreportParameter param : map){
                    if (!jd.getParametersMap().containsKey(param.getName())){
                        JRDesignParameter newParam = new JRDesignParameter();
                        newParam.setName(param.getName());
                        newParam.setDefaultValueExpression(param.getExpression());
                        jd.addParameter(newParam);
                    }
                }
                JRXmlWriter.writeReport(jd, file.getProjectRelativePath().toPortableString(), "UTF-8");
            } catch (Exception e) {         }
        }*/
        subreport.setPropertyValue( JRDesignSubreport.PROPERTY_EXPRESSION , exp ); 
    }
    return subreport;
}
项目:PDFReporter-Studio    文件:JReportsDTO.java   
public JRDesignSubreport getProp1() {
    return prop1;
}
项目:PDFReporter-Studio    文件:JReportsDTO.java   
public void setProp1(JRDesignSubreport prop1) {
    this.prop1 = prop1;
}
项目:ireport-fork    文件:ElementNodeVisitor.java   
/**
 *
 */
public void visitSubreport(JRSubreport subreport)
{
    node = new ElementNode(jasperDesign, (JRDesignSubreport)subreport,doLkp);
    node.setIconBaseWithExtension(ICON_SUBREPORT);
}
项目:ireport-fork    文件:ElementPropertiesFactory.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>();
    sets.add( getCommonPropertySet(element, jd) );

    if (element instanceof  JRDesignGraphicElement)
    {
        sets.addAll( GraphicElementPropertiesFactory.getGraphicPropertySets((JRDesignGraphicElement)element, jd) );
    }
    if (element instanceof  JRDesignTextElement)
    {
        sets.addAll( TextElementPropertiesFactory.getPropertySets(element, jd) );
    }
    if (element instanceof  JRDesignSubreport)
    {
        sets.addAll( SubreportPropertiesFactory.getPropertySets(element, jd) );
    }
    if (element instanceof JRDesignBreak)
    {
        sets.add( getBreakPropertySet((JRDesignBreak)element) );

    }

    if (element instanceof  JRDesignChart)
    {
        sets.addAll( ChartPropertiesFactory.getPropertySets((JRDesignChart)element, jd) );
    }



    if (element instanceof  JRBox)
    {
        sets.add( getBoxPropertySet((JRBox)element) );
    }

    if (element instanceof  JRDesignGenericElement)
    {
        sets.add(  getGenericElementPropertySet((JRDesignGenericElement)element, jd ) );
    }

    return sets;
}
项目:ireport-fork    文件:SubreportWizardIterator.java   
private void configureElement(JRDesignSubreport element) throws IOException, JRException
{
    Boolean useSubParam  = (Boolean)wizard.getProperty("addsubreportparameter");
        String exp = (String)wizard.getProperty("subreportexpression");
        String subreport_directory = (String)wizard.getProperty("subreport_directory");
        String con_exp = (String)wizard.getProperty("subreport_connection_expression");
        String ds_exp = (String)wizard.getProperty("subreport_datasource_expression");

        JRParameter[] sub_params = (JRParameter[])wizard.getProperty("subreport_parameters");
        String[] params_expressions = (String[])wizard.getProperty("subreport_parameters_values");

        if (useSubParam != null && useSubParam.booleanValue())
        {
            JasperDesign jd = IReportManager.getInstance().getActiveReport();

            if (!jd.getParametersMap().containsKey("SUBREPORT_DIR"))
            {
            JRDesignParameter param = new JRDesignParameter();
            param.setName("SUBREPORT_DIR");
            param.setForPrompting(false);
            // TODO: set as directory the target directory for compiled files....
            if (subreport_directory == null)
            {
                subreport_directory = Misc.getDataFolderPath( ((TemplateWizard)wizard).getTargetFolder() ) + File.separator;
            }
            subreport_directory = Misc.string_replace("\\\\","\\",subreport_directory);
            subreport_directory = "\"" + subreport_directory + "\"";
            param.setDefaultValueExpression( Misc.createExpression("java.lang.String", subreport_directory));
            param.setValueClassName("java.lang.String");

            // add the parameter to the document...
                try {
                    jd.addParameter(param);
                } catch (JRException ex)
                {}
            }
        }

        if (exp != null)
        {
            element.setExpression( Misc.createExpression("java.lang.String", exp) );
        }

        if (con_exp != null)
        {
            element.setConnectionExpression( Misc.createExpression("java.sql.Connection", con_exp) );
        }

        if (ds_exp != null)
        {
            element.setDataSourceExpression( Misc.createExpression("net.sf.jasperreports.engine.JRDataSource", ds_exp) );
        }

        if (sub_params != null && params_expressions != null)
        {
            for (int i=0; i<sub_params.length && i<params_expressions.length; ++i)
            {
                JRDesignSubreportParameter sp = new JRDesignSubreportParameter();
                sp.setName(  sub_params[i].getName() );
                sp.setExpression( Misc.createExpression(null, params_expressions[i] ) );
                element.addParameter(sp);
            }
        }
}