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);?
。。。。。。。