List of usage examples for org.eclipse.jface.resource JFaceResources getFontRegistry
public static FontRegistry getFontRegistry()
From source file:org.eclipse.mylyn.tasks.ui.wizards.AbstractTaskRepositoryPage.java
License:Open Source License
/** * @since 3.1// w w w . jav a 2 s . co m */ protected ExpandableComposite createSection(final Composite parentControl, String title) { final ExpandableComposite section = toolkit.createExpandableComposite(parentControl, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT | ExpandableComposite.COMPACT); section.clientVerticalSpacing = 0; section.setBackground(parentControl.getBackground()); section.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT)); section.addExpansionListener(new ExpansionAdapter() { @Override public void expansionStateChanged(ExpansionEvent e) { parentControl.layout(true); getControl().getShell().pack(); } }); section.setText(title); GridDataFactory.fillDefaults().indent(0, 5).grab(true, false).span(3, SWT.DEFAULT).applyTo(section); return section; }
From source file:org.eclipse.mylyn.wikitext.tasks.ui.editor.MarkupTaskEditorExtension.java
License:Open Source License
@Override public SourceViewer createViewer(TaskRepository taskRepository, Composite parent, int style, IAdaptable context) {//from www. j a v a2 s. c o m if (markupLanguage == null) { throw new IllegalStateException(); } MarkupViewer markupViewer = new MarkupViewer(parent, null, style | SWT.FLAT | SWT.WRAP); MarkupLanguageType markupLanguageCopy = createRepositoryMarkupLanguage(taskRepository); configureMarkupLanguage(taskRepository, markupLanguageCopy); markupViewer.setMarkupLanguage(markupLanguageCopy); MarkupViewerConfiguration configuration = createViewerConfiguration(taskRepository, markupViewer, context); configuration.setDisableHyperlinkModifiers(true); configuration.setEnableSelfContainedIncrementalFind(true); if (markupLanguageCopy instanceof AbstractMarkupLanguage && ((AbstractMarkupLanguage) markupLanguageCopy).isDetectingRawHyperlinks()) { // bug 264612 don't detect hyperlinks twice configuration.addHyperlinkDetectorDescriptorFilter(new DefaultHyperlinkDetectorDescriptorFilter( "org.eclipse.mylyn.tasks.ui.hyperlinks.detectors.url")); //$NON-NLS-1$ } markupViewer.configure(configuration); markupViewer.setEditable(false); markupViewer.getTextWidget().setCaret(null); if (JFaceResources.getFontRegistry().hasValueFor(WikiTextTasksUiPlugin.FONT_REGISTRY_KEY_DEFAULT_FONT)) { markupViewer.getTextWidget().setFont( JFaceResources.getFontRegistry().get(WikiTextTasksUiPlugin.FONT_REGISTRY_KEY_DEFAULT_FONT)); } if (JFaceResources.getFontRegistry().hasValueFor(WikiTextTasksUiPlugin.FONT_REGISTRY_KEY_MONOSPACE_FONT)) { markupViewer.setDefaultMonospaceFont( JFaceResources.getFontRegistry().get(WikiTextTasksUiPlugin.FONT_REGISTRY_KEY_MONOSPACE_FONT)); } markupViewer.setStylesheet(WikiTextUiPlugin.getDefault().getPreferences().getStylesheet()); IFocusService focusService = (IFocusService) PlatformUI.getWorkbench().getService(IFocusService.class); if (focusService != null) { focusService.addFocusTracker(markupViewer.getTextWidget(), MARKUP_VIEWER); } markupViewer.getTextWidget().setData(ISourceViewer.class.getName(), markupViewer); return markupViewer; }
From source file:org.eclipse.mylyn.wikitext.ui.viewer.HtmlTextPresenter.java
License:Open Source License
public String updatePresentation(Drawable drawable, String hoverInfo, TextPresentation presentation, int maxWidth, int maxHeight) { if (hoverInfo == null || hoverInfo.length() == 0) { return hoverInfo; }//from w ww . jav a2 s. c om HtmlTextPresentationParser parser = new HtmlTextPresentationParser(); parser.setPresentation(presentation); parser.setDefaultFont(JFaceResources.getFontRegistry().defaultFont()); String html = hoverInfo; if (!HTML_OPEN_TAG_PATTERN.matcher(html).find()) { html = "<html><body>" + html + "</body></html>"; //$NON-NLS-1$ //$NON-NLS-2$ } GC gc = new GC(drawable); try { html = html.replaceAll("<br>", "<br/>"); //$NON-NLS-1$ //$NON-NLS-2$ parser.setMaxWidth(maxWidth); parser.setGC(gc); parser.parse(html); return parser.getText(); } catch (Exception e) { return exceptionToHoverInfo(hoverInfo, presentation, e); } finally { gc.dispose(); } }
From source file:org.eclipse.nebula.widgets.nattable.util.GUIHelper.java
License:Open Source License
public static Font getFont(FontData... fontDatas) { StringBuilder keyBuilder = new StringBuilder(); for (FontData fontData : fontDatas) { keyBuilder.append(fontData.toString()); }/* w ww . j ava 2 s . c om*/ String key = keyBuilder.toString(); if (JFaceResources.getFontRegistry().hasValueFor(key)) { return JFaceResources.getFont(key); } else { JFaceResources.getFontRegistry().put(key, fontDatas); return JFaceResources.getFont(key); } }
From source file:org.eclipse.nebula.widgets.richtext.painter.ResourceHelper.java
License:Open Source License
public static Font getFont(FontData... fontDatas) { StringBuilder keyBuilder = new StringBuilder(); for (FontData fontData : fontDatas) { keyBuilder.append(fontData.toString()); }// w w w. j a v a 2 s. c o m String key = keyBuilder.toString(); if (!JFaceResources.getFontRegistry().hasValueFor(key)) { JFaceResources.getFontRegistry().put(key, fontDatas); } return JFaceResources.getFont(key); }
From source file:org.eclipse.pde.api.tools.ui.internal.preferences.ApiErrorsWarningsConfigurationBlock.java
License:Open Source License
/** * Creates an {@link ExpandableComposite} with a client composite and a * default grid layout//ww w .j a va 2 s .c om * * @param parent * @param title * @return */ private Composite createExpansibleComposite(Composite parent, String title) { ExpandableComposite ecomp = SWTFactory.createExpandibleComposite(parent, title, 1, GridData.FILL_HORIZONTAL); ecomp.addExpansionListener(new ExpansionAdapter() { @Override public void expansionStateChanged(ExpansionEvent e) { Object obj = e.getSource(); handleExpand(getScrollingParent(obj)); } }); ecomp.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT)); fExpComps.add(ecomp); Composite client = SWTFactory.createComposite(ecomp, 2, 1, GridData.FILL_BOTH); ecomp.setClient(client); return client; }
From source file:org.eclipse.php.internal.debug.core.preferences.AbstractDebuggerConfigurationDialog.java
License:Open Source License
/** * Creates a composite with a highlighted Note entry and a message text. * This is designed to take up the full width of the page. * //from w w w . j a v a2s . co m * @param font * the font to use * @param composite * the parent composite * @param title * the title of the note * @param message * the message for the note * @return the composite for the note */ protected Composite createNoteComposite(Font font, Composite composite, String title, String message, int horizontalSpan) { Composite messageComposite = new Composite(composite, SWT.NONE); GridLayout messageLayout = new GridLayout(); messageLayout.numColumns = 2; messageLayout.marginWidth = 0; messageLayout.marginHeight = 0; messageLayout.marginTop = 10; messageComposite.setLayout(messageLayout); GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gridData.horizontalSpan = horizontalSpan; gridData.widthHint = convertWidthInCharsToPixels(title.length() + message.length() + 1); messageComposite.setLayoutData(gridData); messageComposite.setFont(font); final Label noteLabel = new Label(messageComposite, SWT.BOLD); noteLabel.setText(title); noteLabel.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT)); noteLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); Label messageLabel = new Label(messageComposite, SWT.WRAP); messageLabel.setText(message); messageLabel.setFont(font); return messageComposite; }
From source file:org.eclipse.php.internal.debug.ui.views.coverage.CodeCoverageLabelProvider.java
License:Open Source License
public Font getFont(Object element, int columnIndex) { if (columnIndex == 1) { if (element instanceof ISourceModule || element instanceof IFile) { return JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT); }// w w w . j av a2s . c om } return JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT); }
From source file:org.eclipse.php.internal.ui.compare.TextMergeViewer.java
License:Open Source License
/** * Creates a text merge viewer under the given parent control. * /*from w ww . j av a 2 s . c o m*/ * @param parent * the parent control * @param style * SWT style bits for top level composite of this viewer * @param configuration * the configuration object */ public TextMergeViewer(Composite parent, int style, CompareConfiguration configuration) { super(style, ResourceBundle.getBundle(BUNDLE_NAME), configuration); fMerger = new DocumentMerger(new IDocumentMergerInput() { public ITokenComparator createTokenComparator(String line) { return TextMergeViewer.this.createTokenComparator(line); } public CompareConfiguration getCompareConfiguration() { return TextMergeViewer.this.getCompareConfiguration(); } public IDocument getDocument(char contributor) { switch (contributor) { case LEFT_CONTRIBUTOR: return fLeft.getDocument(); case RIGHT_CONTRIBUTOR: return fRight.getDocument(); case ANCESTOR_CONTRIBUTOR: return fAncestor.getDocument(); } return null; } public int getHunkStart() { return TextMergeViewer.this.getHunkStart(); } public Position getRegion(char contributor) { switch (contributor) { case LEFT_CONTRIBUTOR: return fLeft.getRegion(); case RIGHT_CONTRIBUTOR: return fRight.getRegion(); case ANCESTOR_CONTRIBUTOR: return fAncestor.getRegion(); } return null; } public boolean isHunkOnLeft() { ITypedElement left = ((ICompareInput) getInput()).getRight(); return left != null && Utilities.getAdapter(left, IHunk.class) != null; } public boolean isIgnoreAncestor() { return TextMergeViewer.this.isIgnoreAncestor(); } public boolean isPatchHunk() { return TextMergeViewer.this.isPatchHunk(); } public boolean isShowPseudoConflicts() { return fShowPseudoConflicts; } public boolean isThreeWay() { return TextMergeViewer.this.isThreeWay(); } public boolean isPatchHunkOk() { return TextMergeViewer.this.isPatchHunkOk(); } }); int inheritedStyle = parent.getStyle(); if ((inheritedStyle & SWT.LEFT_TO_RIGHT) != 0) fInheritedDirection = SWT.LEFT_TO_RIGHT; else if ((inheritedStyle & SWT.RIGHT_TO_LEFT) != 0) fInheritedDirection = SWT.RIGHT_TO_LEFT; else fInheritedDirection = SWT.NONE; if ((style & SWT.LEFT_TO_RIGHT) != 0) fTextDirection = SWT.LEFT_TO_RIGHT; else if ((style & SWT.RIGHT_TO_LEFT) != 0) fTextDirection = SWT.RIGHT_TO_LEFT; else fTextDirection = SWT.NONE; fSymbolicFontName = getClass().getName(); String platform = SWT.getPlatform(); fIsMotif = "motif".equals(platform); //$NON-NLS-1$ fIsCarbon = "carbon".equals(platform); //$NON-NLS-1$ if (fIsMotif) fMarginWidth = 0; Display display = parent.getDisplay(); fPreferenceChangeListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { TextMergeViewer.this.handlePropertyChangeEvent(event); } }; fPreferenceStore = createChainedPreferenceStore(); if (fPreferenceStore != null) { fPreferenceStore.addPropertyChangeListener(fPreferenceChangeListener); checkForColorUpdate(display); fLeftIsLocal = Utilities.getBoolean(getCompareConfiguration(), "LEFT_IS_LOCAL", false); //$NON-NLS-1$ fSynchronizedScrolling = fPreferenceStore.getBoolean(ComparePreferencePage.SYNCHRONIZE_SCROLLING); fShowPseudoConflicts = fPreferenceStore.getBoolean(ComparePreferencePage.SHOW_PSEUDO_CONFLICTS); // fUseSplines= // fPreferenceStore.getBoolean(ComparePreferencePage.USE_SPLINES); fUseSingleLine = fPreferenceStore.getBoolean(ComparePreferencePage.USE_SINGLE_LINE); fHighlightTokenChanges = fPreferenceStore.getBoolean(ComparePreferencePage.HIGHLIGHT_TOKEN_CHANGES); // fUseResolveUI= // fPreferenceStore.getBoolean(ComparePreferencePage.USE_RESOLVE_UI); } buildControl(parent); INavigatable nav = new INavigatable() { public boolean selectChange(int flag) { if (flag == INavigatable.FIRST_CHANGE || flag == INavigatable.LAST_CHANGE) { selectFirstDiff(flag == INavigatable.FIRST_CHANGE); return false; } return navigate(flag == INavigatable.NEXT_CHANGE, false, false); } public Object getInput() { return TextMergeViewer.this.getInput(); } public boolean openSelectedChange() { return false; } public boolean hasChange(int flag) { return getNextVisibleDiff(flag == INavigatable.NEXT_CHANGE, false) != null; } }; fComposite.setData(INavigatable.NAVIGATOR_PROPERTY, nav); fBirdsEyeCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND); JFaceResources.getFontRegistry().addListener(fPreferenceChangeListener); JFaceResources.getColorRegistry().addListener(fPreferenceChangeListener); updateFont(); }
From source file:org.eclipse.php.internal.ui.compare.TextMergeViewer.java
License:Open Source License
/** * Called on the viewer disposal. Unregisters from the compare * configuration. Clients may extend if they have to do additional cleanup. * /*from w w w.j a va2s . c o m*/ * @param event */ protected void handleDispose(DisposeEvent event) { if (fHandlerService != null) fHandlerService.dispose(); Object input = getInput(); removeFromDocumentManager(ANCESTOR_CONTRIBUTOR, input); removeFromDocumentManager(LEFT_CONTRIBUTOR, input); removeFromDocumentManager(RIGHT_CONTRIBUTOR, input); if (DEBUG) DocumentManager.dump(); if (fPreferenceChangeListener != null) { JFaceResources.getFontRegistry().removeListener(fPreferenceChangeListener); JFaceResources.getColorRegistry().removeListener(fPreferenceChangeListener); if (fPreferenceStore != null) fPreferenceStore.removePropertyChangeListener(fPreferenceChangeListener); fPreferenceChangeListener = null; } fLeftCanvas = null; fRightCanvas = null; fVScrollBar = null; fBirdsEyeCanvas = null; fSummaryHeader = null; fAncestorContributor.unsetDocument(fAncestor); fLeftContributor.unsetDocument(fLeft); fRightContributor.unsetDocument(fRight); disconnect(fLeftContributor); disconnect(fRightContributor); disconnect(fAncestorContributor); if (fColors != null) { Iterator i = fColors.values().iterator(); while (i.hasNext()) { Color color = (Color) i.next(); if (!color.isDisposed()) color.dispose(); } fColors = null; } if (fBirdsEyeCursor != null) { fBirdsEyeCursor.dispose(); fBirdsEyeCursor = null; } if (showWhitespaceAction != null) showWhitespaceAction.dispose(); if (toggleLineNumbersAction != null) toggleLineNumbersAction.dispose(); if (fIgnoreWhitespace != null) fIgnoreWhitespace.dispose(); super.handleDispose(event); }