How add restriction to add a new component [message #901832] |
Tue, 14 August 2012 13:37  |
Eclipse User |
|
|
|
Hi,
I made a new component extending a SashForm, just to start to work with toolkit and window builder. My component just make a new SashForm, but it always do a HORIZONTAL style in the constructor. The component is working!
Now, I want to do some validations when the user try to add a new component in my "SashForm".
How I do that? When the user is trying to add a new component, in the icon of the mouse stay a green or red icon, how can I intercept this?
[]'s
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: How add restriction to add a new component [message #901862 is a reply to message #901859] |
Tue, 14 August 2012 15:22   |
Eclipse User |
|
|
|
If you want to limit number of children, this is actually "component-validator", not "GEF.requestValidator.child", because this is parent imposed limitation, not children.
And parent is actually always accessible, both Info and its toolkit Object.
Here is part of Nebula CompositeTable.
<parameter name="flowContainer.component-validator"><![CDATA[ReflectionUtils.getFullyQualifiedName(component.description.componentClass,false) == 'org.eclipse.swt.widgets.Composite' && container.getChildren().size() < 2]]></parameter>
So, something like "container.getChildren().size() < 2" could work.
Only trick is if we move same component inside, we should not include moving component into these "2" components.
But again, if this is creation, then "component.object === null", i.e. we don't have object yet.
Note that for flow containers "container" and "component" variables are available.
Not "parent" and "child".
Also, "ReflectionUtils.getFullyQualifiedName" is not the best way to check type.
[Updated on: Tue, 14 August 2012 15:23] by Moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.11938 seconds