blob: 90890ad1270f663f3c6c746f733fe838957de996 [file] [log] [blame]
/*=============================================================================#
# Copyright (c) 2012, 2021 Stephan Wahlbrink and others.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
# which is available at https://www.apache.org/licenses/LICENSE-2.0.
#
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
#
# Contributors:
# Stephan Wahlbrink <sw@wahlbrink.eu> - initial API and implementation
#=============================================================================*/
package org.eclipse.statet.internal.r.ui.datafilterview;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.CellLabelProvider;
import org.eclipse.jface.viewers.ViewerCell;
import org.eclipse.swt.graphics.Font;
import org.eclipse.statet.ecommons.waltable.data.ControlData;
import org.eclipse.statet.r.ui.dataeditor.RDataTableColumn;
public class ColumnLabelProvider extends CellLabelProvider {
private final RDataTableColumn column;
private Font infoFont;
public ColumnLabelProvider(final RDataTableColumn column) {
this.column= column;
}
@Override
public void update(final ViewerCell cell) {
final Object data= this.column.getDefaultFormat().modelToDisplayValue(cell.getElement());
cell.setFont((data instanceof ControlData) ? getInfoFont() : null);
cell.setText(data.toString());
}
protected Font getInfoFont() {
if (this.infoFont == null) {
this.infoFont= JFaceResources.getFontRegistry().getItalic(JFaceResources.DIALOG_FONT);
}
return this.infoFont;
}
}