Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » RunAndTrack update accessed variables
RunAndTrack update accessed variables [message #1770373] Thu, 10 August 2017 12:58 Go to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 255
Registered: December 2015
Senior Member
I understand that a RunAndTrack is initially executed and something records which context variables are accessed during that execution, say I access a, b, c.

Now, when one of these variables changes, the RunAndTrack is executed again. In that second execution, imagine I access variable only variable d, which hasn't been accessed during the first run.

Which variable changes do now cause re-execution of that run and track? a,b,c, or a,b,c,d, or only d?

The concrete example here is some code in ToolBarManagerRenderer:
public void init() {
		context.set(ToolBarManagerRenderer.class, this);

		String[] vars = {
				"", //$NON-NLS-1$
				IServiceConstants.ACTIVE_SHELL };
		context.set(UPDATE_VARS, updateVariables);
		RunAndTrack enablementUpdater = new RunAndTrack() {

			public boolean changed(IEclipseContext context) {
				for (String var : updateVariables) {
				return true;

At some point in time, my custom variable is added to 'updateVariables', but the RunAndTrack is not re-executed if I change that variables value afterwards :/

Re: RunAndTrack update accessed variables [message #1770383 is a reply to message #1770373] Thu, 10 August 2017 15:37 Go to previous message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 719
Registered: January 2012
Senior Member

Your context needs to request the `UPDATE_VARS` value (with your code above, an easy way would be to add `UPDATE_VARS` to your `updateVariables`), and you need to re-set the value of `UPDATE_VARS` whenever its contents change. That is:
updateVariables.add(UPDATE_VARS); // so the RAT monitors this varname collection too
context.set(UPDATE_VARS, updateVariables);

// later: we add a new variable
updateVariables.add("my new variable");
context.set(UPDATE_VARS, updateVariables); // triggers the RAT

Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Previous Topic:PartSashContainer inside Placeholder - minimalize problem
Next Topic:Preferences IPropertyChangeListener
Goto Forum:

Current Time: Mon Mar 19 01:19:34 GMT 2018

Powered by FUDForum. Page generated in 0.01300 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software