org.eclipse.jface.resource.ColorRegistry Java Examples
The following examples show how to use
org.eclipse.jface.resource.ColorRegistry.
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: XYGraphMediaFactory.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * Private constructor to avoid instantiation. */ private XYGraphMediaFactory() { _colorRegistry = new ColorRegistry(); _imageRegistry = new ImageRegistry(); _fontRegistry = new FontRegistry(); cursorRegistry = new HashMap<String, Cursor>(); _imageCache = new HashMap<ImageDescriptor, Image>(); // dispose all images from the image cache, when the display is disposed Display.getDefault().addListener(SWT.Dispose, new Listener() { public void handleEvent(final Event event) { for (Image img : _imageCache.values()) { img.dispose(); } disposeResources(); } }); }
Example #2
Source File: DefaultEObjectHoverProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected XtextBrowserInformationControlInput getHoverInfo(EObject element, IRegion hoverRegion, XtextBrowserInformationControlInput previous) { String html = getHoverInfoAsHtml(element); if (html != null) { StringBuffer buffer = new StringBuffer(html); ColorRegistry registry = JFaceResources.getColorRegistry(); RGB fgRGB = registry.getRGB("org.eclipse.ui.workbench.HOVER_FOREGROUND"); //$NON-NLS-1$ RGB bgRGB = registry.getRGB("org.eclipse.ui.workbench.HOVER_BACKGROUND"); //$NON-NLS-1$ if (fgRGB != null && bgRGB != null) { HTMLPrinter.insertPageProlog(buffer, 0, fgRGB, bgRGB, getStyleSheet()); } else { HTMLPrinter.insertPageProlog(buffer, 0, getStyleSheet()); } HTMLPrinter.addPageEpilog(buffer); html = buffer.toString(); return new XtextBrowserInformationControlInput(previous, element, html, labelProvider); } return null; }
Example #3
Source File: RenameRefactoringPopup.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
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 #4
Source File: EditorConfigUIPreferenceInitializer.java From editorconfig-eclipse with Apache License 2.0 | 6 votes |
public static void setThemeBasedPreferences(IPreferenceStore store, boolean fireEvent) { ColorRegistry registry = null; if (PlatformUI.isWorkbenchRunning()) registry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry(); setDefault(store, PreferenceConstants.EDITOR_CONFIG_COLORING_PROPERTY_KEY, findRGB(registry, IEditorConfigThemeConstants.EDITOR_CONFIG_COLORING_PROPERTY_KEY, new RGB(0, 0, 0)), fireEvent); setDefault(store, PreferenceConstants.EDITOR_CONFIG_COLORING_PROPERTY_VALUE, findRGB(registry, IEditorConfigThemeConstants.EDITOR_CONFIG_COLORING_PROPERTY_VALUE, new RGB(42, 0, 255)), fireEvent); setDefault(store, PreferenceConstants.EDITOR_CONFIG_COLORING_ASSIGNMENT, findRGB(registry, IEditorConfigThemeConstants.EDITOR_CONFIG_COLORING_ASSIGNMENT, new RGB(0, 0, 0)), fireEvent); setDefault(store, PreferenceConstants.EDITOR_CONFIG_COLORING_COMMENT, findRGB(registry, IEditorConfigThemeConstants.EDITOR_CONFIG_COLORING_COMMENT, new RGB(63, 127, 95)), fireEvent); setDefault(store, PreferenceConstants.EDITOR_CONFIG_COLORING_SECTION, findRGB(registry, IEditorConfigThemeConstants.EDITOR_CONFIG_COLORING_SECTION, new RGB(0, 0, 0)), fireEvent); }
Example #5
Source File: StylerFactory.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@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 #6
Source File: ColorManager.java From birt with Eclipse Public License 1.0 | 5 votes |
private static RGB findRGB(ColorRegistry registry, String key, RGB defaultRGB) { if (registry == null) return defaultRGB; RGB rgb= registry.getRGB(key); if (rgb != null) return rgb; return defaultRGB; }
Example #7
Source File: ColorManager.java From birt with Eclipse Public License 1.0 | 5 votes |
/**Gets the color. * @param id * @param defaultRGB * @return */ public static Color getColor(String id, RGB defaultRGB) { ColorRegistry registry= null; if (PlatformUI.isWorkbenchRunning()) registry= PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry(); RGB rgb = findRGB(registry, id, defaultRGB); return getColor(rgb); }
Example #8
Source File: SyntaxHighlighter.java From textuml with Eclipse Public License 1.0 | 5 votes |
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: JavaUIPreferenceInitializer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Returns the RGB for the given key in the given color registry. * * @param registry the color registry * @param key the key for the constant in the registry * @param defaultRGB the default RGB if no entry is found * @return RGB the RGB * @since 3.4 */ private static RGB findRGB(ColorRegistry registry, String key, RGB defaultRGB) { if (registry == null) return defaultRGB; RGB rgb= registry.getRGB(key); if (rgb != null) return rgb; return defaultRGB; }
Example #10
Source File: SemanticHighlighting.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Returns the RGB for the given key in the given color registry. * * @param key the key for the constant in the registry * @param defaultRGB the default RGB if no entry is found * @return RGB the RGB * @since 3.3 */ private static RGB findRGB(String key, RGB defaultRGB) { if (!PlatformUI.isWorkbenchRunning()) return defaultRGB; ColorRegistry registry= PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry(); RGB rgb= registry.getRGB(key); if (rgb != null) return rgb; return defaultRGB; }
Example #11
Source File: SWTUtils.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
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 #12
Source File: DiffAttributeEditor.java From git-appraise-eclipse with Eclipse Public License 1.0 | 5 votes |
/** * 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 #13
Source File: TmfEventsTable.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * 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 #14
Source File: TimeGraphColorScheme.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
@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 #15
Source File: FilterViewer.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
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 #16
Source File: FilterColorEditorTest.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Test highlight color preference */ @Test public void testPreference() { // change the highlight color preference ColorRegistry colorRegistry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry(); colorRegistry.put(HIGHLIGHT_COLOR_DEFINITION_ID, GREEN); final Rectangle cellBounds = SWTBotUtils.getCellBounds(fTableBot.widget, ROW, SOURCE_COLUMN); ImageHelper before = ImageHelper.grabImage(cellBounds); Multiset<RGB> colorBefore = before.getHistogram(); // Select source column and enter regex fTableBot.click(0, SOURCE_COLUMN); fBot.text().typeText("HostF\n", 100); // make sure selected row is not matching row fTableBot.select(ROW - 1); Multiset<RGB> colorAfter = ImageHelper.waitForNewImage(cellBounds, before).getHistogram(); assertTrue(colorBefore.contains(fBackground)); assertTrue(colorBefore.contains(fForeground)); assertFalse(colorBefore.contains(fHighlight)); assertFalse(colorBefore.contains(fGreen)); assertTrue(colorAfter.contains(fBackground)); assertTrue(colorAfter.contains(fForeground)); assertFalse(colorAfter.contains(fHighlight)); assertTrue(colorAfter.contains(fGreen)); /* * Check that some background became green. */ assertTrue(colorAfter.count(fBackground) < colorBefore.count(fBackground)); assertTrue(colorAfter.count(fGreen) > colorBefore.count(fGreen)); // reset the highlight color preference colorRegistry.put(HIGHLIGHT_COLOR_DEFINITION_ID, fHighlight); }
Example #17
Source File: FilterColorEditorTest.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Test Class setup */ @BeforeClass public static void init() { SWTBotUtils.initialize(); /* set up test trace */ URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(COLUMN_TRACE_PATH), null); URI uri; try { uri = FileLocator.toFileURL(location).toURI(); fTestFile = new File(uri); } catch (URISyntaxException | IOException e) { fail(e.getMessage()); } assumeTrue(fTestFile.exists()); /* Set up for swtbot */ SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */ SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US"; fLogger.removeAllAppenders(); fLogger.addAppender(new ConsoleAppender(new SimpleLayout(), ConsoleAppender.SYSTEM_OUT)); fBot = new SWTWorkbenchBot(); /* Finish waiting for eclipse to load */ WaitUtils.waitForJobs(); ColorRegistry colorRegistry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry(); fHighlight = ImageHelper.adjustExpectedColor(colorRegistry.get(HIGHLIGHT_COLOR_DEFINITION_ID).getRGB()); fGreen = ImageHelper.adjustExpectedColor(GREEN); }
Example #18
Source File: PreferenceConstants.java From typescript.java with MIT License | 5 votes |
/** * Initializes the given preference store with the default values. * * @param store * the preference store to be initialized * */ public static void initializeDefaultValues(IPreferenceStore store) { ColorRegistry registry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry(); // JSX tag border setDefaultAndFireEvent(store, PreferenceConstants.EDITOR_TYPESCRIPT_DECORATOR_COLOR, findRGB(registry, ITypeScriptThemeConstants.EDITOR_TYPESCRIPT_DECORATOR_COLOR, new RGB(100, 100, 100))); store.setDefault(PreferenceConstants.EDITOR_TYPESCRIPT_DECORATOR_BOLD, false); store.setDefault(PreferenceConstants.EDITOR_TYPESCRIPT_DECORATOR_ITALIC, false); // JSX tag border setDefaultAndFireEvent(store, PreferenceConstants.EDITOR_JSX_TAG_BORDER_COLOR, findRGB(registry, ITypeScriptThemeConstants.EDITOR_JSX_TAG_BORDER_COLOR, new RGB(0, 128, 128))); store.setDefault(PreferenceConstants.EDITOR_JSX_TAG_BORDER_BOLD, false); store.setDefault(PreferenceConstants.EDITOR_JSX_TAG_BORDER_ITALIC, false); // JSX tag name setDefaultAndFireEvent(store, PreferenceConstants.EDITOR_JSX_TAG_NAME_COLOR, findRGB(registry, ITypeScriptThemeConstants.EDITOR_JSX_TAG_NAME_COLOR, new RGB(63, 127, 127))); store.setDefault(PreferenceConstants.EDITOR_JSX_TAG_NAME_BOLD, false); store.setDefault(PreferenceConstants.EDITOR_JSX_TAG_NAME_ITALIC, false); // JSX tag attribute name setDefaultAndFireEvent(store, PreferenceConstants.EDITOR_JSX_TAG_ATTRIBUTE_NAME_COLOR, findRGB(registry, ITypeScriptThemeConstants.EDITOR_JSX_TAG_ATTRIBUTE_NAME_COLOR, new RGB(127, 0, 127))); store.setDefault(PreferenceConstants.EDITOR_JSX_TAG_ATTRIBUTE_NAME_BOLD, false); store.setDefault(PreferenceConstants.EDITOR_JSX_TAG_ATTRIBUTE_NAME_ITALIC, false); // JSX tag attribute value setDefaultAndFireEvent(store, PreferenceConstants.EDITOR_JSX_TAG_ATTRIBUTE_VALUE_COLOR, findRGB(registry, ITypeScriptThemeConstants.EDITOR_JSX_TAG_ATTRIBUTE_VALUE_COLOR, new RGB(42, 0, 255))); store.setDefault(PreferenceConstants.EDITOR_JSX_TAG_ATTRIBUTE_VALUE_BOLD, false); store.setDefault(PreferenceConstants.EDITOR_JSX_TAG_ATTRIBUTE_VALUE_ITALIC, true); }
Example #19
Source File: XbaseHoverProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override protected XtextBrowserInformationControlInput getHoverInfo(EObject element, IRegion hoverRegion, XtextBrowserInformationControlInput previous) { //TODO remove this check when the typesystem works without a java project if (isValidationDisabled(element)) return null; EObject objectToView = getObjectToView(element); if(objectToView == null || objectToView.eIsProxy()) return null; String html = getHoverInfoAsHtml(element, objectToView, hoverRegion); if (html != null) { StringBuffer buffer = new StringBuffer(html); ColorRegistry registry = JFaceResources.getColorRegistry(); RGB fgRGB = registry.getRGB("org.eclipse.ui.workbench.HOVER_FOREGROUND"); //$NON-NLS-1$ RGB bgRGB = registry.getRGB("org.eclipse.ui.workbench.HOVER_BACKGROUND"); //$NON-NLS-1$ if (fgRGB != null && bgRGB != null) { HTMLPrinter.insertPageProlog(buffer, 0, fgRGB, bgRGB, getStyleSheet()); } else { HTMLPrinter.insertPageProlog(buffer, 0, getStyleSheet()); } HTMLPrinter.addPageEpilog(buffer); html = buffer.toString(); IJavaElement javaElement = null; if (objectToView != element && objectToView instanceof JvmIdentifiableElement) { javaElement = javaElementFinder.findElementFor((JvmIdentifiableElement) objectToView); } return new XbaseInformationControlInput(previous, objectToView, javaElement, html, labelProvider); } return null; }
Example #20
Source File: TmfEventsTable.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
/** * Initialize the colors. */ private void initializeColors() { ColorRegistry colorRegistry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry(); fHighlightColor = colorRegistry.get(HIGHLIGHT_COLOR_DEFINITION_ID); }
Example #21
Source File: TmfRawEventViewer.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
/** * 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 #22
Source File: ColorsView.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
private static Color getThemeColor(String themeColorName) { ColorRegistry colorRegistry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry(); Color c = colorRegistry.get(themeColorName); return c; }
Example #23
Source File: ModeLineFlasher.java From e4macs with Eclipse Public License 1.0 | 4 votes |
private void setColors() { ColorRegistry colorRegistry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry(); backs[0] = Flasher.invertColor(colorRegistry.get(backgroundKey)); backs[1] = Flasher.invertColor(colorRegistry.get(foregroundKey)); }
Example #24
Source File: EditorConfigUIPreferenceInitializer.java From editorconfig-eclipse with Apache License 2.0 | 3 votes |
/** * Returns the RGB for the given key in the given color registry. * * @param registry * the color registry * @param key * the key for the constant in the registry * @param defaultRGB * the default RGB if no entry is found * @return RGB the RGB */ private static RGB findRGB(ColorRegistry registry, String key, RGB defaultRGB) { if (registry == null) { return defaultRGB; } RGB rgb = registry.getRGB(key); if (rgb != null) { return rgb; } return defaultRGB; }
Example #25
Source File: PreferenceConstants.java From typescript.java with MIT License | 3 votes |
/** * Returns the RGB for the given key in the given color registry. * * @param registry * the color registry * @param key * the key for the constant in the registry * @param defaultRGB * the default RGB if no entry is found * @return RGB the RGB * */ private static RGB findRGB(ColorRegistry registry, String key, RGB defaultRGB) { RGB rgb = registry.getRGB(key); if (rgb != null) return rgb; return defaultRGB; }
Example #26
Source File: ColorHelper.java From birt with Eclipse Public License 1.0 | 3 votes |
/** * Attempts to lookup the RGB value for <code>key</code> from the color * registry. If one is not found, the <code>defaultRGB</code> is used. * * @param registry * The ColorRegistry to search for the RGB value * @param key * The key that the RGB value is stored under in the registry * @param defaultRGB * The default RGB value to return in the absence of one from the * color registry * * @return The RGB value from the color registry for a given key, if it * exists. Otherwise, return the default RGB value. */ public static RGB findRGB( ColorRegistry registry, String key, RGB defaultRGB ) { if ( registry.hasValueFor( key ) ) return registry.getRGB( key ); return defaultRGB; }
Example #27
Source File: ColorHelper.java From birt with Eclipse Public License 1.0 | 3 votes |
/** * Attempts to find the RGB string for <code>key</code> from the color * registry. If one is not found, an RGB string is generated from the * parameters <code>r,g,b</code>. * * @param registry * The ColorRegistry to search for the RGB value * @param key * The key that the RGB value is stored under in the registry * @param r * The default red value * @param g * The default green value * @param b * The default blue value * * @return The String RGB value from the color registry for a given key, if * it exists. Otherwise, return the string RGB value created from * the default r,g,b parameters. * */ public static String findRGBString( ColorRegistry registry, String key, int r, int g, int b ) { if ( registry.hasValueFor( key ) ) return toRGBString( registry.getRGB( key ) ); return getColorString( r, g, b ); }