org.eclipse.jface.viewers.ViewerCell#setBackground ( )源码实例Demo

下面列出了org.eclipse.jface.viewers.ViewerCell#setBackground ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: nebula   文件: XViewerStyledTextLabelProvider.java
@Override
public void update(ViewerCell cell) {
   Object element = cell.getElement();

   StyledString styledString = getStyledText(element, cell.getColumnIndex());
   String newText = styledString.toString();

   StyleRange[] oldStyleRanges = cell.getStyleRanges();
   StyleRange[] newStyleRanges = isOwnerDrawEnabled() ? styledString.getStyleRanges() : null;

   if (!Arrays.equals(oldStyleRanges, newStyleRanges)) {
      cell.setStyleRanges(newStyleRanges);
   }

   cell.setText(newText);
   cell.setImage(getColumnImage(element, cell.getColumnIndex()));
   cell.setFont(getFont(element, cell.getColumnIndex()));
   cell.setForeground(getForeground(element, cell.getColumnIndex()));
   cell.setBackground(getBackground(element, cell.getColumnIndex()));

   // no super call required. changes on item will trigger the refresh.
}
 
源代码2 项目: neoscada   文件: FactoryCellLabelProvider.java
@Override
public void update ( final ViewerCell cell )
{
    final ConfigurationDescriptor cfg = (ConfigurationDescriptor)cell.getElement ();
    switch ( cell.getColumnIndex () )
    {
    case 0:
        cell.setText ( cfg.getConfigurationInformation ().getId () );
        break;
    case 1:
        cell.setText ( "" + cfg.getConfigurationInformation ().getState () );
        break;
    }

    if ( cfg.getConfigurationInformation ().getErrorInformation () != null )
    {
        cell.setBackground ( Display.getCurrent ().getSystemColor ( SWT.COLOR_RED ) );
    }
    else
    {
        cell.setBackground ( null );
    }

    super.update ( cell );
}
 
源代码3 项目: neoscada   文件: NameLabelProviderImpl.java
@Override
public void update ( final ViewerCell cell )
{
    final Object element = cell.getElement ();
    if ( element instanceof TreeNode )
    {
        final TreeNode node = (TreeNode)element;
        cell.setText ( node.getName () );

        final CurrentStyle style = node.getStyle ();
        cell.setImage ( style.image );
        cell.setFont ( style.font );
        cell.setForeground ( style.foreground );
        cell.setBackground ( style.background );
    }
}
 
源代码4 项目: tlaplus   文件: FilteredItemsSelectionDialog.java
public void update(ViewerCell cell) {
	Object element = cell.getElement();

	if (!(element instanceof ItemsListSeparator)
			&& provider instanceof IStyledLabelProvider) {
		IStyledLabelProvider styledLabelProvider = (IStyledLabelProvider) provider;
		StyledString styledString = getStyledText(element,
				styledLabelProvider);

		cell.setText(styledString.getString());
		cell.setStyleRanges(styledString.getStyleRanges());
		cell.setImage(styledLabelProvider.getImage(element));
	} else {
		cell.setText(getText(element));
		cell.setImage(getImage(element));
	}
	cell.setFont(getFont(element));
	cell.setForeground(getForeground(element));
	cell.setBackground(getBackground(element));

	super.update(cell);
}
 
源代码5 项目: tlaplus   文件: ErrorTraceTreeViewer.java
@Override
public void update(final ViewerCell cell) {
	// labels
	cell.setText(getColumnText(cell.getElement(), cell.getColumnIndex()));
	
	// images
	cell.setImage(getColumnImage(cell.getElement(), cell.getColumnIndex()));
	
	// font
	cell.setFont(getFont(cell.getElement(), cell.getColumnIndex()));

	
	final Color bg = getBackground(cell.getElement(), cell.getColumnIndex());
	cell.setBackground(bg);

	if (TLAEditorActivator.getDefault().isCurrentThemeDark()) {
		cell.setForeground((bg == null) ? null : Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
	} else {
		cell.setForeground(null);
	}
}
 
源代码6 项目: JDeodorant   文件: CloneDiffStyledLabelProvider.java
private void setCellBackgroundWithoutCode(ViewerCell cell, CloneStructureNode theNode) {
	if(theNode.getMapping().isAdvancedMatch()) {
		cell.setBackground(StyledStringVisitor.ADVANCED_MATCH_LIGHT_COLOR);
	}
	else {
		cell.setBackground(StyledStringVisitor.UNMAPPED_LIGHT_COLOR);
	}
}
 
源代码7 项目: JDeodorant   文件: CloneDiffStyledLabelProvider.java
private void setCellBackgroundWithCode(ViewerCell cell, CloneStructureNode theNode) {
	if(theNode.getMapping().isAdvancedMatch()) {
		cell.setBackground(StyledStringVisitor.ADVANCED_MATCH_COLOR);
	}
	else {
		cell.setBackground(StyledStringVisitor.UNMAPPED_COLOR);
	}
}
 
源代码8 项目: JDeodorant   文件: SliceProfileDialog.java
public void update(ViewerCell cell) {
	SliceProfileRow element = (SliceProfileRow)cell.getElement();
	int index = cell.getColumnIndex();
	String columnText = getColumnText(element, index);
	cell.setText(columnText);
	cell.setImage(getColumnImage(element, index));
	if(sliceProfileIntersectionIndices.contains(element.getStatementID()-1)) {
		cell.setBackground(highlightColor);
	}
	else
		cell.setBackground(null);
	super.update(cell);
}
 
源代码9 项目: olca-app   文件: DQLabelProvider.java
@Override
public void update(ViewerCell cell) {
	super.update(cell);
	if (cell == null)
		return;
	Object obj = cell.getElement();
	int col = cell.getColumnIndex();
	cell.setText(getColumnText(obj, col));
	cell.setImage(getColumnImage(obj, col));
	cell.setForeground(getForeground(obj, col));
	cell.setBackground(getBackground(obj, col));
}
 
源代码10 项目: neoscada   文件: ItemCellLabelProvider.java
private void updateListEntry ( final ListEntry listEntry, final ViewerCell cell )
{
    cell.setFont ( listEntry.getFont () );
    cell.setForeground ( listEntry.getForeground () );
    cell.setBackground ( listEntry.getBackground () );

    switch ( cell.getColumnIndex () )
    {
        case 0:
            cell.setImage ( listEntry.getImage () );
            cell.setText ( listEntry.getDataItem ().getItem ().getId () );
            break;
        case 1:
            if ( listEntry.getSubscriptionError () != null )
            {
                cell.setText ( String.format ( "%s (%s)", listEntry.getSubscriptionState (), listEntry.getSubscriptionError ().getMessage () ) ); //$NON-NLS-1$
            }
            else
            {
                cell.setText ( listEntry.getSubscriptionState ().name () );
            }
            break;
        case 2:
            if ( listEntry.getValue () != null )
            {
                cell.setText ( listEntry.getValue ().getType ().name () );
            }
            break;
        case 3:
            if ( listEntry.getValue () != null )
            {
                cell.setText ( listEntry.getValue ().asString ( "<null>" ) ); //$NON-NLS-1$
            }
            break;
        case 4:
            if ( listEntry.getItemValue () != null )
            {
                final Calendar timestamp = listEntry.getItemValue ().getTimestamp ();
                if ( timestamp != null )
                {
                    cell.setText ( formatTimestamp ( timestamp ) );
                }
                else
                {
                    cell.setText ( null );
                }
            }
            break;
        default:
            break;
    }
}