org.eclipse.gef.ContextMenuProvider Java Examples

The following examples show how to use org.eclipse.gef.ContextMenuProvider. 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: ReportEditorWithPalette.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected void configureGraphicalViewer( )
{
	super.configureGraphicalViewer( );

	GraphicalViewer viewer = getGraphicalViewer( );
	ActionRegistry actionRegistry = getActionRegistry( );
	ReportRootEditPart root = new ReportRootEditPart( );
	viewer.setRootEditPart( root );

	// hook zoom actions
	hookZoom( root );

	// set key events
	viewer.setKeyHandler( new ReportViewerKeyHandler( viewer,
			actionRegistry ) );

	// configure the context menu
	ContextMenuProvider provider = new SchematicContextMenuProvider( viewer,
			actionRegistry );
	viewer.setContextMenu( provider );

	// hook the viewer into the EditDomain TODO create a function
	getEditDomain( ).addViewer( viewer );
	// acticate the viewer as selection provider for Eclipse
	getSite( ).setSelectionProvider( viewer );

	// initialize the viewer with input
	viewer.setEditPartFactory( getEditPartFactory( ) );

	ModuleHandle model = getModel( );
	WrapperCommandStack commandStack = new WrapperCommandStack( model == null ? null
			: model.getCommandStack( ) );

	viewer.getEditDomain( ).setCommandStack( commandStack );

}
 
Example #2
Source File: DiagramPartitioningEditor.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
protected void configureContextMenu() {
	GraphicalViewer graphicalViewer = getGraphicalViewer();
	ContextMenuProvider provider = new FilteringDiagramContextMenuProvider(this, graphicalViewer);
	graphicalViewer.setContextMenu(provider);
	getSite().registerContextMenu(ActionIds.DIAGRAM_EDITOR_CONTEXT_MENU, provider, viewer);
}
 
Example #3
Source File: ProcessDiagramEditor.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
/**
 *  @generated BonitaSoft
 */
protected void configurePaletteViewer() {

	PaletteViewer viewer = getEditDomain().getPaletteViewer();
	if (viewer == null)
		return;
	ContextMenuProvider paletteContextProvider = new PaletteContextMenuProvider(viewer) {
		/*
		 * (non-Javadoc)
		 * 
		 * @see org.eclipse.gef.ui.palette.PaletteContextMenuProvider#
		 * buildContextMenu(org.eclipse.jface.action.IMenuManager)
		 */
		@Override
		public void buildContextMenu(IMenuManager menu) {
			super.buildContextMenu(menu);
			menu.appendToGroup(GEFActionConstants.GROUP_REST, new Action() {
				public String getText() {
					return org.bonitasoft.studio.common.Messages.switchPaletteAction;
				}

				public void run() {

					IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench()
							.getService(IHandlerService.class);
					ICommandService commandService = (ICommandService) PlatformUI.getWorkbench()
							.getService(ICommandService.class);
					Command switchCommand = commandService
							.getCommand("org.bonitasoft.studio.application.switchPalette");
					ExecutionEvent executionEvent = new ExecutionEvent(switchCommand, Collections.EMPTY_MAP, null,
							handlerService.getClass());
					try {
						switchCommand.executeWithChecks(executionEvent);
					} catch (Exception e) {
						BonitaStudioLog.error(e);
					}

				}
			});
		}
	};
	viewer.setContextMenu(paletteContextProvider);
}