Java Code Examples for org.eclipse.swt.widgets.Table#setBackground()

The following examples show how to use org.eclipse.swt.widgets.Table#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: ColumnBrowserWidget.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Create a column that displays data
 */
private void createTable() {
	final Table table = new Table(composite, SWT.SINGLE | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
	new TableColumn(table, SWT.LEFT);

	table.setLayoutData(new RowData(150, 175));
	columns.add(table);

	addTableListeners(table);

	if (super.getBackground() != null && super.getBackground().getRed() != 240 && super.getBackground().getGreen() != 240 && super.getBackground().getBlue() != 240) {
		table.setBackground(super.getBackground());
	}
	table.setBackgroundImage(super.getBackgroundImage());
	table.setBackgroundMode(super.getBackgroundMode());
	table.setCursor(super.getCursor());
	table.setFont(super.getFont());
	table.setForeground(super.getForeground());
	table.setMenu(super.getMenu());
	table.setToolTipText(super.getToolTipText());

}
 
Example 2
Source File: TableCombo.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * creates the popup shell.
 *
 * @param selectionIndex
 */
void createPopup(final int selectionIndex) {
	// create shell and table
	popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP);

	// create table
	table = new Table(popup, SWT.SINGLE | SWT.FULL_SELECTION);

	if (font != null) {
		table.setFont(font);
	}
	if (foreground != null) {
		table.setForeground(foreground);
	}
	if (background != null) {
		table.setBackground(background);
	}

	// Add popup listeners
	final int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate, SWT.Help };
	for (final int popupEvent : popupEvents) {
		popup.addListener(popupEvent, listener);
	}

	// add table listeners
	final int[] tableEvents = { SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn,
			SWT.Dispose };
	for (final int tableEvent : tableEvents) {
		table.addListener(tableEvent, listener);
	}

	// set the selection
	if (selectionIndex != -1) {
		table.setSelection(selectionIndex);
	}
}
 
Example 3
Source File: RuleDialog.java    From LogViewer with Eclipse Public License 2.0 5 votes vote down vote up
protected Table createEmptyTable(Composite composite, int horizontalSpan)
{
    Table table = new Table(composite, SWT.None);

    GridData gridData = new GridData();
    gridData.horizontalSpan = horizontalSpan;
    gridData.verticalSpan = 1;
    gridData.widthHint = 1;
    gridData.heightHint = 1;
    table.setLayoutData(gridData);
    table.setBackground (composite.getBackground());
    return table;
}
 
Example 4
Source File: StyleCombo.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
void createPopup( Object[] items, int selectionIndex )
{
	// create shell and list
	popup = new Shell( getShell( ), SWT.NO_TRIM | SWT.ON_TOP );

	table = new Table( popup, SWT.SINGLE
			| SWT.V_SCROLL
			| SWT.FULL_SELECTION );
	new TableColumn( table, SWT.LEFT );
	if ( font != null )
		table.setFont( font );
	if ( foreground != null )
		table.setForeground( foreground );
	if ( background != null )
		table.setBackground( background );

	label.setBackground( table.getBackground( ) );
	label.setForeground( table.getForeground( ) );
	label.setFont( table.getFont( ) );

	int[] popupEvents = {
			SWT.Close, SWT.Paint, SWT.Deactivate
	};
	for ( int i = 0; i < popupEvents.length; i++ )
		popup.addListener( popupEvents[i], listener );
	int[] tableEvents = {
			SWT.MouseUp,
			SWT.Selection,
			SWT.Traverse,
			SWT.KeyDown,
			SWT.KeyUp,
			SWT.FocusIn,
			SWT.FocusOut,
			SWT.Dispose
	};
	for ( int i = 0; i < tableEvents.length; i++ )
		table.addListener( tableEvents[i], listener );
}
 
Example 5
Source File: TableCombo.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * creates the popup shell.
 * @param selectionIndex
 */
void createPopup(int selectionIndex) {
    // create shell and table
    popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP);

    // create table
    table = new Table(popup, SWT.SINGLE | SWT.FULL_SELECTION);

    if (font != null)
        table.setFont(font);
    if (foreground != null)
        table.setForeground(foreground);
    if (background != null)
        table.setBackground(background);

    // Add popup listeners
    int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate };
    for (int i = 0; i < popupEvents.length; i++) {
        popup.addListener(popupEvents[i], listener);
    }

    // add table listeners
    int[] tableEvents = { SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn,
            SWT.Dispose };
    for (int i = 0; i < tableEvents.length; i++) {
        table.addListener(tableEvents[i], listener);
    }

    // set the selection
    if (selectionIndex != -1) {
        table.setSelection(selectionIndex);
    }
}
 
Example 6
Source File: KeyAssistDialog.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a dialog area with a table of the partial matches for the current
 * key binding state. The table will be either the minimum width, or
 * <code>previousWidth</code> if it is not
 * <code>NO_REMEMBERED_WIDTH</code>.
 * 
 * @param parent
 *            The parent composite for the dialog area; must not be
 *            <code>null</code>.
 * @param partialMatches
 *            The lexicographically sorted map of partial matches for the
 *            current state; must not be <code>null</code> or empty.
 */
private final void createTableDialogArea(final Composite parent) {
    // Layout the table.
    completionsTable = new Table(parent, SWT.FULL_SELECTION | SWT.SINGLE);
    final GridData gridData = new GridData(GridData.FILL_BOTH);
    completionsTable.setLayoutData(gridData);
    completionsTable.setBackground(parent.getBackground());
    completionsTable.setLinesVisible(true);

    // Initialize the columns and rows.
    bindings.clear();
    final TableColumn columnCommandName = new TableColumn(completionsTable, SWT.LEFT, 0);
    final TableColumn columnKeySequence = new TableColumn(completionsTable, SWT.LEFT, 1);
    final Iterator itemsItr = keybindingToActionInfo.entrySet().iterator();
    while (itemsItr.hasNext()) {
        final Map.Entry entry = (Entry) itemsItr.next();
        final String sequence = (String) entry.getKey();
        final ActionInfo actionInfo = (ActionInfo) entry.getValue();
        final String[] text = { sequence, actionInfo.description };
        final TableItem item = new TableItem(completionsTable, SWT.NULL);
        item.setText(text);
        item.setData("ACTION_INFO", actionInfo);
        bindings.add(actionInfo);
    }

    Dialog.applyDialogFont(parent);
    columnKeySequence.pack();
    columnCommandName.pack();

    /*
     * If you double-click on the table, it should execute the selected
     * command.
     */
    completionsTable.addListener(SWT.DefaultSelection, new Listener() {
        @Override
        public final void handleEvent(final Event event) {
            executeKeyBinding(event);
        }
    });
}
 
Example 7
Source File: TableCombo.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * creates the popup shell.
 * @param selectionIndex
 */
void createPopup(int selectionIndex) {
	// create shell and table
	popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP);

	// set style
	int style = getStyle();
	int tableStyle = SWT.SINGLE | SWT.V_SCROLL;
	if ((style & SWT.FLAT) != 0)
		tableStyle |= SWT.FLAT;
	if ((style & SWT.RIGHT_TO_LEFT) != 0)
		tableStyle |= SWT.RIGHT_TO_LEFT;
	if ((style & SWT.LEFT_TO_RIGHT) != 0)
		tableStyle |= SWT.LEFT_TO_RIGHT;

	// create table
	table = new Table(popup, SWT.SINGLE | SWT.FULL_SELECTION);

	if (font != null)
		table.setFont(font);
	if (foreground != null)
		table.setForeground(foreground);
	if (background != null)
		table.setBackground(background);

	// Add popup listeners
	int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate, SWT.Help };
	for (int i = 0; i < popupEvents.length; i++) {
		popup.addListener(popupEvents[i], listener);
	}

	// add table listeners
	int[] tableEvents = { SWT.MouseMove, SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp,
			SWT.FocusIn, SWT.Dispose };
	for (int i = 0; i < tableEvents.length; i++) {
		table.addListener(tableEvents[i], listener);
	}

	// set the selection
	if (selectionIndex != -1) {
		table.setSelection(selectionIndex);
	}
}
 
Example 8
Source File: TableCombo.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * creates the popup shell.
 * @param selectionIndex
 */
void createPopup(int selectionIndex) {
	// create shell and table
	popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP);

	// set style
	int style = getStyle();
	int tableStyle = SWT.SINGLE | SWT.V_SCROLL;
	if ((style & SWT.FLAT) != 0)
		tableStyle |= SWT.FLAT;
	if ((style & SWT.RIGHT_TO_LEFT) != 0)
		tableStyle |= SWT.RIGHT_TO_LEFT;
	if ((style & SWT.LEFT_TO_RIGHT) != 0)
		tableStyle |= SWT.LEFT_TO_RIGHT;

	// create table
	table = new Table(popup, SWT.SINGLE | SWT.FULL_SELECTION);

	if (font != null)
		table.setFont(font);
	if (foreground != null)
		table.setForeground(foreground);
	if (background != null)
		table.setBackground(background);

	// Add popup listeners
	int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate, SWT.Help };
	for (int i = 0; i < popupEvents.length; i++) {
		popup.addListener(popupEvents[i], listener);
	}

	// add table listeners
	int[] tableEvents = { SWT.MouseMove, SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp,
			SWT.FocusIn, SWT.Dispose };
	for (int i = 0; i < tableEvents.length; i++) {
		table.addListener(tableEvents[i], listener);
	}

	// set the selection
	if (selectionIndex != -1) {
		table.setSelection(selectionIndex);
	}
}
 
Example 9
Source File: SelectionDialog.java    From e4macs with Eclipse Public License 1.0 4 votes vote down vote up
private final void createTableDialogArea(final Composite parent) {

		String[] inputKeys = getSelectableKeys();
		int columnCount = 0;
		Point dimens = getColumnCount( parent, inputKeys, sizeHint.x); 
		int count = dimens.x;

		GridLayout compositeLayout = new GridLayout(count,true);
		parent.setLayout(compositeLayout);
		parent.setLayoutData(new GridData(GridData.FILL_BOTH));
		
		Table table = new Table(parent, SWT.V_SCROLL | SWT.HORIZONTAL | SWT.WRAP | SWT.FULL_SELECTION); //| SWT.MULTI);
		GridData gridData = new GridData(GridData.FILL_BOTH);
		table.setLayoutData(gridData);
		table.setBackground(parent.getBackground());
		table.setLinesVisible(true);
		table.setHeaderVisible(false);
		
		int columnWidth = (sizeHint.x - getSizeAdjustment()) / count;
		
		TableColumn[] columns = new TableColumn[count];
		for (int i = 0; i < count; i++) {
			columns[i] = new TableColumn(table, SWT.LEFT, columnCount++);
			columns[i].setWidth(columnWidth);
		}
		TableColumnLayout layout = new TableColumnLayout();
		for (int i = 0; i < count; i++) {
			layout.setColumnData(columns[i], new ColumnWeightData(100/count,columnWidth,false));
		}
		parent.setLayout(layout);
		
		int len = inputKeys.length;
		int rowCount = len / columnCount;
		if ((len - rowCount * columnCount) > 0) {
			rowCount++;
		}
		for (int i = 0; i < rowCount; i++) {
			String[] row = new String[columnCount];
			for (int j = 0; j < columnCount; j++) {
				int sourceIndex = i * columnCount + j;
				row[j] = (sourceIndex < len ? (String) inputKeys[sourceIndex] : ""); //$NON-NLS-1$ 
			}
			TableItem item = new TableItem(table, SWT.NULL);
			item.setText(row);
		}

		table.pack();
		sizeHint.y = Math.min(table.getBounds().height + getSizeAdjustment(),sizeHint.y);

		Dialog.applyDialogFont(parent);
		addTableListeners(table);
	}
 
Example 10
Source File: ColumnBrowserWidget.java    From nebula with Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Sets the receiver's background color to the color specified by the argument,
 * or to the default system color for the control if the argument is null.
 * <p>
 * Note: This operation is a hint and may be overridden by the platform. For
 * example, on Windows the background of a Button cannot be changed.
 * </p>
 *
 * @param color the new color (or null)
 *
 * @exception IllegalArgumentException
 *                <ul>
 *                <li>ERROR_INVALID_ARGUMENT - if the argument has been
 *                disposed</li>
 *                </ul>
 * @exception SWTException
 *                <ul>
 *                <li>ERROR_WIDGET_DISPOSED - if the receiver has been
 *                disposed</li>
 *                <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
 *                thread that created the receiver</li>
 *                </ul>
 * @see org.eclipse.swt.widgets.Control#setBackground(org.eclipse.swt.graphics.Color)
 */
@Override
public void setBackground(final Color color) {
	super.setBackground(color);
	for (final Table column : columns) {
		column.setBackground(color);
	}
}