/** * */ public static HeaderLabelBuiltinExpression alterHeaderLabel(JRDesignFrame frame, String suffix) { HeaderLabelBuiltinExpression evaluator = null; JRElement[] elements = frame.getElements(); JRElement element = (elements == null || elements.length == 0) ? null : elements[0]; if (element instanceof JRStaticText) { JRElement elementProxy = getProxy((JRStaticText)element, suffix); frame.getChildren().set(0, elementProxy); } else if (element instanceof JRTextField) { evaluator = new HeaderLabelBuiltinExpression(((JRTextField)element).getExpression(), suffix); } return evaluator; }
/** * Creates a new Report object. * * @param band * the band * @param list * the list */ public static void createElementsForBand(ANode band, List<?> list) { for (Object element : list) { ANode node = createNode(band, element, -1); // ExtensionManager m = JaspersoftStudioPlugin.getExtensionManager(); // List<?> children = m.getChildren4Element(element); // if (children != null && !children.isEmpty()) { // createElementsForBand(node, children); // } else if (element instanceof JRDesignFrame) { JRDesignFrame frame = (JRDesignFrame) element; createElementsForBand(node, frame.getChildren()); } else if (element instanceof JRElementGroup) { JRElementGroup group = (JRElementGroup) element; createElementsForBand(node, group.getChildren()); } } }
@Override public void execute() { oldIndex = jrGroup.getChildren().indexOf(jrElement); if (jrGroup instanceof JRDesignElementGroup) { ((JRDesignElementGroup) jrGroup).removeElementGroup(jrElement); if (newIndex < 0 || newIndex > jrGroup.getChildren().size()) ((JRDesignElementGroup) jrGroup).addElementGroup(jrElement); else ((JRDesignElementGroup) jrGroup).addElementGroup(newIndex, jrElement); } else if (jrGroup instanceof JRDesignFrame) { ((JRDesignFrame) jrGroup).removeElementGroup(jrElement); if (newIndex < 0 || newIndex > jrGroup.getChildren().size()) ((JRDesignFrame) jrGroup).addElementGroup(jrElement); else ((JRDesignFrame) jrGroup).addElementGroup(newIndex, jrElement); } }
@Override public void undo() { if (jrGroup instanceof JRDesignElementGroup) { ((JRDesignElementGroup) jrGroup).removeElementGroup(jrElement); if (oldIndex < 0 || oldIndex > jrGroup.getChildren().size()) ((JRDesignElementGroup) jrGroup).addElementGroup(jrElement); else ((JRDesignElementGroup) jrGroup).addElementGroup(oldIndex, jrElement); } else if (jrGroup instanceof JRDesignFrame) { ((JRDesignFrame) jrGroup).removeElementGroup(jrElement); if (oldIndex < 0 || oldIndex > jrGroup.getChildren().size()) ((JRDesignFrame) jrGroup).addElementGroup(jrElement); else ((JRDesignFrame) jrGroup).addElementGroup(oldIndex, jrElement); } }
@Override public void execute() { oldIndex = jrGroup.getChildren().indexOf(jrElement); if (jrGroup instanceof JRDesignElementGroup) { ((JRDesignElementGroup) jrGroup).removeElement(jrElement); if (newIndex < 0 || newIndex > jrGroup.getChildren().size()) ((JRDesignElementGroup) jrGroup).addElement(jrElement); else ((JRDesignElementGroup) jrGroup).addElement(newIndex, jrElement); } else if (jrGroup instanceof JRDesignFrame) { ((JRDesignFrame) jrGroup).removeElement(jrElement); if (newIndex < 0 || newIndex > jrGroup.getChildren().size()) ((JRDesignFrame) jrGroup).addElement(jrElement); else ((JRDesignFrame) jrGroup).addElement(newIndex, jrElement); } }
@Override public void undo() { if (jrGroup instanceof JRDesignElementGroup) { ((JRDesignElementGroup) jrGroup).removeElement(jrElement); if (oldIndex < 0 || oldIndex > jrGroup.getChildren().size()) ((JRDesignElementGroup) jrGroup).addElement(jrElement); else ((JRDesignElementGroup) jrGroup).addElement(oldIndex, jrElement); } else if (jrGroup instanceof JRDesignFrame) { ((JRDesignFrame) jrGroup).removeElement(jrElement); if (oldIndex < 0 || oldIndex > jrGroup.getChildren().size()) ((JRDesignFrame) jrGroup).addElement(jrElement); else ((JRDesignFrame) jrGroup).addElement(oldIndex, jrElement); } }
@Override public void undo() { if (lCmd != null) lCmd.undo(); if (jrGroup != null && jrGroup.getChildren() != null) { if (jrGroup instanceof JRDesignElementGroup) { if (elementPosition > ((JRDesignElementGroup) jrGroup).getChildren().size()) ((JRDesignElementGroup) jrGroup).addElement(jrElement); else ((JRDesignElementGroup) jrGroup).addElement(elementPosition, jrElement); } else if (jrGroup instanceof JRDesignFrame) { if (elementPosition > ((JRDesignFrame) jrGroup).getChildren().size()) ((JRDesignFrame) jrGroup).addElement(jrElement); else ((JRDesignFrame) jrGroup).addElement(elementPosition, jrElement); } } }
@Override public void undo() { jrElement.setX(location.x); jrElement.setY(location.y); if (jrGroup instanceof JRDesignElementGroup) { if (index > ((JRDesignElementGroup) jrGroup).getChildren().size()) ((JRDesignElementGroup) jrGroup).addElement(jrElement); else ((JRDesignElementGroup) jrGroup).addElement(index, jrElement); } else if (jrGroup instanceof JRDesignFrame) { if (index > ((JRDesignFrame) jrGroup).getChildren().size()) ((JRDesignFrame) jrGroup).addElement(jrElement); else ((JRDesignFrame) jrGroup).addElement(index, jrElement); } }
@Override public void execute() { if (jrElement != null) { // set on JRElementGroup ... if (index < 0) index = jrGroup.getChildren().size(); if (jrGroup instanceof JRDesignElementGroup) { if (index < 0 || index > jrGroup.getChildren().size()) ((JRDesignElementGroup) jrGroup).addElementGroup(jrElement); else ((JRDesignElementGroup) jrGroup).addElementGroup(index, jrElement); } else if (jrGroup instanceof JRDesignFrame) { if (index < 0 || index > jrGroup.getChildren().size()) ((JRDesignFrame) jrGroup).addElementGroup(jrElement); else ((JRDesignFrame) jrGroup).addElementGroup(index, jrElement); } } }
private void removeElement(JRElementGroup container, JRDesignElement element) { int index = 0; if (container instanceof JRDesignElementGroup) { index = ((JRDesignElementGroup)container).getChildren().indexOf(element); ((JRDesignElementGroup)container).removeElement(element); } else if (container instanceof JRDesignFrame) { index = ((JRDesignFrame)container).getChildren().indexOf(element); ((JRDesignFrame)container).removeElement(element); } DeleteElementUndoableEdit edit = new DeleteElementUndoableEdit(element,container,index); unduableEdit.concatenate(edit); }
private void removeElementGroup(JRElementGroup container, JRDesignElementGroup group) { int index=0; if (container instanceof JRDesignElementGroup) { index = ((JRDesignElementGroup)container).getChildren().indexOf(group); ((JRDesignElementGroup)container).removeElementGroup(group); } else if (container instanceof JRDesignFrame) { index = ((JRDesignFrame)container).getChildren().indexOf(group); ((JRDesignFrame)container).removeElementGroup(group); } DeleteElementGroupUndoableEdit edit = new DeleteElementGroupUndoableEdit(group,container,index); unduableEdit.concatenate(edit); }
@Override public void undo() throws CannotUndoException { super.undo(); if (container instanceof JRDesignElementGroup) { index = ((JRDesignElementGroup)container).getChildren().indexOf(element); ((JRDesignElementGroup)container).removeElement(element); } else if (container instanceof JRDesignFrame) { index = ((JRDesignFrame)container).getChildren().indexOf(element); ((JRDesignFrame)container).removeElement(element); } }
private void addElement(JRDesignElement element, JRElementGroup elementGroup) { if (elementGroup instanceof JRDesignElementGroup) { ((JRDesignElementGroup)elementGroup).addElement(element); } else if (elementGroup instanceof JRDesignBand) { ((JRDesignBand)elementGroup).addElement(element); } else if (elementGroup instanceof JRDesignCellContents) { ((JRDesignCellContents)elementGroup).addElement(element); } else if (elementGroup instanceof JRDesignFrame) { ((JRDesignFrame)elementGroup).addElement(element); } }
private void addElementGroup(JRDesignElementGroup element, JRElementGroup elementGroup) { if (elementGroup instanceof JRDesignElementGroup) { ((JRDesignElementGroup)elementGroup).addElementGroup(element); } else if (elementGroup instanceof JRDesignBand) { ((JRDesignBand)elementGroup).addElementGroup(element); } else if (elementGroup instanceof JRDesignCellContents) { ((JRDesignCellContents)elementGroup).addElementGroup(element); } else if (elementGroup instanceof JRDesignFrame) { ((JRDesignFrame)elementGroup).addElementGroup(element); } }
private void removeElementGroup(JRDesignElementGroup element, JRElementGroup elementGroup) { if (elementGroup instanceof JRDesignElementGroup) { ((JRDesignElementGroup)elementGroup).removeElementGroup(element); } else if (elementGroup instanceof JRDesignBand) { ((JRDesignBand)elementGroup).removeElementGroup(element); } else if (elementGroup instanceof JRDesignCellContents) { ((JRDesignCellContents)elementGroup).removeElementGroup(element); } else if (elementGroup instanceof JRDesignFrame) { ((JRDesignFrame)elementGroup).removeElementGroup(element); } }
/** * Convenience method for creating {@link JRDesignCrosstabCell} instances. It is possible to be part of a row group and a column group. * * @param type is a {@link Class} is used to determine how to render the {@link JRDesignTextField} contained * in the {@link JRDesignCrosstabCell} * @param value is the {@link String} value to render in the {@link JRDesignCrosstabCell} * @param rowGroup is the name of the rowgroup this cell is part of. * @param colGroup is the name of the column group this cell is part of. */ protected JRDesignCrosstabCell crosstabCell(final Class type, final String value, final String rowGroup, final String colGroup) { LOG.debug("Creating cell with row group = "+ rowGroup+ " and column group = "+ colGroup); final JRDesignCrosstabCell retval = new JRDesignCrosstabCell(); final JRDesignCellContents contents = new JRDesignCellContents(); final JRDesignTextField field = normal(value).toTextField(type); addDesignElementTo(contents, field, 0, 0, CELL_WIDTH, CELL_HEIGHT); contents.setMode(MODE_OPAQUE); contents.setBackcolor(Color.LIGHT_GRAY); final JRDesignFrame frame = new JRDesignFrame(); frame.copyBox(new TravelReportLineBox(contents)); contents.setBox(frame); retval.setWidth(CELL_WIDTH); retval.setHeight(CELL_HEIGHT); retval.setContents(contents); retval.setRowTotalGroup(rowGroup); retval.setColumnTotalGroup(colGroup); return retval; }
@Override public Object createObject(Attributes attributes) { JasperDesign jasperDesign = (JasperDesign)digester.peek(digester.getCount() - 2); return new JRDesignFrame(jasperDesign); }
@Override protected JRDesignFrame createColumnCell(Column column, JRElementGroup parentGroup, Cell cell) { JRDesignFrame frame = (JRDesignFrame) createColumnCell(column, parentGroup, cell, true); addHeaderToolbarElement(column, frame, TableUtil.getCellElement(JRTextField.class, column.getDetailCell(), true)); return frame; }
protected void addIconLabelComponent(Column column, JRDesignFrame frame, String suffix) { List<JRChild> children = frame.getChildren(); if (children.size() > 0) { JRBaseTextElement headerTextElement = (JRBaseTextElement)children.get(0); if (headerTextElement != null) { JRComponentElement componentElement = IconLabelComponentUtil.getInstance(fillContext.getFiller().getJasperReportsContext()).createIconLabelComponentElement(headerTextElement); IconLabelComponent iconLabelComponent = (IconLabelComponent)componentElement.getComponent(); JRDesignTextField labelTextField = (JRDesignTextField)iconLabelComponent.getLabelTextField(); if (headerTextElement instanceof JRTextField) { labelTextField.setExpression(((JRTextField) headerTextElement).getExpression()); } else if (headerTextElement instanceof JRStaticText) { labelTextField.setExpression(builtinEvaluatorFactory.createConstantExpression(((JRStaticText)headerTextElement).getText())); } JRDesignTextField iconTextField = (JRDesignTextField)iconLabelComponent.getIconTextField(); iconTextField.setExpression(builtinEvaluatorFactory.createConstantExpression(suffix)); componentElement.getPropertiesMap().setProperty(MatcherExporterFilter.PROPERTY_MATCHER_EXPORT_FILTER_KEY, TABLE_HEADER_ICON_LABEL_MATCHER_EXPORT_KEY); JRBaseElement element = (JRBaseElement)frame.getChildren().get(0); element.getPropertiesMap().setProperty(MatcherExporterFilter.PROPERTY_MATCHER_EXPORT_FILTER_KEY, TABLE_HEADER_LABEL_MATCHER_EXPORT_KEY); //frame.getChildren().remove(0); frame.getChildren().add(componentElement); } } }
@Override protected JRElement createColumnGroupCell(ColumnGroup columnGroup, Cell cell, JRDesignElementGroup elementGroup) { JRDesignFrame frame = (JRDesignFrame) createCell(elementGroup, cell, columnGroup.getWidth(), fillColumn.getWidth(), xOffset, yOffset, null, deriveUUID(), true); frame.getPropertiesMap().setProperty(HtmlExporter.PROPERTY_HTML_CLASS, "jrcolGroupHeader"); return frame; }
private void switchCharts(JRDesignChart chart1, JRDesignChart chart2) { int index = jrGroup.getChildren().indexOf(chart1); if (jrGroup instanceof JRDesignElementGroup) { ((JRDesignElementGroup) jrGroup).removeElement(chart1); ((JRDesignElementGroup) jrGroup).addElement(index, chart2); } else if (jrGroup instanceof JRDesignFrame) { ((JRDesignFrame) jrGroup).removeElement(chart1); ((JRDesignFrame) jrGroup).addElement(index, chart2); } }
private void switchCharts(JRDesignComponentElement chart1, JRDesignComponentElement chart2) { int index = jrGroup.getChildren().indexOf(chart1); if (jrGroup instanceof JRDesignElementGroup) { ((JRDesignElementGroup) jrGroup).removeElement(chart1); ((JRDesignElementGroup) jrGroup).addElement(index, chart2); } else if (jrGroup instanceof JRDesignFrame) { ((JRDesignFrame) jrGroup).removeElement(chart1); ((JRDesignFrame) jrGroup).addElement(index, chart2); } }
@Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals(StandardTable.PROPERTY_DATASET_RUN)){ addDatasetGroupListener(); } if (evt.getPropertyName().equals(JRDesignFrame.PROPERTY_CHILDREN) || evt.getPropertyName().equals(JRDesignElement.PROPERTY_ELEMENT_GROUP) || evt.getPropertyName().equals(MColumn.PROPERTY_NAME)) { // The children are changed, need to build a new full model when it will // be necessary fullModelTable = null; } if (evt.getPropertyName().equals(MGraphicElement.FORCE_GRAPHICAL_REFRESH)) { ANode parent = getParent(); IGraphicalPropertiesHandler upperGrahpicHandler = null; while (parent != null) { if (parent instanceof IGraphicalPropertiesHandler) { upperGrahpicHandler = (IGraphicalPropertiesHandler) parent; } parent = parent.getParent(); } if (upperGrahpicHandler != null) { ((MGraphicElement) upperGrahpicHandler).getValue().getEventSupport().firePropertyChange(MGraphicElement.FORCE_GRAPHICAL_REFRESH, null, null); } } if (getTableManager() != null && (getParent() instanceof MPage && evt instanceof CollectionElementAddedEvent || evt instanceof CollectionElementRemovedEvent || evt.getOldValue() instanceof DesignCell || evt.getNewValue() instanceof DesignCell)) getTableManager().update(); else if (getTableManager() != null) getTableManager().update(); super.propertyChange(evt); }
/** * Remove an element from its container. This method checks if the container is a frame or an element groups (like a * band or a cell); * * @param container * @param element */ public void removeElement(JRElementGroup container, JRDesignElement element) { if (container instanceof JRDesignElementGroup) { ((JRDesignElementGroup) container).removeElement(element); } if (container instanceof JRDesignFrame) { ((JRDesignFrame) container).removeElement(element); } }
/** * Add an element to a container. This method checks if the container is a frame or an element groups (like a band or * a cell); * * @param container * @param element */ public void addElement(JRElementGroup container, JRDesignElement element) { if (container instanceof JRDesignElementGroup) { ((JRDesignElementGroup) container).addElement(element); } if (container instanceof JRDesignFrame) { ((JRDesignFrame) container).addElement(element); } }
/** * Set the height of a container (which could be a band or a frame). If the height of the container is already bigger * than the passed in value, the container is left unchanged. * * @param container * @param minHeight * - The minimum height of the container */ private void setGroupHeight(JRElementGroup container, int minHeight) { if (container instanceof JRDesignBand) { ((JRDesignBand) container).setHeight(Math.max(minHeight, ((JRDesignBand) container).getHeight())); } if (container instanceof JRDesignFrame) { ((JRDesignFrame) container).setHeight(Math.max(minHeight, ((JRDesignFrame) container).getHeight())); } }
@Override public JRDesignElement createJRElement(JasperDesign jasperDesign) { JRDesignElement jrDesignElement = new JRDesignFrame(); DefaultManager.INSTANCE.applyDefault(this.getClass(), jrDesignElement); jrDesignElement.setWidth(getDefaultWidth()); jrDesignElement.setHeight(getDefaultHeight()); return jrDesignElement; }
@Override public Dimension getSize() { JRDesignFrame jrDesignFrame = getValue(); int h = jrDesignFrame.getHeight(); int w = jrDesignFrame.getWidth(); return new Dimension(w, h); }
@Override public void undo() { if (jrGroup instanceof JRDesignElementGroup) ((JRDesignElementGroup) jrGroup).removeElement(tfPageNumber); else if (jrGroup instanceof JRDesignFrame) ((JRDesignFrame) jrGroup).removeElement(tfPageNumber); if (jrGroup instanceof JRDesignElementGroup) ((JRDesignElementGroup) jrGroup).removeElement(tfPageTotal); else if (jrGroup instanceof JRDesignFrame) ((JRDesignFrame) jrGroup).removeElement(tfPageTotal); }
@Override public void execute() { index = jrGroup.getChildren().indexOf(jrElement); if (jrGroup instanceof JRDesignElementGroup) ((JRDesignElementGroup) jrGroup).removeElementGroup(jrElement); else if (jrGroup instanceof JRDesignFrame) ((JRDesignFrame) jrGroup).removeElementGroup(jrElement); }
@Override public void undo() { if (jrGroup instanceof JRDesignElementGroup) { if (index > ((JRDesignElementGroup) jrGroup).getChildren().size()) ((JRDesignElementGroup) jrGroup).addElementGroup(jrElement); else ((JRDesignElementGroup) jrGroup).addElementGroup(index, jrElement); } else if (jrGroup instanceof JRDesignFrame) { if (index > ((JRDesignFrame) jrGroup).getChildren().size()) ((JRDesignFrame) jrGroup).addElementGroup(jrElement); else ((JRDesignFrame) jrGroup).addElementGroup(index, jrElement); } }
@Override public void undo() { if (commands != null) commands.undo(); if (jrGroup instanceof JRDesignElementGroup) ((JRDesignElementGroup) jrGroup).removeElement(jrElement); else if (jrGroup instanceof JRDesignFrame) ((JRDesignFrame) jrGroup).removeElement(jrElement); }
public static void removeElement(JRDesignElement element, JRElement[] elements) { for (JRElement el : elements) { if (el instanceof IGroupElement) { JRDesignElementGroup egroup = (JRDesignElementGroup) ((IGroupElement) el).getJRElementGroup(); egroup.removeElement(element); removeElement(element, egroup.getElements()); } else if (el instanceof JRDesignFrame) { JRDesignFrame frame = (JRDesignFrame) el; frame.removeElement(element); removeElement(element, frame.getElements()); } } }
@Override public void execute() { if (jrGroup != null && jrGroup.getChildren() != null) { elementPosition = jrGroup.getChildren().indexOf(jrElement); if (jrGroup instanceof JRDesignElementGroup) { ((JRDesignElementGroup) jrGroup).removeElement(jrElement); } else if (jrGroup instanceof JRDesignFrame) { ((JRDesignFrame) jrGroup).removeElement(jrElement); } if (jrGroup instanceof JRPropertiesHolder) { String uuid = null; if (jrGroup instanceof JRBaseElement) uuid = ((JRBaseElement) jrGroup).getUUID().toString(); Dimension d = new Dimension(0, 0); if (jrGroup instanceof JRCommonElement) { JRCommonElement jce = (JRCommonElement) jrGroup; // Commented for back-compatibility in 3.6. // Replaced with the following line. // d.setSize(jce.getWidth(), jce.getHeight()); d.setSize(new Dimension(jce.getWidth(), jce.getHeight())); } if (jrGroup instanceof JRDesignBand) { int w = jDesign.getPageWidth() - jDesign.getLeftMargin() - jDesign.getRightMargin(); // Commented for back-compatibility in 3.6. // Replaced with the following line. // d.setSize(w, ((JRDesignBand) jrGroup).getHeight()); d.setSize(new Dimension(w, ((JRDesignBand) jrGroup).getHeight())); } if (lCmd == null) { ILayout layout = LayoutManager.getLayout(pholder, jDesign, uuid); lCmd = new LayoutCommand(jrGroup, layout, d); lCmd.execute(); } } } }
@Override public void execute() { location = new Point(jrElement.getX(), jrElement.getY()); index = jrGroup.getChildren().indexOf(jrElement); if (jrGroup instanceof JRDesignElementGroup) ((JRDesignElementGroup) jrGroup).removeElement(jrElement); else if (jrGroup instanceof JRDesignFrame) ((JRDesignFrame) jrGroup).removeElement(jrElement); }
@Override public void execute() { elementPosition = jrGroup.getChildren().indexOf(jrElement); if (jrGroup instanceof JRDesignElementGroup) ((JRDesignElementGroup) jrGroup).removeElementGroup(jrElement); else if (jrGroup instanceof JRDesignFrame) ((JRDesignFrame) jrGroup).removeElementGroup(jrElement); }
@Override public void undo() { if (jrGroup instanceof JRDesignElementGroup) { if (elementPosition > ((JRDesignElementGroup) jrGroup).getChildren().size()) ((JRDesignElementGroup) jrGroup).addElementGroup(jrElement); else ((JRDesignElementGroup) jrGroup).addElementGroup(elementPosition, jrElement); } else if (jrGroup instanceof JRDesignFrame) { if (elementPosition > ((JRDesignFrame) jrGroup).getChildren().size()) ((JRDesignFrame) jrGroup).addElementGroup(jrElement); else ((JRDesignFrame) jrGroup).addElementGroup(elementPosition, jrElement); } }
@Override public void undo() { if (jrGroup instanceof JRDesignElementGroup) ((JRDesignElementGroup) jrGroup).removeElementGroup(jrElement); else if (jrGroup instanceof JRDesignFrame) ((JRDesignFrame) jrGroup).removeElementGroup(jrElement); }
public void removeElement(JRElementGroup container, JRDesignElement element) { if (container instanceof JRDesignElementGroup) { ((JRDesignElementGroup) container).removeElement(element); } if (container instanceof JRDesignFrame) { ((JRDesignFrame) container).removeElement(element); } }
public void addElement(JRElementGroup container, JRDesignElement element) { if (container instanceof JRDesignElementGroup) { ((JRDesignElementGroup) container).addElement(element); } if (container instanceof JRDesignFrame) { ((JRDesignFrame) container).addElement(element); } }