| Restrict usage of few Palette objects from dropping onto ViewPart canvas [message #1097905] |
Fri, 30 August 2013 06:09  |
Tilak Sharma Messages: 45 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 #1098173 is a reply to message #1097905] |
Fri, 30 August 2013 14:27   |
Konstantin Scheglov Messages: 554 Registered: July 2009 |
Senior Member |
|
|
1. You probably want to rise priority for your layout factory.
<!-- ======================================================== -->
<!-- GEF factories -->
<!-- ======================================================== -->
<extension point="org.eclipse.wb.core.editPartFactories">
<factory class="org.eclipse.wb.internal.rcp.nebula.gef.EditPartFactory" priority="1"/>
</extension>
2. Also take a look at Designer_2.0_descriptions.pdf and GEF validators - you can put validation script into wbp-component.xml descriptor. So, you can use standard layouts, but custom limitations.
<parameter name="GEF.requestValidator.parent">true</parameter>
<parameter name="GEF.requestValidator.child"><![CDATA[
isComponentType(parent, 'org.eclipse.swt.widgets.Table') &&
parent.object.itemCount <= 2
]]></parameter>
Konstantin Scheglov,
Google, Inc.
|
|
|
|
|
| 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   |
Tilak Sharma Messages: 45 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
|
|
|
|
| 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  |
Tilak Sharma Messages: 45 Registered: July 2009 |
Member |
|
|
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.02078 seconds