Re: lookup confusing me

Oliver Rettig <[email protected]> Thu, 14 Sep 2017 23:05:54 +0200
Newsgroups gmane.comp.java.netbeans.modules.openide.devel
Organization ORAT
Message-ID <2942009.7MlXpc9SGM@l560>
Hi Peter,

the global context represents the active/selected element(s). So If you have 
selected one or more DataObjects, you can find them in the lookup of the global 
context. 

The meaning of "All" in the method lookup.lookupAll () is, that you get all of 
these objects in a list instead only the first found.

The selection can be empty, so the lookup of the global context can be empty.

Does it help or have I misunderstood your question?

The more interesting question is how to get a list of all opend files? In some 
of my apps I have implemented my own global lookup/cache to keep them. But 
maybe there is a more intelligent way.

best regards
Oliver

> Hi
>    I have trouble with lookup, the below code only print out the current
> file instead of all opened files. Lookup lookup =
> Utilities.actionsGlobalContext();
> 
> Collection<? extends DataObject> list = lookup.lookupAll(DataObject.class);
> for (DataObject dataObject : list) {
> ModuleLib.log(dataObject);
> }
> 
> If i use "Lookup.getDefault().lookupAll", looupAll() even returns nothing.
> Please help
> 
> Thanks
> FromPeter