use of org.eclipse.pde.spy.preferences.model.PreferenceEntryManager in project eclipse.pde by eclipse-pde.
the class PreferenceSpyPart method postConstruct.
@SuppressWarnings("unchecked")
@PostConstruct
public void postConstruct(Composite parent, final ESelectionService selectionService, EModelService modelService, MWindow window) {
preferenceEntryManager = new PreferenceEntryManager();
PreferenceEntryPatternFilter patternFilter = new PreferenceEntryPatternFilter();
patternFilter.setIncludeLeadingWildcard(true);
filteredTree = new FilteredTree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, patternFilter);
Tree table = filteredTree.getViewer().getTree();
table.setHeaderVisible(true);
table.setLinesVisible(true);
filteredTree.getViewer().addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
if (selection instanceof IStructuredSelection) {
ArrayList<PreferenceEntry> preferenceEntries = new ArrayList<PreferenceEntry>(((IStructuredSelection) selection).toList());
selectionService.setSelection(preferenceEntries);
}
}
});
createColumn(Fields.nodePath, Messages.PreferenceSpyPart_Nodepath, 300);
createColumn(Fields.key, Messages.PreferenceSpyPart_Key, 300);
createColumn(Fields.oldValue, Messages.PreferenceSpyPart_Old_Value, 150);
createColumn(Fields.newValue, Messages.PreferenceSpyPart_New_Value, 150);
filteredTree.getViewer().setComparator(new PreferenceEntryViewerComparator());
FontDescriptor fontDescriptor = getBoldFontDescriptor();
Realm realm = DisplayRealm.getRealm(filteredTree.getViewer().getControl().getDisplay());
PreferenceEntriesContentProvider contentProvider = new PreferenceEntriesContentProvider(BeanProperties.set("preferenceEntries", PreferenceNodeEntry.class).setFactory(realm), null);
contentProvider.setHierarchicalLayout(hierarchicalLayoutPreference);
filteredTree.getViewer().setContentProvider(contentProvider);
filteredTree.getViewer().setLabelProvider(new PreferenceMapLabelProvider(fontDescriptor, Properties.observeEach(contentProvider.getKnownElements(), BeanProperties.values(PreferenceEntry.class, "nodePath", "key", "oldValue", "newValue"))));
filteredTree.getViewer().setInput(preferenceEntryManager);
}
Aggregations