Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 317683 - Make the creation of custom Ridgets easier
Summary: Make the creation of custom Ridgets easier
Status: NEW
Alias: None
Product: Riena
Classification: RT
Component: ridget (show other bugs)
Version: unspecified   Edit
Hardware: PC All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-23 07:42 EDT by Steffen Kriese CLA
Modified: 2010-06-23 07:55 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 ?