Package org.pentaho.reporting.engine.classic.core

Examples of org.pentaho.reporting.engine.classic.core.RelationalGroup


   *
   * @return the continent group.
   */
  private RelationalGroup createContinentGroup()
  {
    final RelationalGroup continentGroup = new RelationalGroup();
    continentGroup.setName("Continent Group");
    continentGroup.addField("Continent");

    final GroupHeader header = new GroupHeader();
    header.getStyle().setStyleProperty(TextStyleKeys.FONT, "Monospaced");
    header.getStyle().setStyleProperty(TextStyleKeys.FONTSIZE, new Integer(10));
    header.getStyle().setStyleProperty(TextStyleKeys.BOLD, Boolean.TRUE);
    header.getStyle().setStyleProperty(ElementStyleKeys.MIN_HEIGHT, new Float(20));
    header.setName("Continent-Group-Header");

    LabelElementFactory factory = new LabelElementFactory();
    factory.setName("Continent-Group-Header-Label");
    factory.setAbsolutePosition(new Point2D.Float(0, 1));
    factory.setMinimumSize(new FloatDimension(76, 9));
    factory.setHorizontalAlignment(ElementAlignment.LEFT);
    factory.setVerticalAlignment(ElementAlignment.MIDDLE);
    factory.setText("CONTINENT:");
    header.addElement(factory.createElement());

    final TextFieldElementFactory tfactory = new TextFieldElementFactory();
    tfactory.setName("Continent-Group-Header Continent Element");
    tfactory.setAbsolutePosition(new Point2D.Float(96, 1));
    tfactory.setMinimumSize(new FloatDimension(76, 9));
    tfactory.setHorizontalAlignment(ElementAlignment.LEFT);
    tfactory.setVerticalAlignment(ElementAlignment.MIDDLE);
    tfactory.setNullString("<null>");
    tfactory.setFieldname("Continent");
    header.addElement(tfactory.createElement());

    header.addElement(HorizontalLineElementFactory.createHorizontalLine(12, null, new BasicStroke(0.5f)));
    continentGroup.setHeader(header);

    final GroupFooter footer = new GroupFooter();
    footer.setName("Continent-Group-Footer");
    footer.getStyle().setStyleProperty(ElementStyleKeys.MIN_HEIGHT, new Float(20));
    header.getStyle().setStyleProperty(TextStyleKeys.FONT, "Monospaced");
    header.getStyle().setStyleProperty(TextStyleKeys.FONTSIZE, new Integer(10));
    header.getStyle().setStyleProperty(TextStyleKeys.BOLD, Boolean.TRUE);

    factory = new LabelElementFactory();
    factory.setName("Continent-Group-Footer Label");
    factory.setAbsolutePosition(new Point2D.Float(0, 0));
    factory.setMinimumSize(new FloatDimension(100, 12));
    factory.setHorizontalAlignment(ElementAlignment.LEFT);
    factory.setVerticalAlignment(ElementAlignment.MIDDLE);
    factory.setText("Population:");
    footer.addElement(factory.createElement());

    final NumberFieldElementFactory nfactory = new NumberFieldElementFactory();
    nfactory.setName("Continent-Group-Footer Sum");
    nfactory.setAbsolutePosition(new Point2D.Float(260, 0));
    nfactory.setMinimumSize(new FloatDimension(76, 12));
    nfactory.setHorizontalAlignment(ElementAlignment.LEFT);
    nfactory.setVerticalAlignment(ElementAlignment.MIDDLE);
    nfactory.setNullString("<null>");
    nfactory.setFieldname("sum");
    nfactory.setFormatString("#,##0");
    footer.addElement(nfactory.createElement());
    continentGroup.setFooter(footer);
    return continentGroup;
  }
View Full Code Here


    final MasterReport report = new MasterReport();
    final CrosstabElement element = new CrosstabElement();

    CrosstabGroup rootGroup = new CrosstabGroup();

    RelationalGroup relGroup = new RelationalGroup();
    relGroup.setBody(new SubGroupBody(rootGroup));
    element.setRootGroup(relGroup);

    report.getReportHeader().addElement(element);

    final TestReportDesignerContext rdc = new TestReportDesignerContext();
View Full Code Here

  }

  private static UndoEntry deleteGroupBody(final GroupBody data)
  {
    final GroupBody subgroup = (GroupBody) data;
    final RelationalGroup parent = (RelationalGroup) subgroup.getParentSection();
    if (parent != null)
    {
      final GroupBody body = parent.getBody();
      final GroupDataBody newBody = new GroupDataBody();
      parent.setBody(newBody);
      return new SectionEditUndoEntry
          (parent.getObjectID(), ModelUtility.findIndexOf(parent, newBody), body, newBody);
    }
    return null;
  }
View Full Code Here

    final Section parent = groupElement.getParentSection();
    if (parent instanceof SubGroupBody)
    {
      final SubGroupBody parentBody = (SubGroupBody) groupElement.getParentSection();
      final Group oldGroup = parentBody.getGroup();
      final RelationalGroup newRootGroup = new RelationalGroup();
      parentBody.setGroup(newRootGroup);
      return new SectionEditUndoEntry
          (parentBody.getObjectID(), ModelUtility.findIndexOf(parentBody, newRootGroup), oldGroup, newRootGroup);
    }
    if (parent instanceof AbstractReportDefinition)
    {
      final AbstractReportDefinition report = (AbstractReportDefinition) parent;
      final Group oldGroup = report.getRootGroup();
      final RelationalGroup newRootGroup = new RelationalGroup();
      report.setRootGroup(newRootGroup);
      return new SectionEditUndoEntry
          (report.getObjectID(), ModelUtility.findIndexOf(report, newRootGroup), oldGroup, newRootGroup);
    }
    return null;
View Full Code Here

    for (int i = 0; i < groups.length; i++)
    {
      final Group group = groups[i];
      if (group instanceof RelationalGroup)
      {
        final RelationalGroup relationalGroup = (RelationalGroup) group;
        if (ModelUtility.isHideInLayoutGui(relationalGroup.getHeader()) == false)
        {
          rootBandComponents.add(new RootBandRenderer(relationalGroup.getHeader(), renderContext));
        }
      }

      final Element bodyElement = group.getBody();
      if (bodyElement instanceof GroupDataBody)
      {
        final GroupDataBody body = (GroupDataBody) bodyElement;
        if (ModelUtility.isHideInLayoutGui(body.getDetailsHeader()) == false)
        {
          rootBandComponents.add(new RootBandRenderer(body.getDetailsHeader(), renderContext));
        }
        if (ModelUtility.isHideInLayoutGui(body.getNoDataBand()) == false)
        {
          rootBandComponents.add(new RootBandRenderer(body.getNoDataBand(), renderContext));
        }
        if (ModelUtility.isHideInLayoutGui(body.getItemBand()) == false)
        {
          rootBandComponents.add(new RootBandRenderer(body.getItemBand(), renderContext));
        }
        if (ModelUtility.isHideInLayoutGui(body.getDetailsFooter()) == false)
        {
          rootBandComponents.add(new RootBandRenderer(body.getDetailsFooter(), renderContext));
        }
        break;
      }
      else if (group instanceof CrosstabGroup)
      {
        rootBandComponents.add(new CrosstabRenderer((CrosstabGroup) group, renderContext));
        break;
      }
    }

    for (int i = groups.length - 1; i >= 0; i -= 1)
    {
      final Group group = groups[i];
      if (group instanceof RelationalGroup)
      {
        final RelationalGroup relationalGroup = (RelationalGroup) group;
        if (ModelUtility.isHideInLayoutGui(relationalGroup.getFooter()) == false)
        {
          rootBandComponents.add(new RootBandRenderer(relationalGroup.getFooter(), renderContext));
        }
      }
    }

    if (ModelUtility.isHideInLayoutGui(report.getReportFooter()) == false)
View Full Code Here

  {
    Group group = abstractReportDefinition.getRootGroup();
    final ArrayList<GroupDataEntry> data = new ArrayList();
    while (group instanceof RelationalGroup)
    {
      final RelationalGroup rgroup = (RelationalGroup) group;
      data.add(new GroupDataEntry(group.getObjectID(), group.getName(), rgroup.getFieldsArray()));

      final GroupBody body = rgroup.getBody();
      if (body instanceof SubGroupBody)
      {
        final SubGroupBody subGroupBody = (SubGroupBody) body;
        group = subGroupBody.getGroup();
      }
View Full Code Here

  public static void applyGroupData(final AbstractReportDefinition abstractReportDefinition,
                                    final GroupDataEntry[] newEntries)
  {
    final HashMap<InstanceID, RelationalGroup> groups = new HashMap();
    RelationalGroup innermostGroup = null;

    Group group = abstractReportDefinition.getRootGroup();
    while (group instanceof RelationalGroup)
    {
      final RelationalGroup rgroup = (RelationalGroup) group;
      innermostGroup = rgroup;
      groups.put(group.getObjectID(), rgroup);

      final GroupBody body = rgroup.getBody();
      if (body instanceof SubGroupBody)
      {
        final SubGroupBody subGroupBody = (SubGroupBody) body;
        group = subGroupBody.getGroup();
      }
      else
      {
        group = null;
      }
    }

    final RelationalGroup[] resultGroups = new RelationalGroup[newEntries.length];
    for (int i = 0; i < newEntries.length; i++)
    {
      final GroupDataEntry o = newEntries[i];
      final RelationalGroup sourceGroup = groups.get(o.getInstanceID());
      if (sourceGroup == null)
      {
        resultGroups[i] = new RelationalGroup();
      }
      else
      {
        resultGroups[i] = sourceGroup;
      }

      resultGroups[i].setName(o.getName());
      resultGroups[i].setFieldsArray(o.getFields());
    }

    final GroupBody innermostBody;
    if (innermostGroup == null)
    {
      innermostBody = new SubGroupBody(abstractReportDefinition.getRootGroup());
    }
    else
    {
      innermostBody = innermostGroup.getBody();
    }

    if (resultGroups.length > 0)
    {
      for (int i = 0; i < resultGroups.length; i++)
      {
        final RelationalGroup resultGroup = resultGroups[i];
        if (i == 0)
        {
          abstractReportDefinition.setRootGroup(resultGroup);
        }
        else
        {
          final RelationalGroup prevGroup = resultGroups[i - 1];
          final GroupBody body = prevGroup.getBody();
          if (body instanceof SubGroupBody)
          {
            final SubGroupBody sgb = (SubGroupBody) body;
            sgb.setGroup(resultGroup);
          }
          else
          {
            final SubGroupBody sgb = new SubGroupBody();
            sgb.setGroup(resultGroup);
            prevGroup.setBody(sgb);
          }
        }
      }

      resultGroups[resultGroups.length - 1].setBody(innermostBody);
    }
    else
    {

      // all groups had been removed ..
      final RelationalGroup relationalGroup = new RelationalGroup();
      relationalGroup.setBody(innermostBody);
      abstractReportDefinition.setRootGroup(relationalGroup);
    }
  }
View Full Code Here

    if (activeContext == null)
    {
      return;
    }

    final RelationalGroup newGroup = new RelationalGroup();
    final EditGroupUndoEntry groupUndoEntry = EditGroupAction.performEditGroup(getReportDesignerContext(), newGroup, true);
    if (groupUndoEntry == null)
    {
      return;
    }

    // apply the data from the EditGroupAction ..
    newGroup.setName(groupUndoEntry.getNewName());
    newGroup.setFieldsArray(groupUndoEntry.getNewFields());

    try
    {
      Object selectedElement = activeContext.getReportDefinition();
      if (getSelectionModel().getSelectionCount() > 0)
      {
        selectedElement = getSelectionModel().getSelectedElement(0);
      }
      if (selectedElement == activeContext.getReportDefinition()  )
      {
        // execution order is important here.
        // first unlink the old root-group by setting a new one ...
        final AbstractReportDefinition report = (AbstractReportDefinition) selectedElement;
        final Group rootGroup = report.getRootGroup();

        final SubGroupBody body = new SubGroupBody();
        newGroup.setBody(body);
        report.setRootGroup(newGroup);

        // *then* you can set the old-root to the newly inserted group ..
        body.setGroup(rootGroup);

        activeContext.getUndo().addChange(ActionMessages.getString("InsertGroupAction.UndoName"),
            new InsertGroupOnReportUndoEntry(rootGroup, newGroup));
        return;
      }

      if (selectedElement instanceof RelationalGroup == false)
      {
        return;
      }
      final RelationalGroup selectedGroup = (RelationalGroup) selectedElement;

      final GroupBody bodyElement = selectedGroup.getBody();
      if (bodyElement instanceof SubGroupBody)
      {
        final SubGroupBody subGroupBodyReportElement = (SubGroupBody) bodyElement;
        final Group oldBodyContent = subGroupBodyReportElement.getGroup();

        final SubGroupBody body = new SubGroupBody();
        newGroup.setBody(body);
        subGroupBodyReportElement.setGroup(newGroup);
        body.setGroup(oldBodyContent);

        activeContext.getUndo().addChange(ActionMessages.getString("InsertGroupAction.UndoName"),
            new InsertGroupOnGroupUndoEntry(selectedGroup.getObjectID(), oldBodyContent, newGroup));
      }
      else if (bodyElement instanceof GroupDataBody)
      {
        final GroupDataBody oldBody = (GroupDataBody) bodyElement;
        selectedGroup.setBody(new SubGroupBody(newGroup));
        newGroup.setBody(oldBody);
        activeContext.getUndo().addChange(ActionMessages.getString("InsertGroupAction.UndoName"),
            new InsertGroupOnDetailsUndoEntry(selectedGroup.getObjectID(), newGroup));
      }
    }
    catch (Exception ex)
    {
      UncaughtExceptionsModel.getInstance().addException(ex);
View Full Code Here

      this.newRootGroup = newRootGroup;
    }

    public void undo(final ReportDocumentContext renderContext)
    {
      final RelationalGroup selectedGroup = (RelationalGroup)
          ModelUtility.findElementById(renderContext.getReportDefinition(), target);
      final GroupBody bodyElement = selectedGroup.getBody();
      if (bodyElement instanceof SubGroupBody == false)
      {
        throw new IllegalStateException();
      }
View Full Code Here

      subGroupBodyReportElement.setGroup(oldRootGroup);
    }

    public void redo(final ReportDocumentContext renderContext)
    {
      final RelationalGroup selectedGroup = (RelationalGroup)
          ModelUtility.findElementById(renderContext.getReportDefinition(), target);

      final GroupBody bodyElement = selectedGroup.getBody();
      if (bodyElement instanceof SubGroupBody == false)
      {
        throw new IllegalStateException();
      }
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.engine.classic.core.RelationalGroup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.