Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-debug-dev] accessing LaunchConfiguration from a tab

On Tue, May 27, 2008 at 2:26 PM, Mike Frysinger wrote:
> On Tue, May 27, 2008 at 9:02 AM, Darin Wright wrote:
>> It turns out that the "initializeFrom(ILanuchConfiguration)" is a working
>> copy (you could save it in an instance variable). As well, the
>> activated(...)/deactivated(...) methods provide the working copy as a
>> parameter (from AbstractLaunchConfigurationTab).
>
> right ... all tabs get handed an indirect copy so that it can sync the
> config and the widgets, but i guess that's the only way to get at it ?
>  i need to save internally a reference to the LaunchConfiguration in
> one of these functions so that my widgets can modify things on the
> fly.  i dont think that's what people intended when they wrote the
> interface (letting these external references "bleed" in), but if
> that's the only way to do it today, i guess that's what i'll do.

anyone else interested in doing this, there's a slight gotcha.  often
times a tab's initializeFrom() will implicitly trigger the
performApply() function when updating visual controls.  normally this
isnt a problem as the configuration and the tab's state are in sync,
but when the configuration file is purposefully out of sync, you'll
need to be aware (side note: seems like a pretty big waste of cycles
having performApply be called many times).

so the trick i'm using is:
 - in my tab's initializeFrom, save a local reference to the passed in
LaunchConfiguration
 - in my tab's events, use this structure:
	ILaunchConfigurationWorkingCopy workingCopy = launchConfig.getWorkingCopy();
	ILaunchConfigurationWorkingCopy localCopy =
workingCopy.copy(Activator.PLUGIN_ID + ".hubby.bubby.boobly.boo");
	localCopy.setAttribute(...);
	... reconfigure other fun attributes you want ...
	otherTab.initializeFrom(localCopy);
	/* at this point, otherTab.initializeFrom() has indirectly caused
otherTab.performApply()
	 * to be called.  this has the side affect of clobbering the settings
in launchConfig even
	 * if you had set your own stuff. */
	workingCopy.setAttributes(localCopy.getAttributes());
	workingCopy.doSave();
	localCopy.delete();
	workingCopy.delete();
-mike


Back to the top