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

The following examples show how to use org.eclipse.jface.viewers.ViewerCell#getElement() . 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: DiagramLabelProvider.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void update(ViewerCell cell) {
       if (cell.getElement() instanceof DiagramFileStore) {
       	DiagramFileStore filseStore = (DiagramFileStore) cell.getElement();
           StyledString styledString = new StyledString();

           styledString.append(fileStoreLabelProvider.getText(filseStore), null);
           if(filseStore.hasMigrationReport()){
           	  styledString.append(" -- ",StyledString.DECORATIONS_STYLER) ;
           	  styledString.append( Messages.migrationOngoing ,StyledString.COUNTER_STYLER) ;
           }
       
           cell.setText(styledString.getString());
           cell.setImage(fileStoreLabelProvider.getImage(filseStore)) ;
           cell.setStyleRanges(styledString.getStyleRanges());
       }
	super.update(cell);
}
 
Example 2
Source File: CloneDiffTooltip.java    From JDeodorant with MIT License 6 votes vote down vote up
public void update(ViewerCell cell) { 
	Object element = cell.getElement();
	if (element instanceof CloneStructureNode){
		cell.setText("CloneStructureNode");
	}
	if (element instanceof PreconditionViolation){
		PreconditionViolation preconditionViolation = (PreconditionViolation) element;
		StyledString styledString = preconditionViolation.getStyledViolation();
		cell.setText(styledString.getString());
		cell.setStyleRanges(styledString.getStyleRanges());
		cell.setImage(PRECONDITION_VIOLATION_IMAGE);
	}
	if (element instanceof Suggestion){
		Suggestion suggestion = (Suggestion) element;
		cell.setText(suggestion.getSuggestion());
		cell.setImage(SUGGESTION_IMAGE);
	}
}
 
Example 3
Source File: FactoryCellLabelProvider.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@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 );
}
 
Example 4
Source File: VariantLabelProvider.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void update ( final ViewerCell cell )
{
    final DecoratedEvent event = (DecoratedEvent)cell.getElement ();

    if ( this.decoration != null )
    {
        switch ( this.decoration )
        {
        case ACTOR:
            this.labelProviderSupport.decorateWithActorType ( event, cell );
            break;
        case MONITOR:
            this.labelProviderSupport.decorateWithMonitorState ( event, cell );
            break;
        }
    }

    if ( this.key != null && !this.key.isEmpty () )
    {
        cell.setText ( this.labelProviderSupport.toLabel ( event, this.key ) );
    }

}
 
Example 5
Source File: GridColumnLabelProvider.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void update(ViewerCell cell) {
	super.update(cell);

	Object element = cell.getElement();

	String rowText = getRowHeaderText(element);
	int colSpan = getColumnSpan(element);
	int rowSpan = getRowSpan(element);

	GridItem gridItem = (GridItem)cell.getViewerRow().getItem();
	if (rowText != null) {
		gridItem.setHeaderText(rowText);
	}

	gridItem.setColumnSpan(cell.getColumnIndex(), colSpan);
	gridItem.setRowSpan(cell.getColumnIndex(), rowSpan);
}
 
Example 6
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 7
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 8
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 9
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 10
Source File: LabelProvider.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void update ( final ViewerCell cell )
{
    if ( cell.getElement () instanceof ConnectionInformationProvider )
    {
        final ConnectionInformationProvider provider = (ConnectionInformationProvider)cell.getElement ();
        switch ( cell.getColumnIndex () )
        {
            case 0:
                cell.setText ( provider.getLabel () );
                break;
        }
    }
    else if ( cell.getElement () instanceof InformationBean )
    {
        final InformationBean bean = (InformationBean)cell.getElement ();
        switch ( cell.getColumnIndex () )
        {
            case 0:
                cell.setText ( bean.getLabel () );
                break;
            case 1:
                cell.setText ( format ( bean.getValue () ) );
                break;
            case 2:
                cell.setText ( format ( bean.getMin () ) );
                break;
            case 3:
                cell.setText ( format ( bean.getMax () ) );
                break;
        }
    }
    super.update ( cell );
}
 
Example 11
Source File: ServerLabelProvider.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void update ( final ViewerCell cell )
{
    final Object ele = cell.getElement ();
    if ( ele instanceof ServerDescriptor )
    {
        update ( cell, (ServerDescriptor)ele );
    }
    else if ( ele instanceof ServerEndpoint )
    {
        update ( cell, (ServerEndpoint)ele );
    }
}
 
Example 12
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 13
Source File: FileStoreLabelProvider.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 IRepositoryFileStore) {
        final IRepositoryFileStore fileStore = (IRepositoryFileStore) cell.getElement();
        final StyledString styledString = new StyledString();
        styledString.append(fileStore.getName());
        cell.setText(styledString.getString());
        cell.setImage(getImage(cell.getElement()));
        contentValidation(fileStore, styledString, cell);

        cell.setStyleRanges(styledString.getStyleRanges());
    }
}
 
Example 14
Source File: SourceTimestampLabelProvider.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void update ( final ViewerCell cell )
{
    final DecoratedEvent event = (DecoratedEvent)cell.getElement ();

    final String value = this.labelProviderSupport.getDf ().format ( event.getEvent ().getSourceTimestamp () );
    cell.setText ( value );
}
 
Example 15
Source File: DatabaseDriversLabelProvider.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 String) {
		String s = (String)cell.getElement();
		StyledString styledString = new StyledString();
		styledString.append(s,null);
		if (s.equals(defaultDriver)){
			styledString.append(" (Active)",boldgreen);
		}
		cell.setText(styledString.getString());
		cell.setStyleRanges(styledString.getStyleRanges());
	}
}
 
Example 16
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 17
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 18
Source File: ConfigurationCellLabelProvider.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void update ( final ViewerCell cell )
{
    final Map.Entry<?, ?> cfg = (Map.Entry<?, ?>)cell.getElement ();
    switch ( cell.getColumnIndex () )
    {
    case 0:
        cell.setText ( "" + cfg.getKey () );
        break;
    case 1:
        cell.setText ( "" + cfg.getValue () );
        break;
    }
    super.update ( cell );
}
 
Example 19
Source File: StyledConnectorLabelProvider.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 Connector) {
		Connector connector = (Connector) cell.getElement();
		ConnectorDefinition def = connectorDefStore.getDefinition(connector.getDefinitionId(),connector.getDefinitionVersion()) ;
		if(def == null){
			def = connectorDefStore.getDefinition(connector.getDefinitionId(),connector.getDefinitionVersion()) ;
		}
		StyledString styledString = new StyledString();

		styledString.append(getText(connector), null);
		styledString.append(" -- ",StyledString.QUALIFIER_STYLER) ;
		String connectorType = connector.getDefinitionId() +" ("+connector.getDefinitionVersion()+")";
		styledString.append(connectorType, StyledString.DECORATIONS_STYLER);
		EObject parent = connector.eContainer();
           if (!(parent instanceof Expression)) {
			if(connector.getEvent() != null && !connector.getEvent().isEmpty()){
				styledString.append(" -- ",StyledString.QUALIFIER_STYLER) ;
				styledString.append(connector.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.connectorDefinitionNotFound,connector.getDefinitionId() + " ("+connector.getDefinitionVersion()+")")) ;
		}

		cell.setText(styledString.getString());
		cell.setImage(getImage(connector)) ;
		cell.setStyleRanges(styledString.getStyleRanges());
	}
}
 
Example 20
Source File: IntroduceParameterObjectWizard.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void update(ViewerCell cell) {
	ParameterInfo pi= (ParameterInfo) cell.getElement();
	cell.setText(doGetValue(pi));
}