Project: Eclipse_Platform_UI
Bug 301196 [FieldAssist] ContentAssistCommandAdapter should provide an activation expression when activating the command handler
Reported: 2010-01-28 19:34:25 | Status: verified fixed

by providing an activation expression Eclipse can correctly resolve conflicts should the occur. applies to org.eclipse.ui.fieldassist.ContentAssistCommandAdapter see @org.eclipse.ui.internal.handlers.HandlerAuthority.resolveConflicts(String, SortedSet, MultiStatus)@ for details on how handler conflicts are resolved. The handler should only be active when the control has focus: bc. private void activateHandler() { if (activeHandler == null) { activeHandler = handlerService.activateHandler(commandId, proposalHandler,new ActiveFocusControlExpression(getControl())); } } the focus control expression would look something like this: bc.. public class ActiveFocusControlExpression extends Expression { private final Control focusControl; public ActiveFocusControlExpression(Control control) { focusControl = control; } @Override public void collectExpressionInfo(ExpressionInfo info) { info.markDefaultVariableAccessed(); // give it a very high priority info.addVariableNameAccess(ISources.ACTIVE_SHELL_NAME); info.addVariableNameAccess(ISources.ACTIVE_WORKBENCH_WINDOW_NAME); } @Override public EvaluationResult evaluate(IEvaluationContext context) throws CoreException { if (Display.getCurrent() != null && focusControl.isFocusControl()) { return EvaluationResult.TRUE; } return EvaluationResult.FALSE; } }

Files changed in fix:
bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/fieldassist/ContentAssistCommandAdapter.java tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/fieldassist/TextContentAssistCommandAdapterTest.java