读书人

rcp PropertySheetPage设立属性排序功

发布时间: 2012-11-13 10:00:50 作者: rapoo

rcp PropertySheetPage设置属性排序功能

PropertySheetPage 属性有的时候属性不是按照我们添加的顺序排序的。

其实 PropertySheetPage 默认是按照我们的属性名称来排序的,如何来控制属性的顺序呢?

1:首先需要在你的part中实现? IAdaptable

?

?

2:在getAdapter方法中添加?? 如下:

?

if (adapter == IPropertySheetPage.class) {
???PropertySheetPage page = new PropertySheetPage(){
????@Override
????public void createControl(Composite parent) {
?????// TODO Auto-generated method stub
?????PropertySheetSorter sorter = new PropertySheetSorter() {?
????????????????????????? public int compare(IPropertySheetEntry entryA,?
????????????????????????????????? IPropertySheetEntry entryB) {
????????????????????????????? return getCollator().compare(?
????????????????????????????????????? entryA.getDescription(),?
???????????????????????????????????? entryB.getDescription());?
???????????????????????? }?
????????????????????? };?
??????????????????? this.setSorter(sorter);
?????super.createControl(parent);
????}
???};
???page.setRootEntry(new? PropertySheetEntry());
???return page;

?

?

?

重新设置PropertySheetPage 的PropertySheetSorter??????

?

?

?

PropertyDescriptor profileType=new PropertyDescriptor("profileType","规则类型");
???profileType.setDescription("01");
???descriptors.add(profileType);
???
???PropertyDescriptor profid=new PropertyDescriptor("profid","规则ID");
???profid.setDescription("02");
????? descriptors.add(profid);?
?????
???
???PropertyDescriptor profna=new PropertyDescriptor("profna","中文名称");
???profna.setDescription("03");
???descriptors.add(profna);?

。。。。。。。

读书人网 >编程

热点推荐