View Javadoc
1   package org.argeo.connect.ui.util;
2   
3   import javax.jcr.Node;
4   
5   import org.argeo.connect.AppService;
6   import org.argeo.connect.util.ConnectJcrUtils;
7   import org.eclipse.jface.viewers.ColumnLabelProvider;
8   
9   /**
10   * Best effort to determine the most import type of the current Node (or of the
11   * node retrieved in current Row with this selector Name) and returns a human
12   * friendly label.
13   */
14  public class MainNodeTypeLabelProvider extends ColumnLabelProvider {
15  	private static final long serialVersionUID = 6026760216411653801L;
16  
17  	private AppService appService;
18  	private String selectorName = null;
19  
20  	public MainNodeTypeLabelProvider(AppService appService) {
21  		this.appService = appService;
22  	}
23  
24  	public MainNodeTypeLabelProvider(AppService appService, String selectorName) {
25  		this.appService = appService;
26  		this.selectorName = selectorName;
27  	}
28  
29  	@Override
30  	public String getText(Object element) {
31  		Node currNode = ConnectJcrUtils.getNodeFromElement(element, selectorName);
32  		String label = appService.getMainNodeType(currNode);
33  		return appService.getLabel(label);
34  	}
35  }