Java Code Examples for org.eclipse.jface.viewers.StructuredViewer#setLabelProvider()

The following examples show how to use org.eclipse.jface.viewers.StructuredViewer#setLabelProvider() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PackagesView.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void setUpViewer(StructuredViewer viewer){
	Assert.isTrue(viewer != null);

	JavaUILabelProvider labelProvider= createLabelProvider();
	viewer.setLabelProvider(createDecoratingLabelProvider(labelProvider));

	viewer.setComparator(createJavaElementComparator());
	viewer.setUseHashlookup(true);

	createContextMenu();

	//disapears when control disposed
	addKeyListener();

	//this methods only adds listeners to the viewer,
	//these listenters disapear when the viewer is disposed
	hookViewerListeners();

	// Set content provider
	viewer.setContentProvider(createContentProvider());
	//Disposed when viewer's Control is disposed
	initDragAndDrop();

}
 
Example 2
Source File: GroupsWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void configureViewer(final StructuredViewer viewer) {
    viewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(final Object element) {
            final String displayName = ((org.bonitasoft.studio.actors.model.organization.Group) element).getDisplayName();
            if (displayName == null || displayName.isEmpty()) {
                return ((org.bonitasoft.studio.actors.model.organization.Group) element).getName();
            }
            return displayName;
        }
    });

    if (groupList != null && getViewer() != null) {
        getViewer().setInput(groupList);
        ((TreeViewer) getViewer()).expandAll();
    }
}