|
|
|
|
|
|
|
Re: EObject in non Xtext resource [message #537627 is a reply to message #537372] |
Thu, 03 June 2010 06:44 |
Sven Efftinge Messages: 1823 Registered: July 2009 |
Senior Member |
|
|
Filip Kis schrieb:
> Sven Efftinge wrote on Wed, 02 June 2010 08:30
>> I already explained how to do this in an earlier post in this thread:
>>
>> If you want to show only what's visible due to some dependency
>> configuration (i.e. project and classpath dependencies) we provide
>> three different alternatives:
>>
>> Provider<IAllContainersState> getWorkspaceProjectsState()
>>
>> -> uses project dependencies
>>
>> Provider<IAllContainersState> getStrictJavaProjectsState()
>>
>> -> uses classpath entries
>>
>> Provider<IAllContainersState> getJavaProjectsState()
>>
>> -> uses both and is used by default
>
>
> I know you already mentioned them in the first post. But the problem is
> that I don't know what to do with them. I tried changing the one that is
> used in the Module to the strictJava one and I still get all the
> resources. Other then this I don't know how to go from
> IAllContainerStates to IResourceDescriptions. I am probably missing some
> basic understanding of how these things work.
I see that this is not obvious. Sorry for being terse.
If you have the following two methods (which i copied from
StateBasedContainerManager)...
protected List<IContainer> getVisibleContainers(List<String> handles,
IResourceDescriptions resourceDescriptions) {
if (handles.isEmpty())
return Collections.emptyList();
List<IContainer> result =
Lists.newArrayListWithExpectedSize(handles.size());
for(String handle: handles) {
result.add(createContainer(handle, resourceDescriptions));
}
return result;
}
protected IContainer createContainer(final String handle,
IResourceDescriptions resourceDescriptions) {
IContainerState containerState =
new ContainerState(handle, getState(resourceDescriptions));
StateBasedContainer result =
new StateBasedContainer(resourceDescriptions, containerState);
return result;
}
.... you can call them, like this:
@Inject
private IAllContainersState.Provider stateProvider;
..... {
List<String> handles = stateProvider.get(resourceDescriptions)
.getVisibleContainerHandles(nameOfContainerYourJspFileIsCont ained);
List<IContainer> visibleContainers =
getVisibleContainers(handles, resourceDescriptions);
The IContainers are provided in the right order (i.e. like the
classparth entries), and each represents one entry and only provides the
ResourceDescriptions contained there in.
Note that all this is not considered API, so you might have minor
migration effort even in service releases.
In case I missed something look into StateBasedContainerManager, which
can't use directly becaus it expects you have a resourcedescription for
the file your are in, which you obviously don't have.
>
> Sven Efftinge wrote on Wed, 02 June 2010 08:30
>> The three components listed above use the dirty state manager under
>> the hood, which shadows any saved state by the dirty state in open
>> dirty Xtext editors. Not sure if you meant that or whether you have
>> your own resourceset which you modify. The latter is not so easy to
>> accomplish.
>> I'ld recommend to throw things away once you used them.
>
>
> I don't have my own resource set. So in the Xtext editor I used what is
> default. But when I'm in my JSP Editor, from what user enters there I
> get an name of the EObject, then I find it in the ResourceDescription
> and then I resolve it against the resourceSet injected by guice. So it's
> here that the state is not updated. So somehow the injected resourceSet
> stays at some older state.
You should use a Provider<ResourceSet> and throw the ResourceSet away
once you used it.
Sven
--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
|
|
|
Powered by
FUDForum. Page generated in 0.02413 seconds