Java Code Examples for org.eclipse.gef.EditPart#getAdapter()

The following examples show how to use org.eclipse.gef.EditPart#getAdapter() . 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: DeferredGraphicalViewer.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @param editparts
 */
private List flitterEditpart( List editparts )
{
	List copy = new ArrayList( editparts );
	int size = editparts.size( );
	for ( int i = 0; i < size; i++ )
	{
		EditPart part = (EditPart) editparts.get( i );
		if (part.getAdapter( ISelectionFilter.class ) != null)
		{
			copy = ((ISelectionFilter)part.getAdapter( ISelectionFilter.class )).filterEditpart( copy );
		}
	}
	editparts = copy;
	return editparts;
}
 
Example 2
Source File: CrosstabBreadcrumbNodeProvider.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public Object[] getChildren( Object object )
{
	Object element = getRealModel( object );
	Object parent = ProviderFactory.createProvider( element )
			.getParent( element );
	if ( parent instanceof ExtendedItemHandle
			&& ICrosstabConstants.CROSSTAB_EXTENSION_NAME.equals( ( (ExtendedItemHandle) parent ).getExtensionName( ) ) )
	{
		List children = getEditPart( parent ).getChildren( );
		List elements = new ArrayList( );
		for ( int i = 0; i < children.size( ); i++ )
		{
			EditPart child = ( (EditPart) children.get( i ) );
			Object adapter = child.getAdapter( IBreadcrumbNodeProvider.class );
			if ( adapter instanceof CrosstabCellBreadcrumbNodeProvider )
			{
				( (CrosstabCellBreadcrumbNodeProvider) adapter ).setContext( viewer );
				if ( element.equals( ( (CrosstabCellBreadcrumbNodeProvider) adapter ).getParent( child ) ) )
				{
					elements.add( child );
				}
			}
		}
		return elements.toArray( );
	}
	else
	{
		return ProviderFactory.createProvider( element )
				.getChildren( element );
	}
}
 
Example 3
Source File: ReportElementDragTracker.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public void run( )
{
	if (!getSourceEditPart( ).isActive( ))
	{
		return;
	}
	EditPartViewer viewer = getSourceEditPart( ).getViewer( );
	EditPart parent = getSourceEditPart( ).getParent( );
	if ( activeHelper == this
			&& getSourceEditPart( ).isActive( )
			&& viewer.getControl( ) != null
			&& !viewer.getControl( ).isDisposed( ) )
	{
		
		viewer.getControl().removeFocusListener(focus);
		
		viewer.getControl().removeKeyListener(key);
		if ( viewer.getSelectedEditParts( ).size( ) == 1 )
		{
			if ( parent.getAdapter( IDelaySelectionDragTracker.class ) != null )
			{
				proxy = (IDelaySelectionDragTracker) parent.getAdapter( IDelaySelectionDragTracker.class );
				if ( viewer instanceof DeferredGraphicalViewer )
					( (DeferredGraphicalViewer) viewer ).setSelection( new StructuredSelection( proxy.getSourceEditPart( ) ),
							true );

				if ( getSourceEditPart( ) != getEditPartUnderMouse( ) )
				{
					IFigure figure = ( (GraphicalEditPart) getSourceEditPart( ) ).getFigure( );
					Rectangle center = figure.getBounds( ).getCopy( );
					figure.translateToAbsolute( center );
					proxy.setStartLocation( center.getCenter( ) );
				}
				else
				{
					proxy.setStartLocation( getStartLocation( ) );
				}
				//
				proxy.setState( STATE_DRAG_IN_PROGRESS );
			}
			setFlag( FLAG_DELAY_SELECTION, true );
		}
		else
		{
			setFlag( FLAG_DELAY_SELECTION, false );
		}
	}
	else
	{
		setFlag( FLAG_DELAY_SELECTION, false );
	}
	activeHelper = null;

}