org.eclipse.gef.handles.AbstractHandle Java Examples
The following examples show how to use
org.eclipse.gef.handles.AbstractHandle.
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: TransitionExpressionEditPart.java From statecharts with Eclipse Public License 1.0 | 6 votes |
@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; }; }); } } }); }
Example #2
Source File: DeferredGraphicalViewer.java From birt with Eclipse Public License 1.0 | 4 votes |
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 ); }