Search in sources :

Example 1 with PreferenceEntryManager

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);
}
Also used : PreferenceEntriesContentProvider(org.eclipse.pde.spy.preferences.viewer.PreferenceEntriesContentProvider) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ArrayList(java.util.ArrayList) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) FilteredTree(org.eclipse.e4.ui.dialogs.filteredtree.FilteredTree) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PreferenceMapLabelProvider(org.eclipse.pde.spy.preferences.viewer.PreferenceMapLabelProvider) PreferenceEntryManager(org.eclipse.pde.spy.preferences.model.PreferenceEntryManager) PreferenceEntryPatternFilter(org.eclipse.pde.spy.preferences.model.PreferenceEntryPatternFilter) PreferenceEntry(org.eclipse.pde.spy.preferences.model.PreferenceEntry) ISelection(org.eclipse.jface.viewers.ISelection) FilteredTree(org.eclipse.e4.ui.dialogs.filteredtree.FilteredTree) Tree(org.eclipse.swt.widgets.Tree) PreferenceEntryViewerComparator(org.eclipse.pde.spy.preferences.viewer.PreferenceEntryViewerComparator) Realm(org.eclipse.core.databinding.observable.Realm) DisplayRealm(org.eclipse.jface.databinding.swt.DisplayRealm) FontDescriptor(org.eclipse.jface.resource.FontDescriptor) PostConstruct(javax.annotation.PostConstruct)

Aggregations

ArrayList (java.util.ArrayList)1 PostConstruct (javax.annotation.PostConstruct)1 Realm (org.eclipse.core.databinding.observable.Realm)1 FilteredTree (org.eclipse.e4.ui.dialogs.filteredtree.FilteredTree)1 DisplayRealm (org.eclipse.jface.databinding.swt.DisplayRealm)1 FontDescriptor (org.eclipse.jface.resource.FontDescriptor)1 ISelection (org.eclipse.jface.viewers.ISelection)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 PreferenceEntry (org.eclipse.pde.spy.preferences.model.PreferenceEntry)1 PreferenceEntryManager (org.eclipse.pde.spy.preferences.model.PreferenceEntryManager)1 PreferenceEntryPatternFilter (org.eclipse.pde.spy.preferences.model.PreferenceEntryPatternFilter)1 PreferenceEntriesContentProvider (org.eclipse.pde.spy.preferences.viewer.PreferenceEntriesContentProvider)1 PreferenceEntryViewerComparator (org.eclipse.pde.spy.preferences.viewer.PreferenceEntryViewerComparator)1 PreferenceMapLabelProvider (org.eclipse.pde.spy.preferences.viewer.PreferenceMapLabelProvider)1 Tree (org.eclipse.swt.widgets.Tree)1