Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [xtext-dev] How to provide custom IAllContainerState?

Hi Samantha,

please use the forum/newsgroup for such questions.

You need to have a singleton binding if you want guice to inject the same instance all over the place.
The alternative could be to just create a new instance (vew new CustomContainerState()).

Sven 

On Aug 18, 2010, at 10:55 PM, Samantha Chan wrote:


Hi,

I am trying to provide a custom IAllContainerState for my editor.

In my editor plugin, I have bound to the StateBasedContainerManager:

        public Class<? extends IContainer.Manager> bindIContainer$Manager() {
          return StateBasedContainerManager.class;
        }

In my editor.ui plugin, I have tried the following:
        public Provider<IAllContainersState> provideIAllContainersState() {
          return MySharedAccess.getCustomContainerState();
        }

MySharedAccess extends from Access and provides the following method:

        public static Provider<IAllContainersState> getCutomContainerState() {
                return Access.<IAllContainersState>provider(CustomContainerState.class);
        }

My container state is called, however I don't think I am doing this correctly.  Whenever my editor is opened, the CustomContainerState.doInitHandle(URI uri) is called. I did not expect this to happen because I thought the results of the handle, and container visibility is cached.  

I debugged this a bit, and found that every time ContainerState.initHandle(uri) is called, a different instance of my CustomContainerState is used.  I compared the result with the default settings. In the case of the default settings, IAllContainersState object is a singleton, and the same instance is used over and over again.

I could not quite figure out how to set this up, can you provide some tips?

Thanks!
Samantha
_______________________________________________
xtext-dev mailing list
xtext-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/xtext-dev


Back to the top