Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[ve-dev] RE: Sweet BeanInfo for SWT

Title: Message
 
Thanks for this - it's what I figured from the spec but I wanted to check first just to see some code.

Two points:
First - I don't think we should use a property descriptor.  It's not really a property per say, there is no getter or setter.  Right now you can create a java.beans.PropertyDescriptor with no get and set method, but this is not guaranteed to always be that way.  It's just internal code that doesn't enforce either at   least a read or write method.  Instead I think it should be a key value on the BeanDescriptor itself.  
There are 3 kinds of "properties" you have to deal with in SWT:
 
- Traditional JavaBeans properties
- Style bit properties
- Public fields
 
The idea with the current spec is to define a way that lets the builder treat all 3 the same as much as possible.
 
I'm not sure I see a good reason here to abandon this?
For the property sheet it'd be nice if the style bites were categorized into families,  so it could show
style         ->  Push,  Arrow, Toggle, Radio, Flat
alignment -> Left, Right, Center,
arrowStyle -> Up, Down, Left, Right 
I agree here. 
 something like

public BeanDescriptor getBeanDescriptor(){
  BeanDescriptor result = new BeanDescriptor(Button.class)
  result.setValue("CONSTRUCTOR_STYLE_BITS"){
    new Object[][]{
      "style"  , new Object[] {
          "arrow" , "org.eclipse.swt.SWT.ARROW" , new Integer(SWT.ARROW) ,
          "push" , "org.eclipse.swt.SWT.PUSH" , new Integer(SWT.PUSH),
          "toggle" , "org.eclipse.swt.SWT.TOGGLE" , new Integer(SWT.TOGGLE) ,
          "flat" , "org.eclipse.swt.SWT.FLAT" , new Integer(SWT.FLAT) ,
          "radio" , "org.eclipse.swt.SWT.RADIO" , new Integer(SWT.RADIO) } ,
      "alignment" , new Object[] {
          "left" , "org.eclipse.swt.SWT.LEFT" , new Integer(SWT.LEFT) ,
          "right" , "org.eclipse.swt.SWT.RIGHT" , new Integer(SWT.RIGHT) ,
          "center" , "org.eclipse.swt.SWT.CENTER" , new Integer(SWT.CENTER)  } ,
      "arrowDirection", new Object[] {
          "up" , "org.eclipse.swt.SWT.UP" , new Integer(SWT.UP)   ,
          "left" , "org.eclipse.swt.SWT.LEFT" , new Integer(SWT.LEFT)  ,
          "right" , "org.eclipse.swt.SWT.RIGHT" , new Integer(SWT.RIGHT)  } ,
     }
    }
  }
  return result;
}

This gives people the option of having the property sheet put the properties into families.

Another subtle change is to fully qualify the code generation string - the tool can de-qualify it if it wants to. 
This is a good idea too.
For the VE we won't use the actual value itself because it is in the wrong VM, but it is nice to have it for people that want it.  This can be qualified because the BeanInfo can import org.eclipse.swt.*;

I wanted to run these ideas past you before having this discussion on the ve-dev group just to make sure I understood the current spec OK.    Do you want me to post this note pretty much as is to the newsgroup ? 
Sure, it's better to have these conversations in the open.  In fact, I'll just add ve-dev to the CC list right now.
 The timing of this is because we are just about to hit a deadline for NLS'd strings, and the labels such as "arrow" we would externalize and translate into other languages.  
 
Cool, thanks.
 
 
Warmest regards,
 
Dave Orme
 

Best regards,

Joe Winchester

To:        Joe Winchester/UK/IBM@IBMGB
cc:        
Subject:        RE: Sweet BeanInfo for SWT


Joe,
 
Here's an example of how to specify a style bits property for a Button:
 
Assuming you've already created your PropertyDescriptor:
 
// org.eclipse.swt.widgets.Button style bits:
propertyDescriptor.setValue("isStyleBit", new Boolean(true));
enumerationValues = new Object[] {"ARROW",
    new Integer(SWT.ARROW),
    "SWT.ARROW",
    "CHECK",
    new Integer(SWT.CHECK),
    "SWT.CHECK",

     "PUSH",
    new Integer(SWT.PUSH),
    "SWT.PUSH",

     "RADIO",
    new Integer(SWT.RADIO),
    "SWT.RADIO",

     "TOGGLE",
    new Integer(SWT.TOGGLE),
    "SWT.TOGGLE",

     "FLAT",
    new Integer(SWT.FLAT),
    "SWT.FLAT",

     "UP",
    new Integer(SWT.UP),
    "SWT.UP",

     "DOWN",
    new Integer(SWT.DOWN),
    "SWT.DOWN",

     "LEFT",
    new Integer(SWT.LEFT),
    "SWT.LEFT",

     "RIGHT",
    new Integer(SWT.RIGHT),
    "SWT.RIGHT",

     "CENTER",
    new Integer(SWT.CENTER),
    "SWT.CENTER",

};
propertyDescriptor.setValue("enumerationValues", enumerationValues);
 
 
Does this make sense?
 
 
Dave
-----Original Message-----
From:
Joe Winchester [mailto:WINCHEST@xxxxxxxxxx]
Sent:
Monday, March 01, 2004 7:06 AM
To:
Dave Orme
Subject:
Sweet BeanInfo for SWT


Hi Dave,


For the SWT VE I am looking now at constructor style bits.  I've read the Sweet requirements doc, but what I'd really like to get my head around is a concrete example.  Do you have a BeanInfo that I could take a look at for say Button or Composite or any other SWT control.


Best regards,


Joe



Back to the top