显示标签为“eclipse”的博文。显示所有博文
显示标签为“eclipse”的博文。显示所有博文

2009年8月24日星期一

RCP 编程记录

RCP Perspective中View的布局
Perspective用于把一组任务相关的视图组合在一起提供给用户,其中有个区域叫做EditorArea,这个区域用于放置编辑器。
如果你的perspective无需编辑器,则可以通过pageLayout.setEditorAreaVisible(false);把编辑区域隐藏起来。这样,你的workspace就不会有一块灰色的区域了。

如果想让两个view占据一个位置(如IPageLayout.RIGHT),在Perspective类中的createInitialLayout用如下方法:
IFolderLayout folder = layout.createFolder("messages", IPageLayout.RIGHT,
0.75f, IPageLayout.ID_EDITOR_AREA);
folder.addPlaceholder(View1.ID + ":*");
folder.addView(View1.ID);
folder.addPlaceholder(View2.ID + ":*");
folder.addView(View2.ID);

要使得一开始view不可见,只当用户点击触发showView的时候才显示,可以如下:folder.addPlaceholder(View1.ID + ":*");
不要加上folder.addView(View1.ID)就可以了。
如果要使得Editor消失不可见,可以在Perspective类中的createInitialLayout加上一句,如下:
layout.setEditorAreaVisible(false);
如果要使得某个view不能关闭,可以在Perspective类中的createInitialLayout加上一句,如下:
layout.getViewLayout(View.ID).setCloseable(false);


TableListViewer的可编辑cell
按照一般的套路:设置tableviewer的columnProperties;设置CellEditors;设置CellModitifier;
其中实现ICellModitifier接口比较繁琐点。
最后值得注意的是:需要把ListTableView设置为SWT.FULL_SELECTION。否则,就必须单击两次,第一次表示选中,第二次表示编辑。

2009年5月14日星期四

Eclipse's CheckboxCellEditor

项目中需要把表格中的某列用checkbox表示出来,按照《eclipse从入门到精通》中的步骤没有弄出来。
这是eclipse celleditor的一些samples: http://wiki.eclipse.org/index.php/JFaceSnippets#Snippet009CellEditors

TableViewerColumn TableColumn的区别?
TableViewerColumn .getColumn() 返回的是TableColumn对象。什么时候该用哪个呢?

尝试,ComboBoxCellEditor, 发现EditingSupport子类的getValue()需要返回Integer类型。CheckboxCellEditor则需要返回Boolean类型。
跟踪到CheckboxCellEditor的
protected Control createControl(Composite parent) {
return null;
},发现它根本没有实现。所以,CheckboxCellEditor是根本不能使用的。需要你继承它来完成这个方法。真是奇怪eclipse为什么不提供个实现呢?

最后发现了一个类似于CheckboxCellEditor的实现BooleanCellEditor: http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.snippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippets/viewers/BooleanCellEditor.java?view=markup 但是,BooleanCellEditor需要运行在eclipse3.4。