/** * Writes the contents (child elements) of an element container. * * @param elementContainer the element container */ public void writeChildElements( JRElementGroup elementContainer, String parentName) { List<JRChild> children = elementContainer.getChildren(); if (children != null && children.size() > 0) { for(int i = 0; i < children.size(); i++) { String childName = parentName + "_" + i; apiWriterVisitor.setName(childName); children.get(i).visit(apiWriterVisitor); if(children.get(i) instanceof JRElementGroup && !(children.get(i) instanceof JRElement)) { write( parentName +".addElementGroup(" + childName + ");\n\n"); } else if (!(children.get(i) instanceof JRComponentElement))//FIXME component { write( parentName +".addElement(" + childName + ");\n\n"); } } } }
/** * Removes a group element from the frame. * * @param group the group to remove * @return <tt>true</tt> if this frame contained the specified group */ public boolean removeElementGroup(JRElementGroup group) { if (group instanceof JRDesignElementGroup) { ((JRDesignElementGroup) group).setElementGroup(null); } int idx = children.indexOf(group); if (idx >= 0) { children.remove(idx); getEventSupport().fireCollectionElementRemovedEvent(PROPERTY_CHILDREN, group, idx); return true; } return false; }
@Override public void visitElementGroup(JRElementGroup elementGroup) { JRFillElementGroup fillElementGroup = null; if (elementGroup != null) { fillElementGroup = (JRFillElementGroup)get(elementGroup); if (fillElementGroup == null) { fillElementGroup = new JRFillElementGroup(elementGroup, this); } } setVisitResult(fillElementGroup); }
protected boolean inScope(PropertyMetadata propertyMetadata, JRElementGroup container) { if (container instanceof JRFrame) { return inScope(propertyMetadata, (JRElement) container); } List<PropertyScope> scopes = propertyMetadata.getScopes(); if (container instanceof JRBand) { return scopes.contains(PropertyScope.BAND); } if (container instanceof Cell) { return scopes.contains(PropertyScope.TABLE_CELL); } if (container instanceof JRCellContents) { return scopes.contains(PropertyScope.CROSSTAB_CELL); } return false; }
/** * Find a JRDesignStaticText element having exp as text. * * @param band * @param exp * @return the first matching element or null. */ public static JRDesignStaticText findStaticTextElement(JRElementGroup parent, String exp) { JRElement[] elements = parent.getElements(); for (int i = 0; i < elements.length; ++i) { JRElement ele = elements[i]; if (ele instanceof JRDesignStaticText) { JRDesignStaticText st = (JRDesignStaticText) ele; if (st.getText() != null && st.getText().equalsIgnoreCase(exp)) { return st; } } else if (ele instanceof JRElementGroup) { JRDesignStaticText ele2 = findStaticTextElement((JRElementGroup) ele, exp); if (ele2 != null) return ele2; } } return null; }
/** * Find a JRDesignTextField element having exp as expression value. * * @param band * @param exp * @return the first matching element or null. */ public static JRDesignTextField findTextFieldElement(JRElementGroup band, String exp) { JRElement[] elements = band.getElements(); for (int i = 0; i < elements.length; ++i) { JRElement ele = elements[i]; if (ele instanceof JRDesignTextField) { String s = ExprUtil.getExpressionText(((JRDesignTextField) ele).getExpression()); if (s.startsWith("\"")) { //$NON-NLS-1$ s = s.substring(1); } if (s.endsWith("\"")) { //$NON-NLS-1$ s = s.substring(0, s.length() - 1); } if (s.equalsIgnoreCase(exp)) return (JRDesignTextField) ele; } else if (ele instanceof JRElementGroup) { JRDesignTextField ele2 = findTextFieldElement((JRElementGroup) ele, exp); if (ele2 != null) return ele2; } } return null; }
/** * 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()); } } }
public static JRDesignStaticText findStaticTextElement(JRElementGroup parent, String exp) { JRElement[] elements = parent.getElements(); for (int i = 0; i < elements.length; ++i) { JRElement ele = elements[i]; if (ele instanceof JRDesignStaticText) { JRDesignStaticText st = (JRDesignStaticText) ele; if (st.getText() != null && st.getText().equalsIgnoreCase(exp)) { return st; } } else if (ele instanceof JRElementGroup) { JRDesignStaticText ele2 = findStaticTextElement((JRElementGroup) ele, exp); if (ele2 != null) return ele2; } } return null; }
/** * Find in band a JRDesignTextField element having exp as expression value. * * @param band * @param exp * @return the first matching element or null. */ public static JRDesignTextField findTextFieldElement(JRElementGroup band, String exp) { JRElement[] elements = band.getElements(); for (int i = 0; i < elements.length; ++i) { JRElement ele = elements[i]; if (ele instanceof JRDesignTextField) { String s = ExprUtil.getExpressionText(((JRDesignTextField) ele).getExpression()); if (s.startsWith("\"")) { s = s.substring(1); } if (s.endsWith("\"")) { s = s.substring(0, s.length() - 1); } if (s.equalsIgnoreCase(exp)) return (JRDesignTextField) ele; } else if (ele instanceof JRElementGroup) { JRDesignTextField ele2 = findTextFieldElement((JRElementGroup) ele, exp); if (ele2 != null) return ele2; } } return null; }
private List<JRDesignElement> getNotReferencedStyles(JRChild[] childs, HashSet<String> styles) { List<JRDesignElement> result = new ArrayList<JRDesignElement>(); for (JRChild child : childs) { if (child instanceof JRDesignElement) { String styleName = getElementStyle((JRDesignElement) child); if (styleName != null && styles.contains(styleName)) { result.add((JRDesignElement) child); } } if (child instanceof JRElementGroup) { JRElementGroup group = (JRElementGroup) child; List<JRDesignElement> value = getNotReferencedStyles(group.getElements(), styles); result.addAll(value); } } return result; }
private APropertyNode getContainerNode(ANode n) { Object val = n.getValue(); if (n instanceof IGroupElement) return (APropertyNode) n; if (val instanceof JRElementGroup){ if(n instanceof MElementGroup) { return getContainerNode(n.getParent()); } else { return (APropertyNode) n; } } if (val instanceof JRDesignElement) return getContainerNode(n.getParent()); return null; }
private APropertyNode getContainerNode(ANode n) { Object val = n.getValue(); if (n instanceof IGroupElement) return (APropertyNode) n; if (val instanceof JRElementGroup) { if(n instanceof MElementGroup) { return getContainerNode(n.getParent()); } else { return (APropertyNode) n; } } if (val instanceof JRDesignElement) return getContainerNode(n.getParent()); return null; }
/** * Check if an element is orphan or not. * An element is orphan when his parent is null, or if is null one of his ancestor parents */ public static boolean isOrphan(JRDesignElement element, JasperDesign jd) { JRElementGroup group = getTopElementGroup(element); if (group == null) return true; // Check if it belongs to this jasperdesign... if (group instanceof JRBand && !ModelUtils.getBands(jd).contains(group)) return true; // We should check if it the parent belongs for real to this report... if (group instanceof JRDesignCellContents) { // TODO check if this cell contents belongs to a crosstab in this report... JRDesignCellContents cell = (JRDesignCellContents)group; } return false; }
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); }
/** * Find in band a JRDesignStaticText element having exp as text. * @param band * @param exp * @return the first matching element or null. */ public static JRDesignStaticText findStaticTextElement(JRElementGroup parent, String exp) { JRElement[] elements = parent.getElements(); for (int i=0; i<elements.length; ++i) { JRElement ele = elements[i]; if (ele instanceof JRDesignStaticText) { JRDesignStaticText st = (JRDesignStaticText)ele; if (st.getText() != null && st.getText().equalsIgnoreCase(exp)) { return st; } } else if (ele instanceof JRElementGroup) { JRDesignStaticText ele2 = findStaticTextElement((JRElementGroup)ele, exp); if (ele2 != null) return ele2; } } return null; }
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); } }
public List<JRDesignCrosstab> findCrosstabs( JRElementGroup group, List<JRDesignCrosstab> list) { List objects = group.getChildren(); for (int i=0; i<objects.size(); ++i) { Object obj = objects.get(i); if (obj instanceof JRDesignCrosstab) { list.add((JRDesignCrosstab)obj); } else if (obj instanceof JRElementGroup) { findCrosstabs( (JRElementGroup)obj, list); } } return list; }
/** * Initializes basic properties of the element. * @param element an element whose properties are copied to this element. Usually it is a * {@link net.sf.jasperreports.engine.design.JRDesignElement} that must be transformed into an * <tt>JRBaseElement</tt> at compile time. * @param factory a factory used in the compile process */ protected JRBaseElement(JRElement element, JRBaseObjectFactory factory) { factory.put(element, this); defaultStyleProvider = factory.getDefaultStyleProvider(); parentStyle = factory.getStyle(element.getStyle()); parentStyleNameReference = element.getStyleNameReference(); uuid = element.getUUID(); key = element.getKey(); positionTypeValue = element.getPositionTypeValue(); stretchTypeValue = element.getStretchTypeValue(); isPrintRepeatedValues = element.isPrintRepeatedValues(); modeValue = element.getOwnModeValue(); x = element.getX(); y = element.getY(); width = element.getWidth(); height = element.getHeight(); isRemoveLineWhenBlank = element.isRemoveLineWhenBlank(); isPrintInFirstWholeBand = element.isPrintInFirstWholeBand(); isPrintWhenDetailOverflows = element.isPrintWhenDetailOverflows(); forecolor = element.getOwnForecolor(); backcolor = element.getOwnBackcolor(); printWhenExpression = factory.getExpression(element.getPrintWhenExpression()); printWhenGroupChanges = factory.getGroup(element.getPrintWhenGroupChanges()); elementGroup = (JRElementGroup)factory.getVisitResult(element.getElementGroup()); propertiesMap = JRPropertiesMap.getPropertiesClone(element); propertyExpressions = factory.getPropertyExpressions(element.getPropertyExpressions()); }
/** * */ public static JRElement[] getElements(List<JRChild> children) { JRElement[] elements = null; if (children != null) { List<JRElement> allElements = new ArrayList<JRElement>(); Object child = null; JRElement[] childElementArray = null; for(int i = 0; i < children.size(); i++) { child = children.get(i); if (child instanceof JRElement) { allElements.add((JRElement)child); } else if (child instanceof JRElementGroup) { childElementArray = ((JRElementGroup)child).getElements(); if (childElementArray != null) { allElements.addAll( Arrays.asList(childElementArray) ); } } } elements = new JRElement[allElements.size()]; allElements.toArray(elements); } return elements; }
@Override public void visitElementGroup(JRElementGroup elementGroup) { List<JRChild> children = elementGroup.getChildren(); if (children != null && children.size() > 0) { for(int i = 0; i < children.size(); i++) { children.get(i).visit(this); } } }
@Override public void visitElementGroup(JRElementGroup elementGroup) { try { xmlWriter.writeElementGroup(elementGroup); } catch (IOException e) { throw new JRRuntimeException(e); } }
/** * Writes the contents (child elements) of an element container. * * @param elementContainer the element container */ public void writeChildElements(JRElementGroup elementContainer) { List<JRChild> children = elementContainer.getChildren(); if (children != null && children.size() > 0) { for(int i = 0; i < children.size(); i++) { children.get(i).visit(xmlWriterVisitor); } } }
/** * */ public void writeElementGroup(JRElementGroup elementGroup) throws IOException { writer.startElement(JRXmlConstants.ELEMENT_elementGroup, getNamespace()); /* */ writeChildElements(elementGroup); writer.closeElement(); }
/** * */ public void writeElementGroup( JRElementGroup elementGroup, String groupName) { if(elementGroup != null) { write( "JRDesignElementGroup " + groupName + " = new JRDesignElementGroup();\n"); writeChildElements( elementGroup, groupName); flush(); } }
/** * */ public void setElementGroup(JRElementGroup elementGroup) { Object old = this.elementGroup; this.elementGroup = elementGroup; getEventSupport().firePropertyChange(PROPERTY_ELEMENT_GROUP, old, this.elementGroup); }
/** * Specifies the logical group that the element belongs to. More elements can be grouped in order to make some of them * stretch relative to the height of their parent group. * @see StretchTypeEnum */ public void setElementGroup(JRElementGroup elementGroup) { Object old = this.elementGroup; this.elementGroup = elementGroup; getEventSupport().firePropertyChange(PROPERTY_ELEMENT_GROUP, old, this.elementGroup); }
/** * Inserts an element group at specified position into the frame. * * @param index the element group position * @param group the element group to add */ public void addElementGroup(int index, JRElementGroup group) { if (group instanceof JRDesignElementGroup) { ((JRDesignElementGroup) group).setElementGroup(this); } children.add(index, group); getEventSupport().fireCollectionElementAddedEvent(PROPERTY_CHILDREN, group, index); }
protected JRFillElementContainer(JRBaseFiller filler, JRElementGroup container, JRFillObjectFactory factory) { super(container, factory); expressionEvaluator = factory.getExpressionEvaluator(); initDeepElements(); this.filler = filler; @SuppressWarnings("deprecation") boolean depFlag = filler.getFillContext().isLegacyElementStretchEnabled(); legacyElementStretchEnabled = depFlag; }
public List<PropertyMetadata> getContainerProperties(JRElementGroup container) { Collection<PropertyMetadata> allProperties = allProperties(); List<PropertyMetadata> containerProperties = new ArrayList<PropertyMetadata>(); for (PropertyMetadata propertyMetadata : allProperties) { if (inScope(propertyMetadata, container)) { containerProperties.add(propertyMetadata); } } return containerProperties; }
@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; }
private EditChartCommand(ANode parent, MChart mchart, int index) { this.originalNode=mchart; this.jConfig = parent.getJasperConfiguration(); this.oldChart = (JRDesignChart) mchart.getValue(); if (parent instanceof IGroupElement) this.jrGroup = ((IGroupElement) parent).getJRElementGroup(); else this.jrGroup = (JRElementGroup) parent.getValue(); }
private JRElementGroup getJRElementGroup(JRDesignComponentElement value) { JRElementGroup res = null; if (value != null) { JRDesignComponentElement jrElement = value; StandardListComponent jrList = (StandardListComponent) jrElement.getComponent(); res = jrList.getContents(); } return res; }
private EditSpiderChartCommand(ANode parent, MSpiderChart mchart, int index) { this.originalNode=mchart; this.jConfig = parent.getJasperConfiguration(); this.oldChart = (JRDesignComponentElement) mchart.getValue(); if (parent instanceof IGroupElement) this.jrGroup = ((IGroupElement) parent).getJRElementGroup(); else this.jrGroup = (JRElementGroup) parent.getValue(); }
public static List<JRDesignElement> getGElements(JRElementGroup gr) { List<JRDesignElement> res = new ArrayList<JRDesignElement>(); for (Object el : gr.getChildren()) { if (el instanceof JRElementGroup) { res.addAll(getGElements((JRElementGroup) el)); } else if (el instanceof JRDesignElement) { res.add((JRDesignElement) el); if (el instanceof JRDesignCrosstab) res.addAll(getCrosstabElements((JRDesignCrosstab) el)); } } return res; }
/** * Finds the top element group for a specified {@link JRDesignElement}. * * @param element * the design element * @return the top element group if any exists, <code>null</code> otherwise */ public static JRElementGroup getTopElementGroup(JRDesignElement element) { JRElementGroup g1 = element.getElementGroup(); while (g1 != null) { // if (!g1.getChildren().contains(element)) return null; // The element points to its parent, but its parent has // not it as child if (g1 instanceof JRDesignBand || g1 instanceof JRDesignCellContents) return g1; g1 = g1.getElementGroup(); } return null; }
/** * 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); } }