/*******************************************************************************
* Copyright (c) 2009, 2010 Innovation Gate GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Innovation Gate GmbH - initial API and implementation
******************************************************************************/
package de.innovationgate.eclipse.utils.ui.model;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.viewers.ITableColorProvider;
import org.eclipse.jface.viewers.ITableFontProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.StyledCellLabelProvider;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.jface.viewers.ViewerCell;
import org.eclipse.jface.viewers.StyledString.Styler;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.TextStyle;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
public class TaskStatusModelLabelProvider extends StyledCellLabelProvider {
@Override
public void update(ViewerCell cell) {
//String text = _model.getColumnText((TaskStatus)cell.getElement(), cell.getColumnIndex());
StyledString styledString = new StyledString(cell.getColumnIndex() + "#");
cell.setText(styledString.getString());
cell.setStyleRanges(styledString.getStyleRanges());
super.update(cell);
//getViewer().refresh(true);
}
protected void measure(Event event, Object element) {
super.measure(event, element);
}
private TaskStatusModel _model;
public TaskStatusModelLabelProvider(TaskStatusModel model) {
_model = model;
}
public Image getColumnImage(Object element, int column) {
if (column == 2) {
TaskStatus status = (TaskStatus) element;
status.getSeverity();
}
return null;
}
public String getColumnText(Object element, int column) {
if (column != 2) {
return _model.getColumnText((TaskStatus)element, column);
}
return null;
}
public Color getBackground(Object element, int column) {
return Display.getCurrent().getSystemColor(SWT.COLOR_WHITE);
}
public Color getForeground(Object element, int column) {
if (column == 1) {
return Display.getCurrent().getSystemColor(SWT.COLOR_BLUE);
} else {
return Display.getCurrent().getSystemColor(SWT.COLOR_BLACK);
}
}
public Font getFont(Object element, int columnIndex) {
Font font = Display.getCurrent().getFocusControl().getFont();
if (columnIndex == 1) {
font = new Font(Display.getCurrent(), new FontData("Arial", 10, SWT.NORMAL));
}
return font;
}
}