Instance factory implementation for newly created custom component plugin [message #817146] |
Fri, 09 March 2012 17:56  |
Eclipse User |
|
|
|
I am trying to add my custom created widgets to the palette using the a new plugin
i succeeded to add my custom widgets to palette using my newly created plugin. Now i am trying to use factory for the new custom widgets and swt-customized widgets by me. I am trying exactly the same way as Formtoolkit can somebody help me to complete this task.
I did the following steps.
Created factory class.
Created wbp-factoy.xml and wbp-component.xml for this factory.
added the entry for the istance-factory component element of plugin.xml
<instance-factory class="com.widgets.custom.WidgetFactory">
<method name="Button"
signature="createButton(org.eclipse.swt.widgets.Composite,
java.lang.String,int)"/>
</instance-factory>
added the class loader entry this namespace
Can somebody help me find the missing steps to achieve this
|
|
|
|
Re: Instance factory implementation for newly created custom component plugin [message #818399 is a reply to message #817700] |
Sun, 11 March 2012 15:08   |
Eclipse User |
|
|
|
1. Custom Widget class
package com.widgets.custom;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Scale;
import org.eclipse.swt.widgets.Text;
public class CECScale extends Composite {
private final Text text;
/**
* Create the composite.
*
* @param parent
* @param style
*/
public CECScale(final Composite parent, final int style) {
super(parent, style);
setLayout(new GridLayout(1, false));
Group grpCecscale = new Group(this, SWT.NONE);
grpCecscale.setLayout(new GridLayout(2, false));
GridData gd_grpCecscale = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
gd_grpCecscale.widthHint = 236;
grpCecscale.setLayoutData(gd_grpCecscale);
grpCecscale.setText("CECScale");
Scale scale = new Scale(grpCecscale, SWT.NONE);
text = new Text(grpCecscale, SWT.BORDER);
GridData gd_text = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_text.widthHint = 27;
text.setLayoutData(gd_text);
}
@Override
protected void checkSubclass() {
// Disable the check that prevents subclassing of SWT components
}
}
2. Factory class
package com.widgets.custom;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
public class WidgetFactory {
public WidgetFactory(Display display) {
}
public Button createButton(Composite parent, String text, int style) {
Button button = new Button(parent, style );
if (text != null)
button.setText(text);
return button;
}
public CECScale createCECScale(Composite parent, int style){
return new CECScale(parent, style);
}
}
3. WidgetFactory.wbp-factory.xml
<?xml version='1.0' encoding='UTF-8'?>
<factory>
<!-- createButton() -->
<method name="createButton">
<parameter type="org.eclipse.swt.widgets.Composite" parent="true" />
<parameter type="java.lang.String" defaultSource=""New Button"" />
<parameter type="int" defaultSource="org.eclipse.swt.SWT.NONE">
<editor id="style">
<parameter name="class">org.eclipse.swt.SWT</parameter>
<parameter name="set">BORDER</parameter>
<parameter name="select0">type PUSH PUSH CHECK RADIO TOGGLE ARROW
</parameter>
<parameter name="select1">align LEFT LEFT CENTER RIGHT</parameter>
</editor>
</parameter>
<description>Creates a button as a part of the form.</description>
<name>Some name for palette entry.</name>
</method>
<method name="createCECScale" factory = "true">
<parameter type="org.eclipse.swt.widgets.Composite" parent="true" />
<parameter type="int" defaultSource="org.eclipse.swt.SWT.NONE">
</parameter>
<description>Creates a label as a part of the form.</description>
<name>Some name for palette entry.</name>
</method>
</factory>
4. Plugin.xml
<!-- ======================================================== -->
<!-- Toolkit -->
<!-- ======================================================== -->
<extension point="org.eclipse.wb.core.toolkits">
<toolkit id="org.eclipse.wb.rcp">
<resourcePrefixes>
<resourcePrefix>com.widgets.custom.</resourcePrefix>
</resourcePrefixes>
<palette>
<category description="Custom widgets" id="com.widgets.custom" name="MyWidgets">
<component class="com.widgets.custom.CECScale"/>
<instance-factory class="com.widgets.custom.WidgetFactory">
<method
name="CECScale"
signature="createCECScale(org.eclipse.swt.widgets.Composite,int)"/>
<method
name="Button"
signature="createButton(org.eclipse.swt.widgets.Composite,java.lang.String,int)">
</method>
</instance-factory>
</category>
</palette>
<classLoader-bundle
bundle="com.widgets.custom.designer"
namespaces="com.widgets.custom.">
</classLoader-bundle>
</toolkit>
-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
Finaly the factory methods are not getting added to the Palette
I am getting the error message : Factory class com.widgets.custom.WidgetFactory contains no factory methods.
|
|
|
|
Re: Instance factory implementation for newly created custom component plugin [message #820923 is a reply to message #820792] |
Wed, 14 March 2012 18:47   |
Eclipse User |
|
|
|
Thanks for the reply.
But i dont think it will solve my problem .What i am trying to do is we have customized Eclipse ide and also platform which developed on eclipse, all our application use this platform, our platform consist of lot customized widgets, also we are using a factory for creating the widgets. So i want to bundle the new plugin as part of my customized eclipse ide. so that my application developors will be able to use window builder.
So i am looking for a solution which is similar to Form toolkit implementation in window builder, using a separate plugin may be using *.wbp-factory.xml
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03399 seconds