本文整理汇总了Java中org.eclipse.swt.widgets.TableItem.setBackground方法的典型用法代码示例。如果您正苦于以下问题:Java TableItem.setBackground方法的具体用法?Java TableItem.setBackground怎么用?Java TableItem.setBackground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.widgets.TableItem
的用法示例。
在下文中一共展示了TableItem.setBackground方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import org.eclipse.swt.widgets.TableItem; //导入方法依赖的package包/类
@Override
public void update(ViewerCell cell) {
TableItem item = (TableItem) cell.getItem();
Pattern pattern = Pattern.compile("^[a-zA-Z0-9 _]*$");
if (!pattern.matcher(((InputField)cell.getElement()).getFieldName()).matches()) {
item.setBackground(cell.getControl().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
item.setForeground(cell.getControl().getDisplay().getSystemColor(SWT.COLOR_RED));
((InputField)cell.getElement()).getErrorObject().setErrorMessage("Input field should match regular expression- \"^[a-zA-Z0-9_]*$\" ");
((InputField)cell.getElement()).getErrorObject().setHasError(true);
}else{
if(((InputField)cell.getElement()).getFieldName().trim().equalsIgnoreCase("")){
item.setBackground(cell.getControl().getDisplay().getSystemColor(SWT.COLOR_RED));
((InputField)cell.getElement()).getErrorObject().setErrorMessage("Input field should not be empty");
((InputField)cell.getElement()).getErrorObject().setHasError(true);
}else{
((InputField)cell.getElement()).getErrorObject().setHasError(false);
}
}
super.update(cell);
}
示例2: selectAllInTable
import org.eclipse.swt.widgets.TableItem; //导入方法依赖的package包/类
private void selectAllInTable(TableViewer debugDataViewer, TableCursor tableCursor){
Table table = debugDataViewer.getTable();
TableItem[] tableItems = table.getItems();
int recordCount = 0;
for(int rowIndex = 0; rowIndex < tableItems.length; rowIndex++){
TableItem tableItem = tableItems[rowIndex];
for(int colIndex = 1; colIndex <= table.getColumnCount(); colIndex++){
if(StringUtils.containsIgnoreCase(tableItem.getText(colIndex), findText.getText())){
label.setVisible(false);
tableItem.setBackground(colIndex, Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
recordCount++;
}
}
findColIndex=1;
}
findRowIndex = 0;
findColIndex = 0;
if(recordCount > 0){
label.setVisible(true);
label.setText("Match count - " + recordCount);
}else{ label.setVisible(false); }
}
示例3: handleUpdateData
import org.eclipse.swt.widgets.TableItem; //导入方法依赖的package包/类
private void handleUpdateData ( final int index, final Map<String, List<Double>> values, final List<ValueInformation> valueInformation )
{
// FIXME: implement faster
final int len = valueInformation.size ();
for ( int i = 0; i < len; i++ )
{
final TableItem item = this.table.getItem ( i + index );
final double quality = valueInformation.get ( i ).getQuality ();
final double manual = valueInformation.get ( i ).getManualPercentage ();
item.setText ( 0, String.format ( Messages.QueryDataView_Format_Index, index + i ) );
item.setText ( 1, String.format ( Messages.QueryDataView_Format_Quality, quality ) );
item.setText ( 2, String.format ( Messages.QueryDataView_Format_Manual, manual ) );
for ( int j = 0; j < this.colNames.length; j++ )
{
final List<Double> value = values.get ( this.colNames[j] );
item.setText ( j + FIX_FRONT_COLS, getValueString ( value.get ( i ) ) );
}
item.setText ( this.colNames.length + FIX_FRONT_COLS, "" + valueInformation.get ( i ).getSourceValues () ); //$NON-NLS-1$
item.setText ( this.colNames.length + FIX_FRONT_COLS + 1, String.format ( Messages.QueryDataView_InfoFormat, valueInformation.get ( i ).getStartTimestamp (), valueInformation.get ( i ).getEndTimestamp () ) );
if ( quality < 0.33 )
{
item.setBackground ( this.invalidColor );
}
else
{
item.setBackground ( null );
}
}
}
示例4: setDataSize
import org.eclipse.swt.widgets.TableItem; //导入方法依赖的package包/类
private void setDataSize ( final int entries, final Set<String> valueTypes )
{
clearDataSize ();
this.colNames = valueTypes.toArray ( new String[0] );
for ( final String valueType : valueTypes )
{
final TableColumn col = new TableColumn ( this.table, SWT.NONE );
col.setText ( valueType );
col.setWidth ( 100 );
col.setAlignment ( SWT.RIGHT );
this.columns.put ( valueType, col );
}
this.countCol = new TableColumn ( this.table, SWT.NONE );
this.countCol.setText ( Messages.QueryDataView_ColValues );
this.countCol.setWidth ( 40 );
this.infoCol = new TableColumn ( this.table, SWT.NONE );
this.infoCol.setText ( Messages.QueryDataView_ColInfo );
this.infoCol.setWidth ( 150 );
this.table.clearAll ();
this.table.setItemCount ( entries );
for ( int i = 0; i < entries; i++ )
{
final TableItem item = this.table.getItem ( i );
item.setBackground ( this.invalidColor );
item.setText ( 0, String.format ( Messages.QueryDataView_Format_Index, i ) );
}
}
示例5: forwardTableTraverse
import org.eclipse.swt.widgets.TableItem; //导入方法依赖的package包/类
private void forwardTableTraverse(TableViewer debugDataViewer, TableCursor tableCursor){
TableItem previousSelectedTableItem = null;
if(debugDataViewer.getData("SELECTED_ROW_INDEX")!=null){
previousSelectedTableItem = debugDataViewer.getTable().getItem((int) debugDataViewer.getData("SELECTED_ROW_INDEX"));
findColIndex++;
}
Table table = debugDataViewer.getTable();
TableItem[] tableItems = table.getItems();
if(findColIndex == prevColSelection && findRowIndex == prevRowSelection){
findColIndex++;
}
if(findRowIndex < 0){
findRowIndex = 0;
}
for(;findRowIndex<tableItems.length;){
TableItem tableItem = tableItems[findRowIndex];
for(;findColIndex <= table.getColumnCount();findColIndex++){
if(StringUtils.containsIgnoreCase(tableItem.getText(findColIndex), findText.getText())){
if(prevColSelection > 0){
previousSelectedTableItem.setBackground(prevColSelection, Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
}
label.setVisible(false);
table.showItem(tableItem);
table.showColumn(table.getColumn(findColIndex));
tableCursor.setSelection(findRowIndex, findColIndex);
tableCursor.setVisible(false);
tableItem.setBackground(findColIndex, Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
debugDataViewer.setData("SELECTED_ROW_INDEX", findRowIndex);
debugDataViewer.setData("SEELCTED_COLUMN_INDEX", findColIndex);
prevColSelection = findColIndex;
return;
}
}
findRowIndex++;
findColIndex=1;
if(findRowIndex >= tableItems.length){ findRowIndex = 0;}
}
}
示例6: reverseTableTraverse
import org.eclipse.swt.widgets.TableItem; //导入方法依赖的package包/类
private void reverseTableTraverse(TableViewer debugDataViewer, TableCursor tableCursor){
TableItem previousSelectedTableItem = null;
if(debugDataViewer.getData("SELECTED_ROW_INDEX")!=null){
previousSelectedTableItem = debugDataViewer.getTable().getItem((int) debugDataViewer.getData("SELECTED_ROW_INDEX"));
findColIndex -= 1;
}
if(findRowIndex < 0){
findRowIndex = debugDataViewer.getTable().getItems().length - 1;
}
Table table = debugDataViewer.getTable();
TableItem[] tableItems = table.getItems();
for(; findRowIndex >=0; findRowIndex--){
TableItem tableItem = tableItems[findRowIndex];
for( ; findColIndex > 0 ;findColIndex--){
if(StringUtils.containsIgnoreCase(tableItem.getText(findColIndex), findText.getText())){
if(prevColSelection > 0){
previousSelectedTableItem.setBackground(prevColSelection, Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
}
label.setVisible(false);
table.showItem(tableItem);
table.showColumn(table.getColumn(findColIndex));
tableCursor.setSelection(findRowIndex, findColIndex);
tableCursor.setVisible(false);
tableItem.setBackground(findColIndex,Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
if(findColIndex<=0){debugDataViewer.setData("SELECTED_ROW_INDEX", findRowIndex-1);}else{
debugDataViewer.setData("SELECTED_ROW_INDEX", findRowIndex);
}
debugDataViewer.setData("SEELCTED_COLUMN_INDEX", findColIndex);
prevColSelection = findColIndex;
prevRowSelection = findRowIndex;
return ;
}
}
if(findColIndex <= 0){ findColIndex = table.getColumnCount();}
if(findRowIndex == 0){ findRowIndex = tableItems.length; }
}
}
示例7: clearTableItemBgColor
import org.eclipse.swt.widgets.TableItem; //导入方法依赖的package包/类
private void clearTableItemBgColor(TableViewer debugDataViewer){
if(debugDataViewer == null){
return;
}
Table table = debugDataViewer.getTable();
TableItem[] tableItems = table.getItems();
for(int i=0;i<tableItems.length;i++){
TableItem tableItem = tableItems[i];
for(int j=1;j <= table.getColumnCount()-1;j++){
tableItem.getText(j);
tableItem.setBackground(j, Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
}
}
}