Re: lookup confusing me

Peter Cheung <[email protected]> Fri, 15 Sep 2017 02:03:13 +0000
Newsgroups gmane.comp.java.netbeans.modules.openide.devel
Message-ID <ME1PR01MB0260738E52E058BCF23CC711B56C0@ME1PR01MB0260.ausprd01.prod.outlook.com>
i tried to lookupall TopComponents but nothing return. Now i can use lookup=
 listener to track which file is opened. But if the file is closed i have n=
o event. And i think getting the list of all opened files using a listener =
is too heavy. It should be calling one single function to do that.

Peter.

> On 15 Sep 2017, at 6:02 AM, Oliver Rettig <[email protected]> wrote:
>=20
>> The more interesting question is how to get a list of all opend files? I=
n
>> some of my apps I have implemented my own global lookup/cache to keep th=
em.
>> But maybe there is a more intelligent way.
>=20
> Maybe you can get a list of all of your open TopComponents and than you c=
an=20
> ask each TopComponent lookup for your DataObject.
>=20
>> best regards
>> Oliver
>>=20
>>> Hi
>>>=20
>>>   I have trouble with lookup, the below code only print out the current
>>>=20
>>> file instead of all opened files. Lookup lookup =3D
>>> Utilities.actionsGlobalContext();
>>>=20
>>> Collection<? extends DataObject> list =3D
>>> lookup.lookupAll(DataObject.class);
>>> for (DataObject dataObject : list) {
>>> ModuleLib.log(dataObject);
>>> }
>>>=20
>>> If i use "Lookup.getDefault().lookupAll", looupAll() even returns nothi=
ng.
>>> Please help
>>>=20
>>> Thanks
>>> FromPeter
>=20
>=20