Search in sources :

Example 1 with HelperFunction

use of eu.esdihumboldt.cst.functions.groovy.helper.HelperFunction in project hale by halestudio.

the class HelperFunctionLabelProvider method update.

/**
 * @see org.eclipse.jface.viewers.StyledCellLabelProvider#update(org.eclipse.jface.viewers.ViewerCell)
 */
@Override
public void update(ViewerCell cell) {
    Object element = cell.getElement();
    String elementName = null;
    if (element instanceof Category) {
        cell.setText(((Category) element).getName());
        cell.setImage(CommonSharedImages.getImageRegistry().get(CommonSharedImagesConstants.IMG_DEFINITION_GROUP));
    } else if (element instanceof HelperFunctionOrCategory) {
        HelperFunctionSpecification hfs = null;
        elementName = ((HelperFunctionOrCategory) element).getName();
        StyledString text = new StyledString(elementName);
        try {
            HelperFunction<?> helper = ((HelperFunctionOrCategory) element).asFunction();
            hfs = (HelperFunctionSpecification) helper.getSpec(elementName);
            text.append(PageFunctions.getStyledParameters(hfs));
        } catch (Exception e) {
        // 
        }
        cell.setText(text.getString());
        cell.setImage(CommonSharedImages.getImageRegistry().get(CommonSharedImagesConstants.IMG_FUNCTION));
        cell.setStyleRanges(text.getStyleRanges());
    }
    super.update(cell);
}
Also used : HelperFunctionOrCategory(eu.esdihumboldt.cst.functions.groovy.helper.HelperFunctionOrCategory) HelperFunctionOrCategory(eu.esdihumboldt.cst.functions.groovy.helper.HelperFunctionOrCategory) Category(eu.esdihumboldt.cst.functions.groovy.helper.Category) HelperFunctionSpecification(eu.esdihumboldt.cst.functions.groovy.helper.spec.impl.HelperFunctionSpecification) HelperFunction(eu.esdihumboldt.cst.functions.groovy.helper.HelperFunction) StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString)

Aggregations

Category (eu.esdihumboldt.cst.functions.groovy.helper.Category)1 HelperFunction (eu.esdihumboldt.cst.functions.groovy.helper.HelperFunction)1 HelperFunctionOrCategory (eu.esdihumboldt.cst.functions.groovy.helper.HelperFunctionOrCategory)1 HelperFunctionSpecification (eu.esdihumboldt.cst.functions.groovy.helper.spec.impl.HelperFunctionSpecification)1 StyledString (org.eclipse.jface.viewers.StyledString)1