org.eclipse.gef.ui.parts.ScrollingGraphicalViewer Java Examples

The following examples show how to use org.eclipse.gef.ui.parts.ScrollingGraphicalViewer. 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: NoWindowTest.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
private static void run(final Display display, final int x) {
    final Shell shell = new Shell(display);
    shell.setBounds(0, 0, 350, 350);

    shell.setLayout(new FillLayout(SWT.VERTICAL));

    // display.syncExec(new Runnable() {
    // public void run() {

    final ERDiagramEditPartFactory editPartFactory = new ERDiagramEditPartFactory();
    final GraphicalViewer viewer = new ScrollingGraphicalViewer();
    viewer.setControl(new FigureCanvas(shell));

    final ScalableFreeformRootEditPart rootEditPart = new PagableFreeformRootEditPart(diagram);
    viewer.setRootEditPart(rootEditPart);

    viewer.setEditPartFactory(editPartFactory);
    viewer.setContents(diagram);

    viewer.getContents().refresh();

    // }
    // });

    shell.pack();
    shell.open();
    int count = 0;
    while (count < x) {
        if (!display.readAndDispatch()) {
            try {
                Thread.sleep(1000);
                count++;
            } catch (final InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
    viewer.getContents().deactivate();
    // display.dispose();
}
 
Example #2
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 #3
Source File: ReportEditorWithRuler.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
protected void createGraphicalViewer( Composite parent )
	{
		// bidi_hcg start
		/*
		 * If Bidi support is enabled - check model orientation and set the view
		 * orientation accordingly
		 */
		
		if ( getModel( ).isDirectionRTL( ) )
			rulerComp = new EditorRulerComposite( parent, SWT.RIGHT_TO_LEFT );
		else
			rulerComp = new EditorRulerComposite( parent, SWT.LEFT_TO_RIGHT );
		
//		else
//		// bidi_hcg end
//			rulerComp = new EditorRulerComposite( parent, SWT.NONE );
		super.createGraphicalViewer( rulerComp );
		if(Constants.OS_LINUX.equalsIgnoreCase( Platform.getOS( ) )){//Linux and Windows has different color behavior.Add OS judgment to set rulerCompsite background color.
			rulerComp.setBackground(ColorManager.getColor(240, 240, 240));
		}
		rulerComp.setGraphicalViewer( (ScrollingGraphicalViewer) getGraphicalViewer( ), getModel( ) );

		// addAction( new ToggleRulerVisibilityAction( getGraphicalViewer( ) ) {
		//
		// public boolean isChecked( )
		// {
		// return ( (LayoutEditor) editingDomainEditor ).getRulerState( );
		// }
		//
		// public void run( )
		// {
		// // if ( getButtonPane( ) != null )
		// // {
		// // getButtonPane( ).setButtonSelection( ButtonPaneComposite.BUTTON3,
		// // !isChecked( ) );
		// // }
		// getGraphicalViewer( ).setProperty(
		// RulerProvider.PROPERTY_RULER_VISIBILITY,
		// Boolean.valueOf( !isChecked( ) ) );
		// ( (LayoutEditor) editingDomainEditor ).setRulerState( !isChecked( ),
		// LayoutEditor.DESIGNER_INDEX );
		// }
		// } );
		//
		// addAction( new ToggleMarginVisibilityAction( getGraphicalViewer( ) )
		// );
	}
 
Example #4
Source File: GraphicalViewerKeyHandler.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @param viewer
 */
public GraphicalViewerKeyHandler( ScrollingGraphicalViewer viewer )
{
	super( );
	this.viewer = viewer;
}
 
Example #5
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;
}
 
Example #6
Source File: NoWindowTest.java    From ermaster-b with Apache License 2.0 4 votes vote down vote up
private static void run(Display display, int x) {
	Shell shell = new Shell(display);
	shell.setBounds(0, 0, 350, 350);

	shell.setLayout(new FillLayout(SWT.VERTICAL));

	// display.syncExec(new Runnable() {
	// public void run() {

	ERDiagramEditPartFactory editPartFactory = new ERDiagramEditPartFactory();
	GraphicalViewer viewer = new ScrollingGraphicalViewer();
	viewer.setControl(new FigureCanvas(shell));

	ScalableFreeformRootEditPart rootEditPart = new PagableFreeformRootEditPart(
			diagram);
	viewer.setRootEditPart(rootEditPart);

	viewer.setEditPartFactory(editPartFactory);
	viewer.setContents(diagram);

	viewer.getContents().refresh();

	// }
	// });

	shell.pack();
	shell.open();
	int count = 0;
	while (count < x) {
		if (!display.readAndDispatch()) {
			try {
				Thread.sleep(1000);
				count++;
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
	viewer.getContents().deactivate();
	// display.dispose();
}
 
Example #7
Source File: ExportToImageManager.java    From ermasterr with Apache License 2.0 3 votes vote down vote up
private static GraphicalViewer createGraphicalViewer(final Display display, final ERDiagram diagram) {

        final GraphicalViewer[] viewerHolder = new GraphicalViewer[1];

        display.syncExec(new Runnable() {

            @Override
            public void run() {
                final Shell shell = new Shell(display);
                shell.setLayout(new GridLayout(1, false));

                final ERDiagramEditPartFactory editPartFactory = new ERDiagramEditPartFactory();

                final GraphicalViewer viewer = new ScrollingGraphicalViewer();

                viewer.setControl(new FigureCanvas(shell));
                final ScalableFreeformRootEditPart rootEditPart = new PagableFreeformRootEditPart(diagram);
                viewer.setRootEditPart(rootEditPart);

                viewer.setEditPartFactory(editPartFactory);
                viewer.setContents(diagram);

                viewerHolder[0] = viewer;
            }

        });

        return viewerHolder[0];
    }