use of org.eclipse.ui.contexts.IContextService in project erlide_eclipse by erlang.
the class ErlangFileActionProvider method init.
@Override
public void init(final ICommonActionExtensionSite aSite) {
final ICommonViewerSite viewSite = aSite.getViewSite();
if (viewSite instanceof ICommonViewerWorkbenchSite) {
final ICommonViewerWorkbenchSite workbenchSite = (ICommonViewerWorkbenchSite) viewSite;
final IWorkbenchPartSite site = workbenchSite.getSite();
openAction = new OpenErlangAction(aSite, workbenchSite.getSelectionProvider());
searchActionGroup = new ErlangSearchActionGroup(site);
final IContextService service = site.getService(IContextService.class);
if (service != null) {
service.activateContext("org.erlide.ui.erlangOutlineAndNavigatorScope");
}
}
}
use of org.eclipse.ui.contexts.IContextService in project xtext-eclipse by eclipse.
the class CodetemplatesEmbeddedEditorActions method createFocusAndDisposeListeners.
@Override
protected void createFocusAndDisposeListeners() {
final List<IHandlerActivation> handlerActivations = Lists.newArrayListWithExpectedSize(3);
final IHandlerService handlerService = workbench.getAdapter(IHandlerService.class);
final IContextService contextService = workbench.getAdapter(IContextService.class);
Shell shell = viewer.getTextWidget().getShell();
final ActiveShellExpression expression = new ActiveShellExpression(shell);
AtomicReference<IContextActivation> contextActivationHolder = new AtomicReference<>();
shell.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
handlerService.deactivateHandlers(handlerActivations);
}
});
viewer.getTextWidget().addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
IContextActivation contextActivation = contextActivationHolder.get();
if (contextActivation != null) {
contextService.deactivateContext(contextActivation);
}
handlerService.deactivateHandlers(handlerActivations);
handlerActivations.clear();
}
@Override
public void focusGained(FocusEvent e) {
final IContextActivation contextActivation = contextService.activateContext(EMBEDDED_TEXT_EDITOR_SCOPE, expression);
contextActivationHolder.set(contextActivation);
for (final IAction action : allActions.values()) {
handlerActivations.add(handlerService.activateHandler(action.getActionDefinitionId(), new ActionHandler(action), expression, true));
}
}
});
}
use of org.eclipse.ui.contexts.IContextService in project dbeaver by serge-rider.
the class WorkbenchContextListener method partDeactivated.
@Override
public void partDeactivated(IWorkbenchPart part) {
IContextService contextService = PlatformUI.getWorkbench().getService(IContextService.class);
if (contextService == null) {
return;
}
try {
contextService.deferUpdates(true);
if (activationNavigator != null && part instanceof INavigatorModelView) {
contextService.deactivateContext(activationNavigator);
activationNavigator = null;
}
if (activationSQL != null && part instanceof SQLEditorBase) {
contextService.deactivateContext(activationSQL);
activationSQL = null;
}
} finally {
contextService.deferUpdates(false);
}
// log.info(part.getClass().getSimpleName() + " DEACTIVATED: " + contextService.getActiveContextIds());
}
use of org.eclipse.ui.contexts.IContextService in project KaiZen-OpenAPI-Editor by RepreZen.
the class JsonEditor method init.
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
super.init(site, input);
IContextService contextService = (IContextService) site.getService(IContextService.class);
contextService.activateContext(CONTEXT);
}
use of org.eclipse.ui.contexts.IContextService in project tdi-studio-se by Talend.
the class BindingActions method registerActions.
/**
* DOC smallet Comment method "registerActions".
*/
private void registerActions() {
IContextService contextService = (IContextService) PlatformUI.getWorkbench().getAdapter(IContextService.class);
//$NON-NLS-1$
contextService.activateContext("talend.global");
IWorkbench workbench = PlatformUI.getWorkbench();
IHandlerService handlerService = (IHandlerService) workbench.getService(IHandlerService.class);
IHandler handler;
for (IAction action : actions) {
handler = new ActionHandler(action);
handlerService.activateHandler(action.getActionDefinitionId(), handler);
}
}
Aggregations