Java Code Examples for org.eclipse.jface.resource.ColorRegistry#get()

The following examples show how to use org.eclipse.jface.resource.ColorRegistry#get() . 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: RenameRefactoringPopup.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected void createContent(Composite parent) {
	Display display = parent.getDisplay();
	ColorRegistry registry = JFaceResources.getColorRegistry();
	Color foreground= registry.get("org.eclipse.ui.workbench.HOVER_FOREGROUND"); //$NON-NLS-1$
	if (foreground == null) {
		foreground = display.getSystemColor(SWT.COLOR_INFO_FOREGROUND);
	}
	Color background= registry.get("org.eclipse.ui.workbench.HOVER_BACKGROUND"); //$NON-NLS-1$
	if (background == null) {
		background = display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
	}
	StyledText hint = new StyledText(popup, SWT.READ_ONLY | SWT.SINGLE);
	String enterKeyName = getEnterBinding();
	String hintTemplate = "Enter new name, press {0} to refactor";
	hint.setText(Messages.format(hintTemplate, enterKeyName));
	hint.setForeground(foreground);
	hint.setStyleRange(new StyleRange(hintTemplate.indexOf("{0}"), enterKeyName.length(), null, null, SWT.BOLD)); //$NON-NLS-1$
	hint.setEnabled(false); // text must not be selectable
	addViewMenu(parent);
	recursiveSetBackgroundColor(parent, background);
}
 
Example 2
Source File: StylerFactory.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void applyStyles(TextStyle textStyle) {
	ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
	if (fontDescriptor != null) {
		textStyle.font = fontDescriptor.createFont(Display.getCurrent());
	}
	if (foregroundColorName != null) {
		textStyle.foreground = colorRegistry.get(foregroundColorName);
	}
	if (backgroundColorName != null) {
		textStyle.background = colorRegistry.get(backgroundColorName);
	}
}
 
Example 3
Source File: FilterViewer.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static Color getThemeColor(String themeColorName, int systemDefault) {
    ColorRegistry colorRegistry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry();
    Color c = colorRegistry.get(themeColorName);

    if (c == null) {
        c = Display.getDefault().getSystemColor(systemDefault);
    }
    return c;
}
 
Example 4
Source File: TimeGraphColorScheme.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Color get() {
    ColorRegistry colorRegistry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry();
    Color c = colorRegistry.get(themeColorName);
    if (c != null) {
        org.eclipse.swt.graphics.RGB rgb = c.getRGB();
        return new Color(null, rgb.red, rgb.green, rgb.blue);
    }
    return Utils.getSysColor(syscol);
}
 
Example 5
Source File: TmfEventsTable.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Create the resources.
 */
private void createResources() {
    ColorRegistry colorRegistry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry();
    Color c = colorRegistry.get("org.eclipse.tracecompass.tmf.ui.FOREGROUND"); //$NON-NLS-1$
    if (c != null) {
        fGrayColor = c;
    } else {
        fGrayColor = fResourceManager.createColor(ColorUtil.blend(fTable.getBackground().getRGB(), fTable.getForeground().getRGB()));
    }
    fGreenColor = PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_DARK_GREEN);
}
 
Example 6
Source File: DiffAttributeEditor.java    From git-appraise-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Starts a new {@link StyleRange} given a specific line type.
 */
private StyleRange initDiffStyleRangeForLineType(DiffLineType lineType, int startTextOffset) {
  ColorRegistry reg =
      PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry();
  StyleRange range = new StyleRange();
  range.start = startTextOffset;
  switch (lineType) {
    case ADD:
      range.foreground = reg.get(THEME_DiffAddForegroundColor);
      range.background = reg.get(THEME_DiffAddBackgroundColor);
      break;
    case REMOVE:
      range.foreground = reg.get(THEME_DiffRemoveForegroundColor);
      range.background = reg.get(THEME_DiffRemoveBackgroundColor);
      break;
    case HUNK:
      range.foreground = reg.get(THEME_DiffHunkForegroundColor);
      range.background = reg.get(THEME_DiffHunkBackgroundColor);
      break;
    case HEADLINE:
      range.foreground = reg.get(THEME_DiffHeadlineForegroundColor);
      range.background = reg.get(THEME_DiffHeadlineBackgroundColor);
      FontRegistry fontReg =
          PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getFontRegistry();
      range.font = fontReg.get(THEME_DiffHeadlineFont);
      break;
    default:
      break;
  }
  return range;
}
 
Example 7
Source File: SWTUtils.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void run()
{
	ColorRegistry cm = JFaceResources.getColorRegistry();
	RGB errorRGB = new RGB(255, 255, 180);
	cm.put("error", errorRGB); //$NON-NLS-1$
	backgroundErrorColor = cm.get("error"); //$NON-NLS-1$
}
 
Example 8
Source File: SyntaxHighlighter.java    From textuml with Eclipse Public License 1.0 5 votes vote down vote up
protected void initialize(String[] keywords) {
    ColorRegistry registry = JFaceResources.getColorRegistry();

    IToken keyword = new Token(new TextAttribute(registry.get(KEYWORD_COLOR), null, SWT.BOLD));
    IToken string = new Token(new TextAttribute(registry.get(STRING_COLOR)));
    IToken number = new Token(new TextAttribute(registry.get(NUMBER_COLOR)));
    IToken annotation = new Token(new TextAttribute(registry.get(ANNOTATION_COLOR)));
    IToken defaultToken = new Token(new TextAttribute(registry.get(DEFAULT_COLOR)));

    List<IRule> rules = new ArrayList<IRule>();

    // strings
    rules.add(new SingleLineRule("\"", "\"", string, '\\'));

    // annotations
    rules.add(new MultiLineRule("[", "]", annotation));

    // numbers
    rules.add(new NumberRule(number));

    // keywords and normal (default) text
    WordRule wordRule = new WordRule(new WordDetector(), defaultToken);
    for (int i = 0; i < keywords.length; i++) {
        wordRule.addWord(keywords[i], keyword);
    }
    rules.add(wordRule);

    setRules(rules.toArray(new IRule[rules.size()]));
}
 
Example 9
Source File: ColorsView.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
private static Color getThemeColor(String themeColorName) {
    ColorRegistry colorRegistry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry();
    Color c = colorRegistry.get(themeColorName);
    return c;
}
 
Example 10
Source File: TmfRawEventViewer.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Initialize the colors.
 * @since 1.1
 */
protected void initializeColors() {
    ColorRegistry colorRegistry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry();
    fHighlightColor = colorRegistry.get(HIGHLIGHT_COLOR_DEFINITION_ID);
    fSelectionColor = colorRegistry.get(SELECTION_COLOR_DEFINITION_ID);
}
 
Example 11
Source File: TmfEventsTable.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Initialize the colors.
 */
private void initializeColors() {
    ColorRegistry colorRegistry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry();
    fHighlightColor = colorRegistry.get(HIGHLIGHT_COLOR_DEFINITION_ID);
}