| View previous topic :: View next topic |
| Author |
Message |
Klaus Martinschitz Posted via mailing list.
|
Posted: Sat Jul 04, 2009 10:56 am Post subject: Getting InstanceContent from Lookup |
|
|
Hi!
Does anyone know if something like this is possible?
InstanceContent instanceContent=new InstanceContent();
AbstractLookup abstractLookup=new AbstractLookup(instanceContent);
...
myObject.getLookup().lookup(InstanceContent.class).add(myAddedObject);
....
It does not work in this way becaus AbstractLookup doesn't save the
instance content object in its lookup. I just want to understand how to
add objects to lookups dynamically..
Thanks,
BYe,
Klaus |
|
| Back to top |
|
 |
Emilian Bold Posted via mailing list.
|
Posted: Sat Jul 04, 2009 12:19 pm Post subject: Getting InstanceContent from Lookup |
|
|
Well, I think the Lookup isn't supposed to be used like that from an designer's perspective. It's not a bag of objects where anyone external can just add/remove stuff (although it can be used like this).
It's more of a way for "myObject" to expose his capabilities.
So, some normal usage would be: myObject.doSomething(myAddedObject) which *internally* might do something similar to instanceContent.add(myAddedObject) but it also might do something else that changes his lookup.
If you really want to use your code the way you wrote it, bear in mind that the InstanceContent isn't *added* to the lookup, so you can't search for it. InstanceContent *is* the model for the AbstractLookup class and you basically have to keep a reference to it somewhere if you want to change the lookup (for example myObject.getInstanceContent().add(myAddedObject) would do the trick although it's an ugly API).
--emi
On Sat, Jul 4, 2009 at 1:56 PM, Klaus Martinschitz <address-removed ([email]address-removed[/email])> wrote:
| Quote: | Hi!
Does anyone know if something like this is possible?
InstanceContent instanceContent=new InstanceContent();
AbstractLookup abstractLookup=new AbstractLookup(instanceContent);
...
myObject.getLookup().lookup(InstanceContent.class).add(myAddedObject);
....
It does not work in this way becaus AbstractLookup doesn't save the
instance content object in its lookup. I just want to understand how to
add objects to lookups dynamically..
Thanks,
BYe,
Klaus
|
--
Emilian Bold
http://www.emilianbold.ro :Java and NetBeans Platform-loving development from Timisoara, Romania.
http://www.josekibold.ro : Java / iPhone development. |
|
| Back to top |
|
 |
Wade Chandler Posted via mailing list.
|
Posted: Sat Jul 04, 2009 6:47 pm Post subject: Getting InstanceContent from Lookup |
|
|
I have used this on multiple projects successfully:
http://wadechandler.blogspot.com/2007/12/central-lookup-creating-central.html
Of course, the way you are doing it, you could probably add the InstanceContent to itself and that work the way you are trying. I think at that point it would just be a self reference.
Wade
==================
Wade Chandler, CCE
Software Engineer and Developer
Certified Forensic Computer Examiner
NetBeans Dream Team Member and Contributor
http://www.certified-computer-examiner.com
http://wiki.netbeans.org/wiki/view/NetBeansDreamTeam
http://www.netbeans.org
| Quote: |
From: Emilian Bold <address-removed>
To: address-removed
Sent: Saturday, July 4, 2009 8:19:21 AM
Subject: Re: [openide-dev] Getting InstanceContent from Lookup
Well, I think the Lookup isn't supposed to be used like that from an designer's perspective. It's not a bag of objects where anyone external can just add/remove stuff (although it can be used like this).
It's more of a way for "myObject" to expose his capabilities.
So, some normal usage would be: myObject.doSomething(myAddedObject) which *internally* might do something similar to instanceContent.add(myAddedObject) but it also might do something else that changes his lookup.
If you really want to use your code the way you wrote it, bear in mind that the InstanceContent isn't *added* to the lookup, so you can't search for it. InstanceContent *is* the model for the AbstractLookup class and you basically have to keep a reference to it somewhere if you want to change the lookup (for example myObject.getInstanceContent().add(myAddedObject) would do the trick although it's an ugly API).
--emi
On Sat, Jul 4, 2009 at 1:56 PM, Klaus Martinschitz <address-removed ([email]address-removed[/email])> wrote:
| Quote: | Hi!
Does anyone know if something like this is possible?
InstanceContent instanceContent=new InstanceContent();
AbstractLookup abstractLookup=new AbstractLookup(instanceContent);
...
myObject.getLookup().lookup(InstanceContent.class).add(myAddedObject);
....
It does not work in this way becaus AbstractLookup doesn't save the
instance content object in its lookup. I just want to understand how to
add objects to lookups dynamically..
Thanks,
BYe,
Klaus
|
--
Emilian Bold
http://www.emilianbold.ro :Java and NetBeans Platform-loving development from Timisoara, Romania.
http://www.josekibold.ro : Java / iPhone development.
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|
|
|