Restrict usage of few Palette objects from dropping onto ViewPart canvas [message #1097905] |
Fri, 30 August 2013 10:09 |
Tilak Sharma Messages: 48 Registered: July 2009 |
Member |
|
|
Hi,
We are extending WindowBuilder to contribute our custom UI components (like, CustomCanvas, CustomComboBox, CustomTextBox, CustomRadioButton, etc) into the Palette.
We will be having our CustomCanvas on the ViewPart by default. Now we want to restrict Users from dropping any other existing UI components (Composite, Button, Tree, etc) onto our canvas.
How can we achieve that?
I tried extending the extension point ("org.eclipse.wb.core.editPolicyFactories"), but org.eclipse.wb.core.gef.policy.layout.LayoutPolicyUtils.createLayoutEditPolicy() method returns another LayoutEditPolicy object even before it loops till editPolicyFactory I contributed.
Thanks in anticipation,
Tilak
|
|
|
|
|
|
Re: Restrict usage of few Palette objects from dropping onto ViewPart canvas [message #1099266 is a reply to message #1098911] |
Sun, 01 September 2013 11:59 |
Tilak Sharma Messages: 48 Registered: July 2009 |
Member |
|
|
Hi Konstantin,
In the class MyLayoutEditPolicyFactory, I am creating an anonymous ILayoutRequestValidator like:
ILayoutRequestValidator validator = new ILayoutRequestValidator() {
@Override
public boolean validateCreateRequest(EditPart host, CreateRequest request) {
if (((JavaInfo) request.getSelectObject()).toString().contains("com.sample.custom"))
return true;
return false;
}
.
.
.
}
When I drag any existing component onto ViewPart canvas, it is now showing Red marker on the cursor for existing components and Green marker for my custom components.
Now, when I click on the ViewPart canvas to drop the component (ex, my customComboBox), it gives me a callback to MyLayoutEditPolicyFactory.getCreateCommand(CreateRequest request).
Here I want to return a command that handles this drop and adds it to the Canvas.
That is, I want to reuse existing code or class which does that already.
I see that without my extension point definition, the drop is being handled by FlowContainerLayoutEditPolicy or AbsoluteLayoutEditPolicy. I cannot extend them as they are marked final.
Please suggest.
Thanks,
Tilak
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05251 seconds