/** * Return the execution context for the @CanExecute and @Execute methods. * This should be the same as the execution context used by the * EHandlerService. * * @param context * the context for this item * @return the execution context */ private IEclipseContext getExecutionContext(IEclipseContext context) { return context.getActiveLeaf(); }
public IEclipseContext getExecutionContext() { return context.getActiveLeaf(); } }
/** * Return the execution context for the @CanExecute and @Execute methods. * This should be the same as the execution context used by the * EHandlerService. * * @param context * the context for this item * @return the execution context */ private IEclipseContext getExecutionContext(IEclipseContext context) { if (context == null) return null; return context.getActiveLeaf(); }
@Override public boolean changed(IEclipseContext context) { record.updateVisibility(parentContext.getActiveLeaf()); scheduleManagerUpdate(manager); return true; } });
/** * @param context * the context to start the lookup process * @param commandId * @return a handler, or <code>null</code> */ public static Object lookUpHandler(IEclipseContext context, String commandId) { return context.getActiveLeaf().get(H_ID + commandId); }
private MPart getPartToExtend() { return (MPart) e4Context.getActiveLeaf().get(IServiceConstants.ACTIVE_PART); }
private void fillArgs(Object[] actualArgs, String[] keys, boolean[] active) { for (int i = 0; i < keys.length; i++) { if (keys[i] == null) continue; IEclipseContext targetContext = (active[i]) ? context.getActiveLeaf() : context; if (ECLIPSE_CONTEXT_NAME.equals(keys[i])) actualArgs[i] = targetContext; else if (targetContext.containsKey(keys[i])) actualArgs[i] = targetContext.get(keys[i]); } }
@Override public Object compute(IEclipseContext context, String contextKey) { // 1) get active child IEclipseContext current = context.getActiveLeaf(); //2 form an answer going up boolean inDialog = false; Set<Object> rc = new HashSet<>(); while (current != null) { LinkedList<?> locals = (LinkedList<?>) current.getLocal(ContextContextService.LOCAL_CONTEXTS); if (locals != null) { if (!inDialog || !locals.contains("org.eclipse.ui.contexts.window")) { rc.addAll(locals); } if (!inDialog && locals.contains("org.eclipse.ui.contexts.dialog")) { inDialog = true; } } current = current.getParent(); } return rc; }
@Override public Object compute(IEclipseContext context, String contextKey) { // 1) get active child IEclipseContext current = context.getActiveLeaf(); //2 form an answer going up boolean inDialog = false; Set<Object> rc = new HashSet<>(); while (current != null) { LinkedList<?> locals = (LinkedList<?>) current.getLocal(ContextContextService.LOCAL_CONTEXTS); if (locals != null) { if (!inDialog || !locals.contains("org.eclipse.ui.contexts.window")) { rc.addAll(locals); } if (!inDialog && locals.contains("org.eclipse.ui.contexts.dialog")) { inDialog = true; } } current = current.getParent(); } return rc; }
@Override public boolean changed(IEclipseContext context) { record.updateVisibility(parentContext.getActiveLeaf()); manager.update(false); return true; } });
@Override public Object compute(IEclipseContext context, String contextKey) { // 1) get active child IEclipseContext current = context.getActiveLeaf(); //2 form an answer going up boolean inDialog = false; Set<String> rc = new HashSet<String>(); while (current != null) { LinkedList<String> locals = (LinkedList<String>) current.getLocal(ContextContextService.LOCAL_CONTEXTS); if (locals != null) { if (!inDialog || !locals.contains("org.eclipse.ui.contexts.window")) { rc.addAll(locals); } if (!inDialog && locals.contains("org.eclipse.ui.contexts.dialog")) { inDialog = true; } } current = current.getParent(); } return rc; }
/** * Determines what keybinding was used to open this dialog and returns an * info string using that binding. ex: * "Press 'Ctrl-Shift-L') to open the preference page"; * * @return info text for this dialog */ private String getInfoText() { ECommandService commandService = context.getActiveLeaf().get(ECommandService.class); Command cmd = commandService.getCommand(IWorkbenchCommandConstants.WINDOW_SHOW_KEY_ASSIST); if (cmd != null) { EBindingService bindingService = context.getActiveLeaf().get(EBindingService.class); TriggerSequence keySeq = bindingService.getBestSequenceFor(new ParameterizedCommand( cmd, null)); if (keySeq != null) { return NLS.bind(KeyAssistMessages.openPreferencePage, keySeq.format()); } } return ""; //$NON-NLS-1$ }
@Override public boolean changed(IEclipseContext context) { if (getManager(toolbarModel) == null) { // tool bar no longer being managed, ignore it return false; } record.updateVisibility(parentContext.getActiveLeaf()); runExternalCode(new Runnable() { public void run() { manager.update(false); } }); // disposeToolbarIfNecessary(toolbarModel); return true; } });
/** * Check the visible when expression * * @param item * the item * @param context * the context * @return <code>true</code> if visible */ public static boolean checkVisibleWhen(MUIElement item, IEclipseContext context) { if (item.getVisibleWhen() != null && item.getVisibleWhen() instanceof MCoreExpression) { ExpressionContext exprContext = new ExpressionContext(context.getActiveLeaf()); boolean value = ContributionsAnalyzer.isVisible((MCoreExpression) item.getVisibleWhen(), exprContext); item.getTransientData().put(CURRENT_VISIBLE_WHEN, Boolean.valueOf(value)); return value; } return true; }
@Override public boolean changed(IEclipseContext context) { ExpressionInfo info = new ExpressionInfo(); IEclipseContext leafContext = windowContext.getActiveLeaf(); MenuManagerRendererFilter.collectInfo(info, mainMenu, renderer, leafContext, true); // if one of these variables change, re-run the RAT for (String name : info.getAccessedVariableNames()) { leafContext.get(name); } if (canUpdateMenus && workbench.getDisplay() != null) { canUpdateMenus = false; workbench.getDisplay().asyncExec(menuUpdater); } return manageChanges; } };
@Override public Object compute(IEclipseContext context, String contextKey) { /** * This is the specific implementation. TODO: generalize it */ MContext window = context.get(MWindow.class); if (window == null) { window = context.get(MApplication.class); if (window == null) { return null; } } IEclipseContext current = window.getContext(); if (current == null) { return null; } return current.getActiveLeaf().get(MPart.class); } }
IEclipseContext runContext = Util.createLocalHandlerContext(context,context.getActiveLeaf(),"DI-Item"); //$NON-NLS-1$ try { ContributionsAnalyzer.populateModelInterfaces(item, runContext, item.getClass().getInterfaces()); runContext.set(MItem.class.getName(), item); ContextInjectionFactory.invoke(object, Execute.class, context.getActiveLeaf(), runContext, new Object()); } finally { runContext.dispose(); return; final IEclipseContext runContext = Util.createLocalHandlerContext(context,context.getActiveLeaf(),"HI-Item"); //$NON-NLS-1$ try { ContributionsAnalyzer.populateModelInterfaces(item, runContext, item.getClass().getInterfaces());
@Override public boolean changed(IEclipseContext context) { if (getManager(toolbarModel) == null) { // tool bar no longer being managed, ignore it return false; } record.updateVisibility(parentContext.getActiveLeaf()); runExternalCode(() -> { manager.update(false); getUpdater().updateContributionItems(e -> { if (e instanceof MToolBarElement) { if (((MUIElement) ((MToolBarElement) e).getParent()) == toolbarModel) { return true; } } return false; }); }); return true; } });
if (keys[i] == null) continue; IEclipseContext targetContext = (active[i]) ? context.getActiveLeaf() : context; if (ECLIPSE_CONTEXT_NAME.equals(keys[i])) { result[i] = targetContext;
MApplication mApp = context.get(MApplication.class); if(mApp != null) { perspective = findPerspective(mApp.getContext().getActiveLeaf()); MApplication mApp = context.get(MApplication.class); if(mApp != null) { window = findWindow(mApp.getContext().getActiveLeaf());