Extension in Tooling

Before you begin

please create a plugin project “BTTExtensionSample” and add related dependency and extension point.

Procedure

  1. Draft a widget figure class “com.ibm.btt.extension.sample.CurrencyWidgetFigure” to display the widget layout in XUI editor:
    public class CurrencyWidgetFigure extends LabelShape {
    	<SuppressWarnings("unused")
    	private static final java.lang.String COPYRIGHT = "Licensed Materials - Property of IBM "//$NON-NLS-1$
    			+ "Restricted Materials of IBM "//$NON-NLS-1$
    			+ "5724-H82 "//$NON-NLS-1$
    			+ "(C) Copyright IBM Corp. 211 All Rights Reserved. "//$NON-NLS-1$
    			+ "US Government Users Restricted Rights - Use, duplication or disclosure "//$NON-NLS-1$
    			+ "restricted by GSA ADP Schedule Contract with IBM Corp ";//$NON-NLS-1$
    	/**
    	 * Image to be displayed
    	 */	
    	private final static Image image =Activator.getImageDescriptor("icons/CurrencyWidgetFigure.PNG").createImage();	
    	public CurrencyWidgetFigure() {		
    		getLabel().setIcon(image);
    	}
    }
  2. Draft the widget configuration xml file “CurrencyWidget.xml” in folder “widgets”:
    <?xml version="1.0" encoding="UTF-8"?>
    <widget xmlns="http://btt.ibm.com/WidgetSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://btt.ibm.com/WidgetSchema WidgetSchema.xsd ">
    <!--	<figure type="SWT" class="org.eclipse.swt.widgets.Text" />-->
    		<figure type="draw2d" class="com.ibm.btt.extension.sample.CurrencyWidgetFigure" /> 
        <columnWidget editable="true"/>
    	<properties>
    		<!-- common properties -->
    		<property name="id" type="String" showInExpression="true"/>
    		<property name="width" default="80"  showInEditor="true" description="%desc_prop_width"  /> <!-- special means the width of widget can not be edited -->
    		<property name="height" default="25"  showInEditor="true" description="%desc_prop_height"  />
    		<property name="dataName" type="DataName" />
    		<property name="storeURL" type="ListFiles" description="%desc_prop_storurl" showInColumn="true" showInMultiple="false"/>
    		<property name="styleClass" showInEditor="false" showInAction="true" description="%desc_prop_style" />		
    	</properties>		
    	<events>
    		<event name="onClick" description="%desc_event_onclick" />
    		<event name="onFocus" description="%desc_event_onfocus" />
    		<event name="onChange" description="%desc_event_onchange" />	
    	</events>	
    	<functions>
    	<function name="isFocusable" showInAction="false"
    			showInExpression="true" returnType="Boolean" description="%desc_func_isfocusable" />
    		<function name="focus" showInAction="true" showInExpression="false"
    			description="%desc_func_focus" />
    	</functions>	
    </widget>
  3. 3. Add a new widget named “CurrencyWidget” in plugin extension point, specify the configuration as below:
  4. Create an extension mapping file named “alphaMapping.xml” in folder “configure”:
    <?xml version="1.0" encoding="UTF-8"?>
    <mappings prefix="bttdojo:">
    	<widget-mapping widgetName="CurrencyWidget" tagName="currencywidget"> 
    		<property-mapping propName="dataName" attrName="dataName" />
    		<property-mapping propName="storeURL" attrName="storeURL" rule="changePathRule"/>
    	</widget-mapping>		
    </mappings>
  5. Add a new generator named “CurrencyWidget” with file “configure/alphaMapping.xml”