Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Visual Editor (VE) » Setting a Property of a component programmatically
Setting a Property of a component programmatically [message #615211] Thu, 03 May 2007 12:38
Mario Ortegón is currently offline Mario OrtegónFriend
Messages: 19
Registered: July 2009
Junior Member

I am trying to add an extension to the Visual Editor, that would allow
me to do drag & drop into a selected component in order to change some
property. So far, I've seen the code that allows you t make a custom
editor for the properties view, but I have found no example on how to
set the property and force the code generation.

I was able to use the IBeanProxy class to invoke the set method on the
second virtual machine, and the property is rendered correctly in the
second virtual machine. However, the code is not generated.

I get the list of selected edit parts by using:

List selected = vePart.getPrimaryViewer().getSelectedEditParts();

(Where vePart is an instance of JavaVisualEditorPart)

I iterate through them, loooking for Edit Parts and java object instances:

for (Iterator iter = selected.iterator(); iter.hasNext();) {
EditPart part = (EditPart);
Object obj = part.getModel();
if (obj instanceof JavaObjectInstance) {
JavaObjectInstance joi = (JavaObjectInstance)obj;

// More code here


If the object is a JavaObjectInstance, then I set the value

IBeanProxy proxy = BeanProxyUtilities.getBeanProxy(joi);
IBeanProxy valProxy =
proxy.getProxyFactoryRegistry().getBeanProxyFactory().create BeanProxyWith( "SomeString");
IMethodProxy setTypeMethodProxy =
proxy.getTypeProxy().getMethodProxy("setPropText", "java.lang.String");
setTypeMethodProxy.invoke(proxy, valProxy);

Of course, I realize this is wrong, as this will only set the value on
the second virtual machine but nothing is said about generation.
Checking into the code for a custom editor, I see that you need to
return a IJavaInstance object by using BeanUtilities.createJavaObject,
however I fail to see how this is used to generate the code.

I am able to get the EditDomain, the ResourceSet and the init code from
the EditPart.

Any ideas?

thanks in advance!
Previous Topic:VE freezes when running from laptop battery
Next Topic:JMenuItems do not display in design view
Goto Forum:

Current Time: Tue May 22 14:19:01 GMT 2018

Powered by FUDForum. Page generated in 0.01721 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top