我的View中有一个TableViewer,我想使用 org.eclipse.ui.edit.selectAll 命令使用标准的Ctrl + A快捷键选择所有行。
当我进行跟踪时,我可以看到HandlerAuthority类解决了一些冲突,输出如下所示:
HANDLERS >>> Command('org.eclipse.ui.edit.selectAll') has changed to 'org.eclipse.ui.internal.handlers.SelectAllHandler' as its handler
HANDLERS >>> resolveConflicts: eval: HandlerActivation(commandId=org.eclipse.ui.edit.selectAll,
handler=org.eclipse.ui.internal.handlers.SelectAllHandler@2a3e58,
expression=,sourcePriority=0)
HANDLERS >>> Resolved conflict detected. The following activation won:
HANDLERS >>> HandlerActivation(commandId=org.eclipse.ui.edit.selectAll,
handler=org.eclipse.ui.internal.handlers.SelectAllHandler@2a3e58,
expression=,sourcePriority=0)
HANDLERS >>> resolveConflicts: eval: HandlerActivation(commandId=org.eclipse.ui.edit.selectAll,
handler=org.eclipse.ui.internal.handlers.SelectAllHandler@2a3e58,
expression=,sourcePriority=0)
HANDLERS >>> Resolved conflict detected. The following activation won:
HANDLERS >>> HandlerActivation(commandId=org.eclipse.ui.edit.selectAll,
handler=org.eclipse.ui.internal.handlers.SelectAllHandler@2a3e58,
expression=,sourcePriority=0)
HANDLERS >>> resolveConflicts: eval: HandlerActivation(commandId=org.eclipse.ui.edit.selectAll,
handler=ActionHandler(RetargetAction(selectAll)),
expression=ActiveShellExpression(Shell {SPL v0.1.2 (VYVOJ) (DB TEST)}),sourcePriority=17408)
HANDLERS >>> resolveConflicts: eval: HandlerActivation(commandId=org.eclipse.ui.edit.selectAll,
handler=org.eclipse.ui.internal.handlers.SelectAllHandler@2a3e58,
expression=,sourcePriority=0)
HANDLERS >>> Resolved conflict detected. The following activation won:
HANDLERS >>> HandlerActivation(commandId=org.eclipse.ui.edit.selectAll,
handler=ActionHandler(RetargetAction(selectAll)),
expression=ActiveShellExpression(Shell {SPL v0.1.2 (VYVOJ) (DB TEST)}),sourcePriority=17408)
HANDLERS >>> Command('org.eclipse.ui.edit.selectAll') has changed to 'ActionHandler(RetargetAction(selectAll))' as its handler
当我按下Ctrl + A时,我可以看到:
KEYS >>> Listener.handleEvent(type = KeyDown, stateMask = 0x0, keyCode = 0x40000, time = 9403459, character = 0x0)
KEYS >>> Listener.handleEvent(type = KeyDown, stateMask = 0x40000, keyCode = 0x61, time = 9403553, character = 0x1)
KEYS >>> WorkbenchKeyboard.press(potentialKeyStrokes = [CTRL+A])
KEYS >>> WorkbenchKeyboard.executeCommand(commandId = 'org.eclipse.ui.edit.selectAll', parameters = {})
KEYS >>> not handled
调试RetargetAction我发现Action没有被处理,因为它没有设置处理程序。
所以我的问题是,为什么HandlerAuthority将RetargetAction设置为for的处理程序 org.eclipse.ui.edit.selectAll 命令?我想使用默认的(org.eclipse.ui.internal.handlers.SelectAllHandler)。
答案 0 :(得分:0)
所有旨在由多个视图和编辑者实施的操作都使用RetargetAction
。您可以在视图中连接到重定目标操作:
IActionBars bars = getViewSite().getActionBars();
bars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), selectAllAction);
其中selectionAllAction
是Action
,可以在您的桌子上执行全部选择。行动可能如下:
class SelectAllAction extends Action
{
private final TableViewer tableViewer;
SelectAllAction(final TreeViewer viewer)
{
tableViewer = viewer;
}
@Override
public void run()
{
tableViewer.getTable().selectAll();
// Get table view selection synchronized with table selection
tableViewer.setSelection(tableViewer.getSelection());
}
}