Java Code Examples for org.eclipse.swt.widgets.TableItem#setForeground()
The following examples show how to use
org.eclipse.swt.widgets.TableItem#setForeground() .
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 |
/** * 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: HighlightsPreferencePage.java From birt with Eclipse Public License 1.0 | 6 votes |
private void refreshTableItemView( ) { for ( int i = 0; i < fTableViewer.getTable( ).getItemCount( ); i++ ) { TableItem ti = fTableViewer.getTable( ).getItem( i ); HighlightRuleHandle handle = (HighlightRuleHandle) ti.getData( ); if ( handle.getColor( ).isSet( ) ) { ti.setForeground( 0, ColorManager.getColor( handle.getColor( ).getRGB( ) ) ); } ti.setText( 0, provider.getColumnText( handle, 0 ) ); ti.setText( 1, provider.getColumnText( handle, 1 ) ); } fTableViewer.getTable( ).setFocus( ); }
Example 3
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 4
Source File: AbstractGeneratorConfigurationBlock.java From sarl with Apache License 2.0 | 6 votes |
private void refreshItem(final TableItem item) { final TableItemData data = (TableItemData) item.getData(); item.setText(1, data.getSourceFolder()); final String outputDirectory = getOutputDirectory(item); if ("".equals(outputDirectory)) { //$NON-NLS-1$ item.setForeground(2, Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); item.setText(2, getValue(data.getDefaultOutputDirectoryKey())); } else { item.setForeground(2, null); item.setText(2, outputDirectory); } if (isIgnored(item)) { item.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); } else { item.setForeground(null); } }
Example 5
Source File: TypeInfoViewer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void setData(TableItem item) { int index= fTable.indexOf(item); TypeNameMatch type= getTypeInfo(index); if (type == DASH_LINE) { item.setData(fDashLine); fillDashLine(item); } else { item.setData(type); item.setImage(fImageManager.get(fLabelProvider.getImageDescriptor(type))); item.setText(fLabelProvider.getText( getTypeInfo(index - 1), type, getTypeInfo(index + 1))); item.setForeground(null); } }
Example 6
Source File: TmfEventsTable.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
/** * 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 7
Source File: BuilderConfigurationBlock.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
private void refreshItem(final TableItem item) { TableItemData data = (TableItemData) item.getData(); item.setText(1, data.getSourceFolder()); String outputDirectory = getOutputDirectory(item); if ("".equals(outputDirectory)) { item.setForeground(2, Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); item.setText(2, getValue(data.getDefaultOutputDirectoryKey())); } else { item.setForeground(2, null); item.setText(2, outputDirectory); } if (isIgnored(item)) { item.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY)); } else { item.setForeground(null); } }
Example 8
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 9
Source File: RegistryManagementComposite.java From codewind-eclipse with Eclipse Public License 2.0 | 6 votes |
private void createItems() { // Create the items for the table. regTable.removeAll(); for (RegEntry regEntry : regEntries) { TableItem item = new TableItem(regTable, SWT.NONE); item.setData(regEntry); item.setText(0, regEntry.address); item.setText(1, regEntry.username); if (supportsPushReg) { item.setText(2, regEntry.namespace == null ? "" : regEntry.namespace); //$NON-NLS-1$ item.setForeground(2, regEntry.isPushReg ? item.getForeground() : getGray(item)); if (regEntry.isPushReg) { item.setText(3, Messages.RegMgmtPushRegSet); } } } }
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: TmfEventsTable.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * 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 12
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 13
Source File: CompletionProposalPopup.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
private void setDefaultStyle(TableItem item) { Color c = getForegroundColor(fContentAssistSubjectControlAdapter.getControl()); Font f = JFaceResources.getDefaultFont(); item.setFont(2, f); item.setForeground(2, c); }
Example 14
Source File: TypeInfoViewer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void fillDashLine(TableItem item) { Rectangle bounds= item.getImageBounds(0); Rectangle area= fTable.getBounds(); boolean willHaveScrollBar= fExpectedItemCount + 1 > fNumberOfVisibleItems; item.setText(fDashLine.getText(area.width - bounds.x - bounds.width - fTableWidthDelta - (willHaveScrollBar ? fScrollbarWidth : 0))); item.setImage(fSeparatorIcon); item.setForeground(fDashLineColor); item.setData(fDashLine); }
Example 15
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 16
Source File: PTWidgetTable.java From nebula with Eclipse Public License 2.0 | 4 votes |
/** * Fill Data in the widget */ private void fillData() { List<PTProperty> props; if (getParentPropertyTable().sorted) { props = new ArrayList<PTProperty>(getParentPropertyTable().getPropertiesAsList()); Collections.sort(props, new Comparator<PTProperty>() { @Override public int compare(final PTProperty o1, final PTProperty o2) { if (o1 == null && o2 == null) { return 0; } if (o1.getName() == null && o2.getName() != null) { return -1; } if (o1.getName() != null && o2.getName() == null) { return 1; } return o1.getName().compareTo(o2.getName()); } }); } else { props = new ArrayList<PTProperty>(getParentPropertyTable().getPropertiesAsList()); } final List<ControlEditor> editors = new ArrayList<ControlEditor>(); for (final PTProperty p : props) { final TableItem item = new TableItem(table, SWT.NONE); item.setData(p); item.setText(0, StringUtil.safeToString(p.getDisplayName())); if (p.getEditor() == null) { p.setEditor(new PTStringEditor()); } final ControlEditor editor = p.getEditor().render(this, item, p); item.addListener(SWT.Dispose, event -> { if (editor.getEditor() != null) { editor.getEditor().dispose(); } editor.dispose(); }); if (!p.isEnabled()) { item.setForeground(table.getDisplay().getSystemColor(SWT.COLOR_GRAY)); } } table.setData(editors); }
Example 17
Source File: TableComboExampleTab.java From nebula with Eclipse Public License 2.0 | 4 votes |
/** * @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); } } } }