Java Code Examples for org.eclipse.jface.viewers.ViewerCell#setForeground()

The following examples show how to use org.eclipse.jface.viewers.ViewerCell#setForeground() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XViewerStyledTextLabelProvider.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
@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.
}
 
Example 2
Source File: NameLabelProviderImpl.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@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 );
    }
}
 
Example 3
Source File: FilteredItemsSelectionDialog.java    From tlaplus with MIT License 6 votes vote down vote up
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);
}
 
Example 4
Source File: ErrorTraceTreeViewer.java    From tlaplus with MIT License 6 votes vote down vote up
@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);
	}
}
 
Example 5
Source File: GenericLabelProvider.java    From offspring with MIT License 6 votes vote down vote up
@Override
public void update(ViewerCell cell) {
  super.update(cell);

  data[ICellDataProvider.TEXT] = null;
  data[ICellDataProvider.IMAGE] = null;
  data[ICellDataProvider.FONT] = null;
  data[ICellDataProvider.FOREGROUND] = null;

  cellDataProvider.getCellData(cell.getElement(), data);

  if (data[ICellDataProvider.TEXT] != null) {
    cell.setText((String) data[ICellDataProvider.TEXT]);
  }
  if (data[ICellDataProvider.IMAGE] != null) {
    cell.setImage((Image) data[ICellDataProvider.IMAGE]);
  }
  if (data[ICellDataProvider.FONT] != null) {
    cell.setFont((Font) data[ICellDataProvider.FONT]);
  }
  if (data[ICellDataProvider.FOREGROUND] != null) {
    cell.setForeground((Color) data[ICellDataProvider.FOREGROUND]);
  }
}
 
Example 6
Source File: ActorMappingStyledTreeLabelProvider.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@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);
        }
        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));
        cell.setForeground(labelProvider.getForeground(cellElement));
    }
}
 
Example 7
Source File: TypeLabelProvider.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void update(ViewerCell cell) {
    Object element = cell.getElement();
    StyledString styledString = getStyledString(element);
    cell.setText(styledString.getString());

    IStatus status = validator.validate(element);
    if (status.getSeverity() == IStatus.ERROR) {
        cell.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR));
        cell.setForeground(errorColor);
    } else {
        cell.setForeground(null);
        cell.setImage(null);
    }
    cell.setStyleRanges(styledString.getStyleRanges());
}
 
Example 8
Source File: UserManagementPreferencePage.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void update(ViewerCell cell){
	User user = (User) cell.getElement();
	cell.setText(user.getLabel());
	Anwender ac = user.getAssignedContact();
	if (ac != null && ac.isExecutiveDoctor()) {
		Mandant m = Mandant.load(ac.getId());
		Color mc = UiMandant.getColorForMandator(m);
		cell.setImage(MandantSelectionContributionItem.getBoxSWTColorImage(mc));
	} else {
		cell.setImage(Images.IMG_EMPTY_TRANSPARENT.getImage());
	}
	if (user.isAdministrator()) {
		cell.setForeground(UiDesk.getColor(UiDesk.COL_RED));
		cell.setImage(Images.IMG_AUSRUFEZ.getImage());
	}
}
 
Example 9
Source File: SellOrderLabelProvider.java    From offspring with MIT License 5 votes vote down vote up
@Override
public void update(ViewerCell cell) {
  super.update(cell);
  ISellOrder t = (ISellOrder) cell.getElement();
  Object[] data = { null, null, null, null };
  getCellData(t, SellOrderTable.getColumns()[cell.getColumnIndex()], data);
  if (data[TEXT] != null)
    cell.setText((String) data[TEXT]);
  if (data[IMAGE] != null)
    cell.setImage((Image) data[IMAGE]);
  if (data[FONT] != null)
    cell.setFont((Font) data[FONT]);
  if (data[FOREGROUND] != null)
    cell.setForeground((Color) data[FOREGROUND]);
}
 
Example 10
Source File: BuyOrderLabelProvider.java    From offspring with MIT License 5 votes vote down vote up
@Override
public void update(ViewerCell cell) {
  super.update(cell);
  IBuyOrder t = (IBuyOrder) cell.getElement();
  Object[] data = { null, null, null, null };
  getCellData(t, BuyOrderTable.getColumns()[cell.getColumnIndex()], data);
  if (data[TEXT] != null)
    cell.setText((String) data[TEXT]);
  if (data[IMAGE] != null)
    cell.setImage((Image) data[IMAGE]);
  if (data[FONT] != null)
    cell.setFont((Font) data[FONT]);
  if (data[FOREGROUND] != null)
    cell.setForeground((Color) data[FOREGROUND]);
}
 
Example 11
Source File: RepositoryLabelProvider.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void update(final ViewerCell cell) {
    final IRepository element = (IRepository) cell.getElement();
    final StyledString styledString = new StyledString();

    styledString.append(getText(element), null);
    if (RepositoryManager.getInstance().getCurrentRepository().equals(element)) {
        styledString.append(" -- ", StyledString.QUALIFIER_STYLER);
        styledString.append(Messages.current, StyledString.DECORATIONS_STYLER);
    }
    cell.setForeground(getForeground(element));
    cell.setText(styledString.getString());
    cell.setImage(getImage(element));
    cell.setStyleRanges(styledString.getStyleRanges());
}
 
Example 12
Source File: DQLabelProvider.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
@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));
}
 
Example 13
Source File: ItemCellLabelProvider.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
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;
    }
}
 
Example 14
Source File: EntryLabelProvider.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void update ( final ViewerCell cell )
{
    final ArchiveEntry entry = (ArchiveEntry)cell.getElement ();

    if ( cell.getColumnIndex () == 0 )
    {
        if ( entry.isHeartbeat () )
        {
            if ( entry.isDeleted () )
            {
                cell.setImage ( this.resourceManager.createImageWithDefault ( Activator.getImageDescriptor ( "icons/heart-empty.png" ) ) );
            }
            else
            {
                cell.setImage ( this.resourceManager.createImageWithDefault ( Activator.getImageDescriptor ( "icons/heart.png" ) ) );
            }
        }
    }

    if ( entry.isDeleted () )
    {
        cell.setForeground ( this.resourceManager.createColor ( new RGB ( 128, 128, 128 ) ) );
    }
    else if ( entry.isError () )
    {
        cell.setForeground ( this.resourceManager.createColor ( new RGB ( 255, 0, 0 ) ) );
    }

    switch ( cell.getColumnIndex () )
    {
        case 0:
            cell.setText ( DATE_FORMAT.format ( entry.getTimestamp () ) );
            break;
        case 1:
            cell.setText ( "" + entry.getValue () );
            break;
        case 2:
            cell.setText ( makeCheck ( entry.isError () ) );
            break;
        case 3:
            cell.setText ( makeCheck ( entry.isManual () ) );
            break;
        case 4:
            cell.setText ( makeCheck ( entry.isDeleted () ) );
            break;
        case 5:
            cell.setText ( makeCheck ( entry.isHeartbeat () ) );
            break;
    }
}
 
Example 15
Source File: DeployApplicationFileStoreLabelProvider.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void applyUnparsableFileStyle(ViewerCell cell) {
    super.applyUnparsableFileStyle(cell);
    cell.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
}