技术开发 频道

基于Lotus Expeditor6.1的复合应用开发


组件的线接(Wire)

    没有线接的组件是一个个孤立的组件,只有通过线接的组件,组件之间才能进行通讯,以及进行互操作。为了注册一个线接,需要对扩展点 com.ibm.rcp.propertybroker.PropertyBrokerWire 作扩展,同时定义一个线接,如图 7。


图 7. PropertyBrokerWire 扩展点中数据项的指定

    每个线接有如下的属性:

属性名称属性说明
Type 类型,当前只支持 PROPERTY_TO_ACTION 线接类型
sourcename 当前线接的发出者名字
targetname 当前线接的接受者的名字
name 线接的名字
title 线接的题目(与线接不影响)
ownerid 拥有者组件的 id,通过 Property broker 的 API,可以进行查询
odinal 在 broker 注册表中的排序
sourceentityid 发出者的实体 id
sourceparam 线接信息中将要发送给动作的参数
targetentityid 接受者的实体 id
targetparam 线接信息中动作接受者的动作参数
enable 当前线接是否可用,注册时自动设为可用
uid 唯一 id

    通常,实体 id 是视图的 id,即视图的第一 id 和第二 id 并在中间加冒号。

    如下是我们样例中的线接在 plugin.xml 的描述:

<extension id="com.ibm.rcp.portlet.wire" name="Portlet Wire" point="com.ibm.rcp.propertybroker.PropertyBrokerWire"> <wire sourceentityid="com.ibm.rcp.samples.cityselection.views.CityNameView:null" sourcename="CityName_Text" targetentityid="com.ibm.rcp.samples.citytime.views.CityTimeView:null" targetname="setCityName" type="PROPERTY_TO_ACTION"/> </extension>



    当接受者组件收到 property 更改事件时,通过事件获得对应的线接对象,利用 SWTHelper 的 locateView 方法根据接受者组件的实体 id,查找到对应的 View,并对 View 进行刷新。动作的完整代码如下:

public class setTimeAction extends Action {

public void runWithEvent(Event event) { if (eventinstanceof PropertyChangeEvent) { final PropertyChangeEvent pEvent= (PropertyChangeEvent)event; //System.out.println("Event received"); Thread t= new Thread() { publicvoid run() { PropertyValue value= pEvent.getPropertyValue(); Wire wire= pEvent.getWireDefinition(); CityTimeView view= (CityTimeView)SWTHelper.locateView(wire.getTargetEntityId()); //ColorItem color = new ColorItem(); String result= null; result= (String)value.getValue(); System.out.println("CityName received is"+result); view.setCity(result); } }; Display display= Display.getDefault(); display.asyncExec(t); } } }

观看专家视频讲座,了解人员协作信息,赢取免费试用软件。
























0
相关文章