Java Code Examples for org.eclipse.swt.widgets.TableItem#setFont()

The following examples show how to use org.eclipse.swt.widgets.TableItem#setFont() . 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: TableComboSnippet1.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * load a list of rows with 2 columns that includes colors and fonts.
 * @return
 */
private static List<TableItem> loadTwoColumnDatasetWithColorsAndFonts(Table table) {
	List<TableItem> list = loadTwoColumnDataset(table);
	
	int total = (list == null ? 0 : list.size());
	
	for (int index=0; index < total; index++) {
		TableItem ti = ((TableItem)(list.get(index)));
		
		if (index == 0 || index == 14) {
			ti.setForeground(darkRed);
			ti.setFont(boldFont);
		}
		else if (index == 4 || index == 19) {
			ti.setForeground(darkBlue);
			ti.setFont(boldFont);
		}
		else if (index == 9) {
			ti.setForeground(darkGreen);
			ti.setFont(boldFont);
		}
	}
	
	return list;
}
 
Example 2
Source File: DualList.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Fill a table with data
 *
 * @param table table to be filled
 * @param listOfData list of data
 */
private void fillData(final Table table, final List<DLItem> listOfData) {
	final boolean itemsContainImage = itemsContainImage();
	for (final DLItem item : listOfData) {
		final TableItem tableItem = new TableItem(table, SWT.NONE);
		tableItem.setData(item);

		if (item.getBackground() != null) {
			tableItem.setBackground(item.getBackground());
		}

		if (item.getForeground() != null) {
			tableItem.setForeground(item.getForeground());
		}

		if (item.getImage() != null) {
			tableItem.setImage(0, item.getImage());
		}

		if (item.getFont() != null) {
			tableItem.setFont(item.getFont());
		}
		final int textColumn = itemsContainImage ? 1 : 0;
		tableItem.setText(textColumn, item.getText());
	}
}
 
Example 3
Source File: TmfEventsTable.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Set the item data of the "filter status" row.
 *
 * @param item
 *            The item to use as filter status row
 */
protected void setFilterStatusRowItemData(final TableItem item) {
    for (int i = 0; i < fTable.getColumns().length; i++) {
        if (i == MARGIN_COLUMN_INDEX) {
            if ((fTrace == null) || (fFilterCheckCount == fTrace.getNbEvents())) {
                item.setImage(FILTER_IMAGE);
            } else {
                item.setImage(STOP_IMAGE);
            }
        }

        if (i == FILTER_SUMMARY_INDEX) {
            item.setText(FILTER_SUMMARY_INDEX, fFilterMatchCount + "/" + fFilterCheckCount); //$NON-NLS-1$
        } else {
            item.setText(i, EMPTY_STRING);
        }
    }
    item.setData(null);
    item.setData(Key.TIMESTAMP, null);
    item.setData(Key.RANK, null);
    item.setData(Key.STYLE_RANGES, null);
    item.setForeground(null);
    item.setBackground(null);
    item.setFont(fFont);
}
 
Example 4
Source File: TableComboSnippet1.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * load a list of rows with 3 columns that includes colors and fonts.
 * @return
 */
private static List<TableItem> loadThreeColumnDatasetWithColorsAndFonts(Table table) {
	List<TableItem> list = loadThreeColumnDataset(table);
	
	int total = (list == null ? 0 : list.size());
	
	for (int index=0; index < total; index++) {
		TableItem ti = ((TableItem)(list.get(index)));
		
		if (index == 0 || index == 14) {
			ti.setForeground(darkRed);
			ti.setFont(boldFont);
		}
		else if (index == 4 || index == 19) {
			ti.setForeground(darkBlue);
			ti.setFont(boldFont);
		} else if (index==6) {
			ti.setForeground(table.getDisplay().getSystemColor(SWT.COLOR_WHITE));
			ti.setBackground(table.getDisplay().getSystemColor(SWT.COLOR_BLACK));
		} else if (index == 9) {
			ti.setForeground(darkGreen);
			ti.setFont(boldFont);
		}
	}
	
	return list;
}
 
Example 5
Source File: TmfEventsTable.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Set the item data of the header row.
 *
 * @param item
 *            The item to use as table header
 */
protected void setHeaderRowItemData(final TableItem item) {
    if (fHeaderState == HeaderState.NO_SEARCH) {
        item.setImage(SEARCH_IMAGE);
    } else if (fHeaderState == HeaderState.SEARCH) {
        item.setImage(FILTER_ADD_IMAGE);
    }
    item.setForeground(fGrayColor);
    // Ignore collapse and image column
    for (int i = EVENT_COLUMNS_START_INDEX; i < fTable.getColumns().length; i++) {
        final TableColumn column = fTable.getColumns()[i];
        final String filter = (String) column.getData(Key.SEARCH_TXT);
        if (filter == null) {
            item.setText(i, SEARCH_HINT);
            item.setForeground(i, fGrayColor);
            item.setFont(i, fFont);
        } else {
            item.setText(i, filter);
            item.setForeground(i, fGreenColor);
            item.setFont(i, fBoldFont);
        }
    }
    if (!fPackMarginDone) {
        packMarginColumn();
        fPackMarginDone = true;
    }
}
 
Example 6
Source File: CompletionProposalPopup.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private void setDefaultStyle(TableItem item)
{
	Color c = getForegroundColor(fContentAssistSubjectControlAdapter.getControl());
	Font f = JFaceResources.getDefaultFont();
	item.setFont(2, f);
	item.setForeground(2, c);
}
 
Example 7
Source File: TableComboExampleTab.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @param modelList
 * @param tc
 * @return
 */
private void loadData(List modelList, TableCombo tc) {
	// get the number of columns to build in the table
	int numCols = numOfColumnsToDisplaySpinner.getSelection();

	// define the columns
	if (numCols == 1) {
		tc.defineColumns(new String[] {"Id"});
	}
	else if (numCols == 2) {
		tc.defineColumns(new String[] {"Id", "Description"});
	}
	else {
		tc.defineColumns(new String[] {"Id", "Description", "Computed"});	
	}
	
	int total = (modelList == null ? 0 : modelList.size());
	
	// now create the table items
	for (int index=0; index < total; index++) {
		TableItem ti = new TableItem(tc.getTable(), SWT.NONE);
		Model model = (Model)modelList.get(index);
		
		// set the column text
		if (numCols == 1) {
			ti.setText(0, model.getDescription());
		}
		else {
			ti.setText(0, String.valueOf(model.getId()));
		}
		
		if (numCols >= 2) {
			ti.setText(1, model.getDescription());
		}
		
		if (numCols == 3) {
			ti.setText(2, model.getId() + " - " + model.getDescription());
		}
		
		// add images if needed.
		if (showImageInCombo.getSelection()) {
			if (index == 1 || index == 7 || index == 13 || index == 19) {
				ti.setImage(0, testImage);
			}
			else if (index == 3 || index == 9 || index == 15) {
				ti.setImage(0, test2Image);
			}
			else if (index == 5 || index == 11 || index == 17) {
				ti.setImage(0, test3Image);
			}
		}
		
		if (showCustomFontInCombo.getSelection()) {
			if (index == 0 || index == 14) {
				ti.setForeground(darkRed);
				ti.setFont(boldFont);
			}
			else if (index == 4 || index == 19) {
				ti.setForeground(darkBlue);
				ti.setFont(boldFont);
			}
			else if (index == 9) {
				ti.setForeground(darkGreen);
				ti.setFont(boldFont);
			}
		}
	}
}