org.eclipse.jface.commands.ActionHandler Java Examples

The following examples show how to use org.eclipse.jface.commands.ActionHandler. 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: AbstractInfoView.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Fills the actions bars.
 * <p>
 * Subclasses may extend.
 *
 * @param actionBars the action bars
 */
protected void fillActionBars(IActionBars actionBars) {
	IToolBarManager toolBar= actionBars.getToolBarManager();
	fillToolBar(toolBar);

	IAction action;

	action= getCopyToClipboardAction();
	if (action != null)
		actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), action);

	action= getSelectAllAction();
	if (action != null)
		actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), action);

	IHandlerService handlerService= (IHandlerService) getSite().getService(IHandlerService.class);
	handlerService.activateHandler(IWorkbenchCommandConstants.NAVIGATE_TOGGLE_LINK_WITH_EDITOR, new ActionHandler(fToggleLinkAction));
}
 
Example #2
Source File: PackageExplorerActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void setGlobalActionHandlers(IActionBars actionBars) {
	// Navigate Go Into and Go To actions.
	actionBars.setGlobalActionHandler(IWorkbenchActionConstants.GO_INTO, fZoomInAction);
	actionBars.setGlobalActionHandler(ActionFactory.BACK.getId(), fBackAction);
	actionBars.setGlobalActionHandler(ActionFactory.FORWARD.getId(), fForwardAction);
	actionBars.setGlobalActionHandler(IWorkbenchActionConstants.UP, fUpAction);
	actionBars.setGlobalActionHandler(IWorkbenchActionConstants.GO_TO_RESOURCE, fGotoResourceAction);
	actionBars.setGlobalActionHandler(JdtActionConstants.GOTO_TYPE, fGotoTypeAction);
	actionBars.setGlobalActionHandler(JdtActionConstants.GOTO_PACKAGE, fGotoPackageAction);
	actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), fSelectAllAction);

	fRefactorActionGroup.retargetFileMenuActions(actionBars);

	IHandlerService handlerService= (IHandlerService) fPart.getViewSite().getService(IHandlerService.class);
	handlerService.activateHandler(IWorkbenchCommandConstants.NAVIGATE_TOGGLE_LINK_WITH_EDITOR, new ActionHandler(fToggleLinkingAction));
	handlerService.activateHandler(CollapseAllHandler.COMMAND_ID, new ActionHandler(fCollapseAllAction));
}
 
Example #3
Source File: SDView.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void createPartControl(Composite c) {
    Composite parent = new Composite(c, SWT.NONE);
    GridLayout parentLayout = new GridLayout();
    parentLayout.numColumns = 2;
    parentLayout.marginWidth = 0;
    parentLayout.marginHeight = 0;
    parent.setLayout(parentLayout);

    GridData timeLayoutdata = new GridData(GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_FILL);
    timeLayoutdata.widthHint = 10;
    GridData seqDiagLayoutData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_FILL);
    fTimeCompressionBar = new TimeCompressionBar(parent, SWT.NONE);
    fTimeCompressionBar.setLayoutData(timeLayoutdata);
    fSdWidget = new SDWidget(parent, SWT.NONE);
    fSdWidget.setLayoutData(seqDiagLayoutData);
    fSdWidget.setSite(this);
    fSdWidget.setTimeBar(fTimeCompressionBar);

    // Add this view to the key bindings manager
    KeyBindingsManager.getInstance().add(this.getSite().getId());

    createCoolbarContent();

    hookContextMenu();

    fTimeCompressionBar.setVisible(false);
    parent.layout(true);

    fPrintActionHandler = new ActionHandler(new Print(this));
    getSite().getPage().addPartListener(this);

    fNeedInit = restoreLoader();
}
 
Example #4
Source File: OccurrencesSearchResultPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void createControl(Composite parent) {
	super.createControl(parent);

	IActionBars bars= getSite().getActionBars();
	IMenuManager menu= bars.getMenuManager();
	menu.add(fToggleLinkingAction);

	IHandlerService handlerService= (IHandlerService) getSite().getService(IHandlerService.class);
	handlerService.activateHandler(IWorkbenchCommandConstants.NAVIGATE_TOGGLE_LINK_WITH_EDITOR, new ActionHandler(fToggleLinkingAction));
}
 
Example #5
Source File: ERDiagramEditor.java    From ermasterr with Apache License 2.0 4 votes vote down vote up
private void addKeyHandler(final IAction action) {
    final IHandlerService service = getSite().getService(IHandlerService.class);
    service.activateHandler(action.getActionDefinitionId(), new ActionHandler(action));
}
 
Example #6
Source File: MainDiagramEditor.java    From erflute with Apache License 2.0 4 votes vote down vote up
private void addKeyHandler(IAction action) {
    final IHandlerService service = (IHandlerService) getSite().getService(IHandlerService.class);
    service.activateHandler(action.getActionDefinitionId(), new ActionHandler(action));
}
 
Example #7
Source File: JavaBrowsingPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
protected void activateHandlers(IHandlerService handlerService) {
	handlerService.activateHandler(IWorkbenchCommandConstants.NAVIGATE_TOGGLE_LINK_WITH_EDITOR, new ActionHandler(fToggleLinkingAction));
}
 
Example #8
Source File: ProjectsView.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected void activateHandlers(IHandlerService handlerService) {
	super.activateHandlers(handlerService);
	handlerService.activateHandler(CollapseAllHandler.COMMAND_ID, new ActionHandler(fCollapseAllAction));
}
 
Example #9
Source File: ERDiagramEditor.java    From ermaster-b with Apache License 2.0 4 votes vote down vote up
private void addKeyHandler(IAction action) {
	IHandlerService service = (IHandlerService) this.getSite().getService(
			IHandlerService.class);
	service.activateHandler(action.getActionDefinitionId(),
			new ActionHandler(action));
}
 
Example #10
Source File: GlobalActions.java    From elexis-3-core with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Creates an ActionHandler for the given IAction and registers it to the Site's HandlerService,
 * i. e. binds the action to the command so that key bindings get activated. You need to set the
 * action's actionDefinitionId to the command id.
 * 
 * @param action
 *            the action to activate. The action's actionDefinitionId must have been set to the
 *            command's id (using <code>setActionDefinitionId()</code>)
 * @param part
 *            the view this action should be registered for
 */
public static void registerActionHandler(final ViewPart part, final IAction action){
	String commandId = action.getActionDefinitionId();
	if (!StringTool.isNothing(commandId)) {
		IHandlerService handlerService = part.getSite().getService(IHandlerService.class);
		IHandler handler = new ActionHandler(action);
		handlerService.activateHandler(commandId, handler);
	}
}