Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » ComboBoxPropertyDescriptor is not intended to be subclassed
ComboBoxPropertyDescriptor is not intended to be subclassed [message #22088] Mon, 20 July 2009 14:57 Go to next message
Tim Costermans is currently offline Tim CostermansFriend
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, it’s 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 Go to previous message
Eclipse UserFriend
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
Re: ComboBoxPropertyDescriptor is not intended to be subclassed [message #510256 is a reply to message #510255] Tue, 26 January 2010 17:52 Go to previous message
Eclipse UserFriend
Originally posted by: janila.web.de

Ups, I answered to an old message...
Previous Topic:How to use Databinding to provide content and labels for editable viewers with calculated values?
Next Topic:Remove an action from a context menu in my editor
Goto Forum:
  


Current Time: Wed Apr 24 14:30:03 GMT 2024

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

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

Back to the top