Home » Eclipse Projects » WindowBuilder » How add restriction to delete a component
| | | | | | | |
Re: How add restriction to delete a component [message #902270 is a reply to message #902254] |
Thu, 16 August 2012 16:51   |
Eclipse User |
|
|
|
I implement this on *.wbp-component.xml
<parameter name="canDelete">isComponentType(object.getParent(),'com.test.fw.wb.mvc.core.VerticalBox')</parameter>
I saw that in the variable object, the script put the Info object, in org.eclipse.wb.internal.core.model.JavaInfoUtils.executeScript(JavaInfo, String)
Is wrong what I've done? Because always return false.
To understand, the object just can be deleted if it parent is a VerticalBox...
|
|
|
Re: How add restriction to delete a component [message #902273 is a reply to message #902270] |
Thu, 16 August 2012 17:41   |
Konstantin Scheglov Messages: 555 Registered: July 2009 |
Senior Member |
|
|
IIRC "isComponentType" is available only for flow/simple containers.
And if there is any error in "canDelete" script, we consider this as "false".
In other scripts you have only ReflectionUtils class.
But actually all this can be done using ReflectionUtils, see org.eclipse.wb.internal.core.model.generic.ContainerObjectValidators.DEF_functions
private static final String DEF_functions = StringUtils.join(new String[]{
"def isModelType(model, c) {",
" if (c is String) {",
" return ReflectionUtils.isSuccessorOf((Class) model.description.componentClass, c);",
" } else {",
" return c.isAssignableFrom(model.description.componentClass);",
" }",
"};",
"def isSuccessorOf(o, c) {",
" if (c is String) {",
" return ReflectionUtils.isSuccessorOf(o, c);",
" } else {",
" return o != null && c.isAssignableFrom(o.getClass());",
" }",
"};",
"def isComponentType(c) {",
" return isModelType(component, c);",
"};",
"def isReferenceType(c) {",
" return isModelType(reference, c);",
"};",
"def isContainerType(c) {",
" return isModelType(container, c);",
"};",
"def isContainerThis() {",
" return isSuccessorOf(container.creationSupport, "
+ "'org.eclipse.wb.internal.core.model.creation.ThisCreationSupport');",
"};",}, "\n");
Konstantin Scheglov,
Google, Inc.
[Updated on: Thu, 16 August 2012 17:41] Report message to a moderator
|
|
|
Re: How add restriction to delete a component [message #902275 is a reply to message #902273] |
Thu, 16 August 2012 17:55   |
Eclipse User |
|
|
|
Ok..
I saw the source code and the default value and the return if it not found the script, shouldn't be true? Actually is false, but if it don't find it return false, and the canDelete() return false without verify the other conditions...
And how can I make de restriction, I don't understand what you say...
It's worng this:
<parameter name="canDelete"><![CDATA[
isComponentType(object.getParent(),"com.test.fw.wb.mvc.core.VerticalBox")]]>
</parameter>
|
|
| | | |
Goto Forum:
Current Time: Fri Feb 07 09:20:23 GMT 2025
Powered by FUDForum. Page generated in 0.07540 seconds
|