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

The following examples show how to use org.eclipse.jface.viewers.ViewerCell#setImage() . 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: CSVLabelProvider.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @see org.eclipse.jface.viewers.StyledCellLabelProvider#update(org.eclipse.jface.viewers.ViewerCell)
 */
@Override
public void update(final ViewerCell cell) {
	final CSVRow element = (CSVRow) cell.getElement();
	final int index = cell.getColumnIndex();
	final String columnText = getColumnText(element, index);
	cell.setText(columnText);
	cell.setImage(null);
	if (searchText != null && searchText.length() > 0) {
		final int intRangesCorrectSize[] = SearchResultStyle.getSearchTermOccurrences(searchText, columnText);
		final List<StyleRange> styleRange = new ArrayList<>();
		for (int i = 0; i < intRangesCorrectSize.length / 2; i++) {
			final StyleRange myStyleRange = new StyleRange(0, 0, null, searchColor);
			myStyleRange.start = intRangesCorrectSize[i];
			myStyleRange.length = intRangesCorrectSize[++i];
			styleRange.add(myStyleRange);
		}
		cell.setStyleRanges(styleRange.toArray(new StyleRange[styleRange.size()]));
	} else {
		cell.setStyleRanges(null);
	}

	super.update(cell);
}
 
Example 3
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 4
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 5
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 6
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 7
Source File: TreeLabelProvider.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void update(ViewerCell cell) {
  Object element = cell.getElement();
  if (element != null && element instanceof ITreeElement) {
    ITreeElement treeElement = (ITreeElement) element;

    StyledString styledString = treeElement.getStyledText();
    if (styledString != null) {
      cell.setText(styledString.toString());
      cell.setStyleRanges(styledString.getStyleRanges());
    } else {
      cell.setText(null);
    }

    cell.setImage(treeElement.getImage());
  }
}
 
Example 8
Source File: SliceProfileDialog.java    From JDeodorant with MIT License 5 votes vote down vote up
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);
}
 
Example 9
Source File: LabelProviderSupport.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
public void decorateWithMonitorState ( final DecoratedEvent event, final ViewerCell cell )
{
    // FIXME: should be done using new StyleBlinker

    if ( !event.isActive () )
    {
        cell.setImage ( null );
    }
    else
    {
        switch ( event.getMonitor ().getStatus () )
        {
            case NOT_OK:
                //$FALL-THROUGH$
            case NOT_OK_AKN:
                if ( event.getMonitor ().getSeverity () == Severity.WARNING )
                {
                    cell.setImage ( this.warningImage );
                }
                else
                {
                    cell.setImage ( this.alarmImage );
                }
                break;
            case NOT_AKN:
                cell.setImage ( this.ackImage );
                break;
            case NOT_OK_NOT_AKN:
                cell.setImage ( this.ackImage );
                break;
            case INACTIVE: //$FALL-THROUGH$
            case INIT: //$FALL-THROUGH$
            case UNSAFE: //$FALL-THROUGH$
            case OK: //$FALL-THROUGH$
                break;
        }
    }
}
 
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: ServerLabelProvider.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
protected void update ( final ViewerCell cell, final ServerDescriptor element )
{
    final StyledString str = new StyledString ();

    final boolean running = element.isRunning ();

    str.append ( element.getLabel () );

    final String add = element.getAdditionalLabel ();
    if ( add != null )
    {
        str.append ( ' ' );
        str.append ( add, StyledString.QUALIFIER_STYLER );
    }

    cell.setText ( str.getString () );
    cell.setStyleRanges ( str.getStyleRanges () );

    if ( element.getError () != null )
    {
        cell.setImage ( this.errorImage );
    }
    else
    {
        cell.setImage ( running ? this.runningImage : this.stoppedImage );
    }
}
 
Example 12
Source File: DataStyledTreeLabelProvider.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void update(ViewerCell cell) {
	if (cell.getElement() instanceof Data) {
		Data d = (Data) cell.getElement();
		StyledString styledString = new StyledString();

		String decoration = " -- " + getTypeLabel(d);
		if (d.isTransient()) {
			styledString.append(d.getName(), italicGrey);
		} else {
			styledString.append(d.getName(), null);
		}
		styledString.append(decoration, StyledString.DECORATIONS_STYLER);
		if(d.getDefaultValue() != null
				&& d.getDefaultValue().getName() != null
				&& !d.getDefaultValue().getName().isEmpty()){
			String content = d.getDefaultValue().getName();
			content = Messages.defaultValue+": "  + content.replaceAll("\n", " ")  ;
			if(content.length() > 150) {
			    content = content.substring(0, 150) + "...";
			}
			styledString.append(" -- ",StyledString.DECORATIONS_STYLER) ;
			styledString.append(content, StyledString.QUALIFIER_STYLER);
		}
		cell.setText(styledString.getString());
		cell.setImage(getImage(d)) ;
		cell.setStyleRanges(styledString.getStyleRanges());
	}
}
 
Example 13
Source File: SearchCellLabelProvider.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
@Override
public void update(ViewerCell cell) {
    Object element = cell.getElement();
    final String text = getText(element);
    cell.setText(text);
    cell.setImage(getImage(element));
    cell.setFont(getFont(element));
    if (filterString != null && !filterString.isEmpty()) {
        int filterIndex = text.indexOf(filterString);
        StyleRange styleRange = new StyleRange(filterIndex, filterString.length(), null, hightLight);
        cell.setStyleRanges(new StyleRange[] { styleRange });
    } else {
        cell.setStyleRanges(null);
    }
}
 
Example 14
Source File: StyledFilterLabelProvider.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@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);
        }
        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());
    }
}
 
Example 15
Source File: DocumentStyledLabelProvider.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 Object element = cell.getElement();
    if (element instanceof Document) {
        final Document document = (Document) element;
        final StyledString styledString = new StyledString();
        styledString.append(document.getName());
        final String decoration = " -- " + getTypeLabel(document);
        styledString.append(decoration, StyledString.DECORATIONS_STYLER);
        styledString.append(" -- ", StyledString.DECORATIONS_STYLER);
        cell.setText(styledString.getString());
        cell.setStyleRanges(styledString.getStyleRanges());
        cell.setImage(getImage(element));
    }
}
 
Example 16
Source File: TestabilityDescriptionMarkerField.java    From testability-explorer with Apache License 2.0 5 votes vote down vote up
@Override
public void update(ViewerCell cell) {
  super.update(cell);
  
  try {
    // TODO(shyamseshadri): Check Item Type and assign image accordingly.
    cell.setImage(Activator.getDefault().getImage("icons/TE.jpg"));
  } catch (ImageNotFoundException e) {
    logger.logException(e);
  }
}
 
Example 17
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 18
Source File: DebugConnectorLabelProvider.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void update(ViewerCell cell) {
    Object object = cell.getElement()  ;
    if(object instanceof Connector){
        super.update(cell) ;
    }else{
        cell.setText(getText(object));
        cell.setImage(getImage(object)) ;
    }
}
 
Example 19
Source File: ApplicationFileStoreLabelProvider.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
protected void applyUnparsableFileStyle(ViewerCell cell) {
    cell.setImage(new DecorationOverlayIcon(getImage(cell.getElement()),
            UIPlugin.getImageDescriptor("icons/problem.gif"), IDecoration.BOTTOM_RIGHT)
                    .createImage());
}
 
Example 20
Source File: ExpressionTypeLabelProvider.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void update(final ViewerCell cell) {
    cell.setText(getText(cell.getElement()));
    cell.setImage(getImage(cell.getElement()));
}