Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » ComboBox in Properties View
ComboBox in Properties View [message #236870] Tue, 10 July 2007 10:20 Go to next message
Eclipse UserFriend
Originally posted by: neliacatarina.portugalmail.pt

Hi

I want to put a combobox in one of the lines of my properties view. I have this:

public static String[] tokens = {"test1","test2"};

static {
descriptors = new IPropertyDescriptor[] {
new TextPropertyDescriptor(NAME, "Name"),
new ComboBoxPropertyDescriptor(TOKEN, "Inicial Place",
tokens),
};
}

...

public Object getPropertyValue(Object propName) {
if (NAME.equals(propName))
return getName();
if (TOKEN.equals(propName)){
return getTokens();
}
return super.getPropertyValue(propName);
}

where getTokens() returns an array of Strings.
I can't see any combobox when I run it. Can you tell me what am I doing wrong?
Thanks
Re: ComboBox in Properties View [message #236876 is a reply to message #236870] Tue, 10 July 2007 14:43 Go to previous messageGo to next message
Anthony Hunter is currently offline Anthony HunterFriend
Messages: 446
Registered: July 2009
Senior Member
Hi Nelia,

Put a breakpoint in PropertySheetPage or PropertySheetEntry to make sure
both IPropertyDescriptor are being retrieved when your object is selected
and that the child property entries are being created.

Cheers...
Anthony

"Nelia Santos" <neliacatarina@portugalmail.pt> wrote in message
news:929891982.4071184062877252.JavaMail.root@cp9.dzone.com...
> Hi
>
> I want to put a combobox in one of the lines of my properties view. I have
> this:
>
> public static String[] tokens = {"test1","test2"};
>
> static {
> descriptors = new IPropertyDescriptor[] {
> new TextPropertyDescriptor(NAME, "Name"),
> new ComboBoxPropertyDescriptor(TOKEN, "Inicial Place",
> tokens),
> };
> }
>
> ..
>
> public Object getPropertyValue(Object propName) {
> if (NAME.equals(propName))
> return getName();
> if (TOKEN.equals(propName)){
> return getTokens();
> }
> return super.getPropertyValue(propName);
> }
>
> where getTokens() returns an array of Strings.
> I can't see any combobox when I run it. Can you tell me what am I doing
> wrong?
> Thanks
Re: ComboBox in Properties View [message #236929 is a reply to message #236870] Fri, 13 July 2007 18:15 Go to previous message
Eclipse UserFriend
Originally posted by: vaceslav.ustinov.gmail.com

Hi,

You have an Error in your getPropertyValue() function.

The return value of getPropertyValue must be an "int"-value, this is the index of your array.

In your example for test1 you must return "0" and for test2 "1".

apply for the function setPropertyValue() the same.


See my example.


public void initProperty(){

.....
.....
String[] values = { "false", "true" };
PropertyDescriptor comboBoxPropertyDescriptor = new ComboBoxPropertyDescriptor("PropertyId", "PropertyLabel", values);
comboBoxPropertyDescriptor.setCategory("Basic");
.....
.....
}


public Object getPropertyValue(Object id) {
if (id.equals("PropertyId"){
if (booleanFunction())
return 1;
else
return 0;
}
}


public void setPropertyValue(Object id, Object value) {
if (id.equals("PropertyId"){
setPropertyValue((Integer)value);
}
}



public void setPropertyValue(Integer value) {
if (value.intValue() == 1)
this.booleanVar = true;
else if (value.intValue() == 0)
this.booleanVar = false;
firePropertyChange("PropertyId", null, value);
}

Regards.
Vaceslav Ustinov

Nelia Santos schrieb:
> Hi
>
> I want to put a combobox in one of the lines of my properties view. I have this:
>
> public static String[] tokens = {"test1","test2"};
>
> static {
> descriptors = new IPropertyDescriptor[] {
> new TextPropertyDescriptor(NAME, "Name"),
> new ComboBoxPropertyDescriptor(TOKEN, "Inicial Place",
> tokens),
> };
> }
>
> ..
>
> public Object getPropertyValue(Object propName) {
> if (NAME.equals(propName))
> return getName();
> if (TOKEN.equals(propName)){
> return getTokens();
> }
> return super.getPropertyValue(propName);
> }
>
> where getTokens() returns an array of Strings.
> I can't see any combobox when I run it. Can you tell me what am I doing wrong?
> Thanks
Previous Topic:Ctrl+C and Ctrl+V not working
Next Topic:Hovered Figure/EditPart
Goto Forum:
  


Current Time: Tue Aug 09 13:53:01 GMT 2022

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

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

Back to the top