@Override public void addVariable(String name, Object value) { fParent.addVariable(name, value); } @Override
@Override public void addVariable(String name, Object value) { fParent.addVariable(name, value); } @Override
@Override public void addVariable(String name, Object value) { fParent.addVariable(name, value); } @Override
/** * {@inheritDoc} */ @Override public void addVariable(String name, Object value) { fManagedPool.addVariable(name, value); }
/** * {@inheritDoc} */ @Override public void addVariable(String name, Object value) { fManagedPool.addVariable(name, value); }
@Override public void addVariable(String name, Object value) { fManagedPool.addVariable(name, value); }
public void addVariable(String name, Object value) { fParent.addVariable(name, value); } public Object removeVariable(String name) {
/** * {@inheritDoc} */ public void addVariable(String name, Object value) { fManagedPool.addVariable(name, value); }
private void copyVariable(IEvaluationContext context, IEvaluationContext tmpContext, String var) { Object o = tmpContext.getVariable(var); if (o != null) { context.addVariable(var, o); } }
/** * Changes the variable of the given name. If the <code>value</code> is * <code>null</code>, then the variable is removed. * * @param name * The name of the variable to change; must not be * <code>null</code>. * @param value * The new value; the variable should be removed if this is * <code>null</code>. */ protected final void changeVariable(final String name, final Object value) { if (value == null) { context.removeVariable(name); } else { context.addVariable(name, value); } }
/** * Constructs a new instance of <code>ExpressionAuthority</code>. */ protected ExpressionAuthority() { context = new EvaluationContext(null, this); context.setAllowPluginActivation(true); context.addVariable("org.eclipse.core.runtime.Platform", Platform.class); //$NON-NLS-1$ // this is not as useful as it appears // context.addVariable("java.lang.System", System.class); //$NON-NLS-1$ }
/** * Creates a listing of the launch shortcut extensions that are applicable to the underlying resource * @param resource the underlying resource * @return a listing of applicable launch shortcuts or an empty list, never <code>null</code> * @since 3.3 */ public List<LaunchShortcutExtension> getLaunchShortcuts(IResource resource) { List<LaunchShortcutExtension> list = new ArrayList<>(); List<LaunchShortcutExtension> sc = getLaunchShortcuts(); List<IResource> ctxt = new ArrayList<>(); if(resource != null) { ctxt.add(resource); } IEvaluationContext context = DebugUIPlugin.createEvaluationContext(ctxt); context.addVariable("selection", ctxt); //$NON-NLS-1$ for (LaunchShortcutExtension ext : sc) { try { if(ext.evalEnablementExpression(context, ext.getContextualLaunchEnablementExpression()) && !WorkbenchActivityHelper.filterItem(ext)) { if(!list.contains(ext)) { list.add(ext); } } } catch(CoreException ce) {/*do nothing*/} } return list; }
/** * Checks if the enablement expression for the factory evaluates to true for the * given selection. * @param selection the current view selection * @return <code>true</code> if the backing {@link IDetailPaneFactory} applies to the given selection, <code>false</code> otherwise */ public boolean isEnabled(IStructuredSelection selection) { boolean enabled = false; // Only the default factory should be enabled for null selections if (selection == null || selection.isEmpty()){ return "org.eclipse.debug.ui.defaultDetailPaneFactory".equals(fConfigElement.getAttribute(IConfigurationElementConstants.ID)); //$NON-NLS-1$ } Expression expression = getEnablementExpression(); if (expression != null) { List<?> list = selection.toList(); IEvaluationContext context = DebugUIPlugin.createEvaluationContext(list); context.addVariable("selection", list); //$NON-NLS-1$ enabled = evalEnablementExpression(context, expression); } else { enabled = true; } return enabled; }
/** * @return an Evaluation context with default variable = selection */ private IEvaluationContext createContext() { IStructuredSelection ss = SelectedResourceManager.getDefault().getCurrentSelection(); Object o = ss.getFirstElement(); List<IEditorInput> list = new ArrayList<>(0); if(o instanceof IEditorPart) { list.add(((IEditorPart)o).getEditorInput()); } else { list.addAll(ss.toList()); } IEvaluationContext context = DebugUIPlugin.createEvaluationContext(list); context.setAllowPluginActivation(true); context.addVariable("selection", list); //$NON-NLS-1$ return context; }
/** * Returns true if enabled for the given object. * * @param obj an object * @return <code>true</code> if enabled * @throws CoreException if anything goes wrong */ public boolean isEnabled(Object obj) throws CoreException { if (getContextualLaunchEnablementExpression() == null) return true; IEvaluationContext context = new EvaluationContext(null, obj); context.addVariable("server", obj); return evalEnablementExpression(context, getContextualLaunchEnablementExpression()); } }
/** * Returns true if enabled for the given object. * * @param obj an object * @return <code>true</code> if enabled * @throws CoreException if anything goes wrong */ public boolean isEnabled(Object obj) throws CoreException { if (getContextualLaunchEnablementExpression() == null) return true; IEvaluationContext context = new EvaluationContext(null, obj); context.addVariable("server", obj); return evalEnablementExpression(context, getContextualLaunchEnablementExpression()); }
private CommandContributionItem createItem(String itemAction, final TableViewer tableViewer) { IWorkbench workbench = PlatformUI.getWorkbench(); CommandContributionItemParameter itemParam = new CommandContributionItemParameter( workbench, null, itemAction, STYLE_PUSH); IWorkbenchWindow activeWorkbenchWindow = workbench .getActiveWorkbenchWindow(); IHandlerService hsr = (IHandlerService) activeWorkbenchWindow .getService(IHandlerService.class); IEvaluationContext ctx = hsr.getCurrentState(); ctx.addVariable(ACTIVE_MENU_SELECTION_NAME, tableViewer.getSelection()); return new CommandContributionItem(itemParam); }
private CommandContributionItem createItem(String itemAction) { IWorkbench workbench = PlatformUI.getWorkbench(); CommandContributionItemParameter itemParam = new CommandContributionItemParameter( workbench, null, itemAction, STYLE_PUSH); IWorkbenchWindow activeWorkbenchWindow = workbench .getActiveWorkbenchWindow(); IHandlerService hsr = (IHandlerService) activeWorkbenchWindow .getService(IHandlerService.class); IEvaluationContext ctx = hsr.getCurrentState(); ctx.addVariable(ACTIVE_MENU_SELECTION_NAME, getContext().getSelection()); return new CommandContributionItem(itemParam); }
/** * Creates {@link ExecutionEvent} based on current selection * * @return {@link ExecutionEvent} with current selection */ protected ExecutionEvent createExecutionEvent() { IServiceLocator locator = getServiceLocator(); ICommandService srv = (ICommandService) locator .getService(ICommandService.class); IHandlerService hsrv = (IHandlerService) locator .getService(IHandlerService.class); Command command = srv.getCommand(commandId); ExecutionEvent event = hsrv.createExecutionEvent(command, null); if (event.getApplicationContext() instanceof IEvaluationContext) ((IEvaluationContext) event.getApplicationContext()).addVariable( ISources.ACTIVE_CURRENT_SELECTION_NAME, mySelection); return event; }
/** * Since these actions are re-created each time the run/debug as menu is * filled, the enablement of this action is static. */ private void updateEnablement() { boolean enabled = false; IStructuredSelection ss = SelectedResourceManager.getDefault().getCurrentSelection(); Object o = ss.getFirstElement(); if(o instanceof IEditorPart) { enabled = true; } else { try { // check enablement logic, if any Expression expression = fShortcut.getShortcutEnablementExpression(); if (expression == null) { enabled = !ss.isEmpty(); } else { List<?> list = ss.toList(); IEvaluationContext context = DebugUIPlugin.createEvaluationContext(list); context.addVariable("selection", list); //$NON-NLS-1$ enabled = fShortcut.evalEnablementExpression(context, expression); } } catch (CoreException e) {} } setEnabled(enabled); }