ComboBoxPropertyDescriptor is not intended to be subclassed [message #22088] |
Mon, 20 July 2009 14:57 |
Tim Costermans Messages: 5 Registered: July 2009 Location: Belgium |
Junior Member |
|
|
I'm currently using a ComboBoxPropertyDescriptor to create a dropdownbox
in a property sheet.
I already found out that the ComboBoxPropertyDescriptor will create a
ComboBoxCellEditor at runtime.
The problem:
I want to create a combobox with for example 3 values: value 1, value 2,
and value 3.
In my case, there is some sort of model were the previous selected state
is stored. For example: value 2 was selected.
I can display a combo box with the 3 values, but I can't change the
selection to value 2.
The ComboBoxPropertyDescriptor class explicitly states to not subclass,
although following subclass would solve my problem:
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor;
import org.eclipse.swt.widgets.Composite;
public class CustomComboBoxPropertyDescriptor extends
ComboBoxPropertyDescriptor {
private int selection = 0;
public CustomComboBoxPropertyDescriptor(Object arg0, String arg1, String[]
arg2) {
super(arg0, arg1, arg2);
}
@Override
public CellEditor createPropertyEditor(Composite parent) {
CellEditor cellEditor = super.createPropertyEditor(parent);
cellEditor.setValue(new Integer(selection));
return cellEditor;
}
public int getSelection() {
return selection;
}
public void setSelection(int selection) {
this.selection = selection;
}
}
How can I solve this issue?
I want to work with the ComboBoxCellEditor in a dynamic way. Alter values
at runtime, but this property descriptor prevents this.
Am I doing something wrong?
In this specific case I have an editor with graphical widgets. Every time
a widget is selected the property sheet is populated with properties a
user can change.
When a new widget is created in the editor, its possible the content (fe.
displayed using a combobox in a property sheet) of an existing widget will
enlarge.
|
|
|
Re: ComboBoxPropertyDescriptor is not intended to be subclassed [message #510255 is a reply to message #22088] |
Tue, 26 January 2010 22:43 |
Eclipse User |
|
|
|
Originally posted by: janila.web.de
> How can I solve this issue?
> I want to work with the ComboBoxCellEditor in a dynamic way. Alter
> values at runtime, but this property descriptor prevents this.
> Am I doing something wrong?
Can only give general advice here. If something is not meant for
subclassing, then composition is the alternative for adding new
functionality. So you could probably write a new class with a member
field ComboBoxPropertyDescriptor and then provide all methods that you
would also use on ComboBoxPropertyDescriptor in which you more or less
directly refer to the inner field. This will include some boiler plate
code but otherwise I would not have any idea.
Regards
jan
|
|
|
|
Powered by
FUDForum. Page generated in 0.03236 seconds