自定义的事物SWT编辑器。
编辑器包含两个要素,一个是编辑控件,另外一个是数据模型,这里约定第一个子事物为控件,第二个子事物为模型定义。
注意:
数据模型应该返回的是一个Map。
字段摘要 |
---|
方法摘要 | |
---|---|
|
create
|
子事物摘要 | |
---|---|
|
AnimationGif
动画GIF,可绑定到父控件作为动画背景图,如果父控件已销毁那么动画GIF的相关资源也销毁。 |
|
BREAK
终止当前操作,循环或者SWITCH等可以终止BREAK,如果没有循环或SWITCH那么可能会直接调出方法的调用。 |
|
Browser
Instances of this class implement the browser user interface metaphor. It allows the user to visualize and navigate through HTML documents. |
|
Button
|
|
CBanner
Instances of this class implement a Composite that lays out its children and allows programmatic control of the layout. It draws a separator between the left and right children which can be dragged to resize the right control. CBanner is used in the workbench to layout the toolbar area and perspective switching toolbar. |
|
CCombo
The CCombo class represents a selectable user interface object that combines a text field and a list and issues notification when an item is selected from the list. |
|
CONTINUE
调到循环的开头继续执行循环,当前循环内部剩余的跳过。 |
|
CTabFolder
Instances of this class implement the notebook user interface metaphor. It allows the user to select a notebook page from set of pages. |
|
Canvas
|
|
ChartComposite
A SWT GUI composite for displaying a {@link JFreeChart} object. |
|
ChatText
|
|
Code
在创建SWT窗体时只执行一次的Groovy代码。 |
|
CodeEditor
可以对代码着色的编辑器,可以显示列数和行数。创建后返回的是StyleText。 |
|
Combo
|
|
Composite
Instances of this class are controls which are capable of containing other controls. |
|
ControlEditor
A ControlEditor is a manager for a Control that appears above a composite and tracks with the moving and resizing of that composite. It can be used to display one control above another control. This could be used when editing a control that does not have editing capabilities by using a text editor or for launching a dialog by placing a button above a control. |
|
CoolBar
|
|
Cursor
Cursor创建后需要显式的dispose。 |
|
DO
循环控制语句。语法是: |
|
DataObjectEditCompoiste
一个有查询和表格的数据对象编辑面板。 |
|
DataObjectForm
数据对象表单,和事物表单类似,参看事物表单。 |
|
DataStore
|
|
DataStores
各种DataStore的注册地。 |
|
DataTable
DataTable已经很少用了,使用Table和DataStore代替。 |
|
DataTree
使用Tree和TreeModel代替。 |
|
DateChooser
|
|
DateChooserCombo
|
|
DatePickerCombo
日期输入和选择控件,本事物创建后返回Text框,变量保存的也是Text框。 |
|
DateTime
|
|
DragMove
向父控件天价MouseListener和MouseMoveListener,实现监听拖拽。 |
|
EditableTable
已不再使用,使用Table+DataStore的方式实现。 |
|
EventFilter
|
|
ExpandBar
|
|
ExtendWidget
可以继承其他组件,比如继承一个已编辑好的界面等,等价于调用被继承的界面的create方法。 |
|
FormattedText
|
|
Group
|
|
HtmlEditor
HTML编辑器,使用FCKEditor编辑HTML。 |
|
IF
IF条件,条件使用Ognl表达式。 |
|
ITERATOR
迭代器,使用Java中的Iterator,只能对集合有效。 |
|
IconSelector
图标选择器,用于选择图片。 |
|
Image
Image的生存周期是和parent控件绑定在一起的,由于资源是共享的所以可以有多个parent,当所有的父控件失效后图片移除。 |
|
JavaAction
在创建SWT窗体时只执行一次的Java代码。 |
|
Label
|
|
LightweightSystem
The LightweightSystem is the link between SWT and Draw2d. It is the component that provides the ability for Figures to be hosted on an SWT Canvas. |
|
Link
|
|
List
Instances of this class represent a selectable user interface object that displays a list of strings and issues notification when a string is selected. A list may be single or multi select. |
|
Menu
|
|
MenuFromText
|
|
Model
校验表单中的数据。 |
|
Models
Model的集合,只是方便创建Model。 |
|
ObjectViewer
对象查看器 |
|
OleClientSite
OleClientSite provides a site to manage an embedded OLE Document within a container. |
|
OleControlSite
|
|
OleFrame
OleFrame is an OLE Container's top level frame. |
|
PagingToolbar
|
|
ProgressBar
|
|
RETURN
结束方法调用,返回返回值。 |
|
Region
Instances of this class represent areas of an x-y coordinate system that are aggregates of the areas covered by a number of polygons. |
|
Resource
集中创建SWT的各种资源。 |
|
SWITCH
Switch条件判断语句。 |
|
Sash
|
|
SashForm
The SashForm is a composite control that lays out its children in a row or column arrangement (as specified by the orientation) and places a Sash between each child. One child may be maximized to occupy the entire size of the SashForm. The relative sizes of the children may be specified using weights. |
|
Scale
|
|
ScrolledComposite
A ScrolledComposite provides scrollbars and will scroll its content when the user uses the scrollbars. |
|
Shell
Instances of this class represent the "windows" which the desktop or "window manager" is managing. Instances that do not have a parent (that is, they are built using the constructor, which takes a Display as the argument) are described as top level shells. Instances that do have a parent are described as secondary or dialog shells. |
|
Slider
Instances of this class are selectable user interface objects that represent a range of positive, numeric values. |
|
Spinner
Instances of this class are selectable user interface objects that allow the user to enter and modify numeric values. |
|
SplitButton
|
|
StyleSet
样式管理,在ActionContext里建一个名为StyleManager的Map,保存Style,每一个Style是Control的基本属性集合。 |
|
StyledText
A StyledText is an editable user interface object that displays lines of text. |
|
SwtThingTemplate
SWT事物模板。 |
|
TRY
类似Java的try{}catch(){}finally语句。 |
|
TabFolder
Instances of this class implement the notebook user interface metaphor. It allows the user to select a notebook page from set of pages. |
|
Table
|
|
TableViewer
|
|
TaskMonitor
任务监控器 |
|
Text
Instances of this class are selectable user interface objects that allow the user to enter and modify text. |
|
ThingDescBrowser
浏览事物描述的浏览器。 |
|
ThingDescritporForm
已不再使用,可以用ThingForm代替。 |
|
ThingEditor
事物编辑器。 |
|
ThingForm
事物表单 |
|
ThingRegistSelector
可以选择注册的事物的控件,比如选择注册的子事物、模板、特征、笔记、分类等。 |
|
ThingViewer
事物查看组件,用于查看事物。 |
|
ToolBar
|
|
Tracker
Instances of this class implement rubber banding rectangles that are drawn onto a parent Composite or Display . These rectangles can be specified to respond to mouse and key events by either moving or resizing themselves accordingly. Trackers are typically used to represent window geometries in a lightweight manner. |
|
TrayItem
Instances of this class represent icons that can be placed on the system tray or task bar status area. |
|
Tree
Instances of this class provide a selectable user interface object that displays a hierarchy of items and issues notification when an item in the hierarchy is selected. |
|
TriggerField
一个输入框和按钮组成的类似于Combo效果的输入界面。 |
|
ViewForm
Instances of this class implement a Composite that positions and sizes children and allows programmatic control of layout and border parameters. ViewForm is used in the workbench to lay out a view's label/menu/toolbar local bar. |
|
WHILE
循环控制语句。语法是: |
|
actions(Actions)
动作的容器(ActionContainer),可以定义一些动作在运行后期被调用。 |
字段详细信息 |
---|
方法详细信息 |
---|
子事物详细信息 |
---|
动画GIF,可绑定到父控件作为动画背景图,如果父控件已销毁那么动画GIF的相关资源也销毁。
终止当前操作,循环或者SWITCH等可以终止BREAK,如果没有循环或SWITCH那么可能会直接调出方法的调用。
Instances of this class implement the browser user interface metaphor. It allows the user to visualize and navigate through HTML documents.
Note that although this class is a subclass of Composite
, it does not make sense to set a layout on it.
Instances of this class implement a Composite that lays out its children and allows programmatic control of the layout. It draws a separator between the left and right children which can be dragged to resize the right control. CBanner is used in the workbench to layout the toolbar area and perspective switching toolbar.
Note that although this class is a subclass of Composite
, it does not make sense to set a layout on it.
The CCombo class represents a selectable user interface object that combines a text field and a list and issues notification when an item is selected from the list.
CCombo was written to work around certain limitations in the native combo box. Specifically, on win32, the height of a CCombo can be set; attempts to set the height of a Combo are ignored. CCombo can be used anywhere that having the increased flexibility is more important than getting native L&F, but the decision should not be taken lightly. There is no is no strict requirement that CCombo look or behave the same as the native combo box.
Note that although this class is a subclass of Composite
, it does not make sense to add children to it, or set a layout on it.
调到循环的开头继续执行循环,当前循环内部剩余的跳过。
Instances of this class implement the notebook user interface metaphor. It allows the user to select a notebook page from set of pages.
The item children that may be added to instances of this class must be of type CTabItem
. Control
children are created and then set into a tab item using CTabItem#setControl
.
Note that although this class is a subclass of Composite
, it does not make sense to set a layout on it.
A SWT GUI composite for displaying a {@link JFreeChart} object.
在创建SWT窗体时只执行一次的Groovy代码。
可以执行一些目前SWT事物还不能完成的事情,比如使用XWorker还未定义的SWT控件或手工创建和处理SWT控件等。
可以添加Widgets子节点。
可以对代码着色的编辑器,可以显示列数和行数。创建后返回的是StyleText。
和CodeText不同的是CodeEditor包装在ViewForm下,可以显示列数和行数。查看示例。
Instances of this class are controls which are capable of containing other controls.
Note: The NO_BACKGROUND
, NO_FOCUS
, NO_MERGE_PAINTS
, and NO_REDRAW_RESIZE
styles are intended for use with Canvas
. They can be used with Composite
if you are drawing your own, but their behavior is undefined if they are used with subclasses of Composite
other than Canvas
.
Note: The CENTER
style, although undefined for composites, has the same value as EMBEDDED
(which is used to embed widgets from other widget toolkits into SWT). On some operating systems (GTK, Motif), this may cause the children of this composite to be obscured. The EMBEDDED
style is for use by other widget toolkits and should normally never be used.
A ControlEditor is a manager for a Control that appears above a composite and tracks with the moving and resizing of that composite. It can be used to display one control above another control. This could be used when editing a control that does not have editing capabilities by using a text editor or for launching a dialog by placing a button above a control.
循环控制语句。语法是:
do{
}while(condition)。先执行do括号中的内容,如果条件成立那么继续重复执行。
一个有查询和表格的数据对象编辑面板。
会产生的变量有:dataTable,dataStore,queryFrom, buttonComposite,pageingToolbar等。
数据对象表单,和事物表单类似,参看事物表单。
各种DataStore的注册地。
DataTable已经很少用了,使用Table和DataStore代替。
使用Tree和TreeModel代替。
日期输入和选择控件,本事物创建后返回Text框,变量保存的也是Text框。
返回的SWT控件
保存到全局变量中的SWT控件是Text,变量名是当前控件的名称。
查看示例。
向父控件天价MouseListener和MouseMoveListener,实现监听拖拽。
事件:
DragMove的属性:
已不再使用,使用Table+DataStore的方式实现。
可以继承其他组件,比如继承一个已编辑好的界面等,等价于调用被继承的界面的create方法。
HTML编辑器,使用FCKEditor编辑HTML。
一般用户属性编辑,如要在一般界面使用HtmlEditor,可以参看HtmlEditor的示例。
IF条件,条件使用Ognl表达式。
迭代器,使用Java中的Iterator,只能对集合有效。
每次遍历会有<varName>,<varName>_index(当前位置int),<varName>_hasNext(是否有下一个记录)三个临时变量。
图标选择器,用于选择图片。
接受事件SWT.Selection和SWT.DefaultSelection。
Image的生存周期是和parent控件绑定在一起的,由于资源是共享的所以可以有多个parent,当所有的父控件失效后图片移除。
在创建SWT窗体时只执行一次的Java代码。
可以执行一些目前SWT事物还不能完成的事情,比如使用XWorker还未定义的SWT控件或手工创建和处理SWT控件等。
可以添加Widgets子节点。
The LightweightSystem is the link between SWT and Draw2d. It is the component that provides the ability for Figures
to be hosted on an SWT Canvas.
Normal procedure for using a LightweightSystem:
Instances of this class represent a selectable user interface object that displays a list of strings and issues notification when a string is selected. A list may be single or multi select.
校验表单中的数据。
Model的集合,只是方便创建Model。
Model用于对控件赋值、取值和校验数据。
对象查看器
对象查看器,相当于eclipse中调试时的查看变量控件。
对象查看器主要方法
OleClientSite provides a site to manage an embedded OLE Document within a container.
The OleClientSite provides the following capabilities:
This object implements the OLE Interfaces IUnknown, IOleClientSite, IAdviseSink, IOleInPlaceSite
Note that although this class is a subclass of Composite
, it does not make sense to add Control
children to it, or set a layout on it.
OleFrame is an OLE Container's top level frame.
This object implements the OLE Interfaces IUnknown and IOleInPlaceFrame
OleFrame allows the container to do the following:
结束方法调用,返回返回值。
return控制语句,返回常量、变量或者表达式变量。
Instances of this class represent areas of an x-y coordinate system that are aggregates of the areas covered by a number of polygons.
Application code must explicitly invoke the Region.dispose()
method to release the operating system resources managed by each instance when those instances are no longer required.
集中创建SWT的各种资源。
这里的资源和父控件绑定,当父控件销毁时自动销毁,简化资源管理。
Switch条件判断语句。
使用Ognl表达式来判断是否符合条件。
The SashForm is a composite control that lays out its children in a row or column arrangement (as specified by the orientation) and places a Sash between each child. One child may be maximized to occupy the entire size of the SashForm. The relative sizes of the children may be specified using weights.
A ScrolledComposite provides scrollbars and will scroll its content when the user uses the scrollbars.
Instances of this class represent the "windows" which the desktop or "window manager" is managing. Instances that do not have a parent (that is, they are built using the constructor, which takes a Display
as the argument) are described as top level shells. Instances that do have a parent are described as secondary or dialog shells.
Instances of this class are selectable user interface objects that represent a range of positive, numeric values.
At any given moment, a given slider will have a single 'selection' that is considered to be its value, which is constrained to be within the range of values the slider represents (that is, between its minimum and maximum values).
Typically, sliders will be made up of five areas:
Based on their style, sliders are either HORIZONTAL
(which have a left facing button for decrementing the value and a right facing button for incrementing it) or VERTICAL
(which have an upward facing button for decrementing the value and a downward facing buttons for incrementing it).
On some platforms, the size of the slider's thumb can be varied relative to the magnitude of the range of values it represents (that is, relative to the difference between its maximum and minimum values). Typically, this is used to indicate some proportional value such as the ratio of the visible area of a document to the total amount of space that it would take to display it. SWT supports setting the thumb size even if the underlying platform does not, but in this case the appearance of the slider will not change.
Instances of this class are selectable user interface objects that allow the user to enter and modify numeric values.
Note that although this class is a subclass of Composite
, it does not make sense to add children to it, or set a layout on it.
样式管理,在ActionContext里建一个名为StyleManager的Map,保存Style,每一个Style是Control的基本属性集合。
StyleManager应尽量提前初始化,应该放在界面定义的最上方。
A StyledText is an editable user interface object that displays lines of text.
SWT事物模板。
调用事物模板创建SWT事物,然后在执行SWT事物的create方法创建界面。其中事物所用到的数据需要预先准备好。
类似Java的try{}catch(){}finally语句。
Catch的表达式应是类的全名,用此判断是否Catch相关抛除的对象。
Instances of this class implement the notebook user interface metaphor. It allows the user to select a notebook page from set of pages.
The item children that may be added to instances of this class must be of type TabItem
. Control
children are created and then set into a tab item using TabItem#setControl
.
Note that although this class is a subclass of Composite
, it does not make sense to set a layout on it.
任务监控器
创建后启动一个线程执行任务列表,并把执行情况反映在进度条和标签上。
动态任务
如果动态任务=true,表示任务可以追加,此时忽略进度条,进度条最后设置成反复滚动的,否则会根据任务数量设置进度条的值。
create
创建后返回的是一个事物(Thing)副本。
注册任务
新的任务类型可以以子事物的方式注册到xworker.swt.util.Tasks下。
Instances of this class are selectable user interface objects that allow the user to enter and modify text.
浏览事物描述的浏览器。
如果在运行期设置事物,使用<name>Action.doAction("setThing", ["thing":thing])设置,其中<name>为浏览器的名称。
已不再使用,可以用ThingForm代替。
事物编辑器。
保存到变量上下文的是编辑器的自己的变量上下文,创建后返回的是变量上下文。
设置和读取事物的方法
事物表单
通过描述者创建输入表单,规则同XWorker编辑器表单以及DataObject的表单。
变量上下文和相关变量
事物表单会创建独立的变量上下文,表单中的属性控件都在新的变量上下文中,表单自身的变量上下文中的有哪些变量参看事物表单,或XWorker网站。
事物表单创建完毕后返回的是主Composite,当前变量上下文中保存的变量为表单事物(Thing),可以通过表单事物(Thing)对表单进行操作。
事物表单保存的数据
Thing form = new Thing("xworker.swt.xworker.ThingForm"); form.setData("formThing", self); //原始表单事物 form.setData("parent", composite); //主Composite,表单的主容器 form.setData("actionContext", ac); //新的变量上下文,表单自己的变量上下文
表单的主要方法
可以选择注册的事物的控件,比如选择注册的子事物、模板、特征、笔记、分类等。
界面的样式
会根据不同的属性组合选择不同的控件。
事件,重写以下方法可以实现监听
变量
保存到全局变量的是界面中的actions,actions有以下方法:
事物查看组件,用于查看事物。
Instances of this class implement rubber banding rectangles that are drawn onto a parent Composite
or Display
. These rectangles can be specified to respond to mouse and key events by either moving or resizing themselves accordingly. Trackers are typically used to represent window geometries in a lightweight manner.
Instances of this class represent icons that can be placed on the system tray or task bar status area.
Instances of this class provide a selectable user interface object that displays a hierarchy of items and issues notification when an item in the hierarchy is selected.
The item children that may be added to instances of this class must be of type TreeItem
.
Style VIRTUAL
is used to create a Tree
whose TreeItem
s are to be populated by the client on an on-demand basis instead of up-front. This can provide significant performance improvements for trees that are very large or for which TreeItem
population is expensive (for example, retrieving values from an external source).
Here is an example of using a Tree
with style VIRTUAL
:
final Tree tree = new Tree(parent, SWT.VIRTUAL | SWT.BORDER);
tree.setItemCount(20);
tree.addListener(SWT.SetData, new Listener() {
public void handleEvent(Event event) {
TreeItem item = (TreeItem)event.item;
TreeItem parentItem = item.getParentItem();
String text = null;
if (parentItem == null) {
text = "node " + tree.indexOf(item);
} else {
text = parentItem.getText() + " - " + parentItem.indexOf(item);
}
item.setText(text);
System.out.println(text);
item.setItemCount(10);
}
});
Note that although this class is a subclass of Composite
, it does not normally make sense to add Control
children to it, or set a layout on it, unless implementing something like a cell editor.
Styles:
SINGLE, MULTI, CHECK, FULL_SELECTION, VIRTUAL, NO_SCROLL
Events:
Selection, DefaultSelection, Collapse, Expand, SetData, MeasureItem, EraseItem, PaintItem
Note: Only one of the styles SINGLE and MULTI may be specified.
一个输入框和按钮组成的类似于Combo效果的输入界面。
使用者必须实现自己createShell方法,在弹出的Shell中的动作上下文中,设置result变量会返回结果,如actionContext.getScope(0).put("result", "ok")。
Instances of this class implement a Composite that positions and sizes children and allows programmatic control of layout and border parameters. ViewForm is used in the workbench to lay out a view's label/menu/toolbar local bar.
Note that although this class is a subclass of Composite
, it does not make sense to set a layout on it.
循环控制语句。语法是:
while(condiiton){
};先判断条件,如何成立则执行括号的内容,执行完括号的内容后再判断条件,如果程序那么继续执行括号中的内容。
动作的容器(ActionContainer),可以定义一些动作在运行后期被调用。
比如一个工作台(Workbentch)的界面通常需要提供打开视图、打开编辑器等功能,这些功能则可以定义在动作容器中。调用动作的方法是<动作容器名>.doAction(<name>, ....),如workbentchActions.doAction("openView", ["viewName":"outline"])。
动作容器的方法主要有: