Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 317683

Summary: Make the creation of custom Ridgets easier
Product: [RT] Riena Reporter: Steffen Kriese <steffen.kriese>
Component: ridgetAssignee: Project Inbox <riena.ui-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: christian.campo
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard:

Description Steffen Kriese CLA 2010-06-23 07:42:47 EDT
In an Riena-application we often have e.g. TextRidgets with specific a configuration for let's say a postcalcode. So we would like to write our own NumericTextRidget that is limited to 5 digits, shows a warning when the text is shorter than the 5 digits. 
At the moment this can be accomplished by following these steps:

1. extend the NumericTextRidget and set all the properties we need in the constructor

2. register the PostcalCodeRidget by calling SwtControlRidgetMapper.getInstance().addMapping(Text.class, PostalcodeTextRidget.class,
				new TypedTextWidgetCondition(UIControlsFactory.TYPE_POSTALCODE));
				
3. In our CustomUIControlsFactory we have to create a method like:

public static Text createPostcalcodeText(Composite parent, String bindingId) {
		Text text = createTextNumeric(parent, bindingId);
		text.setData(KEY_TYPE, TYPE_POSTALCODE);
		return text;
}

and mark our text widget with a KEY_TYPE, so the RidgetMapper knows when to create a standard NumericTextRidget or a PostalcodeRidget.

I think the possibility to create custom Ridgets by just writing a couple of lines of code is a huge benefit. At the moment this is only possible by using internal API (the ridgets itself, TypedTextWidgetCondition is final and internal). So I would like to see this as an official feature in Riena with a well defined API. Maybe we could haven extensionpoint to define custom ridgets.
Comment 1 Christian Campo CLA 2010-06-23 07:55:58 EDT
Couldnt you write a factory that just does that like

MyUIControlsFactory.createPostalCode()

and then the factory does all the tricks and changes and settings without subclassing anything and with using internal API ?