65.9K
CodeProject 正在变化。 阅读更多。
Home

动态 UI 创建:扩展 R2build:添加新工具支持,创建插件配置

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.21/5 (8投票s)

2007年10月8日

GPL3

5分钟阅读

viewsIcon

76323

在本文中,我将介绍如何在 R2build 中为新工具创建新的 XML 配置文件。

Screenshot - dashboard_600.jpg

Screenshot - mainui_600.jpg

摘要

在本文中,我们将介绍如何在 R2build 系统中支持一个新工具(新应用程序)。R2build 使用插件机制和 XML 配置文件,以便轻松支持新工具。

关于 R2build

R2build 是一个面向桌面应用程序开发人员的工具/框架,可以非常轻松地建立您的日常构建(或夜间构建、构建自动化或持续集成系统)。它包括但不限于:VB/VC++/.NET/Delphi/Ant/Nant/C++ Builder 的插件、电子邮件通知、FTP、各种安装程序打包工具以及各种源代码管理工具,如 vss、clearcase、cvs、perforce……。

引言

R2build 使用 XML 文件来描述节点 UI 对话框及其相关参数。要支持 R2build 中的新工具/应用程序,您应该检查该新应用程序的命令行参数,然后在 $R2buildInstallDir/plugins 中创建一个新的 XML 文件。当 R2build 启动时,它将扫描所有插件配置文件 XML,并在工具箱中构建相应的节点。此 XML 描述命令行参数,也称为应用程序描述 XML。

一个简单示例

让我们从一个非常简单的例子开始。您有一个新应用程序,simple.exe,通过调用 simple.exe –h,您知道 simple.exe 有两个参数。

Simple.exe –f filename –x text 
-f filename: file to open 
-x text: text to delete from file. 

要将 simple.exe 添加到 R2build 工具箱,您需要将 simple.xml 文件创建到 $R2BuildInstallDir/Plugins 目录中,您可以创建自己的文件夹,并将 simple.xml 放入该文件夹中。以下是 XML 文件:

<?xml version='1.0' encoding='utf-8'?>
<Plugin version='1' group="" name="Simple" appName="Simple" description=""> 

<Type>command</Type> - a command console application 
<Executor>simple.exe</Executor> - the application's executable file name 
<FixedParameter></FixedParameter> -Fixed parameter 
<SubExecutor></SubExecutor> -the sub executor of this application 
<Icon>simple.png</Icon> -the icon file of this application 
<ParameterConfigUI> - the main config section 
<FileBrowser display="File to open" BrowseDir="FALSE" 
Filter="" type="Parameter" relatedParameter="-f "></FileBrowser> -first parameter 
<LineEdit display="Text to delete" type="Parameter" relatedParameter="-x">
</LineEdit> -the second parameter 
</ParameterConfigUI> 
<ReturnValues> -enum return values of this application 
<ReturnValue name="Yes" Condition="$RETURN!=0"></ReturnValue> 
<ReturnValue name="No" Condition="$RETURN==0"></ReturnValue> 
</ReturnValues> 
</Plugin> 

将在 R2build 中显示为以下截图:

Screenshot - image_createpluginxml.jpg

XML 文件结构

<Plugin> 
<Type>command</Type> 
//Type is the plugin type, values are : command/plugin 
<Executor>cleartool.exe</Executor> 
//provide the executor file name, for command plugin, 
//it's command's executable file, for plugin, it's plugin's .dll file name 
//in the same dir of this file 
<FixedParameter></FixedParameter> 
//provide the required and non-configurable parameters 
<SubExecutor>update</SubExecutor> 
//The sub-command of this plugin, some of the tool support sub-command, 
//for example cleartool.exe has a sub-command update 
<Icon>Update Snapshot View.png</Icon> 
//The icon of this plugin 
<ParameterConfigUI> 
//The section for describing the plugin parameter dialog 
//and the related plugin parameterA list of Config items… 
<ComboBox display="this is a combox sample" relatedParameter="-d">
availableValue="selectionA;selectionB;selectionC" value="selectionA"></ ComboBox > 
<LineEdit display="UserName and password(seperate by ',')" 
type="Parameter" relatedParameter="-Y"></LineEdit> 
<FileBrowser display="Sourcesafe Database " BrowseDir="TRUE" 
Filter="srcsafe.ini" type="Env" relatedParameter="SSDIR"></FileBrowser> 
…… 
…… 
…… 
</ParameterConfigUI> 
<ReturnValues> //the possible return values for this plugin 
<ReturnValue name="Success" Condition="$RETURN==0"></ReturnValue> 
<ReturnValue name="Fail" Condition="$RETURN!=0"></ReturnValue> 
</ReturnValues> 
</Plugin> 

支持的 ParameterConfigUI 控件

下表列出了所有支持的 ParameterConfigUI 控件。任何控件的 XML 属性都由“通用属性”+“特定属性”组成。

配置 UI 控件 描述 此 UI 控件的特定属性(有关适用于所有控件的属性,请参阅“通用属性”)
ComboBox ComboBox 中显示多个项目,并允许用户选择一个 availableValue:在 listbox 中列出所有可用值,用 ; 分隔。 availableValue 列出 listbox 中所有可显示的可用值,值之间用 ; 分隔。
InternalValue 内部值是将在命令中应用的实际值,值之间用 ; 分隔。
ListBox 显示多个项目,并允许用户选择多个。 availableValue 列出 listbox 中所有可用值,值之间用 ; 分隔。
selectionMode :single,multi,extended
InputBox: 显示输入框,允许用户直接输入参数。
RadioGroupBox 显示单选分组。 checkable 如果 checkable 为 TRUE,则在分组框中放置一个复选框来启用/禁用整个组。
layout RadioGroupBox 子项的布局。如果为 1,表示我们有单列;2 表示两列。
value checkable 的默认值。
RadioBox 在单选按钮组中显示选择项,允许用户选择其中一个。
LineEdit 显示多行编辑器,允许用户输入多行作为参数。 isPasswordBox 如果此 lineedit 是密码编辑器,则值为 TRUEFALSE。如果是密码框,输入时会显示掩码。
CheckBox 显示复选框,允许用户勾选/取消勾选某些参数。
FileBrowser 显示打开文件/目录对话框,允许用户选择文件或目录,具有以下属性: BrowserDir 如果此文件浏览器是 目录浏览器(TRUE)文件浏览器(FALSE),所有字母大写。
Filter filebrowser 的过滤器,格式为“Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)”
VarViewBox 显示所有已定义的变量。
TabView 显示选项卡视图。 CurrentPage 选项卡的当前页。
TabViewItem 显示一个选项卡。

ParameterConfigUI 控件通用属性

每个配置 UI 控件都具有以下通用属性:

  • display:此控件的标签 (display)。
  • type:参见“支持的 ParameterConfigUI 控件类型”。
  • relatedParameter:此配置项的相关参数。
  • ParaSeperator:此配置项的参数分隔符。它将添加到 relatedParameter 和值之间。如果未配置,则参数标志和值之间没有分隔符。例如,-i"c:\aaa.txt",paraSeperator 是逗号;-i c:\aaa.txt,paraSeparator 是一个空格。
  • Required:如果此字段是必需参数,则值为:TRUEFALSE(所有大写)。TRUE 表示此参数是必需的。如果未设置,则默认值为 TRUE

支持的 ParameterConfigUI 控件类型

每个配置 UI 控件都应属于以下类型:

  • Group:此配置 UI 控件用于容纳其他配置 UI 控件。
  • ExecutorParameter:主执行器的参数,此配置 UI 控件用于获取命令参数的值,relatedParameter 字段显示其相关参数。
  • Parameter:子执行器的参数,此配置 UI 控件用于获取命令参数的值,relatedParameter 字段显示其相关参数。
  • Env:此配置 UI 控件用于设置环境变量的值,relatedParameter 字段是 env 变量名。注意Env 变量将作为工作环境变量传递给命令。
  • Property:此配置 UI 控件用于获取命令的其他属性,relatedParameter 字段是属性名。支持的属性是 WorkingFolder(命令工作的文件夹)。

更多示例

有关更多示例,请参阅 $R2buildInstallDir/Plugins

分享您的插件

将您的插件发送至 R2build@gmail.com,即可将其纳入 R2build 官方发布或发布在 R2build 网站上,您的反馈非常重要。

R2Build 2.0 Build 416 - SOFTPEDIA “100% Clean”奖

该产品于 2008 年 9 月 12 日由 Alexandra Anton 在 Softpedia 实验室最后一次测试。Softpedia 保证 R2Build 2.0 Build 416 是 100% Clean,这意味着它不包含任何形式的恶意软件,包括但不限于:间谍软件、病毒、木马和后门。
URL:http://www.softpedia.com/progClean/R2Build-Clean-89119.html

© . All rights reserved.