Partially solved the problem to show variables in the properties sheet. [message #17180] |
Wed, 28 January 2004 09:55  |
Eclipse User |
|
|
|
Hi!.
I've partially solved the problem to show variables in the properties
sheet.
But now I have another problem.
But first, I comment the procedure that I did:
* I've a class named MyClass.
* This class is in a package named com.utils.
Then:
* I've changed the org.eclipse.ve.jfc_0.5.0/plugin.xml file. I added this
lines:
<override package="com.utils"
path="platform:/plugin/org.eclipse.ve.jfc/overrides/com/utils " />
* I create a new subdirectory tree in the overrides directory:
eclipse
plugins
org.eclipse.ve.jfc_0.5.0
overrides
com
utils
* In the utils subdirectoy I've created a new file named MyClass.override
with this lines:
<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:org.eclipse.ve.internal.cde.decorators="http:///org/eclipse/ve/internal/cde/decorators.ecore"
xmlns:org.eclipse.ve.internal.cde.utility="http:///org/eclipse/ve/internal/cde/utility.ecore"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:event="event.xmi">
<event:Add featureName="eAnnotations">
<addedEObjects
xsi:type=" org.eclipse.ve.internal.cde.decorators:ClassDescriptorDecora tor "
labelProviderClassname=" org.eclipse.ve.java.core/org.eclipse.ve.internal.java.core.D efaultLabelProviderWithNameAndAttribute:label ">
<graphic
xsi:type="org.eclipse.ve.internal.cde.utility:GIFFileGraphic "
resourceName=" platform:/plugin/org.eclipse.ve.jfc/icons/full/clcl16/checkb ox_obj.gif "/>
</addedEObjects>
</event:Add>
<event:Add featureName="eReferences">
<addedEObjects xsi:type="ecore:EReference" name="myPropertie"
unsettable="true">
<eAnnotations
xsi:type=" org.eclipse.ve.internal.cde.decorators:BasePropertyDecorator "
labelProviderClassname=" org.eclipse.ve.java.core/org.eclipse.ve.internal.java.vce.Ja vaBeanLabelProvider "
cellEditorClassname=" org.eclipse.ve.java.core/org.eclipse.ve.internal.java.vce.Me mberJavaBeanCellEditor:javax.swing.JComponent "/>
</addedEObjects>
</event:Add>
</xmi:XMI>
This code is modified from CheckBox.override file. Can be see that appears
a checkbox_obj.gif file.
* With this, I've a JavaBean with a 'myPropertie' property (the get and
set methods exists in MyClass.java file) that shows all variables of
JComponent type that appears in my form.
But I've anothers problems:
First: If I've created and object directly as:
Button myButton = new Button();
When I added this component throught properties sheet VE added similar
lines as:
myObject.add(myButton());
It thinks that myButton is a method instead a variable name.
Why I can do that VE don't write parenthesis characters?
Second: When I've a object (as JPanel) that can receive a Border object as
parameter, the propeties sheet opens a Border Editor dialog.
Why I can do that this Border Editor dialog not appears and the property
acts as the other properties that I've modified?
Note: I don't want to open my own dialog (to do this I can use the
setPropertyEditorClass method).
I want that the property shows a combo with all the variable borders that
are in my form (as if a property anyone it be).
Many thanks.
|
|
|
|
|
Re: Partially solved the problem to show variables in the properties sheet. [message #17754 is a reply to message #17180] |
Thu, 29 January 2004 06:06   |
Eclipse User |
|
|
|
Hi David,
The Visual Editor internally uses EMF representations of the class that is a combination of introspected details plus any overrides.
You've successfuly use the overrides extension point to tell the VE where to look for XMI override files for your package. The
override file lets you specify things that are inside the IDE, such as cell editors, label provides, GEF edit parts, etc... The
BeanInfo lets you specify things that run in the JavaBeans VM and are part of the BeanInfo spec - so it's basically stuff in the
java.beans package that makes no assumption about being inside the VE versus inside any other builder.
> * With this, I've a JavaBean with a 'myPropertie' property (the get and
> set methods exists in MyClass.java file) that shows all variables of
> JComponent type that appears in my form.
Yes, MemberJavaBeanCellEditor:JComponent is picked up as the cell editor, so what happens is that the property sheet uses this instead
of using a java.beans.PropertyEditor. Because this editor runs inside Eclipse it can have access to model data. The :JComponent is
the initializationData (if you look at the source code for MemberJavaBeanCellEditor it is passed into the setInitializationData(...)
method) and the editor shows all JComponents. I'm not sure whether you will get JComponents that are children of other ones, but I
think you will because in the VE model all components are themselves top level members, and child relationships are by reference and
not containment.
> But I've anothers problems:
>
> First: If I've created and object directly as:
>
> Button myButton = new Button();
>
> When I added this component throught properties sheet VE added similar
> lines as:
>
> myObject.add(myButton());
>
> It thinks that myButton is a method instead a variable name.
> Why I can do that VE don't write parenthesis characters?
I'm surprised that the cell editor even shows myButton as being selectable unless there is a myButton() method. The myButton() method
is there because the VE needs to know what method initializes each JavaBean - this is the same one that is used to generate the set
methods when property values are changed (such as the text property to the button's label). Right now the VE doesn't really support
fields being initialized in their field declarations (as you have done) and also by using the get method rather than a direct field
reference does ensure that the field will have been propertly instantiated and initialized.
> Second: When I've a object (as JPanel) that can receive a Border object as
> parameter, the propeties sheet opens a Border Editor dialog.
>
> Why I can do that this Border Editor dialog not appears and the property
> acts as the other properties that I've modified?
>
> Note: I don't want to open my own dialog (to do this I can use the
> setPropertyEditorClass method).
> I want that the property shows a combo with all the variable borders that
> are in my form (as if a property anyone it be).
You could do the same that you have done already, and create an XMI file for JComponent. You would have to define an extension package
for javax.swing pointing to your /overrides directory. The VE works OK with a package being overriden several times, and your override
should be applied on top of the base one. Then you could have a cell editor that was similar to the MemberJavaBeanCellEditor. However
right now the MemberJavaBeanCellEditor (or any other one for that matter) only works against stuff that has been successfully parsed
into the model from the source. Right now non-visual components (of which javax.swing.Border is one) is only parsed if the field name
starts with ivj.
What you've done is sort of stumbled across the internal API that the VE uses for allowing it to be extended. However, be aware that
this is just something we developed at IBM before the VE became open-source and it's not our intention to support or publish this API
as is - we want to design a better one that the VE project supports going forward.
Best regards,
Joe Winchester
|
|
|
|
|
|
Layout Cell Editor obtained but VE writes incorrect code. [message #17770 is a reply to message #17767] |
Mon, 02 February 2004 03:16  |
Eclipse User |
|
|
|
Hi!.
I use TFrame class that extends from JFrame, and the BeanInfo class has
this property:
PropertyDescriptor Layout = new PropertyDescriptor("Layout", cls);
('cls' is the class with the functional code).
I created mi own .override file for the class thar use Layout property
with this code:
TFrame.override:
<?xml version="1.0" encoding="UTF-8"?><xmi:XMI xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:org.eclipse.ve.internal.cde.decorators="http:///org/eclipse/ve/internal/cde/decorators.ecore"
xmlns:org.eclipse.ve.internal.cde.utility="http:///org/eclipse/ve/internal/cde/utility.ecore"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:event="event.xmi"><event:Add
featureName="eReferences"><addedEObjects xsi:type="ecore:EReference"
name="Layout" unsettable="true"><eAnnotations
xsi:type=" org.eclipse.ve.internal.cde.decorators:BasePropertyDecorator "
labelProviderClassname=" org.eclipse.ve.java.core/org.eclipse.ve.internal.java.vce.Ja vaBeanLabelProvider "
cellEditorClassname=" org.eclipse.ve.jfc/org.eclipse.ve.internal.jfc.core.LayoutMa nagerCellEditor "/></addedEObjects></event:Add></xmi:XMI>
With this, the property shows me a combo with the possibles layouts (as
the original layout) but... when I change the property VE writes:
tFrame.setLayout(new java.awt.FlowLayout());
instead of:
tFrame.getContentPane().setLayout(new java.awt.FlowLayout());
ans shows me an error.
¿Why can I do that VE writes the corrected line of code?
Many thanks.
|
|
|
Re: Partially solved the problem to show variables in the properties sheet. [message #579816 is a reply to message #17180] |
Thu, 29 January 2004 02:30  |
Eclipse User |
|
|
|
Hi David,
> Second: When I've a object (as JPanel) that can receive a Border object as
> parameter, the propeties sheet opens a Border Editor dialog.
>
> Why I can do that this Border Editor dialog not appears and the property
> acts as the other properties that I've modified?
>
> Note: I don't want to open my own dialog (to do this I can use the
> setPropertyEditorClass method).
> I want that the property shows a combo with all the variable borders that
> are in my form (as if a property anyone it be).
>
I haven't tried it, but I think you should override the BeanInfo for your
class and specify either "enumerationValues" so it could be listed as a
combo (but then you should have only fixed values) or a PropertyDescriptor
class that returns a list of values (@see
java.beans.PropertyEditorSupport#getTags()).
I think the second option is preferable.
Hope that helps,
S
|
|
|
I can't use the getTags method. [message #579823 is a reply to message #17321] |
Thu, 29 January 2004 03:43  |
Eclipse User |
|
|
|
Hi.
If I use the option to use getTags method I lose the capability to show
variables in the property sheet because I can't read the source code of
the class. I need that the border property does nothing by default (as the
other properties of my bean that receibes objects as JButton, JPanel...)
to be able to use the solution to show variables names in the property
sheet.
Many thanks for yout cooperation.
Sébastien Alonzo wrote:
> Hi David,
> > Second: When I've a object (as JPanel) that can receive a Border object as
> > parameter, the propeties sheet opens a Border Editor dialog.
> >
> > Why I can do that this Border Editor dialog not appears and the property
> > acts as the other properties that I've modified?
> >
> > Note: I don't want to open my own dialog (to do this I can use the
> > setPropertyEditorClass method).
> > I want that the property shows a combo with all the variable borders that
> > are in my form (as if a property anyone it be).
> >
> I haven't tried it, but I think you should override the BeanInfo for your
> class and specify either "enumerationValues" so it could be listed as a
> combo (but then you should have only fixed values) or a PropertyDescriptor
> class that returns a list of values (@see
> java.beans.PropertyEditorSupport#getTags()).
> I think the second option is preferable.
> Hope that helps,
> Sébastien.
|
|
|
Re: Partially solved the problem to show variables in the properties sheet. [message #579835 is a reply to message #17180] |
Thu, 29 January 2004 06:06  |
Eclipse User |
|
|
|
Hi David,
The Visual Editor internally uses EMF representations of the class that is a combination of introspected details plus any overrides.
You've successfuly use the overrides extension point to tell the VE where to look for XMI override files for your package. The
override file lets you specify things that are inside the IDE, such as cell editors, label provides, GEF edit parts, etc... The
BeanInfo lets you specify things that run in the JavaBeans VM and are part of the BeanInfo spec - so it's basically stuff in the
java.beans package that makes no assumption about being inside the VE versus inside any other builder.
> * With this, I've a JavaBean with a 'myPropertie' property (the get and
> set methods exists in MyClass.java file) that shows all variables of
> JComponent type that appears in my form.
Yes, MemberJavaBeanCellEditor:JComponent is picked up as the cell editor, so what happens is that the property sheet uses this instead
of using a java.beans.PropertyEditor. Because this editor runs inside Eclipse it can have access to model data. The :JComponent is
the initializationData (if you look at the source code for MemberJavaBeanCellEditor it is passed into the setInitializationData(...)
method) and the editor shows all JComponents. I'm not sure whether you will get JComponents that are children of other ones, but I
think you will because in the VE model all components are themselves top level members, and child relationships are by reference and
not containment.
> But I've anothers problems:
>
> First: If I've created and object directly as:
>
> Button myButton = new Button();
>
> When I added this component throught properties sheet VE added similar
> lines as:
>
> myObject.add(myButton());
>
> It thinks that myButton is a method instead a variable name.
> Why I can do that VE don't write parenthesis characters?
I'm surprised that the cell editor even shows myButton as being selectable unless there is a myButton() method. The myButton() method
is there because the VE needs to know what method initializes each JavaBean - this is the same one that is used to generate the set
methods when property values are changed (such as the text property to the button's label). Right now the VE doesn't really support
fields being initialized in their field declarations (as you have done) and also by using the get method rather than a direct field
reference does ensure that the field will have been propertly instantiated and initialized.
> Second: When I've a object (as JPanel) that can receive a Border object as
> parameter, the propeties sheet opens a Border Editor dialog.
>
> Why I can do that this Border Editor dialog not appears and the property
> acts as the other properties that I've modified?
>
> Note: I don't want to open my own dialog (to do this I can use the
> setPropertyEditorClass method).
> I want that the property shows a combo with all the variable borders that
> are in my form (as if a property anyone it be).
You could do the same that you have done already, and create an XMI file for JComponent. You would have to define an extension package
for javax.swing pointing to your /overrides directory. The VE works OK with a package being overriden several times, and your override
should be applied on top of the base one. Then you could have a cell editor that was similar to the MemberJavaBeanCellEditor. However
right now the MemberJavaBeanCellEditor (or any other one for that matter) only works against stuff that has been successfully parsed
into the model from the source. Right now non-visual components (of which javax.swing.Border is one) is only parsed if the field name
starts with ivj.
What you've done is sort of stumbled across the internal API that the VE uses for allowing it to be extended. However, be aware that
this is just something we developed at IBM before the VE became open-source and it's not our intention to support or publish this API
as is - we want to design a better one that the VE project supports going forward.
Best regards,
Joe Winchester
|
|
|
Re: Partially solved the problem to show variables in the properties sheet. [message #579869 is a reply to message #17754] |
Thu, 29 January 2004 07:25  |
Eclipse User |
|
|
|
Many thanks for you information.
During this time I'm investigating and I change the method to obtain the
variables names.
Example:
I 've an object name myPersonalObject with a method that receives a
JButton.
Instead write a file name MyPersonalObject.override with the name of the
method that must show variable names I rewrite the JButton.override file
and add similar lines:
<event:Add featureName="eAnnotations">
<addedEObjects
xsi:type=" org.eclipse.ve.internal.cde.decorators:BasePropertyDecorator "
labelProviderClassname=" org.eclipse.ve.java.core/org.eclipse.ve.internal.java.vce.Ja vaBeanLabelProvider "
cellEditorClassname=" org.eclipse.ve.java.core/org.eclipse.ve.internal.java.vce.Me mberJavaBeanCellEditor:javax.swing.JButton "/>
</event:Add>
</xmi:XMI>
With this change, all JavaBeans with methods that return/receives a
JButton as parameter show variables name of previous declarated JButton
objects in the properties sheet.
But now, I've other problem.
My JavaBean has a get/set method that uses a layout as parameter. This
property must do just like the original Layout prooperty and shows
available dafault layouts. But a LayoutMager.override file doesn't exist
and I don't know the lines that I must write within.
Many thanks again.
|
|
|
About the border [message #579886 is a reply to message #17754] |
Thu, 29 January 2004 07:28  |
Eclipse User |
|
|
|
Hi.
I've rewrite the file Border.override and I've can eliminate the Border
Editor and do that this property type shows equals that other properties
that receives objects as JLabel, JPanel...
|
|
|
Re: Partially solved the problem to show variables in the properties sheet. [message #579903 is a reply to message #17761] |
Fri, 30 January 2004 06:35  |
Eclipse User |
|
|
|
Hi David,
> But now, I've other problem.
> My JavaBean has a get/set method that uses a layout as parameter. This
> property must do just like the original Layout prooperty and shows
> available dafault layouts. But a LayoutMager.override file doesn't exist
> and I don't know the lines that I must write within.
You are definitely going where angels fear to tread. Totally unsupported answers here but I don't want to leave you in the lurch.
I think there is no need for a LayoutManager.xmi file. This would only be needed it you wanted to do something special to
LayoutManager. What you want to do is something special to the "layout" property on your JavaBean. This is similar to how the
cell editor is defined for the checkboxGroup property in java/awt/Checkbox. I'm missing something here, but why do you need to
override LayoutManager.XMI as opposed to just put the cell editor on the layout property of your JavaBean ?
Best regards,
Joe
|
|
|
Layout Cell Editor obtained but VE writes incorrect code. [message #579919 is a reply to message #17767] |
Mon, 02 February 2004 03:16  |
Eclipse User |
|
|
|
Hi!.
I use TFrame class that extends from JFrame, and the BeanInfo class has
this property:
PropertyDescriptor Layout = new PropertyDescriptor("Layout", cls);
('cls' is the class with the functional code).
I created mi own .override file for the class thar use Layout property
with this code:
TFrame.override:
<?xml version="1.0" encoding="UTF-8"?><xmi:XMI xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:org.eclipse.ve.internal.cde.decorators="http:///org/eclipse/ve/internal/cde/decorators.ecore"
xmlns:org.eclipse.ve.internal.cde.utility="http:///org/eclipse/ve/internal/cde/utility.ecore"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:event="event.xmi"><event:Add
featureName="eReferences"><addedEObjects xsi:type="ecore:EReference"
name="Layout" unsettable="true"><eAnnotations
xsi:type=" org.eclipse.ve.internal.cde.decorators:BasePropertyDecorator "
labelProviderClassname=" org.eclipse.ve.java.core/org.eclipse.ve.internal.java.vce.Ja vaBeanLabelProvider "
cellEditorClassname=" org.eclipse.ve.jfc/org.eclipse.ve.internal.jfc.core.LayoutMa nagerCellEditor "/></addedEObjects></event:Add></xmi:XMI>
With this, the property shows me a combo with the possibles layouts (as
the original layout) but... when I change the property VE writes:
tFrame.setLayout(new java.awt.FlowLayout());
instead of:
tFrame.getContentPane().setLayout(new java.awt.FlowLayout());
ans shows me an error.
¿Why can I do that VE writes the corrected line of code?
Many thanks.
|
|
|
Powered by
FUDForum. Page generated in 0.09352 seconds