Access to a bean property [message #611321] |
Tue, 15 November 2005 16:08 |
Simon Lengaigne Messages: 9 Registered: July 2009 |
Junior Member |
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.02763 seconds