List of usage examples for org.eclipse.jface.resource JFaceResources getColorRegistry
public static ColorRegistry getColorRegistry()
From source file:customButton.CustomButton.java
License:Open Source License
private Color getSavedColor(int r, int g, int b) { String colorString = "COLOR:" + r + "-" + g + "-" + b; ColorRegistry colorRegistry = JFaceResources.getColorRegistry(); if (!colorRegistry.hasValueFor(colorString)) { colorRegistry.put(colorString, new RGB(r, g, b)); }//w w w. j ava2 s.co m return colorRegistry.get(colorString); }
From source file:cz.vutbr.fit.xhriba01.bc.jdt.ui.PreferenceConstants.java
License:Open Source License
/** * Initializes deprecated color constants. * /*from www.j a v a2 s .co m*/ * @param store the preference store * @since 3.6 */ private static void initializeDeprecatedColorConstants(IPreferenceStore store) { RGB bgRGB = null; RGB fgRGB = null; // Don't fail in headless mode //if (PlatformUI.isWorkbenchRunning()) { bgRGB = JFaceResources.getColorRegistry().getRGB(JFacePreferences.CONTENT_ASSIST_BACKGROUND_COLOR); fgRGB = JFaceResources.getColorRegistry().getRGB(JFacePreferences.CONTENT_ASSIST_FOREGROUND_COLOR); //} // Workaround for https://bugs.eclipse.org/306736 if (bgRGB == null) bgRGB = new RGB(255, 255, 255); if (fgRGB == null) fgRGB = new RGB(0, 0, 0); setRGBValue(store, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, bgRGB); setRGBValue(store, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, fgRGB); }
From source file:de.babe.eclipse.plugins.quickREx.views.QuickRExView.java
License:Open Source License
private void updateMatchView(Match match, boolean evaluated) { testText.setStyleRange(new StyleRange(0, testText.getText().length(), null, null)); if (!evaluated) { testText.setBackground(JFaceResources.getColorRegistry().get(NOT_EVALUATED_BG_COLOR_KEY)); } else {//from w w w. j av a2s . co m testText.setBackground(null); } if (hits.getAllMatches() != null && hits.getAllMatches().length > 0) { testText.setStyleRanges(getStyleRanges(hits.getAllMatches())); } if (match != null) { testText.setStyleRange(new StyleRange(match.getStart(), match.getEnd() - match.getStart(), JFaceResources.getColorRegistry().get(CURRENT_MATCH_FG_COLOR_KEY), JFaceResources.getColorRegistry().get(CURRENT_MATCH_BG_COLOR_KEY), SWT.NORMAL)); if (match.getCurrentGroup() != null && match.getCurrentGroup().getStart() >= 0) { testText.setStyleRange(new StyleRange(match.getCurrentGroup().getStart(), match.getCurrentGroup().getEnd() - match.getCurrentGroup().getStart(), JFaceResources.getColorRegistry().get(CURRENT_MATCH_FG_COLOR_KEY), JFaceResources.getColorRegistry().get(CURRENT_MATCH_BG_COLOR_KEY), SWT.BOLD)); } // scroll horizontally if needed testText.setTopIndex(testText.getLineAtOffset(match.getStart())); } }
From source file:de.babe.eclipse.plugins.quickREx.views.QuickRExView.java
License:Open Source License
private StyleRange[] getStyleRanges(Match[] matches) { StyleRange[] ranges = new StyleRange[matches.length]; for (int i = 0; i < matches.length; i++) { int start = matches[i].getStart(); int length = matches[i].getEnd() - start; Color foreground = JFaceResources.getColorRegistry().get(MATCH_FG_COLOR_KEY); Color background = JFaceResources.getColorRegistry().get(MATCH_BG_COLOR_KEY); ranges[i] = new StyleRange(start, length, foreground, background); }//from w ww.jav a2 s .co m return ranges; }
From source file:de.femodeling.e4.ui.progress.internal.ProgressInfoItem.java
License:Open Source License
/** * Set the color base on the index/*from ww w . j a v a 2 s .co m*/ * * @param i */ public void setColor(int i) { currentIndex = i; if (selected) { setAllBackgrounds(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION)); setAllForegrounds(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT)); return; } if (i % 2 == 0) { setAllBackgrounds(JFaceResources.getColorRegistry().get(DARK_COLOR_KEY)); } else { setAllBackgrounds(getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); } setAllForegrounds(getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND)); }
From source file:de.volanakis.ribbonide.internal.presentation.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;/* ww w . j ava2 s.c o m*/ }
From source file:de.volanakis.ribbonide.internal.presentation.DefaultThemeListener.java
License:Open Source License
@Override 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) }; callback.setColors(//from w w w.j a v a 2 s. com 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); callback.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); callback.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); callback.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); callback.setFont((Font) theme.getValue(IWorkbenchThemeConstants.TAB_TEXT_FONT, Font.class)); }
From source file:de.walware.ecommons.ui.breadcrumb.AbstractBreadcrumb.java
License:Open Source License
@Override public Control createContent(final Composite parent) { assert (fComposite == null); fComposite = new Composite(parent, SWT.NONE); final GridLayout gridLayout = LayoutUtil.applySashDefaults(new GridLayout(), 1); fComposite.setLayout(gridLayout);// w ww .jav a2 s . c om fDisplayFocusListener = new Listener() { @Override public void handleEvent(final Event event) { if (isBreadcrumbEvent(event)) { if (fHasFocus) { return; } fIsActive = true; focusGained(); } else { if (!fIsActive) { return; } if (hasInputFocus()) { fIsActive = false; } if (!fHasFocus) { return; } focusLost(); } } }; Display.getCurrent().addFilter(SWT.FocusIn, fDisplayFocusListener); fBreadcrumbViewer = createViewer(fComposite); fBreadcrumbViewer.getControl().setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); fBreadcrumbViewer.addOpenListener(new IOpenListener() { @Override public void open(final OpenEvent event) { doRevealOrOpen(event.getSelection()); } }); fBreadcrumbViewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(final DoubleClickEvent event) { final Object element = ((IStructuredSelection) event.getSelection()).getFirstElement(); if (element == null) { return; } if (doRevealOrOpen(event.getSelection())) { return; } // final BreadcrumbItem item = (BreadcrumbItem) fBreadcrumbViewer.doFindItem(element); // if (item == null) { // return; // } // final int index = fBreadcrumbViewer.getIndexOfItem(item); // final BreadcrumbItem parentItem = fBreadcrumbViewer.getItem(index - 1); // parentItem.openDropDownMenu(); } }); // fBreadcrumbViewer.addMenuDetectListener(new MenuDetectListener() { // public void menuDetected(final MenuDetectEvent event) { // final ISelectionProvider selectionProvider = (fBreadcrumbViewer.isDropDownOpen()) ? // fBreadcrumbViewer.getDropDownSelectionProvider() : fBreadcrumbViewer; // // System.out.println(fBreadcrumbViewer.isDropDownOpen()); // System.out.println(event); // // final MenuManager manager = new MenuManager(); // try { // fillContextMenu(manager, (IStructuredSelection) selectionProvider.getSelection()); // if (manager.isEmpty()) { // return; // } // final Menu menu = manager.createContextMenu(fBreadcrumbViewer.getControl()); // menu.setLocation(event.x + 10, event.y + 10); // menu.setVisible(true); // while (!menu.isDisposed() && menu.isVisible()) { // if (!menu.getDisplay().readAndDispatch()) { // menu.getDisplay().sleep(); // } // } // } // finally { // manager.dispose(); // } // } // }); fPropertyChangeListener = new IPropertyChangeListener() { @Override public void propertyChange(final PropertyChangeEvent event) { if (ACTIVE_TAB_BG_END.equals(event.getProperty())) { if (fComposite.isFocusControl()) { fComposite.setBackground(JFaceResources.getColorRegistry().get(ACTIVE_TAB_BG_END)); } } } }; JFaceResources.getColorRegistry().addListener(fPropertyChangeListener); return fComposite; }
From source file:de.walware.ecommons.ui.breadcrumb.AbstractBreadcrumb.java
License:Open Source License
@Override public void dispose() { if (isServiceLocatorReady(false)) { fBreadcrumbServiceState = -1;// ww w . j a v a 2 s. c o m fBreadcrumbServices.dispose(); fBreadcrumbServices = null; } if (fPropertyChangeListener != null) { JFaceResources.getColorRegistry().removeListener(fPropertyChangeListener); } if (fDisplayFocusListener != null) { Display.getDefault().removeFilter(SWT.FocusIn, fDisplayFocusListener); } deinstallDisplayListeners(); }
From source file:de.walware.ecommons.ui.breadcrumb.AbstractBreadcrumb.java
License:Open Source License
/** * Focus has been transfered into the breadcrumb. */// ww w .j ava2 s .c o m private void focusGained() { if (fHasFocus) { focusLost(); } fComposite.setBackground(JFaceResources.getColorRegistry().get(ACTIVE_TAB_BG_END)); fHasFocus = true; installDisplayListeners(); activateBreadcrumb(); updateActions(); }