本文整理汇总了Java中org.eclipse.jface.commands.ActionHandler类的典型用法代码示例。如果您正苦于以下问题:Java ActionHandler类的具体用法?Java ActionHandler怎么用?Java ActionHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ActionHandler类属于org.eclipse.jface.commands包,在下文中一共展示了ActionHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addAction
import org.eclipse.jface.commands.ActionHandler; //导入依赖的package包/类
@Override
public void addAction(final IAction action) {
Check.notNull(action, "action"); //$NON-NLS-1$
final String commandId = action.getActionDefinitionId();
if (commandId == null) {
throw new IllegalArgumentException("action does not have an action definition ID set"); //$NON-NLS-1$
}
final TriggerSequence[] bindings = bindingService.getActiveBindingsFor(commandId);
if (bindings.length > 0) {
final IHandler handler = new ActionHandler(action);
/*
* Call this deprecated overload for 3.1 support
*/
final IHandlerActivation activation =
handlerService.activateHandler(commandId, handler, expression, sourcePriorities);
handlerActivations.add(activation);
}
}
示例2: createContentAssistActionHandler
import org.eclipse.jface.commands.ActionHandler; //导入依赖的package包/类
private ActionHandler createContentAssistActionHandler(
final ITextOperationTarget textOperationTarget) {
Action proposalAction = new Action() {
@Override
public void run() {
if (textOperationTarget
.canDoOperation(ISourceViewer.CONTENTASSIST_PROPOSALS)
&& getTextWidget().isFocusControl())
textOperationTarget
.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
}
};
proposalAction
.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
return new ActionHandler(proposalAction);
}
示例3: fillActionBars
import org.eclipse.jface.commands.ActionHandler; //导入依赖的package包/类
/**
* 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));
}
示例4: setGlobalActionHandlers
import org.eclipse.jface.commands.ActionHandler; //导入依赖的package包/类
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));
}
示例5: fillActionBars
import org.eclipse.jface.commands.ActionHandler; //导入依赖的package包/类
@Override
protected void fillActionBars(final IActionBars actionBars) {
super.fillActionBars(actionBars);
actionBars.setGlobalActionHandler(ActionFactory.BACK.getId(), fBackAction);
actionBars.setGlobalActionHandler(ActionFactory.FORWARD.getId(), fForthAction);
fInputSelectionProvider.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
actionBars.setGlobalActionHandler(JdtActionConstants.OPEN_ATTACHED_JAVA_DOC, fOpenBrowserAction);
}
});
IHandlerService handlerService= (IHandlerService) getSite().getService(IHandlerService.class);
handlerService.activateHandler(IWorkbenchCommandConstants.NAVIGATE_TOGGLE_LINK_WITH_EDITOR, new ActionHandler(fToggleLinkAction));
}
示例6: configureToolBar
import org.eclipse.jface.commands.ActionHandler; //导入依赖的package包/类
@Override
protected void configureToolBar(final IToolBarManager manager)
{
super.configureToolBar(manager);
final IDiagramOutputActionFactory factory = JiveUIPlugin.getDefault()
.getDiagramOutputActionFactory();
final ScalableRootEditPart root = (ScalableRootEditPart) viewer.getRootEditPart();
final IAction zoomIn = new ZoomInAction(root.getZoomManager());
final IAction zoomOut = new ZoomOutAction(root.getZoomManager());
final IUpdatableAction saveAs = factory.createDiagramExportAction(viewer);
final IUpdatableAction print = factory.createPrintAction(viewer);
addUpdatableAction(saveAs);
addUpdatableAction(print);
// reference: http://dev.eclipse.org/newslists/news.eclipse.platform/msg60866.html
// register action handlers for zoom in and zoom out:
final IHandlerService handlerService = (IHandlerService) getSite().getService(
IHandlerService.class);
handlerService.activateHandler(zoomIn.getActionDefinitionId(), new ActionHandler(zoomIn));
handlerService.activateHandler(zoomOut.getActionDefinitionId(), new ActionHandler(zoomOut));
manager.insertBefore(AbstractJiveView.GROUP_STEP_CONTROLS, new Separator(
AbstractGraphicalJiveView.ZOOM_CONTROLS_GROUP));
manager.appendToGroup(AbstractGraphicalJiveView.ZOOM_CONTROLS_GROUP, saveAs);
manager.appendToGroup(AbstractGraphicalJiveView.ZOOM_CONTROLS_GROUP, print);
manager.appendToGroup(AbstractGraphicalJiveView.ZOOM_CONTROLS_GROUP, zoomIn);
manager.appendToGroup(AbstractGraphicalJiveView.ZOOM_CONTROLS_GROUP, zoomOut);
}
示例7: execute
import org.eclipse.jface.commands.ActionHandler; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
try {
InputStream in = null;
String resource = "plugin.properties"; //$NON-NLS-1$
ClassLoader loader = this.getClass().getClassLoader();
if (loader != null) {
in = loader.getResourceAsStream(resource);
}
else {
in = ClassLoader.getSystemResourceAsStream(resource);
}
IWorkbenchPart part = HandlerUtil.getActivePart(event);
FindReplaceAction findReplaceAction = new FindReplaceAction(new PropertyResourceBundle(in), null, part);
ActionHandler actionHandler = new ActionHandler(findReplaceAction);
return actionHandler.execute(event);
} catch (Exception e) {
throw new ExecutionException("Could not execute command!", e); //$NON-NLS-1$
}
}
示例8: viewerFocusGained
import org.eclipse.jface.commands.ActionHandler; //导入依赖的package包/类
public void viewerFocusGained(FocusEvent event) {
final IHandlerService handlerService = getHandlerService();
copyHandlerActivation = handlerService
.activateHandler(IWorkbenchCommandConstants.EDIT_COPY,
new ActionHandler(copyAction));
refreshHandlerActivation = handlerService
.activateHandler(IWorkbenchCommandConstants.FILE_REFRESH,
new ActionHandler(reloadAction));
removeHandlerActivation = handlerService
.activateHandler(IWorkbenchCommandConstants.EDIT_DELETE,
new ActionHandler(removeAction));
}
示例9: prepareZoomContributions
import org.eclipse.jface.commands.ActionHandler; //导入依赖的package包/类
private void prepareZoomContributions(GraphicalViewer viewer) {
ScalableFreeformRootEditPart root = new ScalableFreeformRootEditPart();
// set clipping strategy for connection layer
ConnectionLayer connectionLayer = (ConnectionLayer) root
.getLayer(LayerConstants.CONNECTION_LAYER);
connectionLayer
.setClippingStrategy(new ViewportAwareConnectionLayerClippingStrategy(
connectionLayer));
List<String> zoomLevels = new ArrayList<String>(3);
zoomLevels.add(ZoomManager.FIT_ALL);
zoomLevels.add(ZoomManager.FIT_WIDTH);
zoomLevels.add(ZoomManager.FIT_HEIGHT);
root.getZoomManager().setZoomLevelContributions(zoomLevels);
IAction zoomIn = new ZoomInAction(root.getZoomManager());
IAction zoomOut = new ZoomOutAction(root.getZoomManager());
viewer.setRootEditPart(root);
getActionRegistry().registerAction(zoomIn);
getActionRegistry().registerAction(zoomOut);
//zoom on key strokes: ctrl++ and ctrl--
IHandlerService service =
(IHandlerService)getEditorSite().getService(IHandlerService. class);
service.activateHandler(zoomIn.getActionDefinitionId(),
new ActionHandler(zoomIn));
service.activateHandler(zoomOut.getActionDefinitionId(),
new ActionHandler(zoomOut));
// Scroll-wheel Zoom
getGraphicalViewer().setProperty(
MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1),
MouseWheelZoomHandler.SINGLETON);
}
示例10: createQuickFixActionHandler
import org.eclipse.jface.commands.ActionHandler; //导入依赖的package包/类
private ActionHandler createQuickFixActionHandler(
final ITextOperationTarget textOperationTarget) {
Action quickFixAction = new Action() {
@Override
public void run() {
textOperationTarget.doOperation(ISourceViewer.QUICK_ASSIST);
}
};
quickFixAction
.setActionDefinitionId(ITextEditorActionDefinitionIds.QUICK_ASSIST);
return new ActionHandler(quickFixAction);
}
示例11: createControl
import org.eclipse.jface.commands.ActionHandler; //导入依赖的package包/类
@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));
}
示例12: addAction
import org.eclipse.jface.commands.ActionHandler; //导入依赖的package包/类
public void addAction(Action action){
if(action == null){
throw new IllegalArgumentException("Missing argument action.");
}
if(action instanceof ViewActionBase){
((ViewActionBase)action).setPrefModel(this.prefModel);
}
actionList.add(action);
handlerService.activateHandler(action.getActionDefinitionId(), new ActionHandler(action));
}
示例13: addKeyHandler
import org.eclipse.jface.commands.ActionHandler; //导入依赖的package包/类
private void addKeyHandler(IAction action) {
IHandlerService service = (IHandlerService) getSite().getService(IHandlerService.class);
service.activateHandler(action.getActionDefinitionId(), new ActionHandler(action));
}
示例14: addKeyHandler
import org.eclipse.jface.commands.ActionHandler; //导入依赖的package包/类
private void addKeyHandler(final IAction action) {
final IHandlerService service = getSite().getService(IHandlerService.class);
service.activateHandler(action.getActionDefinitionId(), new ActionHandler(action));
}
示例15: addKeyHandler
import org.eclipse.jface.commands.ActionHandler; //导入依赖的package包/类
private void addKeyHandler(IAction action) {
IHandlerService service = (IHandlerService) this.getSite().getService(
IHandlerService.class);
service.activateHandler(action.getActionDefinitionId(),
new ActionHandler(action));
}