Package org.pentaho.reporting.designer.core.model.selection

Examples of org.pentaho.reporting.designer.core.model.selection.DocumentContextSelectionModel


        return;
      }

      setModel(model);

      final DocumentContextSelectionModel selectionModel = renderContext.getSelectionModel();
      final Object[] selectedElements = selectionModel.getSelectedElements();
      final ArrayList<TreePath> selectionPaths = new ArrayList<TreePath>();
      for (int i = 0; i < selectedElements.length; i++)
      {
        final Object o = selectedElements[i];
        final TreePath path = model.getPathForNode(o);
View Full Code Here


    public void nodeChanged(final ReportModelEvent event)
    {
      if (event.isNodeDeleteEvent())
      {
        final DocumentContextSelectionModel selectionModel = getSelectionModel();
        final AbstractReportDefinition reportDefinition = getReportDefinition();
        final Object element = event.getElement();
        if (element instanceof Element)
        {
          final List<Element> selectedElements = selectionModel.getSelectedElementsOfType(Element.class);
          for (final Element selectedElement : selectedElements)
          {
            if (ModelUtility.isDescendant(reportDefinition, selectedElement) == false)
            {
              selectionModel.remove(element);
            }
          }
        }
        else
        {
          selectionModel.remove(element);
        }
      }
    }
View Full Code Here

      final ElementRenderer rendererRoot = getElementRenderer();
      final ReportDocumentContext renderContext = getRenderContext();

      if (clearSelectionOnDrag)
      {
        final DocumentContextSelectionModel selectionModel = renderContext.getSelectionModel();
        selectionModel.clearSelection();
        clearSelectionOnDrag = false;
      }

      selectionRectangleTarget = e.getPoint();

      // Calculate the bounding box for the selection
      final double y1 = Math.min(normalizedSelectionRectangleOrigin.getY(), normalizedSelectionRectangleTarget.getY());
      final double x1 = Math.min(normalizedSelectionRectangleOrigin.getX(), normalizedSelectionRectangleTarget.getX());
      final double y2 = Math.max(normalizedSelectionRectangleOrigin.getY(), normalizedSelectionRectangleTarget.getY());
      final double x2 = Math.max(normalizedSelectionRectangleOrigin.getX(), normalizedSelectionRectangleTarget.getX());

      final Element[] allNodes = rendererRoot.getElementsAt(x1, y1, x2 - x1, y2 - y1);
      final DocumentContextSelectionModel selectionModel = renderContext.getSelectionModel();

      // Convert between points to micro-points (1 point X 100K is a micro-point)
      final StrictBounds rect1 = StrictGeomUtility.createBounds(x1, y1, x2 - x1, y2 - y1);
      final StrictBounds rect2 = new StrictBounds();

      for (int i = allNodes.length - 1; i >= 0; i -= 1)
      {
        final Element element = allNodes[i];
        if (element instanceof RootLevelBand)
        {
          continue;
        }

        final CachedLayoutData data = ModelUtility.getCachedLayoutData(element);
        rect2.setRect(data.getX(), data.getY(), data.getWidth(), data.getHeight());

        // Checking if the bounding box intersects an element
        if (StrictBounds.intersects(rect1, rect2))
        {
          if (selectionModel.add(element))
          {
            newlySelectedElements.add(element);
          }
        }
      }

      // second step, check which previously added elements are no longer selected by the rectangle.
      for (Iterator<Element> visualReportElementIterator = newlySelectedElements.iterator(); visualReportElementIterator.hasNext(); )
      {
        final Element element = visualReportElementIterator.next();
        final CachedLayoutData data = ModelUtility.getCachedLayoutData(element);
        rect2.setRect(data.getX(), data.getY(), data.getWidth(), data.getHeight());
        if (StrictBounds.intersects(rect1, rect2) == false)
        {
          selectionModel.remove(element);
          visualReportElementIterator.remove();
        }

      }
View Full Code Here

      }

      final ReportDocumentContext renderContext = getRenderContext();
      final ElementRenderer rendererRoot = getElementRenderer();

      final DocumentContextSelectionModel selectionModel = renderContext.getSelectionModel();
      final Element[] allNodes = rendererRoot.getElementsAt
          (normalizedSelectionRectangleOrigin.getX(), normalizedSelectionRectangleOrigin.getY());
      for (int i = allNodes.length - 1; i >= 0; i -= 1)
      {
        final Element element = allNodes[i];
        if (element instanceof RootLevelBand)
        {
          continue;
        }

        if (!e.isShiftDown())
        {
          if (!selectionModel.isSelected(element))
          {
            selectionModel.clearSelection();
            selectionModel.add(element);
            return;
          }
        }
      }
    }
View Full Code Here

      if (point.getX() < 0 || point.getY() < 0)
      {
        return; // we do not handle that one ..
      }

      final DocumentContextSelectionModel selectionModel = getRenderContext().getSelectionModel();
      final ElementRenderer rendererRoot = getElementRenderer();

      // Sorted list of all elements that intersect the point we are seeking
      final Element[] allNodes = rendererRoot.getElementsAt(point.getX(), point.getY());
      for (int i = allNodes.length - 1; i >= 0; i -= 1)
      {
        // Check if element is null due to structural helper node like (SectionRenderBox)
        final Element element = allNodes[i];
        if (element instanceof RootLevelBand)
        {
          continue;
        }

        if (e.isShiftDown())
        {
          toggleSelection(selectionModel, element);

        }
        else
        {
          if (!selectionModel.isSelected(element))
          {
            selectionModel.clearSelection();
            selectionModel.add(element);
          }
        }

        return;
      }

      if (e.isShiftDown() == false)
      {
        selectionModel.clearSelection();
      }

      final Element element = rendererRoot.getElement();
      if (element instanceof RootLevelBand)
      {
        if (e.isShiftDown())
        {
          toggleSelection(selectionModel, element);

        }
        else
        {
          if (!selectionModel.isSelected(element))
          {
            selectionModel.clearSelection();
            selectionModel.add(element);
          }
        }
      }
    }
View Full Code Here

  /**
   * Invoked when an action occurs.
   */
  public void actionPerformed(final ActionEvent e)
  {
    final DocumentContextSelectionModel model = getSelectionModel();
    if (model == null)
    {
      return;
    }
    final List<Element> visualElements = model.getSelectedElementsOfType(Element.class);
    if (visualElements.isEmpty())
    {
      return;
    }

View Full Code Here

    }
    else if (owner instanceof RootBandRenderComponent)
    {
      final RootBandRenderComponent rc = (RootBandRenderComponent) owner;
      final Section reportElement = rc.getRendererRoot().getElement();
      final DocumentContextSelectionModel selectionModel = getActiveContext().getSelectionModel();
      selectRecursively(selectionModel, reportElement);
      if (reportElement instanceof RootLevelBand)
      {
        final RootLevelBand re = (RootLevelBand) reportElement;
        final int count = re.getSubReportCount();
        for (int i = 0; i < count; i++)
        {
          selectionModel.add(re.getSubReport(i));
        }
      }
    }
  }
View Full Code Here

  /**
   * Invoked when an action occurs.
   */
  public void actionPerformed(final ActionEvent e)
  {
    final DocumentContextSelectionModel model = getSelectionModel();
    if (model == null)
    {
      return;
    }
    final List<Element> visualElements = model.getSelectedElementsOfType(Element.class);
    if (visualElements.isEmpty())
    {
      return;
    }

View Full Code Here

  /**
   * Invoked when an action occurs.
   */
  public void actionPerformed(final ActionEvent e)
  {
    final DocumentContextSelectionModel model = getSelectionModel();
    if (model == null)
    {
      return;
    }
    final List<Element> visualElements = model.getSelectedElementsOfType(Element.class);
    if (visualElements.isEmpty())
    {
      return;
    }

View Full Code Here

  /**
   * Invoked when an action occurs.
   */
  public void actionPerformed(final ActionEvent e)
  {
    final DocumentContextSelectionModel model = getSelectionModel();
    if (model == null)
    {
      return;
    }
    final List<Element> visualElements = model.getSelectedElementsOfType(Element.class);
    if (visualElements.isEmpty())
    {
      return;
    }

View Full Code Here

TOP

Related Classes of org.pentaho.reporting.designer.core.model.selection.DocumentContextSelectionModel

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.