Restrict usage of few Palette objects from dropping onto ViewPart canvas [message #1097905] |
Fri, 30 August 2013 06:09  |
Eclipse User |
|
|
|
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 07:59   |
Eclipse User |
|
|
|
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
|
|
|
|
Re: Restrict usage of few Palette objects from dropping onto ViewPart canvas [message #1110662 is a reply to message #1099403] |
Tue, 17 September 2013 02:43  |
Eclipse User |
|
|
|
Hi Konstantin,
I am able to show only my Custom components in the Palette now. I achieved that by having a file org.eclipse.wb.rcp.wbp-palette-commands.xml under wbp-meta folder apart from org.eclipse.wb.rcp.wbp-palette.xml.
In this file (org.eclipse.wb.rcp.wbp-palette-commands.xml), I have the the commands to remove the existing categories, so that everytime I launch the WindowBuilder editor, I will see only the category of custom components I contributed.
Thanks,
Tilak
|
|
|
Powered by
FUDForum. Page generated in 0.04538 seconds