Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ve-dev] Content pane problem.


Hi Xavier,

What you want can't be completely done with VE until 1.2 comes out.  For this we are doing a lot of work to implement implicit settings which is what you have - the getMainPanel() is an implicit bean that is created by your window.  

Having said that, your XMI does seem wrong.  You have specified the name of the EReference as "contentPane".  The name you want to call it is "mainPanel" and what occurs is that the VE first performs introspection on your Window, see the getMainPanel() method and create a java.beans.PropertyDescriptor (or uses BeanInfo if you have one).  Then the .override is merged in with this and because the feature name is "mainPanel" this meshes up with the introspected one and adds any additional details.  However... because mainPanel has no set method it will be described as a read only feature and what will occur is that you are likely to get an exception thrown by someone trying to set a read only property with VE 1.1 because implicit isn't fully implemented until 1.2, although a lot of this code is released into the CVS HEAD stream.

All you have to do in your code if you want to do something like add something to the mainPanel of a Window is

IJavaInstance window;
IJavaInstance mainPanel = BeanUtilities.getFeatureValue(window,"mainPanel");
IJavaInstance theColorRed = BeanUtilities.createJavaObject("java.awt.Color", window.eResource().getResourceset() , "java.awt.Color.RED");
EStructuralFeature backgroundfSF = mainPanel.getEStructuralFeature("background");
RuledCommandBuilder builder = new RuledCommandBuilder();
builder.applyAttributeSetting(mainPanel,backgroundSF,theColorRed);
editDomain.getCommandStack().execute(builder.getCommand());

Let's assume that window is an instance variable in your class.  With 1.1 the VE realizes that you are setting a property on a property and creates a field for the intermediate which is the mainPanel.  However the allocation given to it is to try and create one for you and it will get an exception when it tries to set the "mainPanel" feature and EMF realizes it is read only.  With 1.2 however it should keep the implicit allocation of getMainPanel() and work.

Best regards,

Joe Winchester

Please respond to Discussions people developing code for the Visual Editor project <ve-dev@xxxxxxxxxxx>

Sent by:        ve-dev-bounces@xxxxxxxxxxx

To:        ve-dev@xxxxxxxxxxx
cc:        
Subject:        [ve-dev] Content pane problem.


Hi, I'm developing a VE extension to be used with a
custom graphic toolkit. It has Window class which has
getMainPanel() method just like
JFrame.getContentPane(), but the problem is it doesn't
allow one to change it so lacks setter method
setMainPanel().

I've declared it as a structural feature in override
file like below :

<event:Add  featureName="eStructuralFeatures">
  <addedEObjects xsi:type="ecore:EReference"
ame="contentPane" unsettable="true">
     <eAnnotations
xsi:type="org.eclipse.ve.internal.jcm:BeanFeatureDecorator"
linkType="CHILD"/>
  </addedEObjects>
</event:Add>

But call to eGet method on Window class model instance
with mainPanel always return null and getMainPanel
method on target VM is never actually called.

When I make corresting setMainPanel method, this
method is called on targetvm, but still the eGet
method always return null.

So if anyone could enlighten me about what am I doing
wrong please? I've digged through the ve-jfc source
but couldn't figure out how they handle the implicit
allocation of contentPanel property.

Thanks in advance,

Xavier Cho


               
                                 
______________________________________________________
Yahoo! for Good
Donate to the Hurricane Katrina relief effort.
http://store.yahoo.com/redcross-donate3/

_______________________________________________
ve-dev mailing list
ve-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ve-dev


Back to the top