List of usage examples for org.eclipse.jface.resource JFaceResources getColorRegistry
public static ColorRegistry getColorRegistry()
From source file:org.eclipse.lsp4e.operations.hover.LSBasedHover.java
License:Open Source License
@Override public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { if (textViewer == null || hoverRegion == null) { return null; }// w w w .java 2 s . c o m if (!(hoverRegion.equals(this.lastRegion) && textViewer.equals(this.textViewer) && this.requests != null)) { initiateHoverRequest(textViewer, hoverRegion.getOffset()); } try { CompletableFuture.allOf(this.requests.toArray(new CompletableFuture[this.requests.size()])).get(500, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { LanguageServerPlugin.logError(e); } String result = ""; //$NON-NLS-1$ if (!(this.hoverResults == null || this.hoverResults.isEmpty())) { result += hoverResults.stream().filter(Objects::nonNull).map(LSBasedHover::getHoverString) .filter(Objects::nonNull).collect(Collectors.joining("\n\n")); //$NON-NLS-1$ } if (result.isEmpty()) { return null; } result = MARKDOWN_PARSER.parseToHtml(result); // put CSS styling to match Eclipse style ColorRegistry colorRegistry = JFaceResources.getColorRegistry(); Color foreground = colorRegistry.get("org.eclipse.ui.workbench.HOVER_FOREGROUND"); //$NON-NLS-1$ Color background = colorRegistry.get("org.eclipse.ui.workbench.HOVER_BACKGROUND"); //$NON-NLS-1$ String style = "<style TYPE='text/css'>html { " + //$NON-NLS-1$ "font-family: " + JFaceResources.getDefaultFontDescriptor().getFontData()[0].getName() + "; " + //$NON-NLS-1$ //$NON-NLS-2$ "font-size: " //$NON-NLS-1$ + Integer.toString(JFaceResources.getDefaultFontDescriptor().getFontData()[0].getHeight()) + "pt; " //$NON-NLS-1$ + (background != null ? "background-color: " + toHTMLrgb(background.getRGB()) + "; " : "") + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ (foreground != null ? "color: " + toHTMLrgb(foreground.getRGB()) + "; " : "") + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ " }</style>"; //$NON-NLS-1$ int headIndex = result.indexOf("<head>"); //$NON-NLS-1$ StringBuilder builder = new StringBuilder(result.length() + style.length()); builder.append(result.substring(0, headIndex + "<head>".length())); //$NON-NLS-1$ builder.append(style); builder.append(result.substring(headIndex + "<head>".length())); //$NON-NLS-1$ return builder.toString(); }
From source file:org.eclipse.mat.ui.internal.views.NotesView.java
License:Open Source License
@Override public void createPartControl(Composite parent) { parent.setLayout(new FillLayout()); // No need for a dispose listener - the SaveablePart will save it textViewer = new TextViewer(parent, SWT.MULTI | SWT.V_SCROLL | SWT.LEFT | SWT.H_SCROLL); textViewer.setDocument(new Document()); textViewer.getControl().setEnabled(false); textViewer.getTextWidget().setWordWrap(false); font = JFaceResources.getFont("org.eclipse.mat.ui.notesfont"); //$NON-NLS-1$ textViewer.getControl().setFont(font); hyperlinkColor = JFaceResources.getColorRegistry().get(JFacePreferences.HYPERLINK_COLOR); getSite().getPage().addPartListener(this); undoManager = new TextViewerUndoManager(UNDO_LEVEL); undoManager.connect(textViewer);//from w ww . j a v a2 s .c o m textViewer.setUndoManager(undoManager); textViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { updateActions(); } }); textViewer.addTextListener(new ITextListener() { public void textChanged(TextEvent event) { modified = true; searchForHyperlinks(textViewer.getDocument().get(), 0); firePropertyChange(PROP_DIRTY); } }); textViewer.setHyperlinkPresenter(new DefaultHyperlinkPresenter(hyperlinkColor)); textViewer.setHyperlinkDetectors(new IHyperlinkDetector[] { new ObjectAddressHyperlinkDetector() }, SWT.MOD1); makeActions(); hookContextMenu(); showBootstrapPart(); updateActions(); }
From source file:org.eclipse.mylyn.commons.workbench.DecoratingPatternStyledCellLabelProvider.java
License:Open Source License
/** * @see org.eclipse.jface.viewers.StyledCellLabelProvider#initialize(org.eclipse.jface.viewers.ColumnViewer, * org.eclipse.jface.viewers.ViewerColumn) *///from w ww. j av a 2 s . c o m @Override public void initialize(ColumnViewer viewer, ViewerColumn column) { PlatformUI.getPreferenceStore().addPropertyChangeListener(this); JFaceResources.getColorRegistry().addListener(this); setOwnerDrawEnabled( PlatformUI.getPreferenceStore().getBoolean(IWorkbenchPreferenceConstants.USE_COLORED_LABELS)); super.initialize(viewer, column); }
From source file:org.eclipse.mylyn.commons.workbench.DecoratingPatternStyledCellLabelProvider.java
License:Open Source License
/** * @see org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider#dispose() *///from w ww . j a va2 s .c o m @Override public void dispose() { PlatformUI.getPreferenceStore().removePropertyChangeListener(this); JFaceResources.getColorRegistry().removeListener(this); this.labelProvider.dispose(); super.dispose(); }
From source file:org.eclipse.mylyn.internal.sandbox.search.ui.DesktopSearchLabelProvider.java
License:Open Source License
private void registerListeners() { PlatformUI.getPreferenceStore().addPropertyChangeListener(this); JFaceResources.getColorRegistry().addListener(this); }
From source file:org.eclipse.mylyn.internal.sandbox.search.ui.DesktopSearchLabelProvider.java
License:Open Source License
private void deregisterListeners() { JFaceResources.getColorRegistry().removeListener(this); PlatformUI.getPreferenceStore().removePropertyChangeListener(this); }
From source file:org.eclipse.mylyn.internal.tasks.ui.editors.HighlightingHyperlinkTextPresentationManager.java
License:Open Source License
@Override protected void decorate(StyleRange styleRange) { styleRange.foreground = JFaceResources.getColorRegistry().get(JFacePreferences.ACTIVE_HYPERLINK_COLOR); }
From source file:org.eclipse.mylyn.internal.wikitext.ui.viewer.CssStyleManager.java
License:Open Source License
public Color getColorFromRgb(RGB rgb) { if (rgb == null) { return null; }//from w w w. ja v a 2s . co m String symbolicName = String.format("#%02X%02X%02X", rgb.red, rgb.green, rgb.blue); //$NON-NLS-1$ Color color = JFaceResources.getColorRegistry().get(symbolicName); if (color == null) { JFaceResources.getColorRegistry().put(symbolicName, rgb); color = JFaceResources.getColorRegistry().get(symbolicName); } return color; }
From source file:org.eclipse.nebula.widgets.nattable.util.GUIHelper.java
License:Open Source License
public static Color getColor(int red, int green, int blue) { String key = getColorKey(red, green, blue); if (JFaceResources.getColorRegistry().hasValueFor(key)) { return JFaceResources.getColorRegistry().get(key); } else {// ww w .ja va 2s . c o m JFaceResources.getColorRegistry().put(key, new RGB(red, green, blue)); return getColor(key); } }
From source file:org.eclipse.nebula.widgets.nattable.util.GUIHelper.java
License:Open Source License
public static Color getColor(String key) { return JFaceResources.getColorRegistry().get(key); }