org.eclipse.gef.EditPartViewer Java Examples

The following examples show how to use org.eclipse.gef.EditPartViewer. 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: CustomDragDropEditPolicy.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private boolean isSourceAndTargetAreEventSubProc(final ChangeBoundsRequest request) {
    final EditPartViewer hostViewer = getHost().getViewer();
    if(hostViewer.findObjectAt(request.getLocation()) instanceof IGraphicalEditPart){
        final IGraphicalEditPart target = (IGraphicalEditPart) hostViewer.findObjectAt(request.getLocation());
        if(target.resolveSemanticElement() instanceof SubProcessEvent){
            for(final Object ep : request.getEditParts()){
                if(ep instanceof IGraphicalEditPart){
                    if(((IGraphicalEditPart) ep).resolveSemanticElement() instanceof SubProcessEvent){
                        return true ;
                    }
                }
            }
        }
    }
    return false;
}
 
Example #2
Source File: FixedAspectRatioResizableEditPolicy.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
protected void createResizeHandle(List handles, final int direction) {
	handles.add(new ResizeHandle(getHost(), direction) {
		@Override
		protected DragTracker createDragTracker() {
			return new LiveFeedbackResizeTracker(getHost(), direction) {
				@Override
				public void mouseDrag(MouseEvent event, EditPartViewer viewer) {
					event.stateMask |= SWT.SHIFT;
					super.mouseDrag(event, viewer);
				}
			};
		};
	});
}
 
Example #3
Source File: MovablePanningSelectionTool.java    From erflute with Apache License 2.0 6 votes vote down vote up
@Override
public void mouseDown(MouseEvent e, EditPartViewer viewer) {
    if (viewer.getContents() instanceof AbstractModelEditPart) {
        // マウスポインタがクリックされた位置を記録する。コピーしたオブジェクトの貼り付け位置として使う、等。
        final AbstractModelEditPart editPart = (AbstractModelEditPart) viewer.getContents();
        final IERDiagram diagram = (IERDiagram) editPart.getModel();
        diagram.setMousePoint(new Point(e.x, e.y));
        editPart.getFigure().translateToRelative(diagram.getMousePoint());

        final ERFluteMultiPageEditor multiPageEditor = diagram.getEditor();
        final int QUICK_OUTLINE_OPEN_BUTTON = 2;
        if (e.button == QUICK_OUTLINE_OPEN_BUTTON && multiPageEditor != null) {
            final MainDiagramEditor mainDiagramEditor = (MainDiagramEditor) multiPageEditor.getActiveEditor();
            mainDiagramEditor.runERDiagramQuickOutlineAction();
        }
    }

    super.mouseDown(e, viewer);
}
 
Example #4
Source File: CommandCombinedTemplateCreationEntry.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected void performCreation( int button )
{
	try
	{
		getCreateRequest( ).setFactory( this.factory );
		CommandUtils.setVariable( "targetEditPart", getTargetEditPart( ) ); //$NON-NLS-1$
		CommandUtils.setVariable( "request", getTargetRequest( ) ); //$NON-NLS-1$
		Object model = paletteEntry.executeCreate( );
		EditPartViewer viewer = getCurrentViewer( );
		selectAddedObject( model, viewer );
	}
	catch ( Exception e )
	{
		ExceptionHandler.handle( e );
	}
}
 
Example #5
Source File: CustomZoomTool.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected void performMarqueeSelect() {
	EditPartViewer viewer = getCurrentViewer();
	ZoomableEditPart zoomableEditPart = null;
	if (viewer.getRootEditPart() instanceof ZoomableEditPart)
		zoomableEditPart = (ZoomableEditPart)viewer.getRootEditPart();
	
	Rectangle zoomRect = getMarqueeSelectionRectangle();
	if (zoomRect.width < 2 || zoomRect.height < 2) {
		if (getZoomMode() == ZOOM_OUT_MODE) {
			zoomableEditPart.zoomOut(getLocation());
		} else if (getZoomMode() == ZOOM_IN_MODE) {
			zoomableEditPart.zoomIn(getLocation());
		}
	}
	else {
		zoomableEditPart.zoomTo(zoomRect);
	}
}
 
Example #6
Source File: CrosstabUIHelper.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public static void validateFixedColumnWidth(ExtendedItemHandle handle)
{
	EditPartViewer viewer = UIUtil.getLayoutEditPartViewer( );
	Object obj = viewer.getEditPartRegistry( ).get( handle );
	if (!(obj instanceof CrosstabTableEditPart))
	{
		return;
	}
	CrosstabTableEditPart part = (CrosstabTableEditPart)obj;
	Dimension tableSize = part.getFigure( ).getSize( );

	part.getCrosstabHandleAdapter( )
			.setWidth( converPixToDefaultUnit( tableSize.width, part),
					getDefaultUnits(part ) );
	
	adjustOthersColumn( new ArrayList( ), part,  getAdjustValue( part ));
}
 
Example #7
Source File: ValidateAction.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
private static void addMarker(EditPartViewer viewer, IFile target, String elementId, String location,
		String message, int statusSeverity) {
	if (target == null) {
		return;
	}
	ProcessMarkerNavigationProvider.addMarker(target, elementId, location, message, statusSeverity);
}
 
Example #8
Source File: ViewDialog.java    From erflute with Apache License 2.0 5 votes vote down vote up
public ViewDialog(Shell parentShell, EditPartViewer viewer, ERView copyData, ColumnGroupSet columnGroups) {
    super(parentShell);

    this.viewer = viewer;
    this.copyData = copyData;

    this.tabWrapperList = new ArrayList<>();
}
 
Example #9
Source File: BonitaTreeOutlinePage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected EditPartViewer getViewer() {
    if (viewer == null) {
        viewer = new BonitaTreeViewer();
    }
    return viewer;
}
 
Example #10
Source File: ViewDialog.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
public ViewDialog(Shell parentShell, EditPartViewer viewer, View copyData,
		GroupSet columnGroups) {
	super(parentShell);

	this.viewer = viewer;
	this.copyData = copyData;

	this.tabWrapperList = new ArrayList<ValidatableTabWrapper>();
}
 
Example #11
Source File: ReportTemplateTransferDropTargetListener.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void selectAddedObject( Request request )
{
	final Object model = getCreateRequest( ).getExtendedData( )
			.get( DesignerConstants.KEY_NEWOBJECT );
	final EditPartViewer viewer = getViewer( );
	viewer.getControl( ).setFocus( );
	ReportCreationTool.selectAddedObject( model, viewer, request );
}
 
Example #12
Source File: ReportTemplateTransferDropTargetListener.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void selectAddedObject( )
{
	final Object model = getCreateRequest( ).getExtendedData( )
			.get( DesignerConstants.KEY_NEWOBJECT );
	final EditPartViewer viewer = getViewer( );
	viewer.getControl( ).setFocus( );
	ReportCreationTool.selectAddedObject( model, viewer );
}
 
Example #13
Source File: DiagramEditorContextMenuProvider.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
* @generated
*/
public DiagramEditorContextMenuProvider(IWorkbenchPart part, EditPartViewer viewer) {
	super(part, viewer);
	this.part = part;
	deleteAction = new DeleteElementAction(part);
	deleteAction.init();
}
 
Example #14
Source File: EditorRulerRootEditPart.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @see org.eclipse.gef.RootEditPart#setViewer(org.eclipse.gef.EditPartViewer)
 */
public void setViewer( EditPartViewer newViewer )
{
	if ( viewer == newViewer )
		return;
	if ( viewer != null )
		unregister( );
	viewer = newViewer;
	if ( viewer != null )
		register( );
}
 
Example #15
Source File: DeleteTableGroupAction.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void run( )
{
	if ( Policy.TRACING_ACTIONS )
	{
		System.out.println( "Delete table action >> Run ..." ); //$NON-NLS-1$
	}
	if ( getTableGroup( ) != null && getTableEditPart( ) != null )
	{
		TableEditPart part = getTableEditPart( );
		EditPartViewer viewer = part.getViewer( );
		part.removeGroup( getTableGroup( ) );
		viewer.select( part );
	}
}
 
Example #16
Source File: ReportElementDragTracker.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void mouseUp( MouseEvent me, EditPartViewer viewer )
{
	if ( proxy != null )
	{
		eraseSourceFeedback( );
		eraseTargetFeedback( );

		proxy.mouseUp( me, viewer );
		proxy = null;
		return;
	}
	activeHelper = null;
	super.mouseUp( me, viewer );
}
 
Example #17
Source File: ERTableEditPart.java    From erflute with Apache License 2.0 5 votes vote down vote up
@Override
public void performRequestOpen() {
    final ERTable table = (ERTable) getModel();
    final ERDiagram diagram = getDiagram();
    final ERTable copyTable = table.copyData();
    final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    final EditPartViewer viewer = getViewer();
    final ColumnGroupSet groups = diagram.getDiagramContents().getColumnGroupSet();
    final TableDialog dialog = new TableDialog(shell, viewer, copyTable, groups);
    if (dialog.open() == IDialogConstants.OK_ID) {
        final CompoundCommand command = createChangeTablePropertyCommand(diagram, table, copyTable);
        executeCommand(command.unwrap());
    }
}
 
Example #18
Source File: TableDialog.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
public TableDialog(Shell parentShell, EditPartViewer viewer,
		ERTable copyData, GroupSet columnGroups) {
	super(parentShell);

	this.viewer = viewer;
	this.copyData = copyData;

	this.tabWrapperList = new ArrayList<ValidatableTabWrapper>();
}
 
Example #19
Source File: ProcessDiagramEditor.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected EditPartViewer getViewer() {
	if (viewer == null) {
		viewer = new BonitaTreeViewer();
	}
	return viewer;
}
 
Example #20
Source File: CellDragTracker.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @see org.eclipse.gef.Tool#setViewer(org.eclipse.gef.EditPartViewer)
 */
public void setViewer( EditPartViewer viewer )
{
	if ( viewer == getCurrentViewer( ) )
		return;
	super.setViewer( viewer );
	if ( viewer instanceof GraphicalViewer )
		setDefaultCursor( SharedCursors.CROSS );
	else
		setDefaultCursor( SharedCursors.NO );
}
 
Example #21
Source File: UIUtil.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Gets EditPartViewer in layout editor.
 * 
 * @return the EditPartViewer in layout editor, or null if not found.
 */
public static EditPartViewer getLayoutEditPartViewer( )
{
	IEditorPart part = PlatformUI.getWorkbench( )
			.getActiveWorkbenchWindow( )
			.getActivePage( )
			.getActiveEditor( );

	AbstractMultiPageEditor reportEditor = null;
	if ( part instanceof AbstractMultiPageEditor )
	{
		reportEditor = (AbstractMultiPageEditor) part;
	}
	else if ( part instanceof IReportEditor )
	{
		IEditorPart activeEditor = ( (IReportEditor) part ).getEditorPart( );
		if ( activeEditor instanceof AbstractMultiPageEditor )
		{
			reportEditor = (AbstractMultiPageEditor) activeEditor;
		}
	}

	if ( reportEditor == null
			|| !( reportEditor.getActivePageInstance( ) instanceof GraphicalEditorWithFlyoutPalette ) )
	{
		return null;
	}
	return ( (GraphicalEditorWithFlyoutPalette) reportEditor.getActivePageInstance( ) ).getGraphicalViewer( );
}
 
Example #22
Source File: DeleteRowHandler.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public Object execute( ExecutionEvent event ) throws ExecutionException
{
	super.execute( event );

	TableEditPart part = getTableEditPart( );
	if ( part != null )
	{
		EditPartViewer viewer = part.getViewer( );
		part.deleteRow( getRowNumbers( ) );
		viewer.select( part );
	}

	return Boolean.TRUE;
}
 
Example #23
Source File: DeleteColumnHandler.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public Object execute( ExecutionEvent event ) throws ExecutionException
{
	super.execute( event );

	TableEditPart part = getTableEditPart( );
	if ( part != null )
	{
		EditPartViewer viewer = part.getViewer( );
		part.deleteColumn( getColumnNumbers( ) );
		viewer.select( part );
	}
	return Boolean.TRUE;
}
 
Example #24
Source File: AbstractPageFlowLayout.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected Result getReportBounds( Rectangle reportSize )
{
	Result revValue = new Result( );
	revValue.reportSize.y = MINTOPSPACE;
	revValue.reportSize.width = reportSize.width;
	revValue.reportSize.height = reportSize.height;

	EditPartViewer viewer = owner.getViewer( );
	Scrollable control = viewer == null ? null : (Scrollable)viewer.getControl( );
	Rectangle containerSize = control == null ? new Rectangle( )
			: new Rectangle( control.getClientArea( ) );

	PrecisionDimension dim = new PrecisionDimension( containerSize.width,
			containerSize.height );

	double scale = getZoomManager( ).getZoom( );
	dim.performScale( 1 / scale );
	if ( dim.width > reportSize.width + MINLEFTSPACE + MINRIGHTSPACE )
	{
		revValue.reportSize.x = ( dim.width - reportSize.width ) / 2;
		revValue.rightSpace = ( dim.width - reportSize.width ) / 2;
	}
	else
	{
		revValue.reportSize.x = MINLEFTSPACE;
		revValue.rightSpace = MINRIGHTSPACE;
	}

	if ( dim.height > reportSize.height + MINTOPSPACE + MINBOTTOMSPACE )
	{
		revValue.bottomSpace = dim.height - reportSize.height
				- revValue.reportSize.y;
	}
	else
	{
		revValue.bottomSpace = MINBOTTOMSPACE;
	}

	return revValue;
}
 
Example #25
Source File: PaletteToolTransferDropTargetListenerWithSelection.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public static void insertOnSequenceFlow(final Command command, final EditPart targetEditPart, final EditPartViewer viewer, final boolean correctOffset) {
    final InsertElementOnSequenceFlowCommand cmd = new InsertElementOnSequenceFlowCommand(command, (IGraphicalEditPart) targetEditPart, viewer,
            correctOffset);
    final ICommandProxy iCommandProxy = new ICommandProxy(cmd);
    if (iCommandProxy.canExecute()) {
        viewer.getEditDomain().getCommandStack().execute(iCommandProxy);
    }
}
 
Example #26
Source File: ToggleLinkingAction.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void selectionChanged(final SelectionChangedEvent event) {
    Display.getDefault().asyncExec(new Runnable() {

        @Override
        public void run() {
            if (editor != null && viewer != null && !viewer.getSelection().isEmpty()) {
                final Change change = (Change) ((IStructuredSelection) viewer.getSelection()).getFirstElement();
                final String uuid = change.getElementUUID();
                if (uuid != null) {
                    EObject element = editor.getDiagram().eResource().getEObject(uuid);
                    if (PROCESS_ID.equals(editor.getContributorId())) {
                        while (element != null && !(element instanceof SequenceFlow || element instanceof Container || element instanceof FlowElement)) {
                            element = element.eContainer();
                        }
                    } else {
                        return;
                    }

                    if (element != null) {
                        final EditPart ep = findEditPart(editor.getDiagramEditPart(), element);
                        if (ep != null) {
                            final EditPartViewer viewerDiagram = editor.getDiagramEditPart().getViewer();
                            viewerDiagram.select(ep);
                            viewerDiagram.reveal(ep);
                            PropertySelectionProvider.getInstance().fireSelectionChanged((IGraphicalEditPart) ep, null);
                        }
                    }
                }
            }
        }
    });
}
 
Example #27
Source File: MovablePanningSelectionTool.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
@Override
public void mouseDown(MouseEvent e, EditPartViewer viewer) {
	if (viewer.getContents() instanceof ERDiagramEditPart) {
		ERDiagramEditPart editPart = (ERDiagramEditPart) viewer
				.getContents();
		ERDiagram diagram = (ERDiagram) editPart.getModel();

		diagram.mousePoint = new Point(e.x, e.y);

		editPart.getFigure().translateToRelative(diagram.mousePoint);
	}

	super.mouseDown(e, viewer);
}
 
Example #28
Source File: BonitaUnspecifiedTypeCreationTool.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setViewer(EditPartViewer viewer) {
	super.setViewer(viewer);
	if(viewer != null && figure != null){
		double zoom = ((DiagramRootEditPart)((DiagramGraphicalViewer)getCurrentViewer()).getRootEditPart()).getZoomManager().getZoom() ;
		if(zoom != oldZoom){
			Rectangle r = figure.getBounds().getCopy() ;
			r.performScale(zoom);
			figure.setBounds(r) ;
			oldZoom = zoom ;
		}
	}
}
 
Example #29
Source File: ValidationMarkerProvider.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private static synchronized void addMarker(final DiagramEditPart diagramEP, final String constaintId, final EditPartViewer viewer, final IFile
        target, final String elementId, final String location, final String message, final int statusSeverity) {
    if (target == null) {
        return;
    }
    addProcessMarker(constaintId, viewer, target, elementId, location, message, statusSeverity);
}
 
Example #30
Source File: ValidationMarkerProvider.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private static void addProcessMarker(final String constraintId, final EditPartViewer viewer, final IFile
        target, final String elementId, final String location, final String message, final int statusSeverity) {
    if (target == null) {
        return;
    }

    final IMarker marker = org.bonitasoft.studio.model.process.diagram.providers.ProcessMarkerNavigationProvider.addMarker(target, elementId, location,
            message, statusSeverity);
    addConstraintId(constraintId, marker);
}