@Test
  public void testCanvasWithPrePostPad() throws Exception {
    final MasterReport report = new MasterReport();
    report.setDataFactory(new TableDataFactory("query", new DefaultTableModel(10, 1)));
    report.setQuery("query");

    final Band table = TableTestUtil.createTable(1, 1, 6, new CustomProducer());
    table.getStyle().setStyleProperty(ElementStyleKeys.MIN_WIDTH, 200f);
    table.getStyle().setStyleProperty(ElementStyleKeys.POS_X, 100f);
    table.getStyle().setStyleProperty(ElementStyleKeys.POS_Y, 10f);
    table.setName("table");
    report.getReportHeader().addElement(TableTestUtil.createDataItem("Pre-Padding", 100, 10));
    report.getReportHeader().addElement(table);

    Element postPaddingItem = TableTestUtil.createDataItem("Post-Padding", 100, 10);
    postPaddingItem.getStyle().setStyleProperty(ElementStyleKeys.POS_X, 300f);
    report.getReportHeader().addElement(postPaddingItem);
    report.getReportHeader().setLayout("canvas");

    PdfReportUtil.createPDF(report, "test-output/PRD-3857-output-canvas.pdf");

    List<LogicalPageBox> pages = DebugReportRunner.layoutPages(report, 0, 1, 2);
    assertPageValid(pages, 0, StrictGeomUtility.toInternalValue(10));
    assertPageValid(pages, 1);
    assertPageValid(pages, 2);
  }
 private void configureBand(final javax.swing.text.Element textElement, final Band band) {
   if ("paragraph".equals(textElement.getName()) || "section".equals(textElement.getName())) {
     band.getStyle().setStyleProperty(BandStyleKeys.LAYOUT, "block");
     band.getStyle().setStyleProperty(ElementStyleKeys.MIN_WIDTH, new Float(-100));
   } else {
     band.getStyle().setStyleProperty(BandStyleKeys.LAYOUT, "inline");
   }
 }
  private Band createTable() {
    final Band tableCellA1 = TableTestUtil.createCell(TableTestUtil.createDataItem("Cell A1"));
    final Band tableCellA2 = TableTestUtil.createCell(TableTestUtil.createDataItem("Cell A2"));
    final Band tableCellB1 = TableTestUtil.createCell(TableTestUtil.createDataItem("Cell B1"));
    final Band tableCellB2 = TableTestUtil.createCell(TableTestUtil.createDataItem("Cell B2"));
    final Band tableCellC1 = TableTestUtil.createCell(TableTestUtil.createDataItem("Cell C1"));
    final Band tableCellC2 = TableTestUtil.createCell(TableTestUtil.createDataItem("Cell C2"));

    final Band tableRowA = TableTestUtil.createRow(tableCellA1, tableCellA2);
    final Band tableRowB = TableTestUtil.createRow(tableCellB1, tableCellB2);
    final Band tableRowC = TableTestUtil.createRow(tableCellC1, tableCellC2);

    final Band tableBody = new Band();
    tableBody.getStyle().setStyleProperty(BandStyleKeys.LAYOUT, BandStyleKeys.LAYOUT_TABLE_BODY);
    tableBody.getStyle().setStyleProperty(ElementStyleKeys.MIN_WIDTH, -100f);
    tableBody.getStyle().setStyleProperty(ElementStyleKeys.MIN_HEIGHT, 150f);
    tableBody.addElement(tableRowA);
    tableBody.addElement(tableRowB);
    tableBody.addElement(tableRowC);

    final Band table = new Band();
    table.getStyle().setStyleProperty(BandStyleKeys.LAYOUT, BandStyleKeys.LAYOUT_TABLE);
    table.getStyle().setStyleProperty(ElementStyleKeys.MIN_WIDTH, -100f);
    table.getStyle().setStyleProperty(ElementStyleKeys.MIN_HEIGHT, 200f);
    table.addElement(tableBody);
    return table;
  }
  public void testMissingTableCell() throws ReportProcessingException, ContentProcessingException {

    final Band tableRow = TableTestUtil.createRow();

    final Band tableBody = new Band();
    tableBody.getStyle().setStyleProperty(BandStyleKeys.LAYOUT, BandStyleKeys.LAYOUT_TABLE_BODY);
    tableBody.getStyle().setStyleProperty(ElementStyleKeys.MIN_WIDTH, -100f);
    tableBody.getStyle().setStyleProperty(ElementStyleKeys.MIN_HEIGHT, 200f);
    tableBody.addElement(TableTestUtil.createAutoBox(tableRow));

    final Band table = new Band();
    table.getStyle().setStyleProperty(BandStyleKeys.LAYOUT, BandStyleKeys.LAYOUT_TABLE);
    table.getStyle().setStyleProperty(ElementStyleKeys.MIN_WIDTH, -100f);
    table.getStyle().setStyleProperty(ElementStyleKeys.MIN_HEIGHT, 200f);
    table.addElement(TableTestUtil.createAutoBox(tableBody));

    final MasterReport report = new MasterReport();
    final ReportHeader band = report.getReportHeader();
    band.addElement(table);

    final LogicalPageBox logicalPageBox =
        DebugReportRunner.layoutSingleBand(report, band, false, false);
    // ModelPrinter.print(logicalPageBox);

    final DescendantMatcher matcher =
        new DescendantMatcher(new ElementMatcher("TableCellRenderBox"));
    final RenderNode[] all = MatchFactory.matchAll(logicalPageBox, matcher);

    assertEquals(0, all.length);
  }
  @Test
  public void testRunSimpleReport() throws Exception {
    final MasterReport report = new MasterReport();
    report.setDataFactory(new TableDataFactory("query", new DefaultTableModel(10, 1)));
    report.setQuery("query");

    final Band table = TableTestUtil.createTable(1, 1, 6, true);
    table.setName("table");
    report.getReportHeader().addElement(table);
    report.getReportHeader().setLayout("block");

    List<LogicalPageBox> pages = DebugReportRunner.layoutPages(report, 0, 1, 2);
    assertPageValid(pages, 0);
    assertPageValid(pages, 1);
    assertPageValid(pages, 2);
  }
  public Object convert(final ReportElement source, final Object value) {
    try {
      final Document doc = RichTextConverterUtilities.parseDocument(editorKit, value);
      if (doc == null) {
        return value;
      }

      final Element element = process(doc.getDefaultRootElement());
      final Band band =
          RichTextConverterUtilities.convertToBand(StyleKey.getDefinedStyleKeys(), source, element);
      band.getStyle().setStyleProperty(BandStyleKeys.LAYOUT, "inline");
      return band;
    } catch (Exception e) {
      return value;
    }
  }
    public void run() {
      if (rootband) {
        final int result =
            JOptionPane.showOptionDialog(
                dragContext.getRepresentationContainer(),
                Messages.getInstance()
                    .getString("TocElementDragHandler.BandedOrInlineSubreportQuestion"),
                Messages.getInstance().getString("TocElementDragHandler.InsertSubreport"),
                JOptionPane.YES_NO_CANCEL_OPTION,
                JOptionPane.PLAIN_MESSAGE,
                null,
                new String[] {
                  Messages.getInstance().getString("TocElementDragHandler.Inline"),
                  Messages.getInstance().getString("TocElementDragHandler.Banded"),
                  Messages.getInstance().getString("TocElementDragHandler.Cancel")
                },
                Messages.getInstance().getString("TocElementDragHandler.Inline"));
        if (result == JOptionPane.CLOSED_OPTION || result == 2) {
          return;
        }

        if (result == 0) {
          final ReportDocumentContext context = dragContext.getRenderContext();
          final UndoManager undo = context.getUndo();
          undo.addChange(
              Messages.getInstance().getString("TocElementDragHandler.UndoEntry"),
              new ElementEditUndoEntry(
                  parent.getObjectID(), parent.getElementCount(), null, subReport));
          parent.addElement(subReport);
        } else {
          final AbstractRootLevelBand arb = (AbstractRootLevelBand) parent;

          final ReportDocumentContext context = dragContext.getRenderContext();
          final UndoManager undo = context.getUndo();
          undo.addChange(
              Messages.getInstance().getString("TocElementDragHandler.UndoEntry"),
              new BandedSubreportEditUndoEntry(
                  parent.getObjectID(), arb.getSubReportCount(), null, subReport));
          arb.addSubReport(subReport);
        }
      } else {
        final ReportDocumentContext context = dragContext.getRenderContext();
        final UndoManager undo = context.getUndo();
        undo.addChange(
            Messages.getInstance().getString("TocElementDragHandler.UndoEntry"),
            new ElementEditUndoEntry(
                parent.getObjectID(), parent.getElementCount(), null, subReport));
        parent.addElement(subReport);
      }

      dragContext
          .getRenderContext()
          .getSelectionModel()
          .setSelectedElements(new Object[] {subReport});
    }
  @Test
  public void testBlockWithPrePostPad() throws Exception {
    final MasterReport report = new MasterReport();
    report.setDataFactory(new TableDataFactory("query", new DefaultTableModel(10, 1)));
    report.setQuery("query");

    final Band table = TableTestUtil.createTable(1, 1, 6, true);
    table.setName("table");
    report.getReportHeader().addElement(TableTestUtil.createDataItem("Pre-Padding", 100, 10));
    report.getReportHeader().addElement(table);
    report.getReportHeader().addElement(TableTestUtil.createDataItem("Post-Padding", 100, 10));
    report.getReportHeader().setLayout("block");

    PdfReportUtil.createPDF(report, "test-output/PRD-3857-output-block.pdf");

    List<LogicalPageBox> pages = DebugReportRunner.layoutPages(report, 0, 1, 2);
    assertPageValid(pages, 0, StrictGeomUtility.toInternalValue(10));
    assertPageValid(pages, 1);
    assertPageValid(pages, 2);
    //    assertPageValid(report, 3);
    //    assertPageValid(report, 4);
  }
  private Element process(final javax.swing.text.Element textElement) throws BadLocationException {
    if (textElement.isLeaf()) {
      final int endOffset = textElement.getEndOffset();
      final int startOffset = textElement.getStartOffset();
      final String text = textElement.getDocument().getText(startOffset, endOffset - startOffset);
      final Element result = new Element();
      result.setElementType(LabelType.INSTANCE);
      result.setAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, text);
      configureStyle(textElement.getAttributes(), result);
      return result;
    }

    final Band band = new Band();
    configureStyle(textElement.getAttributes(), band);
    configureBand(textElement, band);
    final int size = textElement.getElementCount();
    for (int i = 0; i < size; i++) {
      final Element element = process(textElement.getElement(i));
      band.addElement(element);
    }
    return band;
  }
  public void testResourceLabelAfterSerialization() throws Exception {
    final File url = GoldTestBase.locateGoldenSampleReport("Prd-3514.prpt");
    assertNotNull(url);
    final ResourceManager resourceManager = new ResourceManager();
    resourceManager.registerDefaults();
    final Resource directly = resourceManager.createDirectly(url, MasterReport.class);
    final MasterReport org = (MasterReport) directly.getResource();

    final MasterReport report = postProcess(org);

    RelationalGroup relationalGroup = report.getRelationalGroup(0);
    GroupHeader header = relationalGroup.getHeader();
    Band band = (Band) header.getElement(0);
    Element element = band.getElement(1);
    assertTrue(element.getElementType() instanceof ResourceMessageType);
    element.setName("DateTitleField");
    //    LogicalPageBox logicalPageBox = DebugReportRunner.layoutPage(report, 1);
    LogicalPageBox logicalPageBox =
        DebugReportRunner.layoutSingleBand(report, header, false, false);
    RenderNode dateTitleField = MatchFactory.findElementByName(logicalPageBox, "DateTitleField");
    assertNotNull(dateTitleField);
    //    ModelPrinter.INSTANCE.print(logicalPageBox);
  }
Ejemplo n.º 11
0
  @Test
  public void testRowWithPrePostPad() throws Exception {
    final MasterReport report = new MasterReport();
    report.setDataFactory(new TableDataFactory("query", new DefaultTableModel(10, 1)));
    report.setQuery("query");

    final Band table = TableTestUtil.createTable(1, 1, 6, true);
    table.getStyle().setStyleProperty(ElementStyleKeys.MIN_WIDTH, 200f);
    table.setName("table");
    report.getReportHeader().addElement(TableTestUtil.createDataItem("Pre-Padding", 100, 10));
    report.getReportHeader().addElement(table);
    report.getReportHeader().addElement(TableTestUtil.createDataItem("Post-Padding", 100, 10));
    report.getReportHeader().setLayout("row");

    PdfReportUtil.createPDF(report, "test-output/PRD-3857-output-row.pdf");
    List<LogicalPageBox> pages = DebugReportRunner.layoutPages(report, 0, 1, 2);

    assertPageValid(pages, 0);
    assertPageValid(pages, 1);
    assertPageValid(pages, 2);
    //    assertPageValid(report, 3);
    //    assertPageValid(report, 4);
  }
Ejemplo n.º 12
0
  @Test
  public void testRunRowSpanReport() throws Exception {
    final MasterReport report = new MasterReport();
    report.setDataFactory(new TableDataFactory("query", new DefaultTableModel(10, 1)));
    report.setQuery("query");

    final Band table = TableTestUtil.createTable(1, 1, 6, true);
    final Band section = (Band) table.getElement(1);
    final Band row = (Band) section.getElement(0);
    final Band cell = TableTestUtil.createCell(6, 1);
    cell.addElement(TableTestUtil.createDataItem("Text", 100, 20));
    row.addElement(0, cell);

    table.setName("table");
    report.getReportHeader().addElement(table);
    report.getReportHeader().setLayout("block");

    PdfReportUtil.createPDF(report, "test-output/PRD-3857-rowspan-output.pdf");
    /*
    assertPageValid(report, 0);
    assertPageValid(report, 1);
    assertPageValid(report, 2);
    */
  }
  public void testWeirdTocLayout() throws ReportProcessingException, ContentProcessingException {
    Element textField = new Element();
    textField.setName("textField");
    textField.getStyle().setStyleProperty(TextStyleKeys.FONT, "Arial");
    textField.getStyle().setStyleProperty(TextStyleKeys.FONTSIZE, 14);
    textField.getStyle().setStyleProperty(TextStyleKeys.TEXT_WRAP, TextWrap.NONE);
    textField.getStyle().setStyleProperty(ElementStyleKeys.MIN_WIDTH, 97f);
    textField.getStyle().setStyleProperty(ElementStyleKeys.MIN_HEIGHT, 20f);
    textField.getStyle().setStyleProperty(ElementStyleKeys.POS_X, 0f);
    textField.getStyle().setStyleProperty(ElementStyleKeys.POS_Y, 0f);
    textField.setElementType(LabelType.INSTANCE);
    textField.setAttribute(
        AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, "Classic Cars");

    Element dotField = new Element();
    dotField.setName("dotField");
    dotField.getStyle().setStyleProperty(TextStyleKeys.FONT, "Arial");
    dotField.getStyle().setStyleProperty(TextStyleKeys.FONTSIZE, 14);
    dotField.getStyle().setStyleProperty(ElementStyleKeys.ALIGNMENT, ElementAlignment.RIGHT);
    dotField.getStyle().setStyleProperty(ElementStyleKeys.VALIGNMENT, ElementAlignment.TOP);
    dotField.getStyle().setStyleProperty(ElementStyleKeys.POS_X, 97f);
    dotField.getStyle().setStyleProperty(ElementStyleKeys.POS_Y, 0f);
    dotField.getStyle().setStyleProperty(ElementStyleKeys.MIN_WIDTH, 628.463f);
    dotField.getStyle().setStyleProperty(ElementStyleKeys.MIN_WIDTH, 20f);
    dotField.getStyle().setStyleProperty(ElementStyleKeys.WIDTH, 100f);
    dotField.getStyle().setStyleProperty(ElementStyleKeys.MAX_WIDTH, 100f);
    dotField.setElementType(LabelType.INSTANCE);
    dotField.setAttribute(
        AttributeNames.Core.NAMESPACE,
        AttributeNames.Core.VALUE,
        " . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . "
            + " . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . "
            + ". . . . . . . . . . . . . . . . . .");

    Band band = new Band();
    band.setName("outer-box");
    band.setLayout("inline");
    band.getStyle().setStyleProperty(ElementStyleKeys.BOX_SIZING, BoxSizing.CONTENT_BOX);
    band.getStyle().setStyleProperty(ElementStyleKeys.OVERFLOW_X, false);
    band.getStyle().setStyleProperty(ElementStyleKeys.OVERFLOW_Y, false);
    band.getStyle().setStyleProperty(TextStyleKeys.LINEHEIGHT, 1f);
    band.getStyle()
        .setStyleProperty(TextStyleKeys.WHITE_SPACE_COLLAPSE, WhitespaceCollapse.PRESERVE_BREAKS);
    band.getStyle().setStyleProperty(ElementStyleKeys.MIN_WIDTH, 708f);
    band.getStyle().setStyleProperty(ElementStyleKeys.MIN_HEIGHT, 12f);
    band.getStyle().setStyleProperty(ElementStyleKeys.MAX_HEIGHT, 20f);
    band.addElement(textField);
    band.addElement(dotField);

    final MasterReport report = new MasterReport();
    report.getReportHeader().addElement(band);

    LogicalPageBox logicalPageBox =
        DebugReportRunner.layoutSingleBand(report, report.getReportHeader(), false, false);
    // ModelPrinter.INSTANCE.print(logicalPageBox);

    RenderBox outerBox = (RenderBox) MatchFactory.findElementByName(logicalPageBox, "outer-box");
    RenderNode dotFieldBox = MatchFactory.findElementByName(logicalPageBox, "dotField");
    RenderNode textFieldBox = MatchFactory.findElementByName(logicalPageBox, "textField");
    assertNotNull(outerBox);
    assertNotNull(dotFieldBox);
    assertNotNull(textFieldBox);

    assertEquals(0, outerBox.getY());
    assertEquals(0, dotFieldBox.getY());
    assertEquals(0, textFieldBox.getY());

    // box only contains one line, and min-size is set to 8, max size = 20, so the line-height of
    // 14.024 is used.
    assertEquals(StrictGeomUtility.toInternalValue(14.024), outerBox.getHeight());
    assertEquals(StrictGeomUtility.toInternalValue(14.024), outerBox.getFirstChild().getHeight());
    assertEquals(StrictGeomUtility.toInternalValue(14), dotFieldBox.getHeight());
    assertEquals(StrictGeomUtility.toInternalValue(14), textFieldBox.getHeight());
  }
  private static boolean isEmptyElement(
      final ReportElement band, final StyleSheet style, final OutputProcessorMetaData metaData) {
    if (isControlBand(style)) {
      return false;
    }

    if (metaData.isFeatureSupported(OutputProcessorFeature.STRICT_COMPATIBILITY)) {
      if (band instanceof Band) {
        final Band b = (Band) band;
        if (b.getElementCount() > 0) {
          return false;
        }
      }
    }

    if (BandStyleKeys.LAYOUT_AUTO.equals(style.getStyleProperty(BandStyleKeys.LAYOUT))) {
      // A auto-band is considered empty.
      return true;
    }

    // A band is not empty, if it has a defined minimum or preferred height
    if (isLengthDefined(ElementStyleKeys.HEIGHT, style)) {
      return false;
    }
    if (isLengthDefined(ElementStyleKeys.WIDTH, style)) {
      return false;
    }
    if (isLengthDefined(ElementStyleKeys.POS_Y, style)) {
      return false;
    }
    if (isLengthDefined(ElementStyleKeys.POS_X, style)) {
      return false;
    }
    if (isLengthDefined(ElementStyleKeys.MIN_HEIGHT, style)) {
      return false;
    }
    if (isLengthDefined(ElementStyleKeys.MIN_WIDTH, style)) {
      return false;
    }
    if (isLengthDefined(ElementStyleKeys.PADDING_TOP, style)) {
      return false;
    }
    if (isLengthDefined(ElementStyleKeys.PADDING_LEFT, style)) {
      return false;
    }
    if (isLengthDefined(ElementStyleKeys.PADDING_BOTTOM, style)) {
      return false;
    }
    if (isLengthDefined(ElementStyleKeys.PADDING_RIGHT, style)) {
      return false;
    }
    if (BorderStyle.NONE.equals(
            style.getStyleProperty(ElementStyleKeys.BORDER_BOTTOM_STYLE, BorderStyle.NONE))
        == false) {
      return false;
    }
    if (BorderStyle.NONE.equals(
            style.getStyleProperty(ElementStyleKeys.BORDER_TOP_STYLE, BorderStyle.NONE))
        == false) {
      return false;
    }
    if (BorderStyle.NONE.equals(
            style.getStyleProperty(ElementStyleKeys.BORDER_LEFT_STYLE, BorderStyle.NONE))
        == false) {
      return false;
    }
    if (BorderStyle.NONE.equals(
            style.getStyleProperty(ElementStyleKeys.BORDER_RIGHT_STYLE, BorderStyle.NONE))
        == false) {
      return false;
    }
    if (style.getStyleProperty(ElementStyleKeys.BACKGROUND_COLOR) != null) {
      return false;
    }

    if (metaData.isExtraContentElement(band.getStyle(), band.getAttributes())) {
      return false;
    }
    return true;
  }
    public void run() {
      final ReportDocumentContext context = dragContext.getRenderContext();
      if (rootband) {
        final int result =
            JOptionPane.showOptionDialog(
                dragContext.getRepresentationContainer(),
                Messages.getString(
                    "CrosstabReportElementDragHandler.BandedOrInlineSubreportQuestion"),
                Messages.getString("CrosstabReportElementDragHandler.InsertSubreport"),
                JOptionPane.YES_NO_CANCEL_OPTION,
                JOptionPane.PLAIN_MESSAGE,
                null,
                new String[] {
                  Messages.getString("CrosstabReportElementDragHandler.Inline"),
                  Messages.getString("CrosstabReportElementDragHandler.Banded"),
                  Messages.getString("CrosstabReportElementDragHandler.Cancel")
                },
                Messages.getString("CrosstabReportElementDragHandler.Inline"));
        if (result == JOptionPane.CLOSED_OPTION || result == 2) {
          return;
        }

        if (result == 0) {
          final UndoManager undo = context.getUndo();
          undo.addChange(
              Messages.getString("CrosstabReportElementDragHandler.UndoEntry"),
              new ElementEditUndoEntry(
                  parent.getObjectID(), parent.getElementCount(), null, subReport));
          parent.addElement(subReport);
        } else {
          final AbstractRootLevelBand arb = (AbstractRootLevelBand) parent;
          final UndoManager undo = context.getUndo();
          undo.addChange(
              Messages.getString("CrosstabReportElementDragHandler.UndoEntry"),
              new BandedSubreportEditUndoEntry(
                  parent.getObjectID(), arb.getSubReportCount(), null, subReport));
          arb.addSubReport(subReport);
        }
      } else {
        final UndoManager undo = context.getUndo();
        undo.addChange(
            Messages.getString("CrosstabReportElementDragHandler.UndoEntry"),
            new ElementEditUndoEntry(
                parent.getObjectID(), parent.getElementCount(), null, subReport));
        parent.addElement(subReport);
      }

      final ReportDesignerContext designerContext = dragContext.getDesignerContext();
      final Window window = LibSwingUtil.getWindowAncestor(designerContext.getView().getParent());
      final AbstractReportDefinition reportDefinition =
          designerContext.getActiveContext().getReportDefinition();

      try {
        // Create the new subreport tab - this is where the contents of the Crosstab
        // dialog will go.  Zoom the crosstab canvas to 150% as crosstab has a lot of elements to
        // display
        subReport.setDataFactory(reportDefinition.getDataFactory());
        subReport
            .getReportDefinition()
            .setAttribute(ReportDesignerBoot.DESIGNER_NAMESPACE, ReportDesignerBoot.ZOOM, 1.5f);

        final ResourceBundleFactory rbf = subReport.getResourceBundleFactory();
        subReport.setResourceBundleFactory(rbf);

        final int idx = designerContext.addSubReport(designerContext.getActiveContext(), subReport);
        designerContext.setActiveDocument(designerContext.getReportRenderContext(idx));
      } catch (ReportDataFactoryException e) {
        UncaughtExceptionsModel.getInstance().addException(e);
      }

      // Prompt user to either create or use an existing data-source.
      final SubReportDataSourceDialog crosstabDataSourceDialog;
      if (window instanceof Dialog) {
        crosstabDataSourceDialog = new SubReportDataSourceDialog((Dialog) window);
      } else if (window instanceof Frame) {
        crosstabDataSourceDialog = new SubReportDataSourceDialog((Frame) window);
      } else {
        crosstabDataSourceDialog = new SubReportDataSourceDialog();
      }

      // User has prompted to select a data-source.  Get the selected query
      final String queryName = crosstabDataSourceDialog.performSelection(designerContext);
      if (queryName != null) {
        subReport.setQuery(queryName);

        // Invoke Crosstab dialog
        final InsertCrosstabGroupAction crosstabAction = new InsertCrosstabGroupAction();
        crosstabAction.setReportDesignerContext(designerContext);
        crosstabAction.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, ""));
      }

      dragContext
          .getRenderContext()
          .getSelectionModel()
          .setSelectedElements(new Object[] {subReport});
    }