Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Retrieving Variables from the Project PathVariableManager

Alena Laskavaia wrote:
> So why you trying to get it from workspace? Get your project instance
> first,
> for example from selection

Something like ResourcesPlugin.getSelected().getProject()? I am still
fairly new to Java and absolutely new to Eclipse plugin development.
Thanks for the advice, I think it is enough for me to go on next time I
sit down to work on this project. :-]

I was thinking that if I could not get a handle on the project interface I
would have to use an xml parser to grab the variable out of the .cproject
file. How frustrating, to know where the variable is stored yet be too
ignorant to access it programmatically.

Anyway, thank you very much for the help!

Wayne

>
> On Tue, Mar 1, 2011 at 4:26 PM, wwarren <wwarren@xxxxxxxxxxx> wrote:
>> Hi,
>>
>> I have been able to store path variables in the project path variable
>> manager but I have not been able to figure out how to retrieve these
>> values.  Here is a code snippet showing what I have tried so far:
>>
>> IWorkspace iw = ResourcesPlugin.getWorkspace();
>>
>> IWorkspaceRoot iwr = iw.getRoot();
>>
>> IProject ip = iwr.getProject();
>>
>> IPathVariableManager ipvm = ip.getPathVariableManager();
>>
>> URI u = ipvm.getURIValue(sdk_var_name);
>>
>> String s = u.getPath();
>>
>> Looking at the debugger Variables View, I can see that iwr.getProject();
>> returns null. I guess this makes sense since getProject() is supposed to
>> return null for the workspace. This code is run in resolveValue() inside
>> a class implementing IDynamicVariableResolver. What I really want is to
>> get the IPathVariableManager of the project so I can get at the variable
>> I want (which does appear in the project preferences).
>>
>> The other option I could see would be to use the IWorkspaceRoot version
>> that takes the name of the project as an argument. I am certain this
>> would work, but I am not so sure of how to get the project's name.
>>
>> Sorry if this is a trivial problem, I just feel like I am banging my
>> head against the API and not getting much out of it probably due to my
>> own ignorance. Thanks in advance for the assistance!
>>
>> Wayne
>>
>>
>>
>> _______________________________________________
>> cdt-dev mailing list
>> cdt-dev@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/cdt-dev
>>
>


-- 
S. Wayne Warren
EMAC Engineer
(618)305 0579




Back to the top