Flowable 6.6.0 Eclipse设计器 - 5.扩展Flowable设计器 - 5.1定制调色板(3)

Flowable 6.6.0 用户指南相关文档下载

有关Flowable文档的其他资料,参见:

《Flowable文档大全》


《Flowable 6.6.0 Eclipse设计器》

1 安装(Installation
2 Flowable 设计器编辑器特性(Flowable Designer editor features)
3 Flowable设计器BPMN 特性(Flowable Designer BPMN features)
4 Flowable设计器部署特性(Flowable Designer deployment features)
5 扩展Flowable设计器(Extending Flowable Designer)

5 扩展Flowable设计器(Extending Flowable Designer)

5.1 定制调色板(Customizing the palette)

5.1.3 向调色板增加形状(Adding shapes to the palette)

With your project set up, you can now easily add shapes to the palette. Each shape you wish to add is represented by a class in your JAR. Take note that these classes are not the classes that will be used by the Flowable engine during runtime. In your extension you describe the properties that can be set in Flowable Designer for each shape. From these shapes, you can also define the runtime characteristics that should be used by the engine when a process instance reaches the node in the process. The runtime characteristics can use any of the options that Flowable supports for regular ServiceTasks. See this section for more details.

设置好项目后,现在可以轻松地将形状添加到调色板。每个您希望添加的形状都由JAR中的一个类表示。请注意,这些类不是Flowable引擎在运行时使用的类。在您的扩展中,您描述了可在Flowable 设计器中为每个形状设置的属性。从这些形状中,您还可以定义流程实例到达流程中的节点时引擎应使用的运行时特性。运行时特性可以使用Flowable支持的各种选项来支持常规服务任务(ServiceTasks)。有关更多详细信息,请参阅此节( this section)。

A shape’s class is a simple Java class, to which a number of annotations are added. The class should implement the CustomServiceTask interface, but you shouldn’t implement this interface yourself. Extend the AbstractCustomServiceTask base class instead (at the moment you MUST extend this class directly, so no abstract classes in between). In the Javadoc for that class you can find instructions on the defaults it provides and when you should override any of the methods it already implements. Overrides allow you to do things such as providing icons for the palette and in the shape on the canvas (these can be different) and specifying the base shape you want the node to have (activity, event, gateway).

形状的类是一个简单的Java类,其中添加了许多注解。该类应该实现CustomServiceTask接口,但您不应该自己实现此接口。而应该扩展AbstractCustomServiceTask基类(此时必须直接扩展该类,因此中间没有抽象类)。在该类的Javadoc中,您可以找到关于它提供的默认值以及何时应该重写已经实现的各种方法的说明。覆盖允许您执行一些操作,例如为调色板和画布上的形状提供图标(这些图标可以不同),并指定希望节点具有的基本形状(活动、事件、网关)。

/**
 * @author John Doe
 * @version 1
 * @since 1.0.0
 */
public class AcmeMoneyTask extends AbstractCustomServiceTask {
...
}

You will need to implement the getName() method to determine the name the node will have in the palette. You can also put the nodes in their own drawer and provide an icon. Override the appropriate methods from AbstractCustomServiceTask. If you want to provide an icon, make sure it’s in the src/main/resources package in your JAR and is about 16x16 pixels and in JPEG or PNG format. The path you supply is relative to that folder.
您需要实现getName()方法来确定节点在调色板中的名称。您还可以将节点放在它们自己的抽屉中(drawer)并提供一个图标。重写AbstractCustomServiceTask中的适当方法。如果您想提供一个图标,请确保它位于JAR中的src/main/resources包中,大小约为16x16像素,采用JPEG或PNG格式。您提供的路径是相对于该文件夹的。
You can add properties to the shape by adding members to the class and annotating them with the @Property annotation like this:
通过向类中添加成员并使用@Property对其进行注解,可以将属性添加到形状中,如下所示:

@Property(type = PropertyType.TEXT, displayName = "Account Number")
@Help(displayHelpShort = "Provide an account number", displayHelpLong = HELP_ACCOUNT_NUMBER_LONG)
private String accountNumber;

There are several PropertyType values you can use, which are described in more detail in this section. You can make a field required by setting the required attribute to true. A message and red background will appear if the user doesn’t fill in the field.
If you want to fix the order of the various properties in your class as they appear in the property screen, you should specify the order attribute of the @Property annotation.

您可以使用多个PropertyType值,本节将对此进行更详细的描述。通过将required属性设置为true,可以使字段成为必需的。如果用户不填写该字段,将显示一条消息和红色背景。
如果您想修正在属性屏幕(property screen)上类中各种属性出现的顺序,您应该指定@property注解的order属性。

As you can see, there’s also a @Help annotation that’s used to provide the user some guidance when filling in the field. You can also use the @Help annotation on the class itself - this information is shown at the top of the property sheet presented to the user.
Below is the listing for further elaboration of the MoneyTask. A comment field has been added and you can see an icon is included for the node.

如您所见,还有一个@Help注解,用于在填充字段时为用户提供一些指导。您还可以在类本身上使用@Help注解—此信息显示在呈现给给用户的属性清单(property sheet)的顶部。
以下是MoneyTask的详细说明清单。添加了一个注解字段,您可以看到该节点包含一个图标。

/**
 * @author John Doe
 * @version 1
 * @since 1.0.0
 */
@Runtime(javaDelegateClass = "org.acme.runtime.AcmeMoneyJavaDelegation")
@Help(displayHelpShort = "Creates a new account", displayHelpLong =
    "Creates a new account using the account number specified")
public class AcmeMoneyTask extends AbstractCustomServiceTask {

  private static final String HELP_ACCOUNT_NUMBER_LONG =
      "Provide a number that is suitable as an account number.";

  @Property(type = PropertyType.TEXT, displayName = "Account Number", required = true)
  @Help(displayHelpShort = "Provide an account number", displayHelpLong = HELP_ACCOUNT_NUMBER_LONG)
  private String accountNumber;

  @Property(type = PropertyType.MULTILINE_TEXT, displayName = "Comments")
  @Help(displayHelpShort = "Provide comments", displayHelpLong =
      "You can add comments to the node to provide a brief description.")
  private String comments;

  @Override
  public String contributeToPaletteDrawer() {
    return "Acme Corporation";
  }

  @Override
  public String getName() {
    return "Money node";
  }

  @Override
  public String getSmallIconPath() {
    return "icons/coins.png";
  }
}

If you extend Flowable Designer with this shape, the palette and corresponding node will look like this:

如果使用此形状扩展Flowable设计器,调色板和相应的节点将如下所示:
在这里插入图片描述
The properties screen for the money task is shown below. Note the required message for the accountNumber field.
money任务的属性屏幕如下所示。请注意accountNumber字段所需的消息。
在这里插入图片描述
Users can enter static text or use expressions that use process variables in the property fields when creating diagrams (for example, “This little piggy went to ${piggyLocation}”). Generally, this applies to text fields where users are free to enter any text. If you expect users to want to use expressions and you apply runtime behavior to your CustomServiceTask (using @Runtime), make sure to use Expression fields in the delegate class so the expressions are correctly resolved at runtime. More information on runtime behavior can be found in this section.

用户可以在创建图时输入静态文本或表达式,可在其属性字段中使用流程变量(例如,“This little piggy went to ${piggyLocation}”)。通常,这适用于用户可以自由输入文本的文本字段。如果希望用户使用表达式,并且将运行时行为应用于CustomServiceTask(使用@ Runtime),请确保在委托类中使用表达式字段,以便在运行时正确解析表达式。有关运行时行为的更多信息,请参阅this section。

The help for fields is offered by the buttons to the right of each property. Clicking on the button shows a popup as displayed below.

字段的帮助由每个属性右侧的按钮提供。点击按钮显示一个弹出窗口,如下所示。
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

月满闲庭

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值