List of usage examples for org.eclipse.jface.resource JFaceResources getFontRegistry
public static FontRegistry getFontRegistry()
From source file:org.eclipse.birt.report.designer.util.FontManager.java
License:Open Source License
/** * This map stores font name - Font pairs, used to quickly lookup a Font of * a predefined font.// w w w. j a v a2s . c o m */ public static Font getFont(String family, int size, int style) { Font font = null; if (size < 0) { size = 0; } String key = family + Integer.toString(size) + Integer.toString(style); if (JFaceResources.getFontRegistry().hasValueFor(key)) { font = JFaceResources.getFontRegistry().get(key); } else { JFaceResources.getFontRegistry().put(key, new FontData[] { new FontData(family, size, style) }); font = JFaceResources.getFontRegistry().get(key); } return font; }
From source file:org.eclipse.birt.report.designer.util.FontManager.java
License:Open Source License
/** * Gets font by FontData, the font will be cached and disposed * automatically.// ww w . j av a 2 s . c om */ public static Font getFont(FontData fd) { if (fd == null) { return null; } Font font = null; String key = fd.toString(); if (JFaceResources.getFontRegistry().hasValueFor(key)) { font = JFaceResources.getFontRegistry().get(key); } else { JFaceResources.getFontRegistry().put(key, new FontData[] { fd }); font = JFaceResources.getFontRegistry().get(key); } return font; }
From source file:org.eclipse.bluesky.colors.ColorSymbolSupport.java
License:Open Source License
/** * Install color support for the given viewer.o * // www . ja v a2s . co m * @param viewer */ public void install(ISourceViewer viewer) { this.viewer = viewer; colorsMap = new HashMap<>(); // Install mouse tracker to open color picker when colorized square is clicked. this.mouseTracker = new MouseTracker(); StyledText styledText = viewer.getTextWidget(); JFaceResources.getFontRegistry().addListener(fFontPropertyChangeListener); styledText.addMouseListener(mouseTracker); styledText.addMouseTrackListener(mouseTracker); styledText.addMouseMoveListener(mouseTracker); }
From source file:org.eclipse.bluesky.colors.ColorSymbolSupport.java
License:Open Source License
/** * Uninstall color support.//from ww w.j a v a 2s . c om */ public void uninstall() { if (viewer != null) { ((ITextViewerExtension4) viewer).removeTextPresentationListener(this); IAnnotationModel annotationModel = viewer.getAnnotationModel(); annotationModel.removeAnnotationModelListener(this); // Uninstall mouse tracker StyledText styledText = viewer.getTextWidget(); JFaceResources.getFontRegistry().removeListener(fFontPropertyChangeListener); styledText.removeMouseListener(mouseTracker); styledText.removeMouseTrackListener(mouseTracker); styledText.removeMouseMoveListener(mouseTracker); } colorsMap.values().forEach(Color::dispose); this.viewer = null; this.mouseTracker = null; this.colorsMap = null; }
From source file:org.eclipse.bpel.ui.editparts.borders.CollapsableBorder.java
License:Open Source License
public CollapsableBorder(boolean isVertical, int arcWidth, IFigure parentFigure, String labelText, Image image) {//from w w w . j a va2s .co m super(isVertical, arcWidth); this.parentFigure = parentFigure; this.image = image; this.imageLabel = new ImageFigure(image); this.collapsedImage = BPELUIPlugin.INSTANCE.getImage(IBPELUIConstants.ICON_FIGURE_COLLAPSED); this.expandedImage = BPELUIPlugin.INSTANCE.getImage(IBPELUIConstants.ICON_FIGURE_EXPANDED); this.expandedHeight = expandedImage.getBounds().height; this.expandedWidth = expandedImage.getBounds().width; this.collapsedNameLabel = new Label(labelText); this.collapsedNameLabel.setFont(JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT)); }
From source file:org.eclipse.buildship.ui.external.viewer.FilteredTree.java
License:Open Source License
/** * Return a bold font if the given element matches the given pattern. Clients can opt to call * this method from a Viewer's label provider to get a bold font for which to highlight the * given element in the tree./*from w w w . j a va2 s. co m*/ * * @param element element for which a match should be determined * @param tree FilteredTree in which the element resides * @param filter PatternFilter which determines a match * * @return bold font */ public static Font getBoldFont(Object element, FilteredTree tree, PatternFilter filter) { String filterText = tree.getFilterString(); if (filterText == null) { return null; } // Do nothing if it's empty string String initialText = tree.getInitialText(); if (!filterText.equals("") && !filterText.equals(initialText)) {//$NON-NLS-1$ if (tree.getPatternFilter() != filter) { boolean initial = initialText != null && initialText.equals(filterText); if (initial) { filter.setPattern(null); } else if (filterText != null) { filter.setPattern(filterText); } } if (filter.isElementVisible(tree.getViewer(), element) && filter.isLeafMatch(tree.getViewer(), element)) { return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT); } } return null; }
From source file:org.eclipse.cdt.core.testplugin.util.FailureDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { // page group Composite composite = (Composite) super.createDialogArea(parent); composite.setSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); Label label = new Label(composite, SWT.WRAP); label.setText("&Enter a note regarding the failure:"); _text = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); _text.setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT)); GridData data = new GridData(GridData.FILL_BOTH); data.widthHint = SIZING_TEXT_WIDTH;//from ww w. j ava 2 s . co m data.heightHint = SIZING_TEXT_HEIGHT; _text.setLayoutData(data); return composite; }
From source file:org.eclipse.cdt.debug.internal.ui.disassembly.viewer.DisassemblyPane.java
License:Open Source License
public void dispose() { getEditorPreferenceStore().removePropertyChangeListener(this); JFaceResources.getFontRegistry().removeListener(this); JFaceResources.getColorRegistry().removeListener(this); if (fSourceViewerDecorationSupport != null) { fSourceViewerDecorationSupport.dispose(); fSourceViewerDecorationSupport = null; }/* www . ja v a 2 s. c o m*/ if (fActions != null) { fActions.clear(); fActions = null; } }
From source file:org.eclipse.cdt.debug.internal.ui.disassembly.viewer.DisassemblyPane.java
License:Open Source License
protected VirtualSourceViewer createViewer(Composite parent, IVerticalRuler vertRuler, IOverviewRuler ovRuler) { int styles = SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION; VirtualSourceViewer viewer = new VirtualSourceViewer(parent, fVerticalRuler, fOverviewRuler, true, styles); viewer.getControl().setLayoutData(parent.getLayoutData()); viewer.setEditable(false);/* w w w . j av a 2 s . c o m*/ viewer.getTextWidget().setFont(JFaceResources.getFont(IInternalCDebugUIConstants.DISASSEMBLY_FONT)); viewer.setRangeIndicator(new DefaultRangeIndicator()); getSourceViewerDecorationSupport(viewer); viewer.configure(new SourceViewerConfiguration()); JFaceResources.getFontRegistry().addListener(this); JFaceResources.getColorRegistry().addListener(this); getEditorPreferenceStore().addPropertyChangeListener(this); return viewer; }
From source file:org.eclipse.cdt.debug.internal.ui.views.disassembly.DisassemblyView.java
License:Open Source License
/** * Creates the source viewer to be used by this view. * * @param parent the parent control// w w w . j a v a2 s . c om * @param ruler the vertical ruler * @param styles style bits * @return the source viewer */ private SourceViewer createSourceViewer(Composite parent, IVerticalRuler vertRuler, IOverviewRuler ovRuler) { DisassemblyViewer viewer = new DisassemblyViewer(parent, vertRuler, ovRuler); viewer.setRangeIndicator(new DefaultRangeIndicator()); JFaceResources.getFontRegistry().addListener(this); JFaceResources.getColorRegistry().addListener(this); return viewer; }