List of usage examples for org.eclipse.jface.resource JFaceResources getFontRegistry
public static FontRegistry getFontRegistry()
From source file:org.eclipse.php.internal.ui.documentation.PHPDocumentationProvider.java
License:Open Source License
/** * Returns the Javadoc hover style sheet with the current Javadoc font from * the preferences.//from w w w .ja va 2 s . com * * @return the updated style sheet */ protected static String getStyleSheet() { if (fgStyleSheet == null) fgStyleSheet = loadStyleSheet(); String css = fgStyleSheet; if (css != null) { FontData fontData = JFaceResources.getFontRegistry() .getFontData(PreferenceConstants.APPEARANCE_DOCUMENTATION_FONT)[0]; css = HTMLPrinter.convertTopLevelFont(css, fontData); } return css; }
From source file:org.eclipse.php.internal.ui.preferences.PHPSourcePreviewerUpdater.java
License:Open Source License
/** * Creates a Java source preview updater for the given viewer, configuration * and preference store.//from w w w .j a v a 2s .c o m * * @param viewer * the viewer * @param configuration * the configuration * @param preferenceStore * the preference store */ public PHPSourcePreviewerUpdater(final SourceViewer viewer, final SourceViewerConfiguration configuration, final IPreferenceStore preferenceStore) { Assert.isNotNull(viewer); Assert.isNotNull(configuration); Assert.isNotNull(preferenceStore); final IPropertyChangeListener fontChangeListener = new IPropertyChangeListener() { /* * @see * org.eclipse.jface.util.IPropertyChangeListener#propertyChange * (org.eclipse.jface.util.PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals("org.eclipse.wst.sse.ui.textfont")) { //$NON-NLS-1$ Font font = JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont"); //$NON-NLS-1$ viewer.getTextWidget().setFont(font); } } }; final IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener() { /* * @see * org.eclipse.jface.util.IPropertyChangeListener#propertyChange * (org.eclipse.jface.util.PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent event) { // if (configuration. affectsTextPresentation(event)) { // configuration.handlePropertyChangeEvent(event); // viewer.invalidateTextPresentation(); // } } }; viewer.getTextWidget().addDisposeListener(new DisposeListener() { /* * @see * org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse * .swt.events.DisposeEvent) */ public void widgetDisposed(DisposeEvent e) { preferenceStore.removePropertyChangeListener(propertyChangeListener); JFaceResources.getFontRegistry().removeListener(fontChangeListener); } }); JFaceResources.getFontRegistry().addListener(fontChangeListener); preferenceStore.addPropertyChangeListener(propertyChangeListener); }
From source file:org.eclipse.rcptt.ecl.popup.ui.internal.DialogRow.java
License:Open Source License
public DialogRow(Composite parent, String title) { super(parent, SWT.NONE); GridLayoutFactory.swtDefaults().numColumns(2).equalWidth(false).applyTo(this); getGridData().applyTo(this); Label titleLabel = new Label(this, SWT.NONE); titleLabel.setText(title);// w w w .j ava2 s.co m GridDataFactory.swtDefaults().grab(false, false).align(SWT.BEGINNING, SWT.BEGINNING).applyTo(titleLabel); titleLabel.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.TEXT_FONT)); GridDataFactory.swtDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(createContent()); }
From source file:org.eclipse.recommenders.internal.apidocs.rcp.JavadocProvider.java
License:Open Source License
private static String loadStyleSheet() { final Bundle bundle = Platform.getBundle(JavaPlugin.getPluginId()); final URL styleSheetURL = bundle.getEntry("/JavadocViewStyleSheet.css"); //$NON-NLS-1$ if (styleSheetURL == null) { return null; }/*from w ww . j ava 2s . c o m*/ BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader(styleSheetURL.openStream())); final StringBuffer buffer = new StringBuffer(1500); String line = reader.readLine(); while (line != null) { buffer.append(line); buffer.append('\n'); line = reader.readLine(); } final FontData fontData = JFaceResources.getFontRegistry() .getFontData(PreferenceConstants.APPEARANCE_JAVADOC_FONT)[0]; return HTMLPrinter.convertTopLevelFont(buffer.toString(), fontData); } catch (final IOException ex) { JavaPlugin.log(ex); return null; } finally { try { if (reader != null) { reader.close(); } } catch (final IOException e) { } } }
From source file:org.eclipse.recommenders.internal.apidocs.rcp.ProviderArea.java
License:Open Source License
private void createTitleArea() { title = createComposite(container);//from ww w . jav a 2s . c om final String providerName = provider.getDescription().getName(); final Image providerImage = provider.getDescription().getImage(); final CLabel l = new CLabel(title, SWT.NONE); l.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT)); setInfoForegroundColor(l); setInfoBackgroundColor(l); l.setText(providerName); l.setImage(providerImage); }
From source file:org.eclipse.riena.sample.app.client.mail.View.java
License:Open Source License
@Override public void createPartControl(final Composite parent) { final Composite top = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = 0;/* www. ja v a2s . co m*/ layout.marginWidth = 0; top.setLayout(layout); // top banner final Composite banner = new Composite(top, SWT.NONE); banner.setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_FILL, GridData.VERTICAL_ALIGN_BEGINNING, true, false)); layout = new GridLayout(); layout.marginHeight = 5; layout.marginWidth = 10; layout.numColumns = 2; banner.setLayout(layout); // setup bold font final Font boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT); Label l = new Label(banner, SWT.WRAP); l.setText("Subject:"); //$NON-NLS-1$ l.setFont(boldFont); l = new Label(banner, SWT.WRAP); l.setText("This is a message about the cool Eclipse RCP!"); //$NON-NLS-1$ l = new Label(banner, SWT.WRAP); l.setText("From:"); //$NON-NLS-1$ l.setFont(boldFont); final Link link = new Link(banner, SWT.NONE); link.setText("<a>nicole@mail.org</a>"); //$NON-NLS-1$ link.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { RienaMessageDialog.openInformation(getSite().getShell(), "Not Implemented", //$NON-NLS-1$ "Imagine the address book or a new message being created now."); //$NON-NLS-1$ } }); l = new Label(banner, SWT.WRAP); l.setText("Date:"); //$NON-NLS-1$ l.setFont(boldFont); l = new Label(banner, SWT.WRAP); l.setText("10:34 am"); //$NON-NLS-1$ // message contents final Text text = new Text(top, SWT.MULTI | SWT.WRAP); text.setText( "This RCP Application was generated from the PDE Plug-in Project wizard. This sample shows how to:\n" //$NON-NLS-1$ + "- add a top-level menu and toolbar with actions\n" + "- add keybindings to actions\n" + "- create views that can't be closed and\n" + " multiple instances of the same view\n" + "- perspectives with placeholders for new views\n" + "- use the default about dialog\n" + "- create a product definition\n"); text.setLayoutData(new GridData(GridData.FILL_BOTH)); }
From source file:org.eclipse.riena.sample.app.client.rcpmail.MessageView.java
License:Open Source License
@Override public void createPartControl(final Composite parent) { final Composite top = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = 0;//from www. ja v a2 s . c om layout.marginWidth = 0; top.setLayout(layout); // top banner final Composite banner = new Composite(top, SWT.NONE); banner.setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_FILL, GridData.VERTICAL_ALIGN_BEGINNING, true, false)); layout = new GridLayout(); layout.marginHeight = 5; layout.marginWidth = 10; layout.numColumns = 2; banner.setLayout(layout); // setup bold font final Font boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT); Label l = new Label(banner, SWT.WRAP); l.setText("Subject:"); //$NON-NLS-1$ l.setFont(boldFont); delegate.addUIControl(new Label(banner, SWT.WRAP), "subject"); //$NON-NLS-1$ l = new Label(banner, SWT.WRAP); l.setText("From:"); //$NON-NLS-1$ l.setFont(boldFont); delegate.addUIControl(new Label(banner, SWT.WRAP), "from"); //$NON-NLS-1$ l = new Label(banner, SWT.WRAP); l.setText("Date:"); //$NON-NLS-1$ l.setFont(boldFont); delegate.addUIControl(new Label(banner, SWT.WRAP), "date"); //$NON-NLS-1$ // message contents final Text text = new Text(top, SWT.MULTI | SWT.WRAP); text.setLayoutData(new GridData(GridData.FILL_BOTH)); delegate.addUIControl(text, "message"); //$NON-NLS-1$ delegate.injectAndBind(controller); parent.addDisposeListener(new DisposeListener() { public void widgetDisposed(final DisposeEvent e) { delegate.unbind(controller); } }); }
From source file:org.eclipse.rmf.reqif10.pror.presentation.headline.ui.HeadlineCellRenderer.java
License:Open Source License
public int doDrawCellContent(GC gc, Rectangle rect, Object value) { AttributeValueSimple av = (AttributeValueSimple) value; String text = " "; if (av != null && ReqIF10Util.getTheValue(av) != null) { text = ReqIF10Util.getTheValue(av).toString(); }/* w w w .java 2 s . c o m*/ if (font == null || font.isDisposed() || fontSizeChanged) { FontRegistry fr = JFaceResources.getFontRegistry(); FontData[] fontData = { new FontData("Arial", fontSize, SWT.BOLD) }; fr.put(fontHandle + this, fontData); font = fr.get(fontHandle + this); fontSizeChanged = false; } gc.setFont(font); gc.drawText(text, rect.x, rect.y); return gc.textExtent(text).y; }
From source file:org.eclipse.sirius.diagram.ui.tools.internal.views.providers.outline.OutlineLabelProvider.java
License:Open Source License
/** * {@inheritDoc}/*w w w . jav a 2s . c o m*/ * * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object) */ public Font getFont(final Object element) { Font result = JFaceResources.getDefaultFont(); if (element instanceof DDiagramElement) { final DDiagramElement vpe = (DDiagramElement) element; if (!vpe.isVisible() || (vpe instanceof DDiagramElementContainer && new DDiagramElementQuery(vpe).isLabelHidden())) { result = JFaceResources.getFontRegistry().getItalic(JFaceResources.DEFAULT_FONT); } } else if (element instanceof AbstractDDiagramElementLabelItemProvider) { Option<DDiagramElement> optionTarget = ((AbstractDDiagramElementLabelItemProvider) element) .getDiagramElementTarget(); if (optionTarget.some() && new DDiagramElementQuery(optionTarget.get()).isLabelHidden()) { result = JFaceResources.getFontRegistry().getItalic(JFaceResources.DEFAULT_FONT); } } return result; }
From source file:org.eclipse.sirius.ui.tools.internal.views.common.navigator.filter.FilteredCommonTree.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 v a 2 s. c o 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, FilteredCommonTree tree, PatternFilter filter) { Font result = null; String filterText = tree.getFilterString(); if (filterText != 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)) { result = JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT); } } } return result; }