Java Code Examples for org.eclipse.swt.widgets.Control#setForeground()

The following examples show how to use org.eclipse.swt.widgets.Control#setForeground() . These examples are extracted from open source projects. 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 Project: SWET   File: PopupDialog.java    License: MIT License 5 votes vote down vote up
/**
 * Set the specified foreground color for the specified control and all of
 * its children, except for those specified in the list of exclusions.
 * 
 * @param color
 *            the color to use as the foreground color
 * @param control
 *            the control whose color is to be changed
 * @param exclusions
 *            a list of controls who are to be excluded from getting their
 *            color assigned
 */
private void applyForegroundColor(Color color, Control control,
		List<Object> exclusions) {
	if (!exclusions.contains(control)) {
		control.setForeground(color);
	}
	if (control instanceof Composite) {
		Control[] children = ((Composite) control).getChildren();
		for (int i = 0; i < children.length; i++) {
			applyForegroundColor(color, children[i], exclusions);
		}
	}
}
 
Example 2
private void setColorAndFont(Control control, Color foreground, Color background, Font font) {
	control.setForeground(foreground);
	control.setBackground(background);
	control.setFont(font);

	if (control instanceof Composite) {
		Control[] children= ((Composite) control).getChildren();
		for (int i= 0; i < children.length; i++) {
			setColorAndFont(children[i], foreground, background, font);
		}
	}
}
 
Example 3
@Override
public void setForegroundColor(Color foreground) {
    super.setForegroundColor(foreground);
    Control[] children= fParent.getChildren();
    for (Control element : children) {
        element.setForeground(foreground);
    }
}
 
Example 4
private void setColorAndFont(Control control, Color foreground, Color background, Font font) {
    control.setForeground(foreground);
    control.setBackground(background);
    control.setFont(font);
    
    if (control instanceof Composite) {
        Control[] children= ((Composite) control).getChildren();
        for (Control element : children) {
            setColorAndFont(element, foreground, background, font);
        }
    }
}
 
Example 5
private void setColorAndFont(Control control, Color foreground, Color background, Font font) {
	control.setForeground(foreground);
	control.setBackground(background);
	control.setFont(font);

	if (control instanceof Composite) {
		Control[] children = ((Composite) control).getChildren();
		for (int i = 0; i < children.length; i++) {
			setColorAndFont(children[i], foreground, background, font);
		}
	}
}
 
Example 6
private void setBlendedColor()
{
	if (!controlIsDisposed())
	{
		Control c = getControl();
		c.setForeground(getColorManager().getColor(
				Theme.alphaBlend(c.getBackground().getRGB(), c.getForeground().getRGB(), alpha)));
	}
}
 
Example 7
private void setColorAndFont(Control control, Color foreground, Color background, Font font) {
	control.setForeground(foreground);
	control.setBackground(background);
	control.setFont(font);

	if (control instanceof Composite) {
		Control[] children= ((Composite) control).getChildren();
		for (int i= 0; i < children.length; i++) {
			setColorAndFont(children[i], foreground, background, font);
		}
	}
}
 
Example 8
Source Project: thym   File: ControlListItem.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void setForeground(Color color) {
	super.setForeground(color);
	Control[] children = getChildren();
	for (Control child : children) {
		child.setForeground(color);
	}
}
 
Example 9
private void setColorAndFont(Control control, Color foreground, Color background, Font font) {
	control.setForeground(foreground);
	control.setBackground(background);
	control.setFont(font);

	if (control instanceof Composite) {
		Control[] children= ((Composite) control).getChildren();
		for (int i= 0; i < children.length; i++) {
			setColorAndFont(children[i], foreground, background, font);
		}
	}
}
 
Example 10
protected void updateTextEditorFeedback(final IStatus status) {
    if (cellEditor != null && cellEditor.getControl() != null && !cellEditor.getControl().isDisposed()) {
        final Control control = cellEditor.getControl();
        if (status.getSeverity() == IStatus.ERROR) {
            control.setBackground(JFaceColors.getErrorBackground(control.getDisplay()));
            control.setForeground(JFaceColors.getErrorText(control.getDisplay()));
        } else {
            control.setBackground(control.getDisplay().getSystemColor(SWT.COLOR_WHITE));
            control.setForeground(control.getDisplay().getSystemColor(SWT.COLOR_BLACK));
        }
    }
}
 
Example 11
private void setWidgetEnabled(Control control, boolean enabled) {
    control.setEnabled(enabled);
    if (control instanceof CLabel) {
        control.setForeground(enabled ? Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND)
                : Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
    }
    if (control instanceof Composite) {
        Stream.of(((Composite) control).getChildren()).forEach(c -> setWidgetEnabled(c, enabled));
    }
}
 
Example 12
public static void normalizeBackground(Control control, Control parent) {
	control.setBackground(parent.getBackground());
	control.setForeground(parent.getForeground());
}
 
Example 13
private static void applyWidget ( final Control label, final CurrentStyle style )
{
    label.setForeground ( style.foreground );
    label.setBackground ( style.background );
    label.setFont ( style.font );
}
 
Example 14
default void setupControl(Control control) {
    control.setForeground(control.getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND));
    control.setBackground(control.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
}
 
Example 15
private void allowFieldUpdate(boolean lockEnabled){
	boolean noExistingInvoicesForThisCoverage = true;
	boolean costBearerEnabled = true;
	if (actFall != null) {
		Query<Rechnung> rQuery = new Query<Rechnung>(Rechnung.class);
		rQuery.add(Rechnung.CASE_ID, Query.EQUALS, actFall.getId());
		List<Rechnung> billMatch = rQuery.execute();
		
		if (billMatch != null && !billMatch.isEmpty()) {
			noExistingInvoicesForThisCoverage = false;
		}
		costBearerEnabled = !BillingSystem.isCostBearerDisabled(actFall.getAbrechnungsSystem());
	}
	
	boolean enable = lockEnabled && (noExistingInvoicesForThisCoverage || invoiceCorrection);
	
	tBezeichnung.setEditable(lockEnabled);
	
	dpVon.setEnabled(enable);
	dpBis.setEnabled(lockEnabled); // coverage must be endable - even if invoices exist
	
	cAbrechnung.setEnabled(enable);
	cReason.setEnabled(enable);
	hlGarant.setEnabled(enable);
	tGarant.setForeground(
		enable ? UiDesk.getColor(UiDesk.COL_BLACK) : UiDesk.getColor(UiDesk.COL_GREY60));
	tGarant.setEditable(enable);
	
	tCostBearer.setForeground((enable && costBearerEnabled) ? UiDesk.getColor(UiDesk.COL_BLACK)
			: UiDesk.getColor(UiDesk.COL_GREY60));
	tCostBearer.setEditable(enable && costBearerEnabled);
	if (!tCostBearer.getEditable()) {
		tCostBearer.setMessage(StringConstants.EMPTY);
	}
	hlCostBearer.setEnabled(enable && costBearerEnabled);
	
	autoFill.setEnabled(enable);
	
	for (Control req : lReqs) {
		if (req instanceof Label) {
			continue;
		}
		
		// keep editable in case it's an optional parameter of accident date/no
		if (keepEditable.contains(req)) {
			req.setEnabled(lockEnabled);
		} else {
			if (req instanceof Text) {
				if (enable) {
					req.setForeground(UiDesk.getColor(UiDesk.COL_BLACK));
				} else {
					req.setForeground(UiDesk.getColor(UiDesk.COL_GREY60));
				}
				((Text) req).setEditable(enable);
			} else {
				req.setEnabled(enable);
			}
		}
	}
}
 
Example 16
/**
 * Utility to set the foreground and the background color of the given control
 * 
 * @param control
 *            the control to modify
 * @param foreground
 *            the color to use for the foreground
 * @param background
 *            the color to use for the background
 */
private static void setColor(Control control, Color foreground, Color background)
{
	control.setForeground(foreground);
	control.setBackground(background);
}