Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Visual Editor (VE) » Access to a bean property
Access to a bean property [message #110860] Tue, 15 November 2005 16:08 Go to next message
Eclipse UserFriend
Originally posted by: SLENGAIGNE_Prestataire.cofidis.fr

Hello,

First, to visually set a bean property, I have created a DialogCellEditor
(like in the tutorial). My problem is that datas in the dialog are
initialized from an other property of this bean and I don't know how I can
access to this.

Here is the code :

public class ValidatorSelectionLabelEditor extends DialogCellEditor
implements INeedData {

private EditDomain fEditDomain;
protected String stringValue = "";

public ValidatorSelectionLabelEditor(Composite aComposite) {
super(aComposite);
}

private IJavaInstance createStringJavaObject(String aString) {
return BeanUtilities.createJavaObject(
"java.lang.String",
JavaEditDomainHelper.getResourceSet(fEditDomain),
BeanUtilities.createStringInitString(aString)
);
}

/* (non-Javadoc)
* @see
org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org .eclipse.swt.widgets.Control)
*/
protected Object openDialogBox(Control cellEditorWindow) {

Display display = cellEditorWindow.getDisplay();
TitleAreaDialog dialog = new TitleAreaDialog(display.getActiveShell()) {
ValidatorSelectionDialogContent content;
protected Control createContents(Composite parent) {
Control result = super.createContents(parent);
// setTitleImage(CustomWidgetPlugin.getCustomImage());
setTitle("Sélection des Validators");
setMessage("Sélectionnez les règles de validation que vous souhaitez
appliquer sur le champ.", IMessageProvider.INFORMATION);
return result;
}
protected Control createDialogArea(Composite parent) {
content = new ValidatorSelectionDialogContent(parent, SWT.NONE);
// TODO find and set additionnal bean info...
content.setSelectedValues(stringValue);
return content;
}

public String toString() {
return content.getSelectedValues();
}
};


if (dialog.open() != Window.CANCEL)
return createStringJavaObject(dialog.toString());
else
return getValue();
}

/* (non-Javadoc)
* @see
org.eclipse.ve.internal.propertysheet.INeedData#setData(java .lang.Object)
*/
public void setData(Object data) {
fEditDomain = (EditDomain) data;
}

protected void doSetValue(Object value) {
if (value != null){
IStringBeanProxy stringBeanProxy = (IStringBeanProxy)
BeanProxyUtilities.getBeanProxy((IJavaInstance) value);
stringValue = stringBeanProxy.stringValue();
}
super.doSetValue(value);
}
protected void updateContents(Object value) {
super.updateContents(stringValue);
}

}

Thanks for your help,
Simon Lengaigne
Re: Access to a bean property [message #110878 is a reply to message #110860] Tue, 15 November 2005 16:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Your cell editor needs to implement the
org.eclipse.ve.internal.propertysheet.ISourced interface too. You will
be given the source objects in the setSources() method.

The sources is an array because you could of selected more than one
component AND this particular property can handle more than one
component. If the property descriptor for this property said it can only
handle one component, then the property would not be in the property
sheet if multiple components were selected.

--
Thanks,
Rich Kulp
Re: Access to a bean property [message #110888 is a reply to message #110878] Wed, 16 November 2005 10:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: SLENGAIGNE_Prestataire.cofidis.fr

Thanks a lot for your answer ;-)

I have an other question, how can I say that my property can handle only
one component ? I think this is in the override file but I don't have
found which attribute I have to set.

Thanks,
Simon Lengaigne
Re: Access to a bean property [message #110910 is a reply to message #110888] Wed, 16 November 2005 16:02 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Unfortunately at the moment it isn't available for bean properties. We
should of made it available for bean properties too. A bean property is
one that is found from Introspection (i.e. there is a get/set method for
the property on the bean).

In this case you need to have a special BeanPropertyDescriptorAdapter
subclass. This subclass would simply override
isCompatibleWith(IPropertyDescriptor anotherProperty) and always return
false.

You would specify this special adapter in your class' override file.
Take a look at the
org.eclipse.ve.jfc/overrides/java/awt/Component.overrride file. In here
look at the "bounds" property.

<objectsToAttach name="bounds" xmi:id="_eStructuralFeatures"
xsi:type="ecore:EReference">
<eAnnotations
propertyDescriptorClassname=" org.eclipse.ve.jfc/org.eclipse.ve.internal.jfc.core.BoundsPr opertyDescriptor "
xsi:type=" org.eclipse.ve.internal.cde.decorators:PropertyDescriptorInf ormation "/>
</objectsToAttach>

The "propertyDescriptorClassname" defines the property descriptor. Don't
forget to include

xmlns:org.eclipse.ve.internal.cde.decorators="http:///org/eclipse/ve/internal/cde/decorators.ecore"

in the first element of the override file, if not already there.

Simon Lengaigne wrote:
> Thanks a lot for your answer ;-)
>
> I have an other question, how can I say that my property can handle only
> one component ? I think this is in the override file but I don't have
> found which attribute I have to set.
>
> Thanks,
> Simon Lengaigne
>

--
Thanks,
Rich Kulp
Re: Access to a bean property [message #611322 is a reply to message #110860] Tue, 15 November 2005 16:17 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Your cell editor needs to implement the
org.eclipse.ve.internal.propertysheet.ISourced interface too. You will
be given the source objects in the setSources() method.

The sources is an array because you could of selected more than one
component AND this particular property can handle more than one
component. If the property descriptor for this property said it can only
handle one component, then the property would not be in the property
sheet if multiple components were selected.

--
Thanks,
Rich Kulp
Re: Access to a bean property [message #611323 is a reply to message #110878] Wed, 16 November 2005 10:12 Go to previous message
Simon Lengaigne is currently offline Simon LengaigneFriend
Messages: 9
Registered: July 2009
Junior Member
Thanks a lot for your answer ;-)

I have an other question, how can I say that my property can handle only
one component ? I think this is in the override file but I don't have
found which attribute I have to set.

Thanks,
Simon Lengaigne
Re: Access to a bean property [message #611325 is a reply to message #110888] Wed, 16 November 2005 16:02 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Unfortunately at the moment it isn't available for bean properties. We
should of made it available for bean properties too. A bean property is
one that is found from Introspection (i.e. there is a get/set method for
the property on the bean).

In this case you need to have a special BeanPropertyDescriptorAdapter
subclass. This subclass would simply override
isCompatibleWith(IPropertyDescriptor anotherProperty) and always return
false.

You would specify this special adapter in your class' override file.
Take a look at the
org.eclipse.ve.jfc/overrides/java/awt/Component.overrride file. In here
look at the "bounds" property.

<objectsToAttach name="bounds" xmi:id="_eStructuralFeatures"
xsi:type="ecore:EReference">
<eAnnotations
propertyDescriptorClassname=" org.eclipse.ve.jfc/org.eclipse.ve.internal.jfc.core.BoundsPr opertyDescriptor "
xsi:type=" org.eclipse.ve.internal.cde.decorators:PropertyDescriptorInf ormation "/>
</objectsToAttach>

The "propertyDescriptorClassname" defines the property descriptor. Don't
forget to include

xmlns:org.eclipse.ve.internal.cde.decorators="http:///org/eclipse/ve/internal/cde/decorators.ecore"

in the first element of the override file, if not already there.

Simon Lengaigne wrote:
> Thanks a lot for your answer ;-)
>
> I have an other question, how can I say that my property can handle only
> one component ? I think this is in the override file but I don't have
> found which attribute I have to set.
>
> Thanks,
> Simon Lengaigne
>

--
Thanks,
Rich Kulp
Previous Topic:VE
Next Topic:Error trying to set new file into editor - NullPointerException
Goto Forum:
  


Current Time: Fri Apr 26 19:23:56 GMT 2024

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

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

Back to the top