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

The following examples show how to use org.eclipse.jface.viewers.ViewerCell#getColumnIndex() . 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: 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 2
Source File: ConnectionAnalyzer.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void update ( final ViewerCell cell )
{
    final Entry entry = (Entry)cell.getElement ();
    switch ( cell.getColumnIndex () )
    {
    case 0:
        cell.setText ( entry.getHandlerName () );
        break;
    case 1:
        cell.setText ( entry.getState ().toString () );
        break;
    case 2:
        final String errorText = makeError ( entry.getError () );
        // only update when we have an error to prevent
        // the error from disapearing
        if ( errorText != null )
        {
            cell.setText ( errorText );
        }
        break;
    }
}
 
Example 3
Source File: ItemCellLabelProvider.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
private void updateAttributePair ( final AttributePair attributePair, final ViewerCell cell )
{
    switch ( cell.getColumnIndex () )
    {
        case 0:
            cell.setText ( attributePair.key );
            break;
        case 2:
            if ( attributePair.value != null )
            {
                cell.setText ( attributePair.value.getType ().name () );
            }
            break;
        case 3:
            if ( attributePair.value != null )
            {
                cell.setText ( attributePair.value.asString ( "<null>" ) ); //$NON-NLS-1$
            }
            break;
        default:
            break;
    }
}
 
Example 4
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 5
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 6
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 7
Source File: MaterialCellLabelProvider.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void update(ViewerCell cell) {
	String text;
	// Switch on the column id and put the keys and values in the right
	// places.
	if (cell.getColumnIndex() == 0) {
		text = ((MaterialProperty) cell.getElement()).key;
	} else {
		text = ((MaterialProperty) cell.getElement()).value.toString();

	}
	cell.setText(text);
}
 
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: LaborResultsComposite.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private List<LabResult> getSelectedResults(ViewerCell cell){
	if (cell != null && cell.getColumnIndex() > 2) {
		TreeViewerColumn column = resultColumns.get(cell.getColumnIndex() - 3);
		TimeTool time = (TimeTool) column.getColumn().getData(COLUMN_DATE_KEY);
		if ((time != null) && (cell.getElement() instanceof LaborItemResults)) {
			LaborItemResults results = (LaborItemResults) cell.getElement();
			return results.getResult(time.toString(TimeTool.DATE_COMPACT));
		}
	}
	return null;
}
 
Example 10
Source File: SimulationView.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void mouseUp(MouseEvent e) {
	ViewerCell cell = viewer.getCell(mouseLocation);
	if (cell == null || cell.getColumnIndex() != 0)
		return;
	Object element = cell.getElement();
	if (element instanceof ExecutionEvent)
		raiseEvent((ExecutionEvent) element);
}
 
Example 11
Source File: SdkToolsControl.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void update(ViewerCell cell) {
    String txt = ""; //$NON-NLS-1$
    Image img = null;
    ModelItem it = (ModelItem)cell.getElement();
    if (it.isRoot()) {
        if (cell.getColumnIndex() == 0) {
            txt = it.rootName; 
            img = ImageUtils.getImage(ImageUtils.PACKAGE_FRAGMENT_IMAGE_NAME);
        }
    } else {
        if (it.tool.isSeparator()) {
            if (cell.getColumnIndex() == 0) {
                txt = Messages.SdkToolsControl_SeparatorLine; 
            }

        } else {
            if (cell.getColumnIndex() == 0) {
                txt = it.tool.getToolName();
                if (!it.tool.isValid()) {
                    img = ImageUtils.getImage(ImageUtils.ERROR_16x16);
                }
            } else {
                txt = it.tool.getLocation();
            }
        }
    }
    cell.setText(txt);
    cell.setImage(img);
}
 
Example 12
Source File: EventsLabelProvider.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void update ( final ViewerCell cell )
{
    final Object o = cell.getElement ();
    if ( o instanceof Event )
    {
        final Event info = (Event)o;

        switch ( cell.getColumnIndex () )
        {
            case 0:
                cell.setText ( this.dateFormat.format ( info.getSourceTimestamp () ) );
                break;
            case 1:
                cell.setText ( this.dateFormat.format ( info.getEntryTimestamp () ) );
                break;
            case 2:
                cell.setText ( getAttributes ( info, Event.Fields.SOURCE.getName () ).asString ( "" ) );
                break;
            case 3:
                cell.setText ( getAttributes ( info, Event.Fields.MONITOR_TYPE.getName () ).asString ( "" ) );
                break;
            case 4:
                cell.setText ( getAttributes ( info, Event.Fields.EVENT_TYPE.getName () ).asString ( "" ) );
                break;
            case 5:
                cell.setText ( getAttributes ( info, Event.Fields.ACTOR_NAME.getName () ).asString ( "" ) );
                break;
            case 6:
                cell.setText ( getAttributes ( info, Event.Fields.VALUE.getName () ).asString ( "" ) );
                break;
            case 7:
                cell.setText ( getAttributes ( info, Event.Fields.MESSAGE.getName () ).asString ( "" ) );
                break;
        }
    }
}
 
Example 13
Source File: MonitorsLabelProvider.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void update ( final ViewerCell cell )
{
    final Object o = cell.getElement ();
    if ( o instanceof MonitorStatusBean )
    {
        final MonitorStatusBean info = (MonitorStatusBean)o;
        switch ( cell.getColumnIndex () )
        {
            case 0: // id
                cell.setText ( info.getId () );
                break;
            case 1: // state
                cell.setText ( info.getStatus ().toString () );
                break;
            case 2: // timestamp
                cell.setText ( getTimestamp ( info.getStatusTimestamp () ) );
                break;
            case 3: // priority
                cell.setText ( getAttribute ( info.getAttributes (), "priority", "<none>" ) );
                break;
            case 4: // value
                cell.setText ( getValue ( info.getValue (), "<none>" ) );
                break;
            case 5: // ack user
                cell.setText ( info.getLastAknUser () != null ? info.getLastAknUser () : "<unknown>" );
                break;
            case 6: // ack timestamp
                cell.setText ( getTimestamp ( info.getLastAknTimestamp () ) );
                break;
            case 7: // fail timestamp
                cell.setText ( getTimestamp ( info.getLastFailTimestamp () ) );
                break;
        }
    }
}
 
Example 14
Source File: TaskSelectionDialog.java    From workspacemechanic with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void update(ViewerCell cell) {
  Object element = cell.getElement();
  int columnIndex = cell.getColumnIndex();
  cell.setText(getColumnText((Task) element, columnIndex));
}
 
Example 15
Source File: TmfSimpleTableViewer.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void mouseDown(MouseEvent e) {
    ViewerCell cell = fTableViewer.getCell(new Point(e.x, e.y));
    fSelectedColumn = (cell != null) ? cell.getColumnIndex() : -1;
}
 
Example 16
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 17
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 18
Source File: AddRowOnEnterCellNavigationStrategy.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
public boolean isContractInputNameColumn(final ViewerCell currentSelectedCell) {
    return currentSelectedCell.getColumnIndex() == 0;
}
 
Example 19
Source File: BlockLabelProvider.java    From offspring with MIT License 4 votes vote down vote up
@Override
public void update(ViewerCell cell) {
  super.update(cell);
  Block b = (Block) cell.getElement();
  switch (BlockTable.getColumns()[cell.getColumnIndex()]) {

  case BlockTable.COLUMN_HEIGHT:
    cell.setText(Integer.toString(b.getHeight()));
    break;

  case BlockTable.COLUMN_NUMBER_OF_TRANSACTIONS:
    cell.setText(Integer.toString(b.getTransactions().size()));
    break;

  case BlockTable.COLUMN_TOTAL_AMOUNT:
    cell.setText(Integer.toString(b.getTotalAmount()));
    break;

  case BlockTable.COLUMN_TOTAL_FEE:
    cell.setText(Integer.toString(b.getTotalFee()));
    break;

  case BlockTable.COLUMN_PAYLOAD_LENGTH:
    cell.setText(Formatter.readableFileSize(b.getPayloadLength()));
    break;

  case BlockTable.COLUMN_VERSION:
    cell.setText(Integer.toString(b.getVersion()));
    break;

  case BlockTable.COLUMN_BASETARGET:
    cell.setText(Formatter.formatBaseTarget(b.getBaseTarget()) + " %");
    break;

  case BlockTable.COLUMN_BLOCK:
    cell.setImage(BLOCK);
    cell.setText(b.getStringId());
    break;

  case BlockTable.COLUMN_GENERATOR:
    // cell.setImage(GENERATOR);
    cell.setText(Long.toString(b.getGeneratorId()));
    break;

  case BlockTable.COLUMN_TIMESTAMP:
    cell.setText(formatTimestamp(b.getTimestamp()));
    break;

  default:
    cell.setText("UNKNOWN " + BlockTable.getColumns()[cell.getColumnIndex()]);
  }
}
 
Example 20
Source File: RichTextCellLabelProvider.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void update(ViewerCell cell) {
	columnIndex = cell.getColumnIndex();
	super.update(cell);
}