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

The following examples show how to use org.eclipse.swt.widgets.Control#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: PopupDialog.java    From SWET with 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
Source File: AnnotationWithQuickFixesHover.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
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
Source File: HoverInformationControl.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void setForegroundColor(Color foreground) {
    super.setForegroundColor(foreground);
    Control[] children= fParent.getChildren();
    for (Control element : children) {
        element.setForeground(foreground);
    }
}
 
Example 4
Source File: HoverInfoWithSpellingAnnotation.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
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
Source File: AbstractAnnotationHover.java    From typescript.java with MIT License 5 votes vote down vote up
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
Source File: AlphaBlendThemer.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private void setBlendedColor()
{
	if (!controlIsDisposed())
	{
		Control c = getControl();
		c.setForeground(getColorManager().getColor(
				Theme.alphaBlend(c.getBackground().getRGB(), c.getForeground().getRGB(), alpha)));
	}
}
 
Example 7
Source File: AbstractAnnotationHover.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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 File: ControlListItem.java    From thym with 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
Source File: AbstractAnnotationHover.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
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
Source File: CustomTextEMFObservableValueEditingSupport.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
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
Source File: SelectArtifactToDeployPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
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
Source File: IDEUtil.java    From codewind-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public static void normalizeBackground(Control control, Control parent) {
	control.setBackground(parent.getBackground());
	control.setForeground(parent.getForeground());
}
 
Example 13
Source File: DataItemHeaderLabel.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
private static void applyWidget ( final Control label, final CurrentStyle style )
{
    label.setForeground ( style.foreground );
    label.setBackground ( style.background );
    label.setFont ( style.font );
}
 
Example 14
Source File: TmfAbstractToolTipHandler.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
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
Source File: FallDetailBlatt2.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
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
Source File: CustomAbstractInformationControl.java    From APICloud-Studio with GNU General Public License v3.0 2 votes vote down vote up
/**
 * 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);
}