Example usage for org.eclipse.jface.viewers ViewerCell setImage

List of usage examples for org.eclipse.jface.viewers ViewerCell setImage

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers ViewerCell setImage.

Prototype

public void setImage(Image image) 

Source Link

Document

Set the Image for the cell.

Usage

From source file:net.tourbook.ui.views.tourBook.TourBookView.java

License:Open Source License

/**
 * column: clouds/* w w w.j  av a2s.  co m*/
 */
private void defineColumn_Weather_Clouds() {

    final TreeColumnDefinition colDef = TreeColumnFactory.WEATHER_CLOUDS.createColumn(_columnManager, _pc);

    colDef.setIsDefaultColumn();

    colDef.setLabelProvider(new CellLabelProvider() {

        @Override
        public void update(final ViewerCell cell) {

            final Object element = cell.getElement();
            final String windClouds = ((TVITourBookItem) element).colClouds;

            if (windClouds == null) {
                cell.setText(UI.EMPTY_STRING);
            } else {
                final Image img = net.tourbook.common.UI.IMAGE_REGISTRY.get(windClouds);
                if (img != null) {
                    cell.setImage(img);
                } else {
                    cell.setText(windClouds);
                }
            }

            setCellColor(cell, element);
        }
    });
}

From source file:net.tourbook.ui.views.tourCatalog.TourCatalogView.java

License:Open Source License

/**
 * column: tour type//from w w  w  .j a  v  a 2s.co m
 */
private void defineColumn_TourType() {

    final TreeColumnDefinition colDef = TreeColumnFactory.TOUR_TYPE.createColumn(_columnManager, _pc);
    colDef.setIsDefaultColumn();
    colDef.setLabelProvider(new CellLabelProvider() {
        @Override
        public void update(final ViewerCell cell) {
            final Object element = cell.getElement();
            if (element instanceof TVICatalogComparedTour) {
                cell.setImage(UI.getInstance().getTourTypeImage(((TVICatalogComparedTour) element).tourTypeId));
            }
        }
    });
}

From source file:net.tourbook.ui.views.tourCatalog.TourCompareResultView.java

License:Open Source License

/**
 * tree column: reference tour/date//  ww  w .  j  a  v a2s.c om
 */
private void defineColumn_1st_ComparedTour() {

    final TreeColumnDefinition colDef = new TreeColumnDefinition(_columnManager, "comparedTour", SWT.LEAD); //$NON-NLS-1$

    colDef.setIsDefaultColumn();
    colDef.setColumnLabel(Messages.Compare_Result_Column_tour);
    colDef.setColumnHeaderText(Messages.Compare_Result_Column_tour);
    colDef.setDefaultColumnWidth(_pc.convertWidthInCharsToPixels(25) + 16);
    colDef.setCanModifyVisibility(false);
    colDef.setLabelProvider(new TourInfoToolTipCellLabelProvider() {

        @Override
        public Long getTourId(final ViewerCell cell) {

            final Object element = cell.getElement();
            if (element instanceof TVICompareResultReferenceTour) {

                return ((TVICompareResultReferenceTour) element).tourId;

            } else if (element instanceof TVICompareResultComparedTour) {

                return ((TVICompareResultComparedTour) element).comparedTourData.getTourId();
            }

            return null;
        }

        @Override
        public void update(final ViewerCell cell) {

            final Object element = cell.getElement();
            if (element instanceof TVICompareResultReferenceTour) {

                final TVICompareResultReferenceTour refItem = (TVICompareResultReferenceTour) element;
                cell.setText(refItem.label);

            } else if (element instanceof TVICompareResultComparedTour) {

                final TVICompareResultComparedTour compareItem = (TVICompareResultComparedTour) element;
                cell.setText(TourManager.getTourDateShort(compareItem.comparedTourData));

                // display an image when a tour is saved
                if (compareItem.isSaved()) {
                    cell.setImage(_dbImage);
                } else {
                    cell.setImage(null);
                }
            }

            setCellColor(cell, element);
        }
    });
}

From source file:net.tourbook.ui.views.tourCatalog.TourCompareResultView.java

License:Open Source License

/**
 * column: tour type//from  w  ww .  j av a2  s  . co m
 */
private void defineColumn_Tour_Type() {

    final TreeColumnDefinition colDef = TreeColumnFactory.TOUR_TYPE.createColumn(_columnManager, _pc);

    colDef.setLabelProvider(new CellLabelProvider() {
        @Override
        public void update(final ViewerCell cell) {
            final Object element = cell.getElement();
            if (element instanceof TVICompareResultComparedTour) {
                final TourData comparedTourData = ((TVICompareResultComparedTour) element).comparedTourData;
                final TourType tourType = comparedTourData.getTourType();
                if (tourType != null) {
                    cell.setImage(net.tourbook.ui.UI.getInstance().getTourTypeImage(tourType.getTypeId()));
                }
            }
        }
    });
}

From source file:org.absmodels.abs.plugin.debug.views.debugview.DebugTreeStyledLabelProvider.java

License:Open Source License

@Override
public void update(ViewerCell cell) {

    Object obj = cell.getElement();

    StyledString styledString = getLabel(obj);

    cell.setText(styledString.toString());
    cell.setStyleRanges(styledString.getStyleRanges());
    cell.setImage(getImage(obj));
    super.update(cell);
}

From source file:org.absmodels.abs.plugin.editor.outline.ABSContentOutlineStyledLabelProvider.java

License:Open Source License

@Override
public void update(ViewerCell cell) {
    Object obj = cell.getElement();

    StyledString styledString = getLabel(obj);

    cell.setText(styledString.toString());
    cell.setStyleRanges(styledString.getStyleRanges());
    cell.setImage(getImage(obj));
    super.update(cell);
}

From source file:org.absmodels.abs.plugin.navigator.ABSNavigatorStyledLabelProvider.java

License:Open Source License

@Override
public void update(ViewerCell cell) {
    Object obj = cell.getElement();

    StyledString styledString = getStyledString(obj);

    cell.setText(styledString.toString());
    cell.setStyleRanges(styledString.getStyleRanges());
    cell.setImage(getImage(obj));
    super.update(cell);
}

From source file:org.apache.directory.studio.openldap.config.editor.wrappers.DatabaseWrapperLabelProvider.java

License:Apache License

/**
 * Shows the Database name, and grey it if it's disabled.
 * //from  w ww. j  a v a  2s.c o m
 * {@inheritDoc}
 */
@Override
public void update(ViewerCell cell) {
    Object element = cell.getElement();

    if (element instanceof DatabaseWrapper) {
        DatabaseWrapper database = (DatabaseWrapper) element;
        OlcDatabaseConfig databaseConfig = database.getDatabase();
        String databaseType = getDatabaseType(databaseConfig);
        String databaseSuffix = getSuffix(databaseConfig);

        String databaseName = new StringBuilder(databaseType).append(" (").append(databaseSuffix).append(")")
                .toString();

        // the olcDisabled AT is only present in 2.5
        // TODO : check with the schemaManager
        /*
        Boolean disabled = database.getDatabase().getOlcDisabled();
        StyledString styledString = null;
                
        // Grey the database if it's disabled.
        if ( ( disabled == null ) || !disabled )
        {  
        styledString = new StyledString( databaseName, grayedStyle );
        }
        else
        {
        styledString = new StyledString( databaseName, null );
        }
        */

        StyledString styledString = new StyledString(databaseName, null);
        cell.setText(styledString.toString());
        cell.setStyleRanges(styledString.getStyleRanges());
        cell.setImage(getImage(database));
    }

    super.update(cell);
}

From source file:org.bonitasoft.studio.actors.configuration.ActorMappingStyledTreeLabelProvider.java

License:Open Source License

@Override
public void update(ViewerCell cell) {
    final Object cellElement = cell.getElement();
    if (cellElement instanceof ActorMapping) {
        ActorMapping actor = (ActorMapping) cellElement;
        StyledString styledString = new StyledString();
        styledString.append(actor.getName(), null);
        if (isNotDefined(actor)) {
            styledString.append(" -- ");
            styledString.append(Messages.notMappedActors, StyledString.DECORATIONS_STYLER);
        }/* ww w .jav  a 2  s.c o m*/
        cell.setText(styledString.getString());
        cell.setImage(null);
        cell.setStyleRanges(styledString.getStyleRanges());
    } else if (cellElement != null) {
        cell.setText(labelProvider.getText(cellElement));
        cell.setImage(labelProvider.getImage(cellElement));
    }
}

From source file:org.bonitasoft.studio.actors.ui.section.StyledFilterLabelProvider.java

License:Open Source License

@Override
public void update(ViewerCell cell) {
    if (cell.getElement() instanceof ActorFilter) {
        ActorFilter filter = (ActorFilter) cell.getElement();
        ConnectorDefinition def = defStore.getDefinition(filter.getDefinitionId(),
                filter.getDefinitionVersion());
        StyledString styledString = new StyledString();

        styledString.append(getText(filter), null);
        styledString.append(" -- ", StyledString.QUALIFIER_STYLER);
        String connectorType = filter.getDefinitionId() + " (" + filter.getDefinitionVersion() + ")";
        styledString.append(connectorType, StyledString.DECORATIONS_STYLER);
        if (filter.getEvent() != null && !filter.getEvent().isEmpty()) {
            styledString.append(" -- ", StyledString.QUALIFIER_STYLER);
            styledString.append(filter.getEvent(), StyledString.COUNTER_STYLER);
        }/* w  w w . j av a2 s .c  om*/
        if (def == null) {
            styledString.setStyle(0, styledString.length(),
                    new org.eclipse.jface.viewers.StyledString.Styler() {

                        @Override
                        public void applyStyles(TextStyle textStyle) {
                            textStyle.strikeout = true;
                        }
                    });
            styledString.append(" ");
            styledString.append(Messages.bind(Messages.filterDefinitionNotFound,
                    filter.getDefinitionId() + " (" + filter.getDefinitionVersion() + ")"));
        }

        cell.setText(styledString.getString());
        cell.setImage(getImage(filter));
        cell.setStyleRanges(styledString.getStyleRanges());
    }
}