Java Code Examples for org.eclipse.gef.ui.parts.ScrollingGraphicalViewer#setRootEditPart()

The following examples show how to use org.eclipse.gef.ui.parts.ScrollingGraphicalViewer#setRootEditPart() . 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: Activator.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
public void run() {
	Shell shell = new Shell(display);
	shell.setLayout(new GridLayout(1, false));

	ERDiagramEditPartFactory editPartFactory = new ERDiagramEditPartFactory();
	viewer = new ScrollingGraphicalViewer();
	viewer.setControl(new FigureCanvas(shell));
	ScalableFreeformRootEditPart rootEditPart = new PagableFreeformRootEditPart(
			diagram);
	viewer.setRootEditPart(rootEditPart);

	viewer.setEditPartFactory(editPartFactory);
	viewer.setContents(diagram);
}
 
Example 2
Source File: LinkGroupsPage.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
private Composite createCubeArea( Composite parent )
{
	Composite viewerContent = new Composite( parent, SWT.BORDER );
	GridData gd = new GridData( GridData.FILL_BOTH );
	gd.widthHint = 500;
	gd.heightHint = 300;
	viewerContent.setLayoutData( gd );
	viewerContent.setLayout( new FillLayout( ) );
	viewer = new ScrollingGraphicalViewer( );
	EditDomain editDomain = new EditDomain( );
	ScalableFreeformRootEditPart root = new ScalableFreeformRootEditPart( );
	viewer.setRootEditPart( root );
	viewer.setEditDomain( editDomain );
	viewer.createControl( viewerContent );
	viewer.getControl( ).setBackground( ColorConstants.listBackground );
	factory = new GraphicalEditPartsFactory( );
	viewer.setEditPartFactory( factory );
	viewer.setKeyHandler( new GraphicalViewerKeyHandler( viewer ) );
	viewer.addSelectionChangedListener( new ISelectionChangedListener( ) {

		public void selectionChanged( SelectionChangedEvent event )
		{
			if ( event.getSelection( ) != null )
			{
				StructuredSelection selection = (StructuredSelection) event.getSelection( );
				if ( selection.getFirstElement( ) instanceof HierarchyNodeEditPart
						|| selection.getFirstElement( ) instanceof DatasetNodeEditPart )
				{
					Object obj = selection.getFirstElement( );
					if ( obj instanceof HierarchyNodeEditPart )
					{
						TabularHierarchyHandle hierarchy = (TabularHierarchyHandle) ( (HierarchyNodeEditPart) obj ).getModel( );
						if ( hierarchy.getPrimaryKeys( ) != null
								&& hierarchy.getPrimaryKeys( ).size( ) > 0 )
						{
							filterButton.setEnabled( false );
						}
						else
							filterButton.setEnabled( true );
					}
					else
						filterButton.setEnabled( true );
				}
				else
					filterButton.setEnabled( false );
			}
			else
				filterButton.setEnabled( false );
		}
	} );
	load( );
	return viewerContent;
}