本文整理汇总了Java中org.eclipse.ui.handlers.IHandlerService.activateHandler方法的典型用法代码示例。如果您正苦于以下问题:Java IHandlerService.activateHandler方法的具体用法?Java IHandlerService.activateHandler怎么用?Java IHandlerService.activateHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.ui.handlers.IHandlerService
的用法示例。
在下文中一共展示了IHandlerService.activateHandler方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fillActionBars
import org.eclipse.ui.handlers.IHandlerService; //导入方法依赖的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));
}
示例2: setGlobalActionHandlers
import org.eclipse.ui.handlers.IHandlerService; //导入方法依赖的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));
}
示例3: registerCommands
import org.eclipse.ui.handlers.IHandlerService; //导入方法依赖的package包/类
public void registerCommands(CompilationUnitEditor editor) {
IWorkbench workbench= PlatformUI.getWorkbench();
ICommandService commandService= (ICommandService) workbench.getAdapter(ICommandService.class);
IHandlerService handlerService= (IHandlerService) workbench.getAdapter(IHandlerService.class);
if (commandService == null || handlerService == null) {
return;
}
if (fCorrectionHandlerActivations != null) {
JavaPlugin.logErrorMessage("correction handler activations not released"); //$NON-NLS-1$
}
fCorrectionHandlerActivations= new ArrayList<IHandlerActivation>();
Collection<String> definedCommandIds= commandService.getDefinedCommandIds();
for (Iterator<String> iter= definedCommandIds.iterator(); iter.hasNext();) {
String id= iter.next();
if (id.startsWith(ICommandAccess.COMMAND_ID_PREFIX)) {
boolean isAssist= id.endsWith(ICommandAccess.ASSIST_SUFFIX);
CorrectionCommandHandler handler= new CorrectionCommandHandler(editor, id, isAssist);
IHandlerActivation activation= handlerService.activateHandler(id, handler, new LegacyHandlerSubmissionExpression(null, null, editor.getSite()));
fCorrectionHandlerActivations.add(activation);
}
}
}
示例4: createPage0
import org.eclipse.ui.handlers.IHandlerService; //导入方法依赖的package包/类
/**
* Creates page 0 of the multi-page editor,
* which contains a text editor.
*/
void createPage0() {
try {
editor = new TextEditor();
int index = addPage(editor, getEditorInput());
setPageText(index, editor.getTitle());
IHandlerService serv = (IHandlerService) getSite().getService(IHandlerService.class);
MyCopyHandler cp = new MyCopyHandler();
serv.activateHandler(org.eclipse.ui.IWorkbenchCommandConstants.EDIT_PASTE, cp);
//serv.activateHandler(org.eclipse.ui.IWorkbenchCommandConstants.EDIT_, cp);
} catch (PartInitException e) {
ErrorDialog.openError(
getSite().getShell(),
"Error creating nested text editor",
null,
e.getStatus());
}
}
示例5: fillActionBars
import org.eclipse.ui.handlers.IHandlerService; //导入方法依赖的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.ui.handlers.IHandlerService; //导入方法依赖的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: viewerFocusGained
import org.eclipse.ui.handlers.IHandlerService; //导入方法依赖的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));
}
示例8: prepareZoomContributions
import org.eclipse.ui.handlers.IHandlerService; //导入方法依赖的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);
}
示例9: installQuickAccessAction
import org.eclipse.ui.handlers.IHandlerService; //导入方法依赖的package包/类
private void installQuickAccessAction() {
fHandlerService= (IHandlerService)fSite.getService(IHandlerService.class);
if (fHandlerService != null) {
IHandler handler= new JDTQuickMenuCreator(fEditor) {
@Override
protected void fillMenu(IMenuManager menu) {
fillQuickMenu(menu);
}
}.createHandler();
fQuickAccessHandlerActivation= fHandlerService.activateHandler(QUICK_MENU_ID, handler);
}
}
示例10: createControl
import org.eclipse.ui.handlers.IHandlerService; //导入方法依赖的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));
}
示例11: addKeyHandler
import org.eclipse.ui.handlers.IHandlerService; //导入方法依赖的package包/类
private void addKeyHandler(IAction action) {
IHandlerService service = (IHandlerService) getSite().getService(IHandlerService.class);
service.activateHandler(action.getActionDefinitionId(), new ActionHandler(action));
}
示例12: activateHandler
import org.eclipse.ui.handlers.IHandlerService; //导入方法依赖的package包/类
private void activateHandler(String id, IHandler handler) {
final IHandlerService hs = (IHandlerService) getSite().getService(
IHandlerService.class);
hs.activateHandler(id, handler);
handlers.add(handler);
}
示例13: createPartControl
import org.eclipse.ui.handlers.IHandlerService; //导入方法依赖的package包/类
/**
* Allows to create the viewer and initialise it.
*/
@Override
public void createPartControl(Composite parent) {
preferences = InstanceScope.INSTANCE.getNode(Notepad4e.PLUGIN_ID);
// Listen to any change to the preferences of the plugin.
preferences.addPreferenceChangeListener(this);
clipboard = new Clipboard(Display.getCurrent());
tabFolder = new CTabFolder(parent, SWT.MULTI | SWT.WRAP);
addPluginDisposeListener();
addCloseTabListener();
addSwapTabListener();
addRenameTabListener();
addTabSelectionListener();
restoreViewFromPreviousSession();
Job autosaveJob = new Job("ScheduledAutosave") {
@Override
protected IStatus run(IProgressMonitor monitor) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
savePluginState();
}
});
schedule(SAVE_INTERVAL_MILLIS);
return Status.OK_STATUS;
}
};
autosaveJob.schedule(SAVE_INTERVAL_MILLIS);
PlatformUI.getWorkbench().getHelpSystem().setHelp(tabFolder, "Notepad4e.viewer");
IContextService contextService = getSite().getService(IContextService.class);
contextService.activateContext("notepad4e.context");
IHandlerService handlerService = getSite().getService(IHandlerService.class);
// Associate each shortcut command with the shortcut handler.
for (NotepadAction notepadAction : NotepadAction.values()) {
if (notepadAction.getCommandID() != null) {
handlerService.activateHandler(notepadAction.getCommandID(), shortcutHandler);
}
}
makeActions();
contributeToActionBars();
}
示例14: addKeyHandler
import org.eclipse.ui.handlers.IHandlerService; //导入方法依赖的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.ui.handlers.IHandlerService; //导入方法依赖的package包/类
private void addKeyHandler(IAction action) {
IHandlerService service = (IHandlerService) this.getSite().getService(
IHandlerService.class);
service.activateHandler(action.getActionDefinitionId(),
new ActionHandler(action));
}