Java 类org.eclipse.gef.handles.AbstractHandle 实例源码

项目:statecharts    文件:TransitionExpressionEditPart.java   
@Override
protected void createDefaultEditPolicies() {
    super.createDefaultEditPolicies();
    installEditPolicy(EditPolicy.COMPONENT_ROLE, new TransitionExpressionComponentEditPolicy());
    installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new ContextSensitiveHelpPolicy(
            HelpContextIds.SC_PROPERTIES_TRANSITION_EXPRESSION));
    // BUGFIX:
    // https://code.google.com/a/eclipselabs.org/p/yakindu/issues/detail?id=26
    installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new NonResizableLabelEditPolicy() {
        @Override
        protected void replaceHandleDragEditPartsTracker(Handle handle) {
            if (handle instanceof AbstractHandle) {
                AbstractHandle h = (AbstractHandle) handle;
                h.setDragTracker(new DragEditPartsTrackerEx(getHost()) {
                    protected boolean isMove() {
                        return true;
                    };
                });
            }
        }
    });
}
项目:PDFReporter-Studio    文件:BandResizableEditPolicy.java   
@Override
protected List<AbstractHandle> createSelectionHandles() {
    List<AbstractHandle> list = new ArrayList<AbstractHandle>();

    MoveHandle handle = new MoveHandle((GraphicalEditPart) getHost());
    handle.setBorder(new MarginBorder(5));
    list.add(handle);

    // BandButtonPadHandle buttonPadHandle=new BandButtonPadHandle((GraphicalEditPart)getHost());
    // buttonPadHandle.setBorder(null);
    // list.add(buttonPadHandle);
    // NonResizableHandleKit.addMoveHandle((GraphicalEditPart) getHost(), list);
    // list.add(new CellResizeHandle2((GraphicalEditPart) getHost(), PositionConstants.SOUTH));
    // // if (hasNorth)
    // list.add(new CellResizeHandle2((GraphicalEditPart) getHost(), PositionConstants.NORTH));
    return list;
}
项目:PDFReporter-Studio    文件:BandResizableEditPolicy.java   
@Override
protected List<AbstractHandle> createSelectionHandles() {
    List<AbstractHandle> list = new ArrayList<AbstractHandle>();

    MoveHandle handle = new MoveHandle((GraphicalEditPart) getHost());
    handle.setBorder(new MarginBorder(5));
    list.add(handle);

    //   BandButtonPadHandle buttonPadHandle=new BandButtonPadHandle((GraphicalEditPart)getHost());
    //   buttonPadHandle.setBorder(null);
    //   list.add(buttonPadHandle);
    // NonResizableHandleKit.addMoveHandle((GraphicalEditPart) getHost(), list);
    // list.add(new CellResizeHandle2((GraphicalEditPart) getHost(), PositionConstants.SOUTH));
    // // if (hasNorth)
    // list.add(new CellResizeHandle2((GraphicalEditPart) getHost(), PositionConstants.NORTH));
    return list;
}
项目:gef-gwt    文件:NonResizableEditPolicy.java   
/**
 * Shows a focus rectangle around the host's figure. The focus rectangle is
 * expanded by 5 pixels from the figure's bounds.
 * 
 * @see org.eclipse.gef.editpolicies.SelectionEditPolicy#showFocus()
 */
protected void showFocus() {
    focusRect = new AbstractHandle((GraphicalEditPart) getHost(),
            new Locator() {
                public void relocate(IFigure target) {
                    IFigure figure = getHostFigure();
                    Rectangle r;
                    if (figure instanceof HandleBounds)
                        r = ((HandleBounds) figure).getHandleBounds()
                                .getCopy();
                    else
                        r = getHostFigure().getBounds().getResized(-1, -1);
                    getHostFigure().translateToAbsolute(r);
                    target.translateToRelative(r);
                    target.setBounds(r.expand(5, 5).resize(1, 1));
                }
            }) {
        {
            setBorder(new FocusBorder());
        }

        protected DragTracker createDragTracker() {
            return null;
        }
    };
    addFeedback(focusRect);
}
项目:birt    文件:DeferredGraphicalViewer.java   
public void reveal( EditPart part )
{
    // In some case, the editor control is not created, but get the sync selection event.
    // Fix this problem temporary.
    if(getFigureCanvas( )==null || getFigureCanvas( ).isDisposed( ))
    {
        return;
    }

    Viewport port = getFigureCanvas( ).getViewport( );
    IFigure target = ( (GraphicalEditPart) part ).getFigure( );

    Rectangle exposeRegion = target.getBounds( ).getCopy( );

    // Get the primary editpolicy
    EditPolicy policy = part.getEditPolicy( EditPolicy.PRIMARY_DRAG_ROLE );

    // If the policy let us access the handles, proceed, otherwise
    // default to original behaviour
    if ( !( policy instanceof ISelectionHandlesEditPolicy ) )
    {
        super.reveal( part );
        return;
    }

    // First translate exposeRegion to the root level
    target = target.getParent( );
    while ( target != null && target != port )
    {
        target.translateToParent( exposeRegion );
        target = target.getParent( );
    }

    // Merge selection handles if any to the exposeRegion
    List handles = ( (ISelectionHandlesEditPolicy) policy ).getHandles( );
    for ( Iterator iter = handles.iterator( ); iter.hasNext( ); )
    {
        AbstractHandle handle = (AbstractHandle) iter.next( );

        Locator locator = handle.getLocator( );
        locator.relocate( handle );
        exposeRegion.union( handle.getBounds( ).getCopy( ) );
    }

    exposeRegion.getExpanded( 5, 5 );

    Dimension viewportSize = port.getClientArea( ).getSize( );

    Point topLeft = exposeRegion.getTopLeft( );
    Point bottomRight = exposeRegion.getBottomRight( )
            .translate( viewportSize.getNegated( ) );
    Point finalLocation = new Point( );
    if ( viewportSize.width < exposeRegion.width )
        finalLocation.x = Math.min( bottomRight.x, Math.max( topLeft.x,
                port.getViewLocation( ).x ) );
    else
        finalLocation.x = Math.min( topLeft.x, Math.max( bottomRight.x,
                port.getViewLocation( ).x ) );

    if ( viewportSize.height < exposeRegion.height )
        finalLocation.y = Math.min( bottomRight.y, Math.max( topLeft.y,
                port.getViewLocation( ).y ) );
    else
        finalLocation.y = Math.min( topLeft.y, Math.max( bottomRight.y,
                port.getViewLocation( ).y ) );

    getFigureCanvas( ).scrollSmoothTo( finalLocation.x, finalLocation.y );
}