The default property sheet provided by EMF sorts the attributes in Alphabetical Order, no matter what is the actual order of definition in the ecore. However EMF uses the generator GAP pattern, so one can change the generated code and mark such API as @generated NOT. So no mess up during regeneration
1. Implement a Custom Sorter
1. Implement a Custom Sorter
package
com.odcgroup.edge.t24ui.common.presentation;
import
org.eclipse.ui.views.properties.IPropertySheetEntry;
import
org.eclipse.ui.views.properties.PropertySheetSorter;
public class
CustomPropertySheetSorter extends PropertySheetSorter {
@Override
public void
sort(IPropertySheetEntry[] entries) {
//
do nothing;
//
or may be your custom logic
}
}
2. Implement a CustomPropertSheetPage
which sets the newly implemented sorter. In simple just replace the getPropertySheetPage() method in the generated Editor (ex : YourEditor.java) by the snippet below
/**
* This accesses a cached version of the property sheet.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public IPropertySheetPage
getPropertySheetPage() {
class
MyCustomPropertySheetPage extends ExtendedPropertySheetPage {
/**
* @param editingDomain
*/
public
MyCustomPropertySheetPage(AdapterFactoryEditingDomain editingDomain) {
super(editingDomain);
setSorter(new
CustomPropertySheetSorter());
}
@Override
public void
setSelectionToViewer(List<?> selection) {
YourEditor.this.setSelectionToViewer(selection);
YourEditor.this.setFocus();
}
@Override
public void
setActionBars(IActionBars actionBars) {
super.setActionBars(actionBars);
getActionBarContributor().shareGlobalActions(this, actionBars);
}
}
PropertySheetPage propertySheetPage = new MyCustomPropertySheetPage(editingDomain);
propertySheetPage.setPropertySourceProvider(new
AdapterFactoryContentProvider(adapterFactory));
propertySheetPages.add(propertySheetPage);
return propertySheetPage;
}
No comments:
Post a Comment