use of org.eclipse.jface.viewers.IFontProvider in project polymap4-core by Polymap4.
the class NavigatorContentServiceLabelProvider method getFont.
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
*/
public Font getFont(Object anElement) {
ILabelProvider[] labelProviders = contentService.findRelevantLabelProviders(anElement);
for (int i = 0; i < labelProviders.length; i++) {
ILabelProvider provider = labelProviders[i];
if (provider instanceof IFontProvider) {
IFontProvider fontProvider = (IFontProvider) provider;
Font font = fontProvider.getFont(anElement);
if (font != null) {
return font;
}
}
}
return null;
}
use of org.eclipse.jface.viewers.IFontProvider in project archi by archimatetool.
the class GraphItemStyler method styleItem.
public static void styleItem(GraphItem item, final IBaseLabelProvider labelProvider) {
if (item instanceof GraphNode) {
GraphNode node = (GraphNode) item;
// set defaults.
if (node.getGraphModel().getNodeStyle() != ZestStyles.NONE) {
node.setNodeStyle(node.getGraphModel().getNodeStyle());
} else {
node.setNodeStyle(SWT.NONE);
}
Object entity = node.getData();
if (labelProvider instanceof IEntityStyleProvider) {
styleNode(node, (IEntityStyleProvider) labelProvider);
}
if (labelProvider instanceof IColorProvider) {
IColorProvider colorProvider = (IColorProvider) labelProvider;
node.setForegroundColor(colorProvider.getForeground(entity));
node.setBackgroundColor(colorProvider.getBackground(entity));
}
if (labelProvider instanceof IFontProvider) {
IFontProvider fontProvider = (IFontProvider) labelProvider;
node.setFont(fontProvider.getFont(entity));
}
if (labelProvider instanceof ILabelProvider) {
String text = ((ILabelProvider) labelProvider).getText(node.getData());
// $NON-NLS-1$
node.setText((text != null) ? text : "");
node.setImage(((ILabelProvider) labelProvider).getImage(node.getData()));
}
if (labelProvider instanceof ISelfStyleProvider) {
((ISelfStyleProvider) labelProvider).selfStyleNode(entity, node);
}
} else if (item instanceof GraphConnection) {
GraphConnection conn = (GraphConnection) item;
// set defaults
if (conn.getGraphModel().getConnectionStyle() != ZestStyles.NONE) {
int s = conn.getGraphModel().getConnectionStyle();
conn.setConnectionStyle(s);
} else {
conn.setConnectionStyle(SWT.NONE);
}
if (labelProvider instanceof ILabelProvider) {
String text = ((ILabelProvider) labelProvider).getText(conn.getExternalConnection());
// $NON-NLS-1$
conn.setText((text != null) ? text : "");
conn.setImage(((ILabelProvider) labelProvider).getImage(conn.getExternalConnection()));
}
if (labelProvider instanceof IEntityConnectionStyleProvider) {
styleEntityConnection(conn, (IEntityConnectionStyleProvider) labelProvider);
} else if (labelProvider instanceof IConnectionStyleProvider) {
styleConnection(conn, (IConnectionStyleProvider) labelProvider);
}
int swt = getLineStyleForZestStyle(conn.getConnectionStyle());
conn.setLineStyle(swt);
if (labelProvider instanceof ISelfStyleProvider) {
((ISelfStyleProvider) labelProvider).selfStyleConnection(conn.getData(), conn);
}
}
}
use of org.eclipse.jface.viewers.IFontProvider in project dbeaver by serge-rider.
the class ObjectListDialog method createObjectSelector.
@NotNull
protected static <T extends DBPObject> DatabaseObjectListControl<T> createObjectSelector(Composite group, boolean singleSelection, String listId, List<T> selectedObjects, DBRRunnableWithResult<List<T>> objectReader) {
return new DatabaseObjectListControl<T>(group, (singleSelection ? SWT.SINGLE : SWT.MULTI), null, new ListContentProvider()) {
private Font boldFont;
private ISearchExecutor searcher = new SearcherFilter();
@NotNull
@Override
protected String getListConfigId(List<Class<?>> classList) {
return listId;
}
@Override
protected LoadingJob<Collection<T>> createLoadService() {
return LoadingJob.createService(new AbstractLoadService<Collection<T>>() {
@Override
public Collection<T> evaluate(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
objectReader.run(monitor);
return objectReader.getResult();
}
@Override
public Object getFamily() {
return ObjectListDialog.class;
}
}, new ObjectsLoadVisualizer() {
@Override
public void completeLoading(Collection<T> items) {
super.completeLoading(items);
performSearch(SearchType.NONE);
getItemsViewer().getControl().setFocus();
}
});
}
protected CellLabelProvider getColumnLabelProvider(ObjectColumn objectColumn) {
return new ObjectLabelProvider(objectColumn);
}
@Override
protected Object getObjectValue(T item) {
if (item instanceof DBSWrapper) {
return ((DBSWrapper) item).getObject();
}
return super.getObjectValue(item);
}
@Override
protected DBPImage getObjectImage(T item) {
if (item instanceof DBNDatabaseNode) {
return ((DBNDatabaseNode) item).getNodeIcon();
}
return null;
}
@Override
protected void setListData(Collection<T> items, boolean append) {
super.setListData(items, append);
if (selectedObjects != null) {
getItemsViewer().setSelection(new StructuredSelection(selectedObjects), true);
}
}
@Override
public void fillCustomActions(IContributionManager contributionManager) {
super.fillCustomActions(contributionManager);
addColumnConfigAction(contributionManager);
}
protected void addSearchAction(IContributionManager contributionManager) {
contributionManager.add(new Action("Filter objects", DBeaverIcons.getImageDescriptor(UIIcon.SEARCH)) {
@Override
public void run() {
performSearch(SearchType.NONE);
}
});
}
@Override
protected ISearchExecutor getSearchRunner() {
return searcher;
}
class ObjectLabelProvider extends ObjectColumnLabelProvider implements IFontProvider {
ObjectLabelProvider(ObjectColumn objectColumn) {
super(objectColumn);
}
@Override
public Font getFont(Object element) {
if (selectedObjects.contains(element)) {
if (boldFont == null) {
boldFont = UIUtils.makeBoldFont(group.getFont());
group.addDisposeListener(e -> boldFont.dispose());
}
return boldFont;
}
return null;
}
}
};
}
use of org.eclipse.jface.viewers.IFontProvider in project dbeaver by dbeaver.
the class ObjectListDialog method createObjectSelector.
@NotNull
protected static <T extends DBPObject> DatabaseObjectListControl<T> createObjectSelector(Composite group, boolean singleSelection, String listId, List<T> selectedObjects, DBRRunnableWithResult<List<T>> objectReader) {
return new DatabaseObjectListControl<T>(group, (singleSelection ? SWT.SINGLE : SWT.MULTI), null, new ListContentProvider()) {
private Font boldFont;
private ISearchExecutor searcher = new SearcherFilter();
@NotNull
@Override
protected String getListConfigId(List<Class<?>> classList) {
return listId;
}
@Override
protected LoadingJob<Collection<T>> createLoadService() {
return LoadingJob.createService(new AbstractLoadService<Collection<T>>() {
@Override
public Collection<T> evaluate(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
objectReader.run(monitor);
return objectReader.getResult();
}
@Override
public Object getFamily() {
return ObjectListDialog.class;
}
}, new ObjectsLoadVisualizer() {
@Override
public void completeLoading(Collection<T> items) {
super.completeLoading(items);
performSearch(SearchType.NONE);
getItemsViewer().getControl().setFocus();
}
});
}
protected CellLabelProvider getColumnLabelProvider(ObjectColumn objectColumn) {
return new ObjectLabelProvider(objectColumn);
}
@Override
protected Object getObjectValue(T item) {
if (item instanceof DBSWrapper) {
return ((DBSWrapper) item).getObject();
}
return super.getObjectValue(item);
}
@Override
protected DBPImage getObjectImage(T item) {
if (item instanceof DBNDatabaseNode) {
return ((DBNDatabaseNode) item).getNodeIcon();
}
return null;
}
@Override
protected void setListData(Collection<T> items, boolean append) {
super.setListData(items, append);
if (selectedObjects != null) {
getItemsViewer().setSelection(new StructuredSelection(selectedObjects), true);
}
}
@Override
public void fillCustomActions(IContributionManager contributionManager) {
super.fillCustomActions(contributionManager);
addColumnConfigAction(contributionManager);
}
protected void addSearchAction(IContributionManager contributionManager) {
contributionManager.add(new Action("Filter objects", DBeaverIcons.getImageDescriptor(UIIcon.SEARCH)) {
@Override
public void run() {
performSearch(SearchType.NONE);
}
});
}
@Override
protected ISearchExecutor getSearchRunner() {
return searcher;
}
class ObjectLabelProvider extends ObjectColumnLabelProvider implements IFontProvider {
ObjectLabelProvider(ObjectColumn objectColumn) {
super(objectColumn);
}
@Override
public Font getFont(Object element) {
if (selectedObjects.contains(element)) {
if (boldFont == null) {
boldFont = UIUtils.makeBoldFont(group.getFont());
group.addDisposeListener(e -> boldFont.dispose());
}
return boldFont;
}
return null;
}
}
};
}
Aggregations