use of org.eclipse.pde.spy.preferences.model.PreferenceEntry in project eclipse.pde by eclipse-pde.
the class PreferenceSpyPart method preferenceChanged.
@Inject
@Optional
public void preferenceChanged(@UIEventTopic(PreferenceSpyEventTopics.PREFERENCESPY_PREFERENCE_CHANGED) PreferenceChangeEvent event) {
PreferenceNodeEntry preferenceNodeEntry = preferenceEntryManager.getRecentPreferenceNodeEntry(event.getNode().absolutePath());
PreferenceEntry preferenceEntry = new PreferenceEntry(event.getNode().absolutePath(), event.getKey());
preferenceEntry.setRecentlyChanged(true);
if (null == preferenceNodeEntry) {
preferenceNodeEntry = new PreferenceNodeEntry(event.getNode().absolutePath());
preferenceNodeEntry.setRecentlyChanged(true);
preferenceNodeEntry.addChildren(preferenceEntry);
preferenceEntry.setParent(preferenceNodeEntry);
preferenceEntryManager.addChildren(preferenceNodeEntry);
filteredTree.getViewer().setInput(preferenceEntryManager);
preferenceEntryManager.putRecentPreferenceEntry(event.getNode().absolutePath(), preferenceNodeEntry);
} else {
preferenceEntry.setParent(preferenceNodeEntry);
PreferenceEntry existingPreferenceEntry = findPreferenceEntry(preferenceEntry);
if (existingPreferenceEntry != null) {
preferenceEntry = existingPreferenceEntry;
} else {
preferenceNodeEntry.addChildren(preferenceEntry);
}
}
preferenceEntry.setOldValue(String.valueOf(event.getOldValue()));
preferenceEntry.setNewValue(String.valueOf(event.getNewValue()));
long currentTimeMillis = System.currentTimeMillis();
preferenceEntry.setTime(currentTimeMillis);
preferenceEntry.getParent().setTime(currentTimeMillis);
filteredTree.getViewer().refresh();
}
use of org.eclipse.pde.spy.preferences.model.PreferenceEntry in project eclipse.pde by eclipse-pde.
the class PreferenceSpyPart method DeletePreferenceEntries.
@Inject
@Optional
public void DeletePreferenceEntries(@UIEventTopic(PreferenceSpyEventTopics.PREFERENCESPY_PREFERENCE_ENTRIES_DELETE) List<PreferenceEntry> preferenceEntries) {
if (preferenceEntries != null && !preferenceEntries.isEmpty()) {
for (PreferenceEntry preferenceEntry : preferenceEntries) {
preferenceEntryManager.removeChildren(preferenceEntry);
}
preferenceEntryManager.removeChildren(preferenceEntries);
filteredTree.getViewer().refresh();
}
}
use of org.eclipse.pde.spy.preferences.model.PreferenceEntry 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);
}
use of org.eclipse.pde.spy.preferences.model.PreferenceEntry in project eclipse.pde by eclipse-pde.
the class PreferenceEntryViewerComparator method compare.
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
if (e1 instanceof PreferenceEntry && e2 instanceof PreferenceEntry) {
PreferenceEntry entry1 = (PreferenceEntry) e1;
PreferenceEntry entry2 = (PreferenceEntry) e2;
long time = entry1.getTime();
long time2 = entry2.getTime();
if (time != 0 && time2 != 0) {
return (int) (time2 - time);
}
}
return super.compare(viewer, e1, e2);
}
Aggregations