List of usage examples for org.eclipse.jface.resource JFaceResources getColorRegistry
public static ColorRegistry getColorRegistry()
From source file:org.eclipse.ui.internal.presentations.defaultpresentation.DefaultThemeListener.java
License:Open Source License
private boolean updateHighlightColor() { if (!useHighlight()) return false; //get newTabBegin from theme, not from ColorRegistry, which may not have been updated yet RGB newTabBegin = getColor(IWorkbenchThemeConstants.ACTIVE_TAB_BG_START, null).getRGB(); RGB newHighlight = LightColorFactory.createHighlightStartColor(newTabBegin); //Registry handles lifecycle of colors so no leakage and if RGB s.equals then no change JFaceResources.getColorRegistry().put(IWorkbenchThemeConstants.ACTIVE_TAB_HIGHLIGHT_START, newHighlight); return true;/*from w ww . j a va 2 s. c om*/ }
From source file:org.eclipse.ui.internal.presentations.defaultpresentation.DefaultThemeListener.java
License:Open Source License
public void update() { Color[] activeFocusBackgroundColors = updateHighlightColor() ? new Color[] { getColor(IWorkbenchThemeConstants.ACTIVE_TAB_BG_START, null), getColor(IWorkbenchThemeConstants.ACTIVE_TAB_BG_END, null), JFaceResources.getColorRegistry().get(IWorkbenchThemeConstants.ACTIVE_TAB_HIGHLIGHT_START) } : new Color[] { getColor(IWorkbenchThemeConstants.ACTIVE_TAB_BG_START, null), getColor(IWorkbenchThemeConstants.ACTIVE_TAB_BG_END, null) }; folder.setColors(new DefaultTabFolderColors(getColor(IWorkbenchThemeConstants.ACTIVE_TAB_TEXT_COLOR, null), activeFocusBackgroundColors, new int[] { getInt(IWorkbenchThemeConstants.ACTIVE_TAB_PERCENT, 0) }, getBoolean(IWorkbenchThemeConstants.ACTIVE_TAB_VERTICAL, true)), StackPresentation.AS_ACTIVE_FOCUS, true);/*from w w w . j a v a 2s . c o m*/ folder.setColors( new DefaultTabFolderColors(getColor(IWorkbenchThemeConstants.ACTIVE_NOFOCUS_TAB_TEXT_COLOR, null), new Color[] { getColor(IWorkbenchThemeConstants.ACTIVE_NOFOCUS_TAB_BG_START, null), getColor(IWorkbenchThemeConstants.ACTIVE_NOFOCUS_TAB_BG_END, null) }, new int[] { getInt(IWorkbenchThemeConstants.ACTIVE_NOFOCUS_TAB_PERCENT, 0) }, getBoolean(IWorkbenchThemeConstants.ACTIVE_NOFOCUS_TAB_VERTICAL, true)), StackPresentation.AS_ACTIVE_FOCUS, false); folder.setColors( new DefaultTabFolderColors(getColor(IWorkbenchThemeConstants.INACTIVE_TAB_TEXT_COLOR, null), new Color[] { getColor(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START, null), getColor(IWorkbenchThemeConstants.INACTIVE_TAB_BG_END, null) }, new int[] { getInt(IWorkbenchThemeConstants.INACTIVE_TAB_PERCENT, 0) }, getBoolean(IWorkbenchThemeConstants.INACTIVE_TAB_VERTICAL, true)), StackPresentation.AS_INACTIVE); folder.setColors( new DefaultTabFolderColors(getColor(IWorkbenchThemeConstants.INACTIVE_TAB_TEXT_COLOR, null), new Color[] { getColor(IWorkbenchThemeConstants.INACTIVE_TAB_BG_START, null) }, new int[0], true), StackPresentation.AS_ACTIVE_NOFOCUS); folder.setFont((Font) theme.getValue(IWorkbenchThemeConstants.TAB_TEXT_FONT, Font.class)); }
From source file:org.eclipse.ui.internal.themes.WorkbenchThemeManager.java
License:Open Source License
public void setCurrentTheme(String id) { ITheme oldTheme = currentTheme;/* w w w .j a v a 2 s. c om*/ if (WorkbenchThemeManager.getInstance().doSetCurrentTheme(id)) { firePropertyChange(CHANGE_CURRENT_THEME, oldTheme, getCurrentTheme()); if (oldTheme != null) { oldTheme.removePropertyChangeListener(currentThemeListener); } currentTheme.addPropertyChangeListener(currentThemeListener); // update the preference if required. if (!PrefUtil.getAPIPreferenceStore().getString(IWorkbenchPreferenceConstants.CURRENT_THEME_ID) .equals(id)) { PrefUtil.getAPIPreferenceStore().setValue(IWorkbenchPreferenceConstants.CURRENT_THEME_ID, id); PrefUtil.saveAPIPrefs(); } // update the jface registries { ColorRegistry jfaceColors = JFaceResources.getColorRegistry(); ColorRegistry themeColors = currentTheme.getColorRegistry(); for (Iterator i = themeColors.getKeySet().iterator(); i.hasNext();) { String key = (String) i.next(); jfaceColors.put(key, themeColors.getRGB(key)); } } { FontRegistry jfaceFonts = JFaceResources.getFontRegistry(); FontRegistry themeFonts = currentTheme.getFontRegistry(); for (Iterator i = themeFonts.getKeySet().iterator(); i.hasNext();) { String key = (String) i.next(); jfaceFonts.put(key, themeFonts.getFontData(key)); } } } }
From source file:org.eclipse.ui.tests.themes.JFaceThemeTest.java
License:Open Source License
private void setAndTest(String themeId, IPropertyChangeListener listener) { JFaceResources.getFontRegistry().addListener(listener); JFaceResources.getColorRegistry().addListener(listener); fManager.setCurrentTheme(themeId);/* w w w . j a v a2 s . c o m*/ ITheme theme = fManager.getTheme(themeId); assertEquals(theme, fManager.getCurrentTheme()); { FontRegistry jfaceFonts = JFaceResources.getFontRegistry(); FontRegistry themeFonts = theme.getFontRegistry(); // don't test for equality - other tests (or clients) may be pushing // new items into jface assertTrue(jfaceFonts.getKeySet().containsAll(themeFonts.getKeySet())); for (Iterator i = themeFonts.getKeySet().iterator(); i.hasNext();) { String key = (String) i.next(); assertArrayEquals(themeFonts.getFontData(key), jfaceFonts.getFontData(key)); } } { ColorRegistry jfaceColors = JFaceResources.getColorRegistry(); ColorRegistry themeColors = theme.getColorRegistry(); assertTrue(jfaceColors.getKeySet().containsAll(themeColors.getKeySet())); for (Iterator i = themeColors.getKeySet().iterator(); i.hasNext();) { String key = (String) i.next(); assertEquals(themeColors.getRGB(key), jfaceColors.getRGB(key)); } } JFaceResources.getFontRegistry().removeListener(listener); JFaceResources.getColorRegistry().removeListener(listener); }
From source file:org.eclipse.vex.ui.internal.swt.ContentAssist.java
License:Open Source License
@Override protected Color getForeground() { return JFaceResources.getColorRegistry().get(JFacePreferences.CONTENT_ASSIST_FOREGROUND_COLOR); }
From source file:org.eclipse.vex.ui.internal.swt.ContentAssist.java
License:Open Source License
@Override protected Color getBackground() { return JFaceResources.getColorRegistry().get(JFacePreferences.CONTENT_ASSIST_BACKGROUND_COLOR); }
From source file:org.eclipse.viatra.query.patternlanguage.emf.ui.labeling.EMFPatternLanguageHoverProvider.java
License:Open Source License
@Override protected XtextBrowserInformationControlInput getHoverInfo(EObject element, IRegion hoverRegion, XtextBrowserInformationControlInput previous) { EObject objectToView = getObjectToView(element); if (objectToView == null || objectToView.eIsProxy()) return null; String html = getHoverInfoAsHtml(element, objectToView, hoverRegion); if (html != null) { StringBuilder buffer = new StringBuilder(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 {//from w w w . j a va2 s . c om 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; }
From source file:org.eclipse.wst.jsdt.internal.ui.infoviews.AbstractInfoView.java
License:Open Source License
final public void dispose() { // cancel possible running computation fComputeCount++;/* w w w .j a v a 2 s.c o m*/ getSite().getWorkbenchWindow().getPartService().removePartListener(fPartListener); ISelectionProvider provider = getSelectionProvider(); if (provider != null) provider.removeSelectionChangedListener(fCopyToClipboardAction); JFaceResources.getColorRegistry().removeListener(this); fBackgroundColorRGB = null; if (fBackgroundColor != null) { fBackgroundColor.dispose(); fBackgroundColor = null; } internalDispose(); }
From source file:org.eclipse.wst.jsdt.internal.ui.typehierarchy.HierarchyLabelProvider.java
License:Open Source License
public Color getForeground(Object element) { if (element instanceof IFunction) { if (fSpecialColor == null) { fSpecialColor = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE); }//from w w w .j a va2s . c o m return fSpecialColor; } else if (element instanceof IType && isDifferentScope((IType) element)) { return JFaceResources.getColorRegistry().get(ColoredViewersManager.QUALIFIER_COLOR_NAME); } return null; }
From source file:org.eclipse.wst.jsdt.internal.ui.typehierarchy.MethodsLabelProvider.java
License:Open Source License
public MethodsLabelProvider(TypeHierarchyLifeCycle lifeCycle, MethodsViewer methodsViewer) { super(DEFAULT_TEXTFLAGS, DEFAULT_IMAGEFLAGS); fHierarchy = lifeCycle;/*from ww w . jav a 2s . c om*/ fShowDefiningType = false; fMethodsViewer = methodsViewer; fColorRegistryListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(ColoredViewersManager.INHERITED_COLOR_NAME)) { fireLabelProviderChanged(new LabelProviderChangedEvent(MethodsLabelProvider.this, null)); } } }; JFaceResources.getColorRegistry().addListener(fColorRegistryListener); }