Java Code Examples for org.pentaho.reporting.engine.classic.core.Element#getParent()

The following examples show how to use org.pentaho.reporting.engine.classic.core.Element#getParent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractReportElementDragHandler.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected Band getInsertionBand( final DropTargetDropEvent event,
                                 final ReportElementEditorContext dragContext,
                                 final Point2D point ) {
  final Element elementForLocation = dragContext.getElementForLocation( point, false );
  Band band;
  if ( elementForLocation instanceof Band ) {
    band = (Band) elementForLocation;
  } else if ( elementForLocation != null ) {
    band = elementForLocation.getParent();
  } else {
    band = null;
  }

  if ( band == null ) {
    final Element defaultEntry = dragContext.getDefaultElement();
    if ( defaultEntry instanceof Band == false ) {
      event.rejectDrop();
      dragContext.getRepresentationContainer().removeAll();
      return null;
    }
    band = (Band) defaultEntry;
  }
  return band;
}
 
Example 2
Source File: AbstractMouseDragOperation.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Tests, whether the array of elements contains a parent of the given element.
 *
 * @param element
 * @param elements
 * @return
 */
protected boolean isDescendant( final Element element, final List<Element> elements ) {
  final HashSet<Element> parents = new HashSet<Element>();
  Element parent = element.getParentSection();
  while ( parent != null ) {
    parents.add( parent );
    parent = parent.getParent();
  }

  for ( Element visualReportElement : elements ) {
    if ( element == visualReportElement ) {
      continue;
    }
    if ( visualReportElement instanceof AbstractReportDefinition ) {
      return false;
    }
    if ( visualReportElement instanceof RootLevelBand ) {
      return true;
    }
    if ( parents.contains( visualReportElement ) ) {
      return true;
    }
  }
  return false;
}
 
Example 3
Source File: AbstractRenderComponent.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void leadSelectionChanged( final ReportSelectionEvent event ) {
  if ( event.getModel().getSelectionCount() != 1 ) {
    return;
  }
  final Object raw = event.getElement();
  if ( raw instanceof Element == false ) {
    return;
  }

  Element e = (Element) raw;
  while ( e != null && e instanceof RootLevelBand == false ) {
    e = e.getParent();
  }

  if ( e == getRootBand() ) {
    setFocused( true );
    repaintConditionally();
    SwingUtilities.invokeLater( new AsyncChangeNotifier() );
  } else {
    setFocused( false );
    repaintConditionally();
    SwingUtilities.invokeLater( new AsyncChangeNotifier() );
  }
}
 
Example 4
Source File: InsertElementAction.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Element findRootBand( Element element ) {
  while ( element != null && ( ( element instanceof RootLevelBand ) == false ) ) {
    element = element.getParent();
  }

  if ( element != null ) {
    return element;
  }

  return null;
}
 
Example 5
Source File: InsertationUtil.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static boolean isBandedSubreport( final Element r ) {
  final Band parent = r.getParent();
  if ( parent instanceof RootLevelBand == false ) {
    return false;
  }
  final RootLevelBand rlb = (RootLevelBand) parent;
  final SubReport[] reports = rlb.getSubReports();
  for ( int i = 0; i < reports.length; i++ ) {
    final SubReport report = reports[ i ];
    if ( r == report ) {
      return true;
    }
  }
  return false;
}
 
Example 6
Source File: AbstractSubReportElementDragHandler.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected Element findRootBand( final ReportElementEditorContext dragContext,
                                final Point2D point ) {
  Element element = dragContext.getElementForLocation( point, false );
  while ( element != null && ( ( element instanceof RootLevelBand ) == false ) ) {
    element = element.getParent();
  }

  if ( element != null ) {
    return element;
  }

  return dragContext.getDefaultElement();
}