/** * Binds the viewer to the specified input, using the specified children * property to generate child nodes, and the specified label properties to * generate labels. * * @param viewer * the tree viewer to set up * @param input * the input to set on the viewer * @param childrenProperty * the property to use as the children of an element * @param labelProperties * the respective properties to use for labels in each of the * viewer's columns */ public static void bind(AbstractTreeViewer viewer, Object input, IListProperty childrenProperty, IValueProperty... labelProperties) { Realm realm = DisplayRealm.getRealm(viewer.getControl().getDisplay()); ObservableListTreeContentProvider contentProvider = new ObservableListTreeContentProvider( childrenProperty.listFactory(realm), null); if (viewer.getInput() != null) viewer.setInput(null); viewer.setContentProvider(contentProvider); viewer.setLabelProvider(new ObservableMapLabelProvider(Properties .observeEach(contentProvider.getKnownElements(), labelProperties))); if (input != null) viewer.setInput(input); }
/** * Binds the viewer to the specified input, using the specified children * property to generate child nodes, and the specified label properties to * generate labels. * * @param viewer * the tree viewer to set up * @param input * the input to set on the viewer * @param childrenProperty * the property to use as the children of an element * @param labelProperties * the respective properties to use for labels in each of the * viewer's columns */ public static void bind(AbstractTreeViewer viewer, Object input, ISetProperty childrenProperty, IValueProperty... labelProperties) { Realm realm = DisplayRealm.getRealm(viewer.getControl().getDisplay()); ObservableSetTreeContentProvider contentProvider = new ObservableSetTreeContentProvider( childrenProperty.setFactory(realm), null); if (viewer.getInput() != null) viewer.setInput(null); viewer.setContentProvider(contentProvider); viewer.setLabelProvider(new ObservableMapLabelProvider(Properties .observeEach(contentProvider.getKnownElements(), labelProperties))); if (input != null) viewer.setInput(input); } }