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

项目:jasperreports    文件:TableReport.java   
@Override
public Void visitColumn(Column column)
{
    Cell cell = columnCell(column);

    if (!isEmpty(cell))
    {
        int rowSpan = cell.getRowSpan() == null ? 1 : cell.getRowSpan();
        int rowLevel = level + rowSpan - 1;
        JRDesignElementGroup elementGroup = bandInfo.getRowElementGroup(rowLevel);

        JRElement cellElement = createColumnCell(column, elementGroup, cell);
        elementGroup.addElement(cellElement);
        bandInfo.cellAdded(level, new CellInfo(cellElement, rowSpan, fillColumn.getColSpan()));

        yOffset += cell.getHeight();
    }

    xOffset += column.getWidth();

    return null;
}
项目:PDFReporter-Studio    文件:MCallout.java   
public void deleteCallout() {
    ANode parent = getParent();
    if (parent != null) {
        properties = getProperities(parent);
        properties.remove("callouts." + i + ".bounds");
        properties.remove("callouts." + i + ".pins");
        properties.remove("callouts." + i + ".text");
        properties.remove("callouts." + i + ".pins");
        properties.remove("callouts." + i + ".bg");
        properties.remove("callouts." + i + ".fg");

        String calloutInfoStr = FileUtils.getPropertyAsString(properties);
        if(calloutInfoStr==null || calloutInfoStr.isEmpty()){
            getPropertiesHolder(parent).getPropertiesMap().removeProperty(PROP_CALLOUT);
        }
        else{
            getPropertiesHolder(parent).getPropertiesMap().setProperty(PROP_CALLOUT,
                    calloutInfoStr);    
        }

        removeChild(this);

        getPropertyChangeSupport().fireIndexedPropertyChange(JRDesignElementGroup.PROPERTY_CHILDREN, -1, true, false);
    }
}
项目:PDFReporter-Studio    文件:MCallout.java   
public static MCallout createCallout(ANode parent, Rectangle location) {
    Properties properties = getProperities(parent);
    Set<Object> keySet = properties.keySet();
    int max = 0;
    for (Object key : keySet) {
        String k = (String) key;
        if (k.matches("callouts\\.[0-9]\\.bounds")) {
            int tmp = Integer.parseInt(k.replaceAll("callouts\\.", "").replaceAll("\\.bounds", ""));
            max = Math.max(tmp, max);
        }
    }
    MCallout mCallout = new MCallout(parent, properties, max + 1);
    mCallout.setPropertyValue(JRDesignElement.PROPERTY_X, location.x);
    mCallout.setPropertyValue(JRDesignElement.PROPERTY_Y, location.y);
    mCallout.setPropertyValue(JRDesignElement.PROPERTY_WIDTH, location.width);
    mCallout.setPropertyValue(JRDesignElement.PROPERTY_HEIGHT, location.height);

    parent.getPropertyChangeSupport()
            .fireIndexedPropertyChange(JRDesignElementGroup.PROPERTY_CHILDREN, -1, true, false);
    return mCallout;
}
项目:PDFReporter-Studio    文件:ReorderElementGroupCommand.java   
@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);
    }
}
项目:PDFReporter-Studio    文件:ReorderElementGroupCommand.java   
@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);
    }
}
项目:PDFReporter-Studio    文件:ReorderElementCommand.java   
@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);
    }
}
项目:PDFReporter-Studio    文件:ReorderElementCommand.java   
@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);
    }
}
项目:PDFReporter-Studio    文件:DeleteElementCommand.java   
@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);
        }
    }
}
项目:PDFReporter-Studio    文件:OrphanElementCommand.java   
@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);
    }
}
项目:PDFReporter-Studio    文件:CreateElementGroupCommand.java   
@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);
        }
    }
}
项目:ireport-fork    文件:ModelUtils.java   
public static void fixElementsExpressions(JRDesignElementGroup group, String oldName, String newName, byte chunckType, String newClassName) {

    List list = group.getChildren();
    for (int i=0; i<list.size(); ++i)
    {
        Object obj = list.get(i);
        if (obj == null) continue;
        if (obj instanceof JRDesignElementGroup)
        {
            fixElementsExpressions((JRDesignElementGroup)obj,oldName,newName,chunckType,newClassName);
        }
        else if (obj instanceof JRDesignTextField)
        {
            fixElementExpressionText((JRDesignTextField)obj,oldName,newName,chunckType,newClassName);
        }
        else if (obj instanceof JRDesignImage)
        {
            fixElementExpressionImage((JRDesignImage)obj,oldName,newName,chunckType,newClassName);
        }


    }

}
项目:ireport-fork    文件:ElementPasteType.java   
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);
}
项目:ireport-fork    文件:ElementPasteType.java   
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);

}
项目:ireport-fork    文件:AddElementUndoableEdit.java   
@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);
    }
}
项目:ireport-fork    文件:UnGroupElementsAction.java   
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);
        }
    }
项目:ireport-fork    文件:UnGroupElementsAction.java   
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);
        }
    }
项目:ireport-fork    文件:UnGroupElementsAction.java   
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);
        }
    }
项目:ireport-fork    文件:ReportAlignWithMoveStrategyProvider.java   
private void updateChildren(List listOfElements, AbstractReportObjectScene scene, ArrayList<Widget> changedWidgets)
{
      for (int i=0; i < listOfElements.size(); ++i)
      {
           if (listOfElements.get(i) instanceof JRDesignElement)
           {
               JRDesignElement element = (JRDesignElement)listOfElements.get(i);
               JRDesignElementWidget w = (JRDesignElementWidget)scene.findWidget(element);
               if (w == null || changedWidgets.contains(w)) continue;
               w.updateBounds();
               w.getSelectionWidget().updateBounds();

               if (w.getChildrenElements() != null)
               {
                   updateChildren(w, scene, changedWidgets);
               }

               changedWidgets.add(w);
           }
           else if (listOfElements.get(i) instanceof JRDesignElementGroup)
           {
               updateChildren(((JRDesignElementGroup)listOfElements.get(i)).getChildren(), scene, changedWidgets);
           }
      }
}
项目:jasperreports    文件:JRElementGroupFactory.java   
@Override
public Object createObject(Attributes atts)
{
    JRDesignElementGroup elementGroup = new JRDesignElementGroup();

    return elementGroup;
}
项目:jasperreports    文件:TableReport.java   
@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;
}
项目:PDFReporter-Studio    文件:EditChartCommand.java   
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);
    }
}
项目:PDFReporter-Studio    文件:MList.java   
@Override
public HashSet<String> generateGraphicalProperties() {
    HashSet<String> properties = super.generateGraphicalProperties();
    properties.add(JRDesignElementGroup.PROPERTY_CHILDREN);
    properties.add(JRDesignElement.PROPERTY_ELEMENT_GROUP);
    properties.add(JRDesignElement.PROPERTY_PARENT_STYLE_NAME_REFERENCE);
    properties.add(PREFIX + DesignListContents.PROPERTY_WIDTH);
    properties.add(PREFIX + DesignListContents.PROPERTY_HEIGHT);
    return properties;
}
项目:PDFReporter-Studio    文件:EditSpiderChartCommand.java   
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);
    }
}
项目:PDFReporter-Studio    文件:DeleteCalloutCommand.java   
@Override
public void undo() {
    mcallout.setParent(parent, -1);
    mcallout.setPropertyValue(JRDesignElement.PROPERTY_X, mcallout.getPropertyValue(JRDesignElement.PROPERTY_X));
    parent.getPropertyChangeSupport()
            .fireIndexedPropertyChange(JRDesignElementGroup.PROPERTY_CHILDREN, -1, true, false);
}
项目:PDFReporter-Studio    文件:DefaultTemplateEngine.java   
/**
 * 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);
    }
}
项目:PDFReporter-Studio    文件:DefaultTemplateEngine.java   
/**
 * 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);
    }
}
项目:PDFReporter-Studio    文件:CreatePageXofYCommand.java   
@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);
}
项目:PDFReporter-Studio    文件:OrphanElementGroupCommand.java   
@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);
}
项目:PDFReporter-Studio    文件:OrphanElementGroupCommand.java   
@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);
    }
}
项目:PDFReporter-Studio    文件:CreateElementCommand.java   
@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);
}
项目:PDFReporter-Studio    文件:CreateElementCommand.java   
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());
        }
    }
}
项目:PDFReporter-Studio    文件:DeleteElementCommand.java   
@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();
            }
        }
    }
}
项目:PDFReporter-Studio    文件:OrphanElementCommand.java   
@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);
}
项目:PDFReporter-Studio    文件:DeleteElementGroupCommand.java   
@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);
}
项目:PDFReporter-Studio    文件:DeleteElementGroupCommand.java   
@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);
    }
}
项目:PDFReporter-Studio    文件:CreateElementGroupCommand.java   
@Override
public void undo() {
    if (jrGroup instanceof JRDesignElementGroup)
        ((JRDesignElementGroup) jrGroup).removeElementGroup(jrElement);
    else if (jrGroup instanceof JRDesignFrame)
        ((JRDesignFrame) jrGroup).removeElementGroup(jrElement);
}
项目:PDFReporter-Studio    文件:ReportGenerator.java   
public void removeElement(JRElementGroup container, JRDesignElement element) {
    if (container instanceof JRDesignElementGroup) {
        ((JRDesignElementGroup) container).removeElement(element);
    }
    if (container instanceof JRDesignFrame) {
        ((JRDesignFrame) container).removeElement(element);
    }
}
项目:PDFReporter-Studio    文件:ReportGenerator.java   
public void addElement(JRElementGroup container, JRDesignElement element) {
    if (container instanceof JRDesignElementGroup) {
        ((JRDesignElementGroup) container).addElement(element);

    }
    if (container instanceof JRDesignFrame) {
        ((JRDesignFrame) container).addElement(element);
    }
}
项目:PDFReporter-Studio    文件:DefaultManager.java   
/**
 * Recursive method to search a jr type inside the current parent and if it is
 * found remove the element with that type and return its parent
 * 
 * @param element use the type of this element to search another element of the same type in the children of the current parent
 * @param actualNode the current parent
 * @return the parent of the removed node if found, null otherwise
 */
private INode searchAndRemoveOld(JRDesignElement element, INode actualNode){
    for(INode node : actualNode.getChildren()){
        if (node.getValue() != null && node.getValue().getClass().equals(element.getClass()) && actualNode.getValue() instanceof JRDesignElementGroup){
            //found must delete and return the parent
            Object parent = actualNode.getValue();
            ((JRDesignElementGroup)parent).removeElement((JRDesignElement)node.getValue());
            return actualNode;
        } else {
            INode subResult = searchAndRemoveOld(element, node);
            if (subResult != null) return subResult;
        }
    }
    return null;
}
项目:PDFReporter-Studio    文件:DefaultManager.java   
/**
 * Add an element to the current selected template set. The element is 
 * added inside the detail band and if there was an element of the same 
 * type of the added one the old one is removed
 * 
 * @param element element to add
 */
private void addNewElement(JRDesignElement element){
    INode parent = searchDetailBand();
    Assert.isNotNull(parent, "The Template Set report must have a detail band");
    if (parent != null){
        searchAndRemoveOld(element, parent);
        ((JRDesignElementGroup)parent.getValue()).addElement(element);
    }
}