/** * Setting the context key * * @param contextKey * the key */ public void setContextKey(@NonNull final String contextKey) { this.contextKey = contextKey; this.context.runAndTrack(new RunAndTrack() { @Override public boolean changed(IEclipseContext context) { notifySubscriptions(getValue()); return true; } }); }
appContext.runAndTrack(new RunAndTrack() { @Override public boolean changed(IEclipseContext context) {
ISources.ACTIVE_PART_ID_NAME, ISources.ACTIVE_SITE_NAME, ISources.ACTIVE_CONTEXT_NAME, ISources.ACTIVE_CURRENT_SELECTION_NAME })); context.runAndTrack(ratUpdater);
@Override public IContextActivation activateContext(final String contextId, final Expression expression) { final IContextActivation activation = new ContextActivation(contextId, expression, this); contextAuthority.activateContext(activation); if (expression == null) { contextService.activateContext(contextId); } else { final UpdateExpression runnable = new UpdateExpression(contextId, expression); activationToRat.put(activation, runnable); eclipseContext.runAndTrack(runnable); } return activation; }
@Override public Object compute(IEclipseContext outerContext, String contextKey) { if( outerContext.containsKey("_local_rat") ) { return null; } outerContext.set("_local_rat", Boolean.TRUE); outerContext.runAndTrack(new RunAndTrack() { @Override public boolean changed(IEclipseContext context) { outerContext.set("activeOutline",createOutline(context)); return true; } }); Outline outline = createOutline(outerContext); return outline; }
context.runAndTrack(enablementUpdater);
protected void processVisible(MMenuItem item) { if (menuItemToExpression.get(item) != null) { return; } MCoreExpression exp = (MCoreExpression) item.getVisibleWhen(); Expression ref = null; if (exp.getCoreExpression() instanceof Expression) { ref = (Expression) exp.getCoreExpression(); } else { ref = new ReferenceExpression(exp.getCoreExpressionId()); exp.setCoreExpression(ref); } menuItemToExpression.put(item, ref); IEclipseContext itemContext = getContext(item); VisibleRAT rat = new VisibleRAT(item, ref, itemContext); menuItemToRAT.put(item, rat); itemContext.runAndTrack(rat); }
@Override public void addEvaluationReference(IEvaluationReference ref) { EvaluationReference eref = (EvaluationReference) ref; refs.add(eref); boolean changed = false; if (eref.getExpression() != null) { ExpressionInfo info = new ExpressionInfo(); eref.getExpression().collectExpressionInfo(info); for (String varName : info.getAccessedVariableNames()) { if (ratVariables.add(varName)) { changed = true; } } if (info.hasDefaultVariableAccess() && ratVariables.add(IServiceConstants.ACTIVE_SELECTION)) { changed = true; } } if (changed) { contextEvaluate(); } eref.participating = true; ratContext.runAndTrack(eref); }
Dummy dummy = r.getInjector().make(Dummy.class, r.getPrimarySupplier()); if( track ) { dummy.context.runAndTrack(new RunAndTrack() {
/** * @param menuModel * @param manager * @param menuContribution * @return true if the menuContribution was processed */ private boolean processAddition(MMenu menuModel, final MenuManager manager, MMenuContribution menuContribution, final HashSet<String> existingMenuIds, HashSet<String> existingSeparatorNames, boolean menuBar) { final ContributionRecord record = new ContributionRecord(menuModel, menuContribution, this); if (!record.mergeIntoModel()) { return false; } if (menuBar || isPartMenu(menuModel)) { final IEclipseContext parentContext = getContext(menuModel); parentContext.runAndTrack(new RunAndTrack() { @Override public boolean changed(IEclipseContext context) { record.updateVisibility(parentContext.getActiveLeaf()); scheduleManagerUpdate(manager); return true; } }); } return true; }
@PostConstruct public void init(IEclipseContext context) { // global context service. ContextManager manager = context.get(ContextManager.class); if (manager == null) { manager = new ContextManager(); context.set(ContextManager.class, manager); } context.set(EContextService.class.getName(), new ContextContextFunction()); context.set(IServiceConstants.ACTIVE_CONTEXTS, new ActiveContextsFunction()); context.runAndTrack(new RunAndTrack() { @Override public boolean changed(IEclipseContext context) { ContextManager manager = context.get(ContextManager.class); if (manager != null) { Object s = context.get(IServiceConstants.ACTIVE_CONTEXTS); if (s instanceof Set) { manager.setActiveContextIds((Set<?>) s); } else { manager.setActiveContextIds(Collections.EMPTY_SET); } } return true; } }); } }
@PostConstruct public void init(IEclipseContext context) { // global context service. ContextManager manager = context.get(ContextManager.class); if (manager == null) { manager = new ContextManager(); context.set(ContextManager.class, manager); } context.set(EContextService.class.getName(), new ContextContextFunction()); context.set(IServiceConstants.ACTIVE_CONTEXTS, new ActiveContextsFunction()); context.runAndTrack(new RunAndTrack() { @Override public boolean changed(IEclipseContext context) { ContextManager manager = context.get(ContextManager.class); if (manager != null) { Object s = context.get(IServiceConstants.ACTIVE_CONTEXTS); if (s instanceof Set) { manager.setActiveContextIds((Set<?>) s); } else { manager.setActiveContextIds(Collections.EMPTY_SET); } } return true; } }); } }
@PostConstruct public void init(IEclipseContext context) { // global context service. ContextManager manager = context.get(ContextManager.class); if (manager == null) { manager = new ContextManager(); context.set(ContextManager.class, manager); } context.set(EContextService.class.getName(), new ContextContextFunction()); context.set(IServiceConstants.ACTIVE_CONTEXTS, new ActiveContextsFunction()); context.runAndTrack(new RunAndTrack() { @Override public boolean changed(IEclipseContext context) { ContextManager manager = context.get(ContextManager.class); if (manager != null) { Object s = context.get(IServiceConstants.ACTIVE_CONTEXTS); if (s instanceof Set) { manager.setActiveContextIds((Set) s); } else { manager.setActiveContextIds(Collections.EMPTY_SET); } } return true; } }); } }
/** * @param menuModel * @param manager * @param menuContribution * @return true if the menuContribution was processed */ private boolean processAddition(MMenu menuModel, final MenuManager manager, MMenuContribution menuContribution, final HashSet<String> existingMenuIds, HashSet<String> existingSeparatorNames, boolean menuBar) { final ContributionRecord record = new ContributionRecord(menuModel, menuContribution, this); if (!record.mergeIntoModel()) { return false; } if (menuBar || isPartMenu(menuModel)) { final IEclipseContext parentContext = getContext(menuModel); parentContext.runAndTrack(new RunAndTrack() { @Override public boolean changed(IEclipseContext context) { record.updateVisibility(parentContext.getActiveLeaf()); manager.update(false); return true; } }); } return true; }
parentContext.runAndTrack(new RunAndTrack() { @Override public boolean changed(IEclipseContext context) {
updateVariables.addAll(Arrays.asList(info.getAccessedVariableNames())); final IEclipseContext parentContext = getContext(toolbarModel); parentContext.runAndTrack(new RunAndTrack() { @Override public boolean changed(IEclipseContext context) {
/** Called whenever trigger details change */ private void hookTriggerCommandEnablement() { final Object data = link.getData(TRIGGER_KEY); if (!(data instanceof ParameterizedCommand) || !PlatformUI.isWorkbenchRunning()) return; // Would be nice to have the window's context, but we're too deep IEclipseContext context = PlatformUI.getWorkbench().getService(IEclipseContext.class); if (context == null) { return; } if (tracker != null) { // stop any existing RATs as the command details may have changed tracker.stop(); } tracker = new HandlerChangeTracker((ParameterizedCommand) data); context.runAndTrack(tracker); }
if (initial) { RunAndTrack trackable = new ContextInjectionListener(context, actualArgs, keys, active, requestor, group); context.runAndTrack(trackable); } else { // we do track if this is done inside a computation, but don't create another runnable fillArgs(actualArgs, keys, active);
@PostConstruct void init(IEventBroker eventBroker) { EventProcessor.attachChildProcessor(eventBroker, this); EventProcessor.attachVisibleProcessor(eventBroker, this); Selector noop = m -> true; eventBroker.subscribe(ScopedObjectFactory.KEYMODIFED_TOPIC, e -> checkExecute(noop)); eventBroker.subscribe(UIEvents.REQUEST_ENABLEMENT_UPDATE_TOPIC, e -> { Object d = e.getProperty(IEventBroker.DATA); if (d instanceof Selector) { checkExecute((Selector) d); } else if (UIEvents.ALL_ELEMENT_ID.equals(d)) { checkExecute(noop); } else if (d != null) { checkExecute(m -> d.equals(m.getElementId())); } }); eventBroker.subscribe(UIEvents.Dirtyable.TOPIC_DIRTY, e -> checkExecute(noop)); this.context.runAndTrack(new RunAndTrack() { @Override public boolean changed(IEclipseContext context) { context.get(IServiceConstants.ACTIVE_CONTEXTS); context.get(IServiceConstants.ACTIVE_SELECTION); context.get(IServiceConstants.ACTIVE_PART); checkExecute(noop); return true; } }); do_init(eventBroker); }
@Override @NonNull public final W createWidget(final @NonNull M element) { final IEclipseContext context = setupRenderingContext(element); W widget = ContextInjectionFactory.make(getWidgetClass(element), context); // Bug 433845 widget.setPropertyChangeHandler((WPropertyChangeEvent<W> e) -> propertyObjectChanged(element, e)); initWidget(element, widget); element.getTransientData().put(CALCULATED_VISIBILITY, Boolean.valueOf(element.isVisible() && checkVisibleWhen(element, getModelContext(element)))); if (element.getVisibleWhen() != null) { ActiveLeafRunAndTrack rat = new ActiveLeafRunAndTrack(element, this._context.get(IEventBroker.class)); this.visibleWhenElements.put(element, rat); IEclipseContext modelContext = getModelContext(element); if (modelContext != null) { modelContext.runAndTrack(rat); } } return widget; }