Java Code Examples for org.eclipse.swt.widgets.TableItem#setBackground()
The following examples show how to use
org.eclipse.swt.widgets.TableItem#setBackground() .
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: SpinnerTable.java From birt with Eclipse Public License 1.0 | 6 votes |
private void createItems( ) { for ( int i = 0; i < ROW_COUNT; i++ ) { TableItem item = new TimeTableItem( table, SWT.NONE ); if ( i == 0 ) { item.setText( new String[]{ SUN, MON, TUE, WED, THU, FRI, SAT } ); item.setBackground( Display.getCurrent( ) .getSystemColor( SWT.COLOR_BLUE ) ); item.setForeground( Display.getCurrent( ) .getSystemColor( SWT.COLOR_WHITE ) ); } } }
Example 2
Source File: DualList.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * 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: JDBCPreferencePage.java From ermaster-b with Apache License 2.0 | 5 votes |
private void setData() { this.table.removeAll(); for (JDBCDriverSetting setting : PreferenceInitializer .getJDBCDriverSettingList()) { TableItem tableItem = new TableItem(this.table, SWT.NONE); tableItem.setBackground(ColorConstants.white); tableItem.setText(0, Format.null2blank(setting.getDb())); tableItem.setText(1, Format.null2blank(setting.getClassName())); tableItem.setText(2, Format.null2blank(setting.getPath())); } }
Example 4
Source File: TransGridDelegate.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private void updateRowFromBaseStep( StepInterface baseStep, TableItem row ) { StepStatus stepStatus = new StepStatus( baseStep ); String[] fields = stepStatus.getTransLogFields(); updateCellsIfChanged( fields, row ); // Error lines should appear in red: if ( baseStep.getErrors() > 0 ) { row.setBackground( GUIResource.getInstance().getColorRed() ); } else { row.setBackground( GUIResource.getInstance().getColorWhite() ); } }
Example 5
Source File: StandardChartDataSheet.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * */ private void updateColumnsTableViewerColor( ) { for ( TableItem item : tableViewerColumns.getTable( ).getItems( ) ) { ColumnBindingInfo cbi = (ColumnBindingInfo) item.getData( ); Color c = ColorPalette.getInstance( ).getColor( cbi.getName( ) ); if ( c == null ) { c = Display.getDefault( ) .getSystemColor( SWT.COLOR_LIST_BACKGROUND ); } item.setBackground( c ); } }
Example 6
Source File: TableComboSnippet1.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * 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 7
Source File: QueryDataView.java From neoscada with Eclipse Public License 1.0 | 5 votes |
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 ); } } }
Example 8
Source File: QueryDataView.java From neoscada with Eclipse Public License 1.0 | 5 votes |
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 ) ); } }
Example 9
Source File: HopGuiPipelineGridDelegate.java From hop with Apache License 2.0 | 5 votes |
private void updateRowFromBaseTransform( ITransform baseTransform, TableItem row ) { TransformStatus transformStatus = new TransformStatus( baseTransform ); String[] fields = transformStatus.getPipelineLogFields(); updateCellsIfChanged( fields, row ); // Error lines should appear in red: if ( baseTransform.getErrors() > 0 ) { row.setBackground( GuiResource.getInstance().getColorRed() ); } else { row.setBackground( GuiResource.getInstance().getColorWhite() ); } }
Example 10
Source File: ShipTable.java From logbook with MIT License | 5 votes |
@Override public void update(TableItem item, ShipBean bean, int index) { // 偶数行に背景色を付ける if ((index % 2) != 0) { item.setBackground(SWTResourceManager.getColor(AppConstants.ROW_BACKGROUND)); } else { item.setBackground(null); } ShipDto ship = bean.getShip(); long cond = ship.getCond(); if (!ship.getLocked()) { // 鍵付きでは無い艦娘をグレー色にする item.setForeground(SWTResourceManager.getColor(SWT.COLOR_DARK_GRAY)); } else if (this.ndocks.contains(ship.getId())) { // 入渠 item.setForeground(SWTResourceManager.getColor(AppConstants.NDOCK_COLOR)); } else if (this.deckmissions.contains(ship.getId())) { // 遠征 item.setForeground(SWTResourceManager.getColor(AppConstants.MISSION_COLOR)); } else if (cond <= AppConstants.COND_RED) { // 赤疲労 item.setForeground(SWTResourceManager.getColor(AppConstants.COND_RED_COLOR)); } else if (cond <= AppConstants.COND_ORANGE) { // 疲労 item.setForeground(SWTResourceManager.getColor(AppConstants.COND_ORANGE_COLOR)); } else if ((cond >= AppConstants.COND_DARK_GREEN) && (cond < AppConstants.COND_GREEN)) { // cond.50-52 item.setForeground(SWTResourceManager.getColor(AppConstants.COND_DARK_GREEN_COLOR)); } else if (cond >= AppConstants.COND_GREEN) { // cond.53- item.setForeground(SWTResourceManager.getColor(AppConstants.COND_GREEN_COLOR)); } else { item.setForeground(null); } // HPのゲージイメージ item.setImage(this.indexHp, ShipTable.hpGauge(ship, this.cache)); // 経験値のゲージイメージ item.setImage(this.indexExp, ShipTable.totalExpGauge(ship, this.cache)); }
Example 11
Source File: PropsUI.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public static void setTableItemLook( TableItem item, Display disp ) { if ( !Const.getOS().startsWith( "Windows" ) ) { return; } Color background = GUIResource.getInstance().getColorBackground(); if ( background != null ) { item.setBackground( background ); } }
Example 12
Source File: ERTableComposite.java From erflute with Apache License 2.0 | 5 votes |
private void column2TableItem(ERColumn column, TableItem tableItem) { disposeCheckBox(column); if (column instanceof NormalColumn) { tableItem.setBackground(ColorConstants.white); final NormalColumn normalColumn = (NormalColumn) column; if (normalColumn.isPrimaryKey()) { tableItem.setImage(0, Activator.getImage(ImageKey.PRIMARY_KEY)); } else { tableItem.setImage(0, null); } if (normalColumn.isForeignKey()) { tableItem.setImage(1, Activator.getImage(ImageKey.FOREIGN_KEY)); } else { tableItem.setImage(1, null); } tableItem.setText(2, Format.null2blank(normalColumn.getPhysicalName())); tableItem.setText(3, Format.null2blank(normalColumn.getLogicalName())); final SqlType sqlType = normalColumn.getType(); tableItem.setText(4, Format.formatType(sqlType, normalColumn.getTypeData(), diagram.getDatabase())); setTableEditor(normalColumn, tableItem); } else { tableItem.setBackground(ColorConstants.white); tableItem.setImage(0, Activator.getImage(ImageKey.GROUP)); tableItem.setImage(1, null); tableItem.setText(2, column.getName()); tableItem.setText(3, ""); tableItem.setText(4, ""); } }
Example 13
Source File: TableItemColorController.java From LogViewer with Eclipse Public License 2.0 | 5 votes |
private void colorItems() { TableItem[] items = table.getItems(); for(int i = 0 ; i < items.length ; i++) { TableItem item = items[i]; Object object = item.getData(); if(!(object instanceof RulePreferenceData)) { return; } RulePreferenceData data = (RulePreferenceData)item.getData(); item.setBackground(new Color(Display.getDefault(),data.getBackgroundColor())); item.setForeground(new Color(Display.getDefault(),data.getForegroundColor())); } }
Example 14
Source File: JDBCPreferencePage.java From erflute with Apache License 2.0 | 5 votes |
private void setData() { table.removeAll(); for (final JDBCDriverSetting setting : PreferenceInitializer.getJDBCDriverSettingList()) { final TableItem tableItem = new TableItem(table, SWT.NONE); tableItem.setBackground(ColorConstants.white); tableItem.setText(0, Format.null2blank(setting.getDb())); tableItem.setText(1, Format.null2blank(setting.getClassName())); tableItem.setText(2, Format.null2blank(setting.getPath())); } }
Example 15
Source File: ERTableComposite.java From ermaster-b with Apache License 2.0 | 4 votes |
private void column2TableItem(Column column, TableItem tableItem) { this.disposeCheckBox(column); if (column instanceof NormalColumn) { tableItem.setBackground(ColorConstants.white); NormalColumn normalColumn = (NormalColumn) column; if (normalColumn.isPrimaryKey()) { tableItem.setImage(0, Activator.getImage(ImageKey.PRIMARY_KEY)); } else { tableItem.setImage(0, null); } if (normalColumn.isForeignKey()) { tableItem.setImage(1, Activator.getImage(ImageKey.FOREIGN_KEY)); } else { tableItem.setImage(1, null); } tableItem.setText(2, Format.null2blank(normalColumn .getPhysicalName())); tableItem.setText(3, Format.null2blank(normalColumn .getLogicalName())); SqlType sqlType = normalColumn.getType(); tableItem.setText(4, Format.formatType(sqlType, normalColumn .getTypeData(), this.diagram.getDatabase())); this.setTableEditor(normalColumn, tableItem); } else { tableItem.setBackground(ColorConstants.white); tableItem.setImage(0, Activator.getImage(ImageKey.GROUP)); tableItem.setImage(1, null); tableItem.setText(2, column.getName()); tableItem.setText(3, ""); tableItem.setText(4, ""); } }
Example 16
Source File: TransDebugDialog.java From pentaho-kettle with Apache License 2.0 | 4 votes |
private void refreshStepList() { GUIResource resource = GUIResource.getInstance(); // Add the list of steps... // int maxIconSize = 0; int indexSelected = -1; wSteps.table.removeAll(); for ( int i = 0; i < transDebugMeta.getTransMeta().getSteps().size(); i++ ) { StepMeta stepMeta = transDebugMeta.getTransMeta().getStep( i ); TableItem item = new TableItem( wSteps.table, SWT.NONE ); Image image = resource.getImagesSteps().get( stepMeta.getStepID() ).getAsBitmapForSize( display, ConstUI.ICON_SIZE, ConstUI.ICON_SIZE ); item.setImage( 0, image ); item.setText( 0, "" ); item.setText( 1, stepMeta.getName() ); if ( image.getBounds().width > maxIconSize ) { maxIconSize = image.getBounds().width; } StepDebugMeta stepDebugMeta = stepDebugMetaMap.get( stepMeta ); if ( stepDebugMeta != null ) { // We have debugging information so we mark the row // item.setBackground( resource.getColorLightPentaho() ); if ( indexSelected < 0 ) { indexSelected = i; } } } wSteps.removeEmptyRows(); wSteps.optWidth( false ); wSteps.table.getColumn( 0 ).setWidth( maxIconSize + 10 ); wSteps.table.getColumn( 0 ).setAlignment( SWT.CENTER ); // OK, select the first used step debug line... // if ( indexSelected >= 0 ) { wSteps.table.setSelection( indexSelected ); showStepDebugInformation(); } }
Example 17
Source File: CheckResultDialog.java From pentaho-kettle with Apache License 2.0 | 4 votes |
/** * Copy information from the meta-data input to the dialog fields. */ public void getData() { wFields.table.removeAll(); for ( int i = 0; i < remarks.size(); i++ ) { CheckResultInterface cr = remarks.get( i ); if ( show_successful_results || cr.getType() != CheckResultInterface.TYPE_RESULT_OK ) { TableItem ti = new TableItem( wFields.table, SWT.NONE ); // MB - Support both JobEntry and Step Checking // 6/25/07 CheckResultSourceInterface sourceMeta = cr.getSourceInfo(); if ( sourceMeta != null ) { ti.setText( 1, sourceMeta.getName() ); } else { ti.setText( 1, "<global>" ); } ti.setText( 2, cr.getType() + " - " + cr.getTypeDesc() ); ti.setText( 3, cr.getText() ); Color col = ti.getBackground(); switch ( cr.getType() ) { case CheckResultInterface.TYPE_RESULT_OK: col = green; break; case CheckResultInterface.TYPE_RESULT_ERROR: col = red; break; case CheckResultInterface.TYPE_RESULT_WARNING: col = yellow; break; case CheckResultInterface.TYPE_RESULT_COMMENT: default: break; } ti.setBackground( col ); } } if ( wFields.table.getItemCount() == 0 ) { wFields.clearAll( false ); } wFields.setRowNums(); wFields.optWidth( true ); if ( show_successful_results ) { wlFields.setText( STRING_HIDE_REMARKS ); wNoOK.setText( STRING_HIDE_SUCESSFUL ); } else { wlFields.setText( STRING_SHOW_REMARKS ); wNoOK.setText( STRING_SHOW_SUCESSFUL ); } shell.layout(); }
Example 18
Source File: Translator.java From hop with Apache License 2.0 | 4 votes |
public void refreshPackages() { int index = wPackages.getSelectionIndex(); // OK, we have a distinct list of packages to work with... wPackages.table.removeAll(); Map<String, Map<String, java.util.List<KeyOccurrence>>> sourceMessagesPackages = crawler.getSourcePackageOccurrences(); // Sort the source folders... // java.util.List<String> sourceFolders = new ArrayList(sourceMessagesPackages.keySet()); Collections.sort( sourceFolders); for ( String sourceFolder : sourceFolders ) { Map<String, java.util.List<KeyOccurrence>> messagesPackages = sourceMessagesPackages.get( sourceFolder ); java.util.List<String> packageNames = new ArrayList( messagesPackages.keySet() ); Collections.sort( packageNames ); for ( String packageName : packageNames ) { TableItem item = new TableItem( wPackages.table, SWT.NONE ); item.setText( 1, sourceFolder ); item.setText( 2, packageName ); // count the number of keys for the package that are NOT yet translated... // if ( selectedLocale != null ) { // Check if there is a bundle file for this package. // If not we'll paint it in light red // BundleFile bundleFile = store.getBundleStore().findBundleFile( packageName, selectedLocale ); if (bundleFile==null) { item.setBackground( new Color(shell.getDisplay(), 230, 150, 150 ) ); } else { java.util.List<KeyOccurrence> todo = getTodoList( selectedLocale, packageName, sourceFolder, true ); if ( todo.size() > 50 ) { item.setBackground( new Color( shell.getDisplay(), 150, 150, 150 ) ); // dark gray } else if ( todo.size() > 25 ) { item.setBackground( new Color( shell.getDisplay(), 170, 170, 170 ) ); } else if ( todo.size() > 10 ) { item.setBackground( new Color( shell.getDisplay(), 190, 190, 190 ) ); } else if ( todo.size() > 5 ) { item.setBackground( new Color( shell.getDisplay(), 210, 210, 210 ) ); } else if ( todo.size() > 0 ) { item.setBackground( new Color( shell.getDisplay(), 230, 230, 230 ) ); // light gray } } } } if ( messagesPackages.size() == 0 ) { new TableItem( wPackages.table, SWT.NONE ); } else { wPackages.setRowNums(); } } if ( index >= 0 ) { wPackages.table.setSelection( index ); wPackages.table.showSelection(); } }
Example 19
Source File: Translator2.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public void refreshPackages() { int index = wPackages.getSelectionIndex(); // OK, we have a distinct list of packages to work with... wPackages.table.removeAll(); Map<String, Map<String, java.util.List<KeyOccurrence>>> sourceMessagesPackages = crawler.getSourcePackageOccurrences(); for ( String sourceFolder : sourceMessagesPackages.keySet() ) { Map<String, java.util.List<KeyOccurrence>> messagesPackages = sourceMessagesPackages.get( sourceFolder ); for ( String messagesPackage : messagesPackages.keySet() ) { TableItem item = new TableItem( wPackages.table, SWT.NONE ); item.setText( 1, sourceFolder ); item.setText( 2, messagesPackage ); // count the number of keys for the package that are NOT yet translated... // if ( selectedLocale != null ) { java.util.List<KeyOccurrence> todo = getTodoList( selectedLocale, messagesPackage, sourceFolder, true ); if ( todo.size() > 50 ) { item.setBackground( GUIResource.getInstance().getColorRed() ); } else if ( todo.size() > 25 ) { item.setBackground( GUIResource.getInstance().getColorOrange() ); } else if ( todo.size() > 10 ) { item.setBackground( GUIResource.getInstance().getColorYellow() ); } else if ( todo.size() > 5 ) { item.setBackground( GUIResource.getInstance().getColorBlue() ); } else if ( !todo.isEmpty() ) { item.setBackground( GUIResource.getInstance().getColorGreen() ); } } } if ( messagesPackages.isEmpty() ) { new TableItem( wPackages.table, SWT.NONE ); } else { wPackages.setRowNums(); wPackages.optWidth( true ); wPackages.getTable().getColumn( 1 ).setWidth( 100 ); } } if ( index >= 0 ) { wPackages.table.setSelection( index ); wPackages.table.showSelection(); } }
Example 20
Source File: PipelineDebugDialog.java From hop with Apache License 2.0 | 4 votes |
private void refreshTransformList() { GuiResource resource = GuiResource.getInstance(); // Add the list of transforms... // int maxIconSize = 0; int indexSelected = -1; wTransforms.table.removeAll(); for ( int i = 0; i < pipelineDebugMeta.getPipelineMeta().getTransforms().size(); i++ ) { TransformMeta transformMeta = pipelineDebugMeta.getPipelineMeta().getTransform( i ); TableItem item = new TableItem( wTransforms.table, SWT.NONE ); Image image = resource.getImagesTransforms().get( transformMeta.getTransformPluginId() ).getAsBitmapForSize( display, ConstUi.ICON_SIZE, ConstUi.ICON_SIZE ); item.setImage( 0, image ); item.setText( 0, "" ); item.setText( 1, transformMeta.getName() ); if ( image.getBounds().width > maxIconSize ) { maxIconSize = image.getBounds().width; } TransformDebugMeta transformDebugMeta = transformDebugMetaMap.get( transformMeta ); if ( transformDebugMeta != null ) { // We have debugging information so we mark the row // item.setBackground( resource.getColorLight() ); if ( indexSelected < 0 ) { indexSelected = i; } } } wTransforms.removeEmptyRows(); wTransforms.optWidth( false ); wTransforms.table.getColumn( 0 ).setWidth( maxIconSize + 10 ); wTransforms.table.getColumn( 0 ).setAlignment( SWT.CENTER ); // OK, select the first used transform debug line... // if ( indexSelected >= 0 ) { wTransforms.table.setSelection( indexSelected ); showTransformDebugInformation(); } }