MenuManager manager = new MenuManager( ); Separator separator = new Separator( "undo" ); manager.add( separator ); separator = new Separator( "copy" ); manager.add( separator ); separator = new Separator( "select" ); manager.add( separator ); manager.appendToGroup( "undo", getAction( "undo", viewer, JdbcPlugin.getResourceString( "sqleditor.action.undo" ), ITextOperationTarget.UNDO ) ); manager.appendToGroup( "undo", getAction( "redo", viewer, JdbcPlugin.getResourceString( "sqleditor.action.redo" ), ITextOperationTarget.REDO ) ); manager.appendToGroup( "copy", getAction( "cut", viewer, JdbcPlugin.getResourceString( "sqleditor.action.cut" ), ITextOperationTarget.CUT ) ); manager.appendToGroup( "copy", getAction( "copy", viewer, JdbcPlugin.getResourceString( "sqleditor.action.copy" ), ITextOperationTarget.COPY ) ); manager.appendToGroup( "copy", getAction( "paste", viewer, JdbcPlugin.getResourceString( "sqleditor.action.paste" ), ITextOperationTarget.PASTE ) ); manager.appendToGroup( "select", getAction( "selectall", viewer, JdbcPlugin.getResourceString( "sqleditor.action.selectAll" ), ITextOperationTarget.SELECT_ALL ) ); Menu menu = manager.createContextMenu( widget );  manager.addMenuListener( new IMenuListener( ) {  public void menuAboutToShow( IMenuManager manager ) { Enumeration elements = htActions.elements( ); while ( elements.hasMoreElements( ) ) { SQLEditorAction action = (SQLEditorAction) elements.nextElement( ); action.update( ); } } } ); widget.setMenu( menu );
TextMenuManager menuManager = new TextMenuManager( viewer ); widget.setMenu( menuManager.getContextMenu( widget ) );
	private final void attachMenus( SourceViewer viewer )	{		StyledText widget = viewer.getTextWidget( );		MenuManager manager = new MenuManager( );		Separator separator = new Separator( "undo" );//$NON-NLS-1$		manager.add( separator );		separator = new Separator( "copy" );//$NON-NLS-1$		manager.add( separator );		separator = new Separator( "select" );//$NON-NLS-1$		manager.add( separator );		manager.appendToGroup( "undo", getAction( "undo", viewer, JdbcPlugin.getResourceString( "sqleditor.action.undo" ), ITextOperationTarget.UNDO ) );//$NON-NLS-1$		manager.appendToGroup( "undo", getAction( "redo", viewer, JdbcPlugin.getResourceString( "sqleditor.action.redo" ), ITextOperationTarget.REDO ) );//$NON-NLS-1$		manager.appendToGroup( "copy", getAction( "cut", viewer, JdbcPlugin.getResourceString( "sqleditor.action.cut" ), ITextOperationTarget.CUT ) );//$NON-NLS-1$		manager.appendToGroup( "copy", getAction( "copy", viewer, JdbcPlugin.getResourceString( "sqleditor.action.copy" ), ITextOperationTarget.COPY ) );//$NON-NLS-1$		manager.appendToGroup( "copy", getAction( "paste", viewer, JdbcPlugin.getResourceString( "sqleditor.action.paste" ), ITextOperationTarget.PASTE ) );//$NON-NLS-1$		manager.appendToGroup( "select", getAction( "selectall", viewer, JdbcPlugin.getResourceString( "sqleditor.action.selectAll" ), ITextOperationTarget.SELECT_ALL ) );//$NON-NLS-1$		Menu menu = manager.createContextMenu( widget );		manager.addMenuListener( new IMenuListener( ) {			public void menuAboutToShow( IMenuManager manager )			{				Enumeration elements = htActions.elements( );				while ( elements.hasMoreElements( ) )				{					SQLEditorAction action = (SQLEditorAction) elements.nextElement( );					action.update( );				}			}		} );		widget.setMenu( menu );	}