/** * Handle the change of the position of a band * * @param evt the event that changed the band position */ private void handleChangeOrder(PropertyChangeEvent evt) { if (evt instanceof IndexedPropertyChangeEvent && evt.getNewValue() instanceof Integer) { JRDesignSection source = (JRDesignSection) evt.getSource(); int newInd = ((IndexedPropertyChangeEvent) evt).getIndex(); JRBand b = source.getBandsList().get(newInd); MBand mb = null; for (INode n : getChildren()) { if (n.getValue() == b) { mb = (MBand) n; break; } } if (mb != null) { newInd = getChildren().indexOf(mb) + (newInd - (Integer) evt.getOldValue()); getChildren().remove(mb); getChildren().add(newInd, mb); } } }
private static void addBands(List<ColumnFieldTO> columnFields, JasperDesign jasperDesign, boolean isGrid, Locale locale) { JRDesignBand band; // Title if (!isGrid) { band = buildTitleBand(jasperDesign); jasperDesign.setTitle(band); } // Page header band = buildPageHeaderBand(columnFields, jasperDesign, isGrid); jasperDesign.setPageHeader(band); // Column header // Detail band = buildDetailBand(columnFields, jasperDesign, isGrid, locale); ((JRDesignSection) jasperDesign.getDetailSection()).addBand(band); // Column footer // Page footer if (!isGrid) { band = buildPageFooterBand(); jasperDesign.setPageFooter(band); } // Summary }
public void updateSectionListeners() { ((JRDesignSection)jd.getDetailSection()).getEventSupport().removePropertyChangeListener(this); ((JRDesignSection)jd.getDetailSection()).getEventSupport().addPropertyChangeListener(this); for (int i=0; i<this.jd.getGroupsList().size(); ++i) { JRDesignGroup grp = (JRDesignGroup)this.jd.getGroupsList().get(i); grp.getEventSupport().removePropertyChangeListener(this); grp.getEventSupport().addPropertyChangeListener(this); if (((JRDesignSection)grp.getGroupHeaderSection() != null)) { ((JRDesignSection)grp.getGroupHeaderSection()).getEventSupport().removePropertyChangeListener(this); ((JRDesignSection)grp.getGroupHeaderSection()).getEventSupport().addPropertyChangeListener(this); } if (((JRDesignSection)grp.getGroupFooterSection() != null)) { ((JRDesignSection)grp.getGroupFooterSection()).getEventSupport().removePropertyChangeListener(this); ((JRDesignSection)grp.getGroupFooterSection()).getEventSupport().addPropertyChangeListener(this); } } }
public void propertyChange(PropertyChangeEvent evt) { com.jaspersoft.ireport.designer.IReportManager.getInstance().notifyReportChange(); if (evt.getPropertyName() == null) return; if (ModelUtils.containsProperty( this.getPropertySets(), evt.getPropertyName())) { //if (evt.getPropertyName().equals(JRBaseBand.PROPERTY_SPLIT_TYPE)) //{ // this.firePropertyChange(JRBaseBand.PROPERTY_SPLIT_ALLOWED, evt.getOldValue(), evt.getNewValue() ); //} this.firePropertyChange(evt.getPropertyName(), evt.getOldValue(), evt.getNewValue() ); } if (evt.getPropertyName().equals( JRDesignGroup.PROPERTY_NAME) || evt.getPropertyName().equals( JRDesignSection.PROPERTY_BANDS)) { String s = ModelUtils.nameOf(band, jd); setDisplayName( s ); this.fireNameChange(null, getDisplayName()); } }
public void updateSectionListeners() { ((JRDesignSection)getJasperDesign().getDetailSection()).getEventSupport().removePropertyChangeListener(this); ((JRDesignSection)getJasperDesign().getDetailSection()).getEventSupport().addPropertyChangeListener(this); for (int i=0; i<getJasperDesign().getGroupsList().size(); ++i) { JRDesignGroup grp = (JRDesignGroup)getJasperDesign().getGroupsList().get(i); grp.getEventSupport().removePropertyChangeListener(this); grp.getEventSupport().addPropertyChangeListener(this); if (((JRDesignSection)grp.getGroupHeaderSection() != null)) { ((JRDesignSection)grp.getGroupHeaderSection()).getEventSupport().removePropertyChangeListener(this); ((JRDesignSection)grp.getGroupHeaderSection()).getEventSupport().addPropertyChangeListener(this); } if (((JRDesignSection)grp.getGroupFooterSection() != null)) { ((JRDesignSection)grp.getGroupFooterSection()).getEventSupport().removePropertyChangeListener(this); ((JRDesignSection)grp.getGroupFooterSection()).getEventSupport().addPropertyChangeListener(this); } } }
protected JRSection wrapBand(JRBand band, BandTypeEnum bandType) { if (band == null) { return null; } JROrigin origin = new JROrigin(null, getName(), bandType); JRDesignSection section = new JRDesignSection(origin); section.addBand(band); return section; }
private void removeUnwantedBand(JasperDesign jd){ /** * Remove unwanted band and the placeholder dataset of the table */ jd.setColumnHeader(null); jd.setColumnFooter(null); JRDesignSection bandSection = (JRDesignSection)jd.getDetailSection(); for(JRBand actualDetail : jd.getDetailSection().getBands()) bandSection.removeBand(actualDetail); //Delete the groups while (jd.getGroupsList().size()>0) jd.getGroupsList().remove(0); }
@Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals(JasperDesign.PROPERTY_COLUMN_COUNT) || evt.getPropertyName().equals(JasperDesign.PROPERTY_LEFT_MARGIN) || evt.getPropertyName().equals(JasperDesign.PROPERTY_RIGHT_MARGIN) || evt.getPropertyName().equals(JasperDesign.PROPERTY_PAGE_WIDTH) || evt.getPropertyName().equals(JasperDesign.PROPERTY_COLUMN_SPACING)){ PageFormatUtils.updateColumnWidth(getValue()); } else if (evt.getPropertyName().equals(JasperDesign.PROPERTY_DATASETS)) { handleDatasourceChanged(evt); } else if (evt.getPropertyName().equals(JasperDesign.PROPERTY_TITLE) || evt.getPropertyName().equals(JasperDesign.PROPERTY_PAGE_HEADER) || evt.getPropertyName().equals(JasperDesign.PROPERTY_COLUMN_HEADER) || evt.getPropertyName().equals(JasperDesign.PROPERTY_COLUMN_FOOTER) || evt.getPropertyName().equals(JasperDesign.PROPERTY_PAGE_FOOTER) || evt.getPropertyName().equals(JasperDesign.PROPERTY_LAST_PAGE_FOOTER) || evt.getPropertyName().equals(JasperDesign.PROPERTY_SUMMARY) || evt.getPropertyName().equals(JasperDesign.PROPERTY_NO_DATA) || evt.getPropertyName().equals(JasperDesign.PROPERTY_DETAIL) || evt.getPropertyName().equals(JasperDesign.PROPERTY_BACKGROUND)) { handleBandChanged(evt); } else if (evt.getPropertyName().equals(JRDesignSection.PROPERTY_BANDS)) { handleDetailBandChanged(evt); } else if (evt.getPropertyName().equals(JRDesignDataset.PROPERTY_GROUPS)) { handleGroupChanged(evt); } else if (evt.getPropertyName().equals(CHANGE_BAND_POSITION)) { handleChangeOrder(evt); } else if (evt.getPropertyName().equals(JRDesignDataset.PROPERTY_QUERY)) return; super.propertyChange(evt); }
protected void performAction(org.openide.nodes.Node[] activatedNodes) { JRDesignGroup group = ((BandNode)activatedNodes[0]).getGroup(); JRDesignBand band = new JRDesignBand(); band.setHeight(50); ((JRDesignSection)group.getGroupHeaderSection()).addBand(band); AddBandUndoableEdit undo = new AddBandUndoableEdit(band,((BandNode)activatedNodes[0]).getJasperDesign()); IReportManager.getInstance().addUndoableEdit(undo); }
protected void performAction(org.openide.nodes.Node[] activatedNodes) { JasperDesign jd = IReportManager.getInstance().getActiveReport(); if (jd != null) { JRDesignBand band = new JRDesignBand(); band.setHeight(50); ((JRDesignSection)jd.getDetailSection()).addBand(band); AddBandUndoableEdit undo = new AddBandUndoableEdit(band,jd); IReportManager.getInstance().addUndoableEdit(undo); } }
protected void performAction(org.openide.nodes.Node[] activatedNodes) { JRDesignGroup group = ((BandNode)activatedNodes[0]).getGroup(); JRDesignBand band = new JRDesignBand(); band.setHeight(50); ((JRDesignSection)group.getGroupFooterSection()).addBand(band); AddBandUndoableEdit undo = new AddBandUndoableEdit(band,((BandNode)activatedNodes[0]).getJasperDesign()); IReportManager.getInstance().addUndoableEdit(undo); }
/** * 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; }
protected void addSummaryGroup(List<FillColumn> fillColumns) { JRDesignGroup summaryGroup = new JRDesignGroup(); summaryGroup.setName(SUMMARY_GROUP_NAME);//TODO check for uniqueness JRDesignBand groupFooter = new JRDesignBand(); groupFooter.setSplitType(SplitTypeEnum.PREVENT); groupFooter.setHeight(pageFooter.getHeight()); // we need to put everything in a frame so that we can tell the frame // not to print when there are no detail bands on the current page // // we can't do that directly to the band since its print when expression // is evaluated too soon JRDesignFrame footerFrame = new JRDesignFrame(); UUID uuid = DigestUtils.instance().deriveUUID( fillContext.getComponentElement().getUUID(), BandTypeEnum.GROUP_FOOTER + "-" + SUMMARY_GROUP_NAME); footerFrame.setUUID(uuid); footerFrame.setX(0); footerFrame.setY(0); footerFrame.setWidth(computeTableWidth(fillColumns)); footerFrame.setHeight(pageFooter.getHeight()); footerFrame.getLineBox().setPadding(0); footerFrame.getLineBox().getPen().setLineWidth(0f); footerFrame.setRemoveLineWhenBlank(true); JRDesignExpression footerPrintWhen = builtinEvaluatorFactory.createExpression(new SummaryGroupFooterPrintWhenEvaluator()); footerFrame.setPrintWhenExpression(footerPrintWhen); // clone the contents of the page footer in the frame List<JRChild> footerElements = pageFooter.getChildren(); for (Iterator<JRChild> iterator = footerElements.iterator(); iterator .hasNext();) { JRChild child = iterator.next(); JRChild childClone = (JRChild) child.clone(footerFrame); if (childClone instanceof JRElement) { footerFrame.addElement((JRElement) childClone); } else if (childClone instanceof JRElementGroup) { footerFrame.addElementGroup((JRElementGroup) childClone); } else { throw new JRRuntimeException( EXCEPTION_MESSAGE_KEY_UNKNOWN_CHILD_TYPE, new Object[]{childClone.getClass().getName()} ); } } groupFooter.addElement(footerFrame); ((JRDesignSection) summaryGroup.getGroupFooterSection()).addBand(groupFooter); mainDataset.addScriptlet(TABLE_SCRIPTLET_NAME, TableReportScriptlet.class); mainDataset.addFirstGroup(summaryGroup); }
protected JRSection wrapBand(JRBand band, JROrigin origin) { JRDesignSection section = new JRDesignSection(origin); section.addBand(band); return section; }
public void propertyChange(PropertyChangeEvent evt) { //System.out.println("Model changed: " + evt.getPropertyName() + " " + evt.getSource()); Runnable r = null; if (evt.getPropertyName() == null) return; if (evt.getPropertyName().equals(JasperDesign.PROPERTY_BACKGROUND) || evt.getPropertyName().equals(JasperDesign.PROPERTY_TITLE) || evt.getPropertyName().equals(JasperDesign.PROPERTY_PAGE_HEADER) || evt.getPropertyName().equals(JasperDesign.PROPERTY_COLUMN_HEADER) || evt.getPropertyName().equals(JasperDesign.PROPERTY_DETAIL) || evt.getPropertyName().equals(JasperDesign.PROPERTY_COLUMN_FOOTER) || evt.getPropertyName().equals(JasperDesign.PROPERTY_PAGE_FOOTER) || evt.getPropertyName().equals(JasperDesign.PROPERTY_LAST_PAGE_FOOTER) || evt.getPropertyName().equals(JasperDesign.PROPERTY_SUMMARY) || evt.getPropertyName().equals(JasperDesign.PROPERTY_NO_DATA) || evt.getPropertyName().equals(JasperDesign.PROPERTY_PAGE_WIDTH) || evt.getPropertyName().equals(JasperDesign.PROPERTY_PAGE_HEIGHT) || evt.getPropertyName().equals(JasperDesign.PROPERTY_TOP_MARGIN) || evt.getPropertyName().equals(JasperDesign.PROPERTY_BOTTOM_MARGIN) || evt.getPropertyName().equals(JasperDesign.PROPERTY_LEFT_MARGIN) || evt.getPropertyName().equals(JasperDesign.PROPERTY_RIGHT_MARGIN) || evt.getPropertyName().equals(JasperDesign.PROPERTY_COLUMN_COUNT) || evt.getPropertyName().equals(JasperDesign.PROPERTY_COLUMN_SPACING) || evt.getPropertyName().equals(JasperDesign.PROPERTY_COLUMN_WIDTH) || evt.getPropertyName().equals(JRDesignGroup.PROPERTY_GROUP_HEADER) || evt.getPropertyName().equals(JRDesignGroup.PROPERTY_GROUP_FOOTER) || evt.getPropertyName().equals(JRDesignDataset.PROPERTY_GROUPS) || evt.getPropertyName().equals(JRDesignSection.PROPERTY_BANDS) || evt.getPropertyName().equals(JasperDesign.PROPERTY_PRINT_ORDER) || evt.getPropertyName().equals(JasperDesign.PROPERTY_COLUMN_DIRECTION) || // PROPERTY_HEIGHT is used only for the background band when it is detached... evt.getPropertyName().equals(JRDesignBand.PROPERTY_HEIGHT)) { updateSectionListeners(); r = new Runnable(){ public void run() { refreshDocument(); }}; } if (r != null) { ThreadUtils.invokeInAWTThread(r); } // Update group listeners... if (evt.getPropertyName().equals(JRDesignDataset.PROPERTY_GROUPS)) { // refresh group listening... for (int i=0; i<this.jasperDesign.getGroupsList().size(); ++i) { JRDesignGroup grp = (JRDesignGroup)this.jasperDesign.getGroupsList().get(i); grp.getEventSupport().removePropertyChangeListener(this); grp.getEventSupport().addPropertyChangeListener(this); } } }
static int addDetailBand(ODLTableDefinition table, int elementWidth, boolean isHeaderRowForSubreport, JasperDesign ret) { // add details JRDesignSection detailSection = (JRDesignSection) ret.getDetailSection(); JRDesignBand band = new JRDesignBand(); List<Double> colWidths = getColumnWidths(table, elementWidth); // decide on the row height.. set differently if have images; assume images are square int headerHeight=0; int rowHeight = 18; if (isHeaderRowForSubreport) { headerHeight = 22; rowHeight = 24; // repeat header for each master report element addColumnHeaderToBand(table, elementWidth, band); } // make row taller if we have an image, based on making the image square int nc = table.getColumnCount(); for (int i = 0; i < nc; i++) { if (table.getColumnType(i) == ODLColumnType.IMAGE) { rowHeight = Math.max(rowHeight, (int)Math.ceil(colWidths.get(i))); } } // Add alternating row background BEFORE column data (so drawn behind) if (!isHeaderRowForSubreport) { addAlternativeRowBackground(elementWidth, rowHeight, band); } // Add column data if (nc > 0) { double dx=0; for (int i = 0; i < nc; i++) { int x = (int) Math.round(dx); JRDesignElement element; if (table.getColumnType(i) == ODLColumnType.IMAGE) { element = createImageField(table, i); } else { JRDesignTextField textField = createTextField(table, i); // make bigger if this is the title row for a subreport if (isHeaderRowForSubreport) { textField.setFontSize(16); textField.setBold(true); } element = textField; } element.setX(x); element.setY(headerHeight); element.setWidth((int) Math.floor(colWidths.get(i))); element.setHeight(rowHeight); if (isHeaderRowForSubreport) { //element.setY(0); element.setStretchType(StretchTypeEnum.NO_STRETCH); } else { element.setStretchType(StretchTypeEnum.RELATIVE_TO_BAND_HEIGHT); } band.addElement(element); dx += colWidths.get(i); } } band.setHeight(headerHeight + rowHeight); detailSection.addBand(band); return headerHeight + rowHeight; }
/** * Instantiates a new reorder band command. * * @param child * the child * @param newIndex * the new index */ public ReorderBandCommandByIndex(MBandGroup child, int newIndex) { super(Messages.common_reorder_elements); this.newIndex = Math.max(0, newIndex); this.jrDesignSection = (JRDesignSection) child.getSection(); this.jrBand = (JRDesignBand) child.getValue(); }
/** * Instantiates a new reorder band command. * * @param child * the child * @param parent * the parent * @param newIndex * the new index */ public ReorderBandCommandByIndex(MBand child, MReport parent, int newIndex) { super(Messages.common_reorder_elements); this.newIndex = Math.max(0, newIndex); this.jrDesignSection = (JRDesignSection) parent.getJasperDesign().getDetailSection(); this.jrBand = (JRDesignBand) child.getValue(); }
/** * Instantiates a new reorder band command. * * @param child * the child * @param newIndex * the new index */ public ReorderBandCommandBySibling(MBandGroup child, JRBand newUpperBand) { super(Messages.common_reorder_elements); this.newUpperBand = newUpperBand; this.jrDesignSection = (JRDesignSection) child.getSection(); this.jrBand = (JRDesignBand) child.getValue(); }
/** * Instantiates a new reorder band command. * * @param child * the child * @param parent * the parent * @param newIndex * the new index */ public ReorderBandCommandBySibling(MBand child, MReport parent, JRBand newUpperBand) { super(Messages.common_reorder_elements); this.newUpperBand = newUpperBand; this.jrDesignSection = (JRDesignSection) parent.getJasperDesign().getDetailSection(); this.jrBand = (JRDesignBand) child.getValue(); }
/** * Instantiates a new reorder band command. * * @param child * the child * @param newIndex * the new index */ public ReorderBandCommandByRelativeIndex(MBandGroup child, int delta) { super(Messages.common_reorder_elements); this.delta = delta; this.jrDesignSection = (JRDesignSection) child.getSection(); this.jrBand = (JRDesignBand) child.getValue(); }
/** * Instantiates a new reorder band command. * * @param child * the child * @param parent * the parent * @param newIndex * the new index */ public ReorderBandCommandByRelativeIndex(MBand child, MReport parent, int delta) { super(Messages.common_reorder_elements); this.delta = delta; this.jrDesignSection = (JRDesignSection) parent.getJasperDesign().getDetailSection(); this.jrBand = (JRDesignBand) child.getValue(); }
/** * Instantiates a new creates the band detail command. * * @param destNode * the dest node * @param srcNode * the src node */ public CreateBandDetailCommand(MBand destNode, MBand srcNode) { super(); this.jrDesignSection = (JRDesignSection) destNode.getJasperDesign().getDetailSection(); if (srcNode != null && srcNode.getValue() != null) this.jrBand = (JRDesignBand) srcNode.getValue(); }
/** * Instantiates a new creates the band group footer command. * * @param destNode * the dest node */ public CreateBandGroupFooterCommand(MBandGroupFooter destNode) { super(); this.jrDesignSection = (JRDesignSection) (destNode.getJrGroup()).getGroupFooterSection(); }
/** * Instantiates a new creates the band group header command. * * @param destNode * the dest node */ public CreateBandGroupHeaderCommand(MBandGroupHeader destNode) { super(); this.jrDesignSection = (JRDesignSection) (destNode.getJrGroup()).getGroupHeaderSection(); }
/** * Instantiates a new delete band group footer command. * * @param destNode * the dest node * @param srcNode * the src node */ public DeleteBandGroupFooterCommand(MReport destNode, MBandGroupFooter srcNode) { super(); this.jrDesignSection = (JRDesignSection) (srcNode.getJrGroup()).getGroupFooterSection(); this.jrBand = (JRDesignBand) srcNode.getValue(); }
/** * Instantiates a new delete band detail command. * * @param destNode * the dest node * @param srcNode * the src node */ public DeleteBandDetailCommand(ANode destNode, MBand srcNode) { super(); this.jrBand = (JRDesignBand) srcNode.getValue(); this.jrDesignSection = (JRDesignSection) srcNode.getJasperDesign().getDetailSection(); }
/** * Instantiates a new delete band group header command. * * @param destNode * the dest node * @param srcNode * the src node */ public DeleteBandGroupHeaderCommand(MReport destNode, MBandGroupHeader srcNode) { super(); this.jrDesignSection = (JRDesignSection) (srcNode.getJrGroup()).getGroupHeaderSection(); this.jrBand = (JRDesignBand) srcNode.getValue(); }
/** * Adds the group listener. * * @param gr * the gr */ private void addGroupListener(JRDesignGroup gr) { ((JRDesignSection) gr.getGroupFooterSection()).getEventSupport().addPropertyChangeListener(this); ((JRDesignSection) gr.getGroupHeaderSection()).getEventSupport().addPropertyChangeListener(this); }
/** * Removes the group listener. * * @param gr * the gr */ private void removeGroupListener(JRDesignGroup gr) { ((JRDesignSection) gr.getGroupFooterSection()).getEventSupport().removePropertyChangeListener(this); ((JRDesignSection) gr.getGroupHeaderSection()).getEventSupport().removePropertyChangeListener(this); }