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

The following examples show how to use org.pentaho.reporting.engine.classic.core.Element#getObjectID() . 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: StyleTableModel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static boolean isSameElements( final Element[] elements,
                                       final ElementType[] elementTypes,
                                       final Element[] oldElements ) {
  if ( elements.length != oldElements.length ) {
    // that is easy!
    return false;
  }

  for ( int i = 0; i < elements.length; i++ ) {
    final Element element = elements[ i ];
    if ( oldElements[ i ].getObjectID() != element.getObjectID() ) {
      return false;
    }
    if ( oldElements[ i ].getElementType() != elementTypes[ i ] ) {
      return false;
    }
  }
  return true;
}
 
Example 2
Source File: DefaultReportSelectionModel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Object computeKey( final Object o ) {
  if ( o instanceof Element ) {
    final Element e = (Element) o;
    return e.getObjectID();
  } else {
    return System.identityHashCode( o );
  }
}
 
Example 3
Source File: BarcodeTypeAction.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Invoked when an action occurs.
 */
public void actionPerformed( final ActionEvent e ) {
  final DocumentContextSelectionModel model = getSelectionModel();
  if ( model == null ) {
    return;
  }

  final Element[] visualElements = filterBarcodeElements( model );
  if ( visualElements.length == 0 ) {
    return;
  }
  final ReportDocumentContext activeContext = getActiveContext();
  if ( activeContext == null ) {
    return;
  }

  final ArrayList<UndoEntry> undos = new ArrayList<UndoEntry>();
  for ( int i = 0; i < visualElements.length; i++ ) {
    final Element element = visualElements[ i ];
    final Object oldValue = element.getAttribute
      ( SimpleBarcodesAttributeNames.NAMESPACE, SimpleBarcodesAttributeNames.TYPE_ATTRIBUTE );
    final UndoEntry entry = new AttributeEditUndoEntry( element.getObjectID(),
      SimpleBarcodesAttributeNames.NAMESPACE, SimpleBarcodesAttributeNames.TYPE_ATTRIBUTE,
      oldValue, type );
    undos.add( entry );
    element.setAttribute( SimpleBarcodesAttributeNames.NAMESPACE, SimpleBarcodesAttributeNames.TYPE_ATTRIBUTE, type );
  }
  getActiveContext().getUndo().addChange( ActionMessages.getString( "BarcodeTypeAction.UndoName", type ),
    new CompoundUndoEntry( undos.toArray( new UndoEntry[ undos.size() ] ) ) );
}
 
Example 4
Source File: HideElementAction.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 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 );

  Boolean value = null;
  final ArrayList<UndoEntry> undos = new ArrayList<UndoEntry>();
  for ( Element element : visualElements ) {
    if ( value == null ) {
      if ( ModelUtility.isHideInLayoutGui( element ) ) {
        value = Boolean.FALSE;
      } else {
        value = Boolean.TRUE;
      }
    }

    final Object oldValue = element.getAttribute( ReportDesignerParserModule.NAMESPACE,
      ReportDesignerParserModule.HIDE_IN_LAYOUT_GUI_ATTRIBUTE );
    final UndoEntry entry = new AttributeEditUndoEntry( element.getObjectID(), ReportDesignerParserModule.NAMESPACE,
      ReportDesignerParserModule.HIDE_IN_LAYOUT_GUI_ATTRIBUTE, oldValue, value );
    undos.add( entry );
    element.setAttribute( ReportDesignerParserModule.NAMESPACE,
      ReportDesignerParserModule.HIDE_IN_LAYOUT_GUI_ATTRIBUTE, value );
  }
  getActiveContext().getUndo().addChange( ActionMessages.getString( "HideElementAction.UndoName" ),
    new CompoundUndoEntry( undos.toArray( new UndoEntry[ undos.size() ] ) ) );
}
 
Example 5
Source File: AbstractAttributeTableModel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected static boolean isSameElements( final ReportElement[] elements,
                                           final ReportElement[] existingElements,
                                           final ElementType[] elementTypes ) {
/*
    if (elements == existingElements)
    {
      return true;
    }
    */
    if ( elements.length != existingElements.length ) {
      // that is easy!
      return false;
    }

    for ( int i = 0; i < elements.length; i++ ) {
      final Element element = (Element) elements[ i ];
      if ( existingElements[ i ].getObjectID() != element.getObjectID() ) {
        return false;
      }
      if ( elementTypes != null ) {
        if ( !element.getElementType().getClass().equals( elementTypes[ i ].getClass() ) ) {
          return false;
        }
      }
    }
    return true;
  }
 
Example 6
Source File: TransferLayoutProcessStep.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void collectElements( final Section sectionReportElement ) {
  final int count = sectionReportElement.getElementCount();
  for ( int i = 0; i < count; i++ ) {
    final Element reportElement = sectionReportElement.getElement( i );
    final InstanceID id = reportElement.getObjectID();
    elementsById.put( id, reportElement );

    if ( reportElement instanceof SubReport ) {
      continue;
    }
    if ( reportElement instanceof Section ) {
      collectElements( (Section) reportElement );
    }
  }
}