- 浏览: 336594 次
- 性别:
- 来自: 重庆
-
文章分类
最新评论
-
hjl0722:
...
Java中的异或 -
lucd:
f(New.<Person, List<Pet&g ...
第15章泛型 -
liujunhao225:
[Error: could not access: List; ...
mvel的使用 -
superscorpio:
public void testImportInContex ...
mvel的使用 -
yuyangtina:
哦,知道了,是继承的方法。谢谢你的分享。
HttpClient3.x发送Soap请求的方法
资源里存储了用户需要的信息,而编辑器是用户创建和修改资源最主要的方式,它是eclipse插件开发中最复
杂也是最主要的部分。
编辑器必须实现org.eclipse.ui.IEditorPart接口,但通常继承子类org.eclipse.ui.part.EditorPart.
IEditorInput描述了编辑器的数据源。IPathEditorInput描述了数据源的格式,IFileEditorInput描述了基于
本地数据源。
当编辑器被创建后,输入源是通过编辑器的init方法来设定的。可以通过getEditorInput方法来重新获取。
MultiPageEditorPart,多页编辑器,每个页面都包含它自己的编辑器。FormEditor,它继承了MultiPageEditorPart类,用来实现表格编辑器。
创建编辑器,首先要在清单文件中声明扩展点,如下所示:
<extension
point="org.eclipse.ui.editors">
<editor
//与视图一样,一个编辑器对应一个class类,该类必须实现IEditorPart接口
class="com.plugindev.addressbook.editors.AddressFormEditor"
//实现了org.eclipse.ui.part.EditorActionBarContributor接口的全权限定名称
contributorClass="com.plugindev.addressbook.editors.AddressFormEditorContributor"
default="true"
//编辑器左上角显示的图像
icon="icons/editors/editor.gif"
id="com.plugindev.addressbook.tableEditor"
name="地址本编辑器"/>
</extension>
FormEditor抽象类,提供了抽象方法addPages(),子类必须实现,用与为编辑器添加页面,
在打开编辑器时,必须同时制定输入的数据源
doubleClickAction = new Action() {
public void run() {
ISelection selection = viewer.getSelection();
AddressItem obj = (AddressItem)((IStructuredSelection)
selection).getFirstElement();
IWorkbenchPage page = PlatformUI.getWorkbench().
getActiveWorkbenchWindow().getActivePage();
try {
SimpleFormEditorInput input = new SimpleFormEditorInput(obj.getName());
page.openEditor(input, "com.plugindev.addressbook.tableEditor");
} catch (PartInitException e) {
System.out.println(e);
}
//为Editor增加的操作
}
};
org.eclipse.ui.forms.editor.FormEditor
在创建表格编辑器时,必须继承FormEditor类,而加入到FormEditor编辑器中的每个页面都必须继承FormPage
类,例如:
public class PageWithSubPages extends FormPage {
private FormEditor editor;
private CTabFolder tabFolder;
public PageWithSubPages(FormEditor editor) {
super(editor, "pageWithSub", Messages.PAGE_NAME_PAGEWITHSUB);
this.editor = editor;
}
protected void createFormContent(IManagedForm managedForm) {
ScrolledForm form = managedForm.getForm();
FormToolkit toolkit = managedForm.getToolkit();
form.setText(Messages.PAGE_TITLE_PAGEWITHSUB);
form.setBackgroundImage(ImageCache.getInstance().getImage
(ImageKeys.getImageDescriptor(ImageKeys.IMG_FORM_BG)));
GridLayout layout = new GridLayout();
layout.marginWidth = 10;
form.getBody().setLayout(layout);
tabFolder = new CTabFolder(form.getBody(), SWT.FLAT|SWT.TOP);
toolkit.adapt(tabFolder, true, true);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.heightHint = 0;
tabFolder.setLayoutData(gd);
Color selectedColor = toolkit.getColors().getColor(FormColors.SEPARATOR);
tabFolder.setSelectionBackground(new Color[] {selectedColor, toolkit.getColors
().getBackground()}, new int[] {50});
}
}
主/从风格的页面
MasterDetailsBlock类采用注册页面的方式来构建主从块,registerPages()方法用来为具体的从属页面注册
所允许的数据模型,从而建立起从属页面和数据模型的一一对应关系。
public class MasterDetailsPage extends FormPage {
//该对象代表页面的MasterDetail部分
private ScrolledPropertiesBlock block;
public MasterDetailsPage(FormEditor editor) {
super(editor, "masterDetail", Messages.PAGE_NAME_MASTERDETAIL);
block = new ScrolledPropertiesBlock(this);
}
protected void createFormContent(final IManagedForm managedForm) {
final ScrolledForm form = managedForm.getForm();
form.setText(Messages.PAGE_TITLE_MASTERDETAIL);
form.setBackgroundImage(null);
//该方法非常重要,负责创建Master和Detail区域,尽量在最后调用
block.createContent(managedForm);
}
public IAction getTableAction(String workbenchActionId) {
return block.getTableAction(workbenchActionId);
}
}
具有MasterDetail模式的页面类都要继承自MasterDetailBlock类,并实现该类的3个方法:
1.createMasterPart
在该方法中创建master部分的控件
2.createToolBarActions
创建该页面的工具栏,本例有垂直和水平2个按钮
3.registerPages
注册master对应的detail部分,可以注册多个
public class ScrolledPropertiesBlock extends MasterDetailsBlock {
private FormPage page;
private TableViewer viewer;
private RemoveAddressListAction removeAction;
private Action vaction;
private Action haction;
public ScrolledPropertiesBlock(FormPage page) {
this.page = page;
}
protected void createMasterPart(final IManagedForm managedForm,
Composite parent) {
//final ScrolledForm form = managedForm.getForm();
FormToolkit toolkit = managedForm.getToolkit();
Section section = toolkit.createSection(parent,
Section.DESCRIPTION|Section.TITLE_BAR);
section.setText(Messages.SCROL_BLOC_NAME);
section.setDescription(Messages.SCROL_BLOC_DESCRIP);
section.marginWidth = 10;
section.marginHeight = 5;
Composite client = toolkit.createComposite(section, SWT.WRAP);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = 2;
layout.marginHeight = 2;
client.setLayout(layout);
Table t = toolkit.createTable(client, SWT.NULL);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 20;
gd.widthHint = 100;
gd.verticalSpan = 2;
t.setLayoutData(gd);
toolkit.paintBordersFor(client);
section.setClient(client);
//代表master部分,且把该对象注册到managedForm中
final SectionPart spart = new SectionPart(section);
managedForm.addPart(spart);
viewer = new TableViewer(t);
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
//当选择变化的时候,必须通过managedForm的该方法来发布事件,该事件接受的地方必须
//在Detail页面进行
managedForm.fireSelectionChanged(spart, event.getSelection());
}
});
viewer.setContentProvider(new MasterContentProvider());
viewer.setLabelProvider(new MasterLabelProvider());
viewer.setInput(page.getEditor().getEditorInput());
}
protected void registerPages(DetailsPart detailsPart) {
detailsPart.registerPage(BasicAddressList.class, new BasicAddressListProperties());
detailsPart.registerPage(PhoneAddressList.class, new PhoneAddressListItemProperties());
detailsPart.registerPage(AreaAddressList.class, new AreaAddressListProperties());
}
}
Detail部分必须实现IDetailPage接口,主要是在createContents方法中创建Detail所需要使用的控件,并且
在selectChanged方法中处理当master对象选中事件发生的代码。
public class AddressListProperties implements IDetailsPage {
public AddressListProperties() {
}
public void initialize(IManagedForm mform) {
}
public void createContents(Composite parent) {
}
protected void createSection(Composite parent,
ArrayList<String> stringKeys, Map<String, Object[]>choiceKeysMap)
{
}
//在此方法中处理mater选择事件
public void selectionChanged(IFormPart part, ISelection selection) {
IStructuredSelection ssel = (IStructuredSelection)selection;
if (ssel.size()==1) {
input = (AddressList)ssel.getFirstElement();
s1.setText(input.getName());
s1.setDescription(input.getDescription());
}
else
input = null;
update();
}
public void commit(boolean onSave) {
}
public void setFocus() {
choices[0][0].setFocus();
}
public void dispose() {
}
public boolean isDirty() {
return false;
}
public boolean isStale() {
return false;
}
public void refresh() {
update();
}
public boolean setFormInput(Object input) {
return false;
}
}
发表评论
-
ViewPart的基本操作
2013-01-08 16:00 1049public class AddressView ext ... -
CoolBar
2012-12-16 15:12 1844CoolBar是一个容器,里面可以放置多个工 ... -
ViewForm
2012-12-16 14:53 1464ViewForm是一个容器,它是编辑器的基座,用来 ... -
SWT容器类
2012-12-16 14:34 3236容器类 我们可以通过容器对组件进行统 ... -
控件支持键盘操作
2012-11-12 14:48 844支持键盘删除操作 private void hookK ... -
eclipse表单
2012-11-09 17:45 1582eclispe表单,它的作用就是使swt/jf ... -
视图工具栏
2012-11-08 17:41 866通过编程方式添加视图工具栏和下拉菜单 priva ... -
几个常用的监听器
2012-11-08 17:38 1244为表格或列表查看器添加选择更改监听器 org.ecli ... -
显示上下文菜单
2012-11-08 17:31 1181通过扩展点添加菜单时,必须添加下面的方法,才能显示上下文 ... -
TableView排序
2012-11-08 17:28 873给TableViewer添加排序器的方法: 1.创建一 ... -
操作Action
2012-11-07 17:32 1931IActionDelegate的子类型有IWork ... -
eclipse整体概况
2012-11-07 17:25 1011eclipse通过插件的依赖关系将不同的插件联 ... -
事件监听
2012-07-25 00:03 936一、概述 1.用户在UI界面上的不同操作,会产生不同的 ... -
绘制图形
2012-07-09 22:45 864swt中的绘图功能是通过org.eclipse.s ... -
系统资源类
2012-07-09 00:12 945一、概述 ... -
表格查看器
2012-07-02 00:12 946package com.test.cxm.plugin0 ... -
常用的布局管理器
2012-07-01 18:29 1263SWT有2种控制控件位置和大小的方法:绝对定位和托管定位。 ... -
常用窗口小部件使用实例
2012-06-29 00:24 1362package com.test.cxm.plugin01.p ... -
SWT概述
2012-06-28 23:46 1003import org.eclipse.swt.layout.F ... -
上下文菜单
2011-06-28 16:18 1414popupmenu扩展点是为各种对象上的右键弹出的菜单,添加菜 ...
相关推荐
tif图片多页面编辑器
swing 类型的文本编辑器,附带实现背景音乐。可以实现多页面文本编辑器。
tif文件编辑器是一款多页面TIF文件快速处理工具,对扫描的多页TIF格式文件可进行编辑及格式转换,可以同时处理所有页面、可一次把所有页面导出为单个个图像文件。 基本简介 传真但面对多页格式的TIF文件束手无策吗...
百度编辑器uedtior在一个页面实例化多个以及怎么简化编辑器 公司让我替换前程序员做的网站 后台的编辑器 我用的是百度的 挺好用的 研究了几天 把自己的成果 分享一下
ossLicenseModelEditor-eclipsePlugin Eclipse多页编辑器插件,用于对开放源代码许可证进行建模和可视化。
Markdown 是一种简单的、轻量级的标记...支持Markdown的编辑器太多,功能也不完全一致,有的是用来进行基本的写作,有的是用来写代码的,有的甚至只是博客平台配套的编辑器。本文按照编辑器的平台进行简单的介绍。
使用说明: 1.将 DXControls.dll 文件放于空间根目录的bin文件夹里. 2.在需要用编辑器的ASPX页面代码...4.其中 id 为编辑器的ID,Path为编辑器所需资源(如JS)所在的文件夹,Height为编辑器高度,Width为编辑器宽度.
多页文本编辑器,实现记事本功能,界面美观,非常好用
用在线编辑器或许都会存在一个问题,即内容发表后呈现的样式会与编辑时的不一样,原因是编辑器其实是个内嵌的iframe,它里面用的大多是浏览器默认的样式(ckeditor 在其中另外定义了字体以及ul, ol 的缩进值),而...
在很多后台发布消息的时候,总会用到富文本编辑器,这一款就是一款很好用的富文本编辑器!
基于Eclipse插件的scatter文件编辑器的设计与开发,江坤,张伟洋,文章介绍了一种scatter插件编辑器,编辑器主要采用Eclipse插件多页编辑器技术实现。在详细分析scatter文件的结构和特点基础上,编辑器利
4、添加更多项编辑器属性到编辑器控件属性中,更方便通过编辑器控件订制编辑器UI 控件2012-08-29更新内容 1、调整编辑器版本为Ueditor1.2.3.0 UTF-8 2、控件属性增加SourceEditorFirst 3、调整控件版本号为1.2.4 4...
Net专版百度在线编辑器 V1.2.1 Ueditor特点: 1、体积小巧,性能优良,使用简单 2、分层架构,方便定制...3、修正母版页的内容页无法初始化编辑器的BUG 4、修正一个页面多次引用编辑器控件时编辑器样式多次注册的BUG
Atom编辑器是一款免费的windows代码编辑器,这款软件最大特点是采用Web技术构建桌面程序。Atom基于Chromium核心和Node.js,整个编辑器就是一个Web页面,通过Node.js实现本地文件系统访问、执行第三方进程等功能。...
hhfeditor1.ascx是简洁版编辑器(适合网页前台客户简单留言等)、 hhfeditor2.ascx是功能版编辑器(适合论坛发帖等)、 hhfeditor3.ascx是全能版编辑器(适合后台管理时新闻发布或者网页编辑) 然后在需要调用的地方...
对于其他在线编辑器来说,这几乎是个很难解决的难题,因为在开启编辑器时需要装载太多的文件.比如CUTEEDITOR,虽然功能比FCKEDITOR还要强大,可是,它本身也够庞大了,至于FREETEXTBOX等,其易用性与FCKEDITOR相比,尚有差距...
现在很多的在线文本编辑器,在提交后,如果服务器端较验没成功,点击“退回”时,原来编辑器中编辑的内容就会丢失,而eWebEditor会保持编辑后的状态,并且能够与Reset按钮同步Reset。 智能粘贴 eWebEditor具有三种...
许多人都希望能找到一个象编辑其它类型的文档的编辑器,事实上在Foxit PDF Editor出现之前,根本没有这样的工具。每一个PDF文件都包含很多页面,每一页包含各种可视对象,如文本对象、图形对象和图像对象。而每一个...